Created
October 10, 2019 18:54
-
-
Save prestonmcgowan/d401f6a50166c373670261306fad8bb0 to your computer and use it in GitHub Desktop.
Zip documents from a MarkLogic database to disk
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
declare namespace z = "xdmp:zip"; | |
let $parts := | |
element z:parts { | |
for $uri in cts:uris('/sources/', "document", cts:element-query(xs:QName('UploadDocumentMetadata'),cts:and-query(())))[1 to 100] | |
return (<z:part>{$uri}</z:part>, <z:part>{fn:doc($uri)//UploadedDocumentPath/text()}</z:part>) | |
} | |
let $zip := xdmp:zip-create($parts, ( | |
for $p in $parts/z:part | |
return fn:doc($p) ) | |
) | |
return xdmp:save("/Users/username/docs.zip", $zip) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment