<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/fn.collection.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>fn.collection</api:function-name><api:suggest>fn.collection</api:suggest><api:suggest>fn</api:suggest><api:suggest>collection</api:suggest><api:function-link mode="xquery" fullname="fn:collection">/apidoc/8.0/fn:collection.xml</api:function-link><api:function mode="javascript" name="collection" type="builtin" lib="fn" category="SequenceBuiltins" bucket="W3C-Standard Functions" hidden="false" prefix="fn" namespace="http://www.w3.org/2005/xpath-functions" fullname="fn.collection"><api:summary>
  Returns all of the documents that belong to the specified collection(s).
</api:summary><api:params><api:param name="uri" type="xs:string*" optional="true"><api:param-description>
  The URI of the collection to retrieve.   If you omit this parameter,
  returns all of the documents in the database. If you specify a list of
  URIs, returns all of the documents in all of the collections at the URIs
  specified in the list.
  </api:param-description><api:param-name>uri</api:param-name><api:param-type>String[]</api:param-type></api:param></api:params><api:return>ValueIterator</api:return><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
fn.collection("mycollection").toArray()[0];
=&gt; returns the first document in the "mycollection" collection
</pre>
</api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
var res = [];
var d = fn.subsequence(fn.collection("my-collection"), 1, 2);
for (var x of d) {
res.push(x); };
res;

=&gt; The first 2 documents in the ValueIterator containing the collection
</pre>
</api:example></api:function></api:function-page>