Created
September 14, 2017 12:24
-
-
Save ableasdale/d16fcb08ebe85d41c98d2f5a4c7a90d9 to your computer and use it in GitHub Desktop.
MarkLogic: Remove CPF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
declare namespace trgr = "http://marklogic.com/xdmp/triggers"; | |
declare namespace dom = "http://marklogic.com/cpf/domains"; | |
declare namespace pipelines = "http://marklogic.com/cpf/pipelines"; | |
declare variable $DATABASE as xs:string := "Triggers"; | |
declare variable $OTHER-DOCS as xs:string+ := ("http://marklogic.com/cpf/configuration/configuration.xml", "/cpf/domains.css", "/cpf/pipelines.css"); | |
declare function local:schedule-delete($uris as xs:string+) { | |
for $i in $uris | |
return xdmp:invoke-function(function() { xdmp:document-delete($i) }, | |
<options xmlns="xdmp:eval"> | |
<database>{xdmp:database($DATABASE)}</database> | |
</options>) | |
}; | |
declare function local:remove-cpf-triggers() { | |
local:schedule-delete(for $i in //trgr:trigger-name | |
where fn:starts-with($i, "cpf:") | |
return xdmp:node-uri($i)) | |
}; | |
declare function local:remove-cpf-domains() { | |
local:schedule-delete(for $i in /dom:domain | |
return xdmp:node-uri($i)) | |
}; | |
declare function local:remove-cpf-pipelines() { | |
local:schedule-delete(for $i in /pipelines:pipeline | |
return xdmp:node-uri($i)) | |
}; | |
( | |
local:remove-cpf-triggers(), | |
local:remove-cpf-domains(), | |
local:remove-cpf-pipelines(), | |
local:schedule-delete($OTHER-DOCS) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment