all()
Get the set of all documents in the collection.
Description
The collection object .all()
method returns the set of all documents
in the collection for the given range.
If all()
is the last expression in a query, the first page of
the Set is returned.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
range |
Object describing the range. Returns all members of the set greater than or equal to from and less than or equal to to, including duplicates for an unordered set. If range is omitted, the method returns all collection objects. Ranges for documents are accepted only by document ID, such that
|
Return value
Type | Description |
---|---|
Set<Document> |
All documents in the collection in the given range. |
Examples
-
First, get all documents in the collection instance:
{ data: [ { id: "359104277765947426", coll: Library, ts: Time("2023-03-13T17:09:36.650Z"), name: "Hamlet", author: { name: "Shakespeare" } }, { id: "359106878286856226", coll: Library, ts: Time("2023-03-13T17:50:56.700Z"), name: "Pygmalion", author: { name: "Shaw" } }, { id: "359106944286326818", coll: Library, ts: Time("2023-03-13T17:51:59.640Z"), name: "Machinal", author: { name: "Treadwell" } } ] }
-
Use a range parameter to get all documents beginning with a given document ID:
{ data: [ { id: "359106878286856226", coll: Library, ts: Time("2023-03-13T17:50:56.700Z"), name: "Pygmalion", author: { name: "Shaw" } }, { id: "359106944286326818", coll: Library, ts: Time("2023-03-13T17:51:59.640Z"), name: "Machinal", author: { name: "Treadwell" } } ] }
-
Get all documents beginning up to a given document ID:
{ data: [ { id: "359104277765947426", coll: Library, ts: Time("2023-03-13T17:09:36.650Z"), name: "Hamlet", author: { name: "Shakespeare" } }, { id: "359106878286856226", coll: Library, ts: Time("2023-03-13T17:50:56.700Z"), name: "Pygmalion", author: { name: "Shaw" } } ] }
-
Get all documents between the given from and to range parameters, inclusive:
{ data: [ { id: "359106878286856226", coll: Library, ts: Time("2023-03-13T17:50:56.700Z"), name: "Pygmalion", author: { name: "Shaw" } } ] }
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!