MarkLogic Server 11.0 Product Documentation
dls.documentUpdatedls.documentUpdate(
uri as String,
doc as Node,
annotation as Sequence,
retain-history as Boolean,
[permissions as Sequence],
[collections as String[]],
[quality as Number?],
[forest-ids as (Number|String)[]]
) as Sequence
Summary
This function updates the managed document at the specified URI
with the specified contents. This function does an implicit
dls.documentPurge
and returns the URI of any version of the document purged as
the result of the established retention policy.
This function must be called in a separate transaction from the
dls.documentCheckout
and
dls.documentCheckin
functions.
You must first check out the document
with
dls.documentCheckout
before you can update,
otherwise an exception is thrown. If the document does not exist, then an
exception is thrown.
Parameters |
uri |
The URI of the document. |
doc |
The new contents of the document.
|
annotation |
Any comments you
want to add to the new versions of the documents. |
retain-history |
Determines whether or not
to retain the document's properties fragment in the database. Set to
true to retain the original document's properties in order to track
when the document was updated and by whom. Otherwise, set to false .
|
permissions |
The permissions to be set on the updated document.
When run in an XQuery context, the permissions are a sequence of
XML elements (sec:permission). When importing this module into
a Server-Side JavaScript context, the permissions are an array
of Objects.
If not supplied, then the existing permissions set for the document remain.
|
collections |
The collection URIs for the collections to which the updated document is to belong.
If not supplied, then the existing collections set for the document remain.
|
quality |
Specifies the quality of the updated document. A positive value increases
the relevance score of the document in text search functions. The converse
is true for a negative value. The default value is 0.
|
forest-ids |
Specifies the ID of the forest in which the updated document is inserted.
If this parameter is not specified, the updated document will remain in the
original document's forest. If no such
forest exists or if no such forest is attached to the context database, an error
is raised. If multiple forests are specified, the document is inserted into one
of the specified forests. If the document exists and the forest in which it is
stored is set to delete-only, then you must set this parameter to include one or
more forests that allow updates, otherwise an exception is thrown.
|
Required Privileges
The
dls-user
role is required to run
this function, or the privilege:
http://marklogic.com/xdmp/privileges/dls-user
Example
// Updates the contents of 'baz.json'.
const dls = require('/MarkLogic/dls');
const bazbook = {
title: "Baz Goes to the Disco",
chapter1: "Baz wakes up",
para: "Baz woke up this afternoon to the sound of James Brown. Soon Baz was feeling a \
little funky, so he put on his cleanest \
propeller hat and headed out in search of a Disco."
};
declareUpdate();
dls.documentUpdate(
"/foo/bar/baz.json",
bazbook,
"Changed the title from Baz Feelin' Funky",
true);
Copyright © 2024 MarkLogic Corporation. MARKLOGIC is a
registered trademark of MarkLogic Corporation.