Loading TOC...

MarkLogic 10 Product Documentation
dls:purge

dls:purge(
   $delete as xs:boolean,
   $retain-history as xs:boolean
) as xs:string*

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:retention-rule 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:document-properties 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

  xquery version "1.0-ml";

  import module namespace dls = "http://marklogic.com/xdmp/dls" 
      at "/MarkLogic/dls.xqy";

  dls:document-purge(fn:true(), fn:true())

  (: Deletes all of the versions of the 'baz.xml' document and its 
     referenced documents. :) 
    

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