MarkLogic 9 Product Documentation
dls.documentVersionDelete

dls.documentVersionDelete(
   uri as String,
   version as Number,
   retain-history as Boolean
) as null

Summary

This function removes the specified version of the managed document at the specified URI. This overrides any configured retention policies and should be used with care. You must have update permissions on the document version in order to delete it.

If you set $retain-history to true, you can use xdmp.documentProperties to view the deleted document's properties fragment in the database. For example, if you had deleted version 1 of /foo/bar/baz.xml, you can view its properties by calling:

xdmp.documentProperties("/foo/bar/baz.xml_versions/1-baz.xml")

Parameters
uri The URI of the document.
version The version of the document to be deleted.
retain-history Determines whether or not to retain the document's properties fragment in the database. Set to true to retain the deleted document's properties in order to track when the document was deleted and by whom. Otherwise, set to false.

Required Privileges

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

Example

// Deletes version 1 of the 'baz.xml' document and records it in the document
// history.

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

declareUpdate();
dls.documentVersionDelete('/foo/bar/baz.xml', 1, true);
   
Powered by MarkLogic Server | Terms of Use | Privacy Policy