Created
September 14, 2017 12:19
-
-
Save ableasdale/6589a61029db7c0eb501accf01bec664 to your computer and use it in GitHub Desktop.
MarkLogic: Get Total Docs for all databases and generate an HTML table
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 function local:get-estimate-for-database-by-id($id as xs:unsignedLong) as xs:unsignedLong { | |
xdmp:invoke-function(function() { xdmp:estimate(doc()) }, | |
<options xmlns="xdmp:eval"> | |
<database>{$id}</database> | |
</options>) | |
(: xdmp:database("Documents") :) | |
}; | |
element table { | |
element thead { | |
element tr {element th {"Database ID"}, element th {"Database Name"}, element th {"Document Count"}} | |
}, | |
element tbody { | |
for $i in xdmp:databases() | |
return element tr { element td{$i}, element td{xdmp:database-name($i)}, element td{local:get-estimate-for-database-by-id($i)} } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment