Loading TOC...

xdmp.invokeFunction

xdmp.invokeFunction(
   $func as function(),
   [$options as Object?]
) as Sequence

Summary

Returns the result of evaluating a JavaScript function value.

Parameters
$func A zero arity function value to execute.
$options Options controlling the evaluation. The default is no options. For xdmp.eval for detailed option information.

Required Privileges

http://marklogic.com/xdmp/privileges/xdmp-invoke

Usage Notes

The XQuery version of this function (xdmp:invoke-function) can only be used to invoke XQuery functions. The Server-Side JavaScript version of this function (xdmp.invokeFunction) can only be used to invoke JavaScript functions.

Example

  function test29197(uri,doc) {
    return {
      setUri: function setUri(_uri) { uri = _uri; },
      setDoc: function setDoc(_doc) { doc = _doc; },
      insert: function docInsert() { xdmp.documentInsert(uri,doc); }
    };
  };
  var testInvoke = test29197("29197.json",{a:1});
  xdmp.invokeFunction(testInvoke.insert,
    {transactionMode:"update-auto-commit"});
  xdmp.eval("cts.doc('29197.json')");

// Insert a doc and then retrieve it. Returns:
//     {"a":1}

Comments

    Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy