Check out v4 of the Fauna CLI

v4 of the Fauna CLI is now GA.

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

Migrating from v3 of the CLI? See the CLI migration guide.

Token.byDocument()

Learn: Tokens

Get a token by its identity document.

Signature

Token.byDocument(document: { *: Any }) => Set<Token>

Description

Gets a token, represented as a Token document, by its identity document. An identity document can have multiple tokens.

A token is a type of authentication secret used to provide identity-based access to a Fauna database. Fauna stores tokens as documents in the Token system collection.

Parameters

Parameter Type Required Description

document

Object

true

Identity document for the token to retrieve.

Return value

Type Description

Set<Token>

Resolved reference to a Token document.

Examples

Token.byDocument(Customer.byId("111"))
{
  data: [
    {
      id: "371233004820889634",
      coll: Token,
      ts: Time("2099-07-25T14:10:32.165Z"),
      document: Customer("111")
    },
    ...
  ]
}

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!