fn.doc( [uri as String | String[] | Sequence] ) as Sequence
Returns the document(s) stored in the database at the specified URI(s).
If you are only getting a single document (specifying a
single URI), you can use cts.doc
instead (so you do not need to iterate through the Sequence to
get to the document).
document-node()
returned for each item in the result
contains an element()
root node for XML documents, a
text()
root node for text documents, an
object-node()
, array-node()
, or another JSON node
for a JSON document, and a binary()
root node for binary
documents.
const d = fn.doc("/mydocs/doc.json"); for (const x of d) { x }; => The variable d holds a Sequence containing the document at the URI /mydocs/doc.json, and x contains the document, so this program returns the document.
const res = []; const d = fn.subsequence(fn.doc(), 1, 2); for (const x of d) { res.push(x); }; res; => The first 2 documents in the Sequence containing the documents