Loading TOC...

dls.documentPurge

dls.documentPurge(
   $uri as String,
   $delete as Boolean,
   $retain-history as Boolean
) as Sequence

Summary

This function deletes all numbered versions of the specified managed document and its referenced documents, as specified by the retention policies set by dls.retentionRule . The document versions are deleted if they have no retention rule causing them to be kept and if they are not included by documents that cannot yet be deleted. If $delete is false, the document's versions are not actually deleted and instead a list of the documents that would have been deleted is returned.

If you set $retain-history to true, you can use xdmp:document-properties to view the deleted document's properties fragment in the database.

Parameters
$uri The URI of the document to be purged.
$delete Determines whether or not to delete the documents. Set to true to remove the documents or false to list which documents would have been deleted.
$retain-history Determines whether to retain the deleted document's property fragment in the database. Set to true to retain the property fragment, or false to delete.

Required Privileges

The dls-user role is required to run this function, or the privilege:
http://marklogic.com/xdmp/privileges/dls-user

Example

// Returns the versions of the 'baz.xml' document and its referenced 
// documents, as specified by the retention policy. 

const dls = require('/MarkLogic/dls');

declareUpdate();
dls.documentPurge('/foo/bar/baz.xml', false, true);
   

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