Created
September 10, 2021 11:26
-
-
Save eouthwaite/dfe00c0f74e78ebed3d9effb37626985 to your computer and use it in GitHub Desktop.
Export workspace(s) into /tmp directory as individual scripts - useful for adding scripts to a git repo; not helpful for importing
This file contains 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"; | |
(: run against App-Services to export workspace(s) into /tmp directory as individual scripts :) | |
declare namespace qconsole="http://marklogic.com/appservices/qconsole"; | |
for $workspace in ('WorkFlow', 'Workspace') | |
let $export := /qconsole:workspace[qconsole:name=$workspace and qconsole:security/qconsole:userid=xdmp:get-current-userid()] | |
return ( (:$export,:) | |
for $qq in ( $export/qconsole:queries/qconsole:query )[1] | |
let $name := fn:replace(fn:concat('/tmp/', $workspace, '_', fn:replace($qq/qconsole:name, '/', '-'), '.xqy'), ' ', '-') | |
let $id := xs:string($qq/qconsole:id) | |
let $uri := fn:concat( | |
'/queries/', $id, '.txt' | |
) | |
let $query := doc($uri) | |
return ($name (:, xdmp:save($name, $query) :) ) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TODO: modify to put each workspace into its own zip file