Loading TOC...

MarkLogic Server 11.0 Product Documentation
op:remove

op:remove(
   [$removeCol as item()?]
) as map:map

Summary

This method deletes a document from the database. If the document does not exist, this method does not throw an error.

Parameters
$removeCol If this column is not specified then it assumes a column 'uri' is present. This can be a string of the uri column name or an op:col. Use op:view-col or op:schema-col if you need to identify columns in the two views that have the same column name. This can also be a map object specify the uri column name.

Usage Notes

op:remove() needs to be run as an update transaction. Use 'declare option xdmp:update "true";' in the prolog, or use xdmp:invoke/xdmp:invoke-function with update="true".

See Also

Example

xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";
declare option xdmp:update "true";

let $docsDescriptor := map:entry("uri", "/optic/update/remove1.json")
return op:from-doc-descriptors($docsDescriptor)
  =>op:remove()
  =>op:result()
  

Example

xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";
declare option xdmp:update "true";

let $docsDescriptor := (
  map:entry("uri", "/optic/update/remove1.json"),
  map:entry("uri", "/optic/update/remove2.json")
  )
return op:from-doc-descriptors($docsDescriptor)
  =>op:remove("uri")
  =>op:execute()
  

Example

xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";
declare option xdmp:update "true";

let $docsDescriptor := (
  map:entry("uri", "/optic/update/remove1.json"),
  map:entry("uri", "/optic/update/remove2.json")
  )
return op:from-doc-descriptors($docsDescriptor)
  =>op:remove(map:entry("uri","uri"))
  =>op:result()
  



op:remove(
   $patch-builder-plan as map:map,
   $path as xs:string
) as map:map

Summary

Delete a node.

Parameters
$patch-builder-plan The Patch Builder Plan. You can either use the XQuery => chaining operator or specify the variable that captures the return value from the previous operation.
$path The path to delete.

Example

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:remove("action" )
          )
=>op:write(op:doc-cols())
=>op:result()
  

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