Loading TOC...


   uri as String,
   version as Number,
   retain-history as Boolean
) as null


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:


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:


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

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

dls.documentVersionDelete('/foo/bar/baz.xml', 1, true);

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