Loading TOC...

MarkLogic 12 EA 2 Product Documentation
xdmp.documentDelete

xdmp.documentDelete(
   uri as String,
   [options as Object?]
) as null

Summary

Deletes a document from the database.

Parameters
uri The URI of the document to be deleted.
options Options with which to customize this operation. This function supports the following options:
ifNotExists
Action if no document exists with the URI. Valid values are "error" and "allow". Default value is "error". An XDMP-DOCNOTFOUND exception is thrown if the document does not exist when "error" is specified or this option is left unspecified.

Usage Notes

The xdmp:document-delete function deletes a document and all of its properties, except, when directory-creation is set to automatic or manual-enforced, the directory property; it does not delete a directory with the same URI as the document being deleted unless directory-creation is set to manual. To delete a directory, use the xdmp:directory-delete function.

Example

declareUpdate();
xdmp.documentDelete('example.xml');

Example

// Enable deletion of a non-existent document without raising an error.
declareUpdate();
xdmp.documentDelete('example.xml',{ifNotExists:"allow"});

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