Check out v4 of the Fauna CLI

v4 of the Fauna CLI is now in beta.

The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start.

Collection.all()

Learn: Collections

Get a Set of all collection definitions.

Signature

Collection.all() => Set<CollectionDef>

Collection.all(range: { from: Any } | { to: Any } | { from: Any, to: Any }) => Set<CollectionDef>

Description

Gets a Set containing all collection definitions, represented as Collection documents, for the database.

Collection documents are FQL versions of a database’s FSL collection schema. Collection documents have the CollectionDef type. See Collections.

To limit the Set, you can provide an optional range of Collection documents.

If this method is the last expression in a query, the first page of the Set is returned. See Pagination.

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

{ from: Any } | { to: Any } | { from: Any, to: Any }

Specifies a range of Collection documents in the form { from: start, to: end }. from and to arguments should be in the order returned by an unbounded Collection.all() call. See Range examples.

The Set only includes documents in this range (inclusive). Omit from or to to run unbounded range searches.

If a range is omitted, all collection definitions are returned.

Range parameters

Name Type Required Description

from

Any

Beginning of the range (inclusive). Must be an Collection document.

to

Any

End of the range (inclusive). Must be an Collection document.

Return value

Type Description

Set<CollectionDef>

Set of Collection documents in the provided range. If a range is omitted, all collection definitions are returned.

The Set is empty if:

  • The database has no collection definitions.

  • There are no collection definitions in the provided range.

  • The provided range’s from value is greater than to.

Examples

Range examples

  1. Get all collection definitions 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"),
          ...
        }
      ]
    }
  2. Given the previous Set, get all collection definitions 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"),
          ...
        }
      ]
    }
  3. Get the Set of collection definitions from Product to Manager, 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!