collection.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:
Category.all()
{ data: [ { id: "<DOCUMENT_ID>", coll: Category, ts: Time("2099-07-30T21:56:38.130Z"), products: "hdW...", name: "party", description: "Party Supplies" }, { id: "<DOCUMENT_ID>", coll: Category, ts: Time("2099-07-30T21:56:38.130Z"), products: "hdW...", name: "frozen", description: "Frozen Foods" }, { id: "<DOCUMENT_ID>", coll: Category, ts: Time("2099-07-30T21:56:38.130Z"), products: "hdW...", name: "produce", description: "Fresh Produce" } ] }
-
Use a range parameter to get all documents beginning with a given document:
let frozen = Category.byName("frozen").first() Category.all({from: frozen})
{ data: [ { id: "<DOCUMENT_ID>", coll: Category, ts: Time("2099-07-30T21:56:38.130Z"), products: "hdW...", name: "frozen", description: "Frozen Foods" }, { id: "<DOCUMENT_ID>", coll: Category, ts: Time("2099-07-30T21:56:38.130Z"), products: "hdW...", name: "produce", description: "Fresh Produce" } ] }
-
Get all documents beginning up to a given document:
let frozen = Category.byName("frozen").first() Category.all({to: frozen})
{ data: [ { id: "<DOCUMENT_ID>", coll: Category, ts: Time("2099-07-30T21:56:38.130Z"), products: "hdW...", name: "party", description: "Party Supplies" }, { id: "<DOCUMENT_ID>", coll: Category, ts: Time("2099-07-30T21:56:38.130Z"), products: "hdW...", name: "frozen", description: "Frozen Foods" } ] }
-
Get all documents between the given from and to range parameters, inclusive:
let party = Category.byName("party").first() let frozen = Category.byName("frozen").first() Category.all({from: party, to: frozen})
{ data: [ { id: "<DOCUMENT_ID>", coll: Category, ts: Time("2099-07-30T21:56:38.130Z"), products: "hdW...", name: "party", description: "Party Supplies" }, { id: "<DOCUMENT_ID>", coll: Category, ts: Time("2099-07-30T21:56:38.130Z"), products: "hdW...", name: "frozen", description: "Frozen Foods" } ] }
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!