Global-Object.declareUpdate( [options as Object] ) as Null
Declares the statement to be an update.
A JavaScript statement is executed as a query unless declareUpdate() is
called at the beginning of the statement. Calling declareUpdate with an
options argument where explicitCommit
property is set to true
starts a multi-statement transaction and requires an explicit commit or
rollback to complete the transaction. If the options argument is omitted,
or the property explicitCommit
property is set to false, an
update is automatically committed. XDMP-OWNTXN is thrown if the request
is in an open transaction.
declareUpdate(); const person = {name:"Jon", age:50}; xdmp.documentInsert("p.json", person);
declareUpdate({explicitCommit: true}); const person = {name:"Jon", age:50}; xdmp.documentInsert("p.json", person); // because explicitCommit is true, you must call xdmp.commit (or // call it in another statement that uses the transaction started // in this statement) xdmp.commit();
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.