Skip to content

Instantly share code, notes, and snippets.

@ableasdale
Created September 14, 2017 12:19
Show Gist options
  • Save ableasdale/6589a61029db7c0eb501accf01bec664 to your computer and use it in GitHub Desktop.
Save ableasdale/6589a61029db7c0eb501accf01bec664 to your computer and use it in GitHub Desktop.
MarkLogic: Get Total Docs for all databases and generate an HTML table
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