I can get all the URIs of the documents in a collection by using below XQuery:
for $doc in fn:collection("transform")
return xdmp:node-uri($doc)
But, when I tried to implement this in a Javascript module in MarkLogic, it is getting only last document in the database collection.
'use strict';
declareUpdate()
var docs = fn.collection("transform");
for(var doc of docs) {
xdmp.nodeUri(doc)
}
It is not giving all the URIs in the collection, but rather it's only returning the last URI of the document.
How can I get it to return all of the URIs?
Create an array and add each of the URIs to that array in your for loop, then either return the array:
or return a Sequence using
Sequence.from():However, if you simply want to return the URIs, then it would be better/easier to use
cts.uris()with acts.collectionQuery():