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.

Token.all()

Learn: Tokens

Get a Set of all tokens.

Signature

Token.all() => Set<Token>

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

Description

Gets a Set containing all tokens, represented as Token documents, for the database. To limit the returned Set, you can provide an optional range.

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

Parameters

Parameter Type Required Description

range

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

Specifies a range of Token documents in the form { from: start, to: end }. from and to arguments should be in the order returned by an unbounded Token.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 tokens are returned.

Range parameters

Name Type Required Description

from

Any

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

to

Any

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

Return value

Type Description

Set<Token>

Set of Token documents in the provided range. If a range is omitted, all tokens are returned.

The Set is empty if:

  • The database has no tokens.

  • There are no tokens in the provided range.

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

Examples

Range examples

  1. Get all tokens for the database:

    Token.all()
    {
      data: [
        {
          id: "123",
          coll: Token,
          ts: Time("2099-06-25T13:32:39.240Z"),
          document: Customer("111")
        },
        {
          id: "456",
          coll: Token,
          ts: Time("2099-06-25T13:32:39.240Z"),
          document: Customer("222")
        },
        {
          id: "789",
          coll: Token,
          ts: Time("2099-06-25T13:32:39.240Z"),
          document: Customer("333")
        }
      ]
    }
  2. Given the previous Set, get all tokens starting with ID 456 (inclusive):

    Token.all({ from: Token.byId("456") })
    {
      data: [
        {
          id: "456",
          coll: Token,
          ts: Time("2099-06-25T13:32:39.240Z"),
          document: Customer("222")
        },
        {
          id: "789",
          coll: Token,
          ts: Time("2099-06-25T13:32:39.240Z"),
          document: Customer("333")
        }
      ]
    }
  3. Get a Set of tokens from ID 456 (inclusive) to 789 (inclusive):

    Token.all({ from: Token.byId("456"),
                to: Token.byId("789") })
    {
      data: [
        {
          id: "456",
          coll: Token,
          ts: Time("2099-06-25T13:32:39.240Z"),
          document: Customer("222")
        },
        {
          id: "789",
          coll: Token,
          ts: Time("2099-06-25T13:32:39.240Z"),
          document: Customer("333")
        }
      ]
    }
  4. Get a Set of tokens up to ID 789 (inclusive):

    Token.all({ to: Token.byId("456") })
    {
      data: [
        {
          id: "123",
          coll: Token,
          ts: Time("2099-06-25T13:32:39.240Z"),
          document: Customer("111")
        },
        {
          id: "456",
          coll: Token,
          ts: Time("2099-06-25T13:32:39.240Z"),
          document: Customer("222")
        }
      ]
    }

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!