Collection.all()
Get the Set of all accessible collection objects.
Signature
Collection.all() => Set<CollectionDef>
Collection.all(range: {from: Any, to: Any}) => Set<CollectionDef>
Description
The Collection.all()
method returns the Set of all CollectionDefs or,
optionally, the Set of CollectionDefs in the given range.
If Collection.all()
is the last expression in a query, the first page
of the Set is returned.
Staged schema
If a database has staged schema, this method interacts with the database’s staged schema, not the active schema.
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. |
Return value
Type | Description |
---|---|
Set<CollectionDef> |
All collection definition object in the given range. If the resulting Set is empty, the method returns an empty Set. For an ordered Set, if from is greater than to, the method returns an empty Set. If the first member of the Set is greater than or equal to from and also less than or equal to to only that value is returned. |
Examples
-
Get all collections for the database:
Collection.all()
{ data: [ { name: "Customer", coll: Collection, ts: Time("2099-07-30T22:04:31.325Z"), ... }, { name: "Product", coll: Collection, ts: Time("2099-07-30T22:04:31.325Z"), ... }, { name: "Category", coll: Collection, ts: Time("2099-07-30T22:04:31.325Z"), ... }, { name: "Order", coll: Collection, ts: Time("2099-07-30T22:04:31.325Z"), ... }, { name: "OrderItem", coll: Collection, ts: Time("2099-07-30T22:04:31.325Z"), ... } ] }
-
Given the previous Set, get all collections starting with
Order
:Collection.all({ from: Collection.byName("Category") })
{ data: [ { name: "Category", coll: Collection, ts: Time("2099-07-30T22:04:31.325Z"), ... }, { name: "Order", coll: Collection, ts: Time("2099-07-30T22:08:57.650Z"), ... }, { name: "OrderItem", coll: Collection, ts: Time("2099-07-30T22:08:57.650Z"), ... } ] }
-
Get the Set of collections from
Product
toManager
, inclusive:Collection.all({ from: Collection.byName("Category"), to: Collection.byName("Order") })
{ data: [ { name: "Category", coll: Collection, ts: Time("2099-07-30T22:04:31.325Z"), ... }, { name: "Order", coll: Collection, ts: Time("2099-07-30T22:08:57.650Z"), ... } ] }
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!