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.

Parameters

Parameter Type Required Description

range

Object

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.

range fields

Name Type Required Description

from

Any

Beginning of range.

to

Any

End of range.

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

  1. Get all collections for the database:

    Collection.all()
    {
      data: [
        {
          name: "Product",
          coll: Collection,
          ts: Time("2099-04-10T17:01:11.995Z"),
          ...
        },
        {
          name: "Manager",
          coll: Collection,
          ts: Time("2099-04-10T17:01:11.995Z"),
          ...
        },
        {
          name: "Order",
          coll: Collection,
          ts: Time("2099-04-10T17:01:11.995Z"),
          ...
        },
        {
          name: "Customer",
          coll: Collection,
          ts: Time("2099-04-10T17:01:11.995Z"),
          ...
        },
        {
          name: "Store",
          coll: Collection,
          ts: Time("2099-04-10T17:01:11.995Z"),
          ...
        }
      ]
    }
  2. Given the previous set, get all collections starting with Manager:

    Collection.all({ from: Collection.byName("Manager") })
    {
      data: [
        {
          name: "Manager",
          coll: Collection,
          ts: Time("2099-04-10T17:01:11.995Z"),
          ...
        },
        {
          name: "Order",
          coll: Collection,
          ts: Time("2099-04-10T17:01:11.995Z"),
          ...
        },
        {
          name: "Customer",
          coll: Collection,
          ts: Time("2099-04-10T17:01:11.995Z"),
          ...
        },
        {
          name: "Store",
          coll: Collection,
          ts: Time("2099-04-10T17:01:11.995Z"),
          ...
        }
      ]
    }
  3. Get the set of collections from Product to Manager, inclusive:

    Collection.all({ from: Collection.byName("Product"),
                     to: Collection.byName("Manager") })
    {
      data: [
        {
          name: "Product",
          coll: Collection,
          ts: Time("2099-04-10T17:01:11.995Z"),
          ...
        },
        {
          name: "Manager",
          coll: Collection,
          ts: Time("2099-04-10T17:01:11.995Z"),
          ...
        }
      ]
    }

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!