Loading TOC...

MarkLogic 12 EA 1 Product Documentation
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 detailed option information, see xdmp.invoke for detailed option information. NOTE: Some options require additional privileges. For details, see the Required Privileges section of xdmp.invoke.

Required Privileges

Use of this function requires the following privilege:

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

Some options require additional privileges. For details, see the Required Privileges for 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); }
    };
  };
  const 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}

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.