op:patch( $plan as map:map, $doc-column as item(), $patch-def as map:map ) as map:map
Builds a patch operation including a sequence of inserts, replaces, replace-inserts and deletes.
Parameters | |
---|---|
$plan | The Optic Plan. You can either use the XQuery => chaining operator or specify the variable that captures the return value from the previous operation. |
$doc-column | The document column which need to be patched. |
$patch-def | The patch definition as op:patch-builder |
xquery version "1.0-ml"; import module namespace op="http://marklogic.com/optic" at "/MarkLogic/optic.xqy"; declare option xdmp:update "true"; let $doc-descriptors := ( map:entry("uri", '/optic/update/write4.xml') =>map:with("doc", <doc><action>write4</action></doc>), map:entry("uri", '/optic/update/write5.xml') =>map:with("doc", <doc><action>write4</action></doc>) =>map:with("collections", ("write")) ) return op:from-doc-descriptors($doc-descriptors) =>op:patch(op:col("doc"),op:patch-builder("/",()) =>op:insert-after("action",<status>NEW</status>) ) =>op:write(op:doc-cols()) =>op:result()
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.