Loading TOC...

dls.purge

dls.purge(
   delete as Boolean,
   retain-history as Boolean
) as Sequence

Summary

This function deletes all numbered versions of managed documents and its referenced documents (such as /foo/bar.xml_versions/1-bar.xml), as specified by the retention policy set by one or more dls.retentionRule functions. Documents are deleted if they have no retention rule causing them to be kept and if they are not included by some document that cannot yet be deleted. If $delete is false, the document versions are not actually deleted and instead a list of the documents that would have been deleted is returned. This function returns a list of URIs that it would/did delete.

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

Parameters
delete Determines whether or not to delete the documents. Set to true to delete the documents or false to list which documents would have been deleted.
retain-history Determines whether to retain the deleted documents' property fragments in the database. Set to true to retain the property fragments, 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

// Deletes all of the versions of the 'baz.xml' document and its 
// referenced documents.

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

declareUpdate();
dls.purge(true, true);
   

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