MarkLogic Server 11.0 Product Documentation
Global-Object.declareUpdate

Global-Object.declareUpdate(
   [options as Object]
) as Null

Summary

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.

Parameters
options Options to use for this operation. If "explicitCommit" property is set to true, declareUpdate starts a multi-statement transaction and requires an explicit commit or rollback to complete the transaction.

Example

  declareUpdate();
  const person = {name:"Jon", age:50};
  xdmp.documentInsert("p.json", person);

Example

  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();
Powered by MarkLogic Server | Terms of Use | Privacy Policy