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.

Credential.all()

Learn: Credentials

Get a Set of all credentials.

Signature

Credential.all() => Set<Credential>

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

Description

Gets a Set containing all credentials, represented as Credential 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 Credential documents in the form { from: start, to: end }. from and to arguments should be in the order returned by an unbounded Credential.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 credentials are returned.

Range parameters

Name Type Required Description

from

Any

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

to

Any

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

Return value

Type Description

Set<Credential>

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

The Set is empty if:

  • The database has no credentials.

  • There are no credentials in the provided range.

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

Examples

Range examples

  1. Get all credentials for the database:

    Credential.all()
    {
      data: [
        {
          id: "401670531158376525",
          coll: Credential,
          ts: Time("2099-06-25T13:21:59.270Z"),
          document: Customer("111")
        },
        {
          id: "401670531164667981",
          coll: Credential,
          ts: Time("2099-06-25T13:21:59.270Z"),
          document: Customer("222")
        },
        {
          id: "401670531170959437",
          coll: Credential,
          ts: Time("2099-06-25T13:21:59.270Z"),
          document: Customer("333")
        }
      ]
    }
  2. Given the previous Set, get all credentials starting with the credential for Customer("222") (inclusive):

    Credential.all({ from: Credential.byDocument(Customer.byId("222")) })
    {
      data: [
        {
          id: "401670531164667981",
          coll: Credential,
          ts: Time("2099-06-25T13:21:59.270Z"),
          document: Customer("222")
        },
        {
          id: "401670531170959437",
          coll: Credential,
          ts: Time("2099-06-25T13:21:59.270Z"),
          document: Customer("333")
        }
      ]
    }
  3. Get a Set of credentials from the credential for Customer("111") (inclusive) to the credential for Customer("222") (inclusive):

    Credential.all({
      from: Credential.byDocument(Customer.byId("111")),
      to: Credential.byDocument(Customer.byId("222"))
    })
    {
      data: [
        {
          id: "401670531158376525",
          coll: Credential,
          ts: Time("2099-06-25T13:21:59.270Z"),
          document: Customer("111")
        },
        {
          id: "401670531164667981",
          coll: Credential,
          ts: Time("2099-06-25T13:21:59.270Z"),
          document: Customer("222")
        }
      ]
    }
  4. Get a Set of credentials up to the credential for Customer("222") (inclusive):

    Credential.all({ to: Credential.byDocument(Customer.byId("222")) })
    {
      data: [
        {
          id: "401670531158376525",
          coll: Credential,
          ts: Time("2099-06-25T13:21:59.270Z"),
          document: Customer("111")
        },
        {
          id: "401670531164667981",
          coll: Credential,
          ts: Time("2099-06-25T13:21:59.270Z"),
          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!