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.firstWhere()

Learn: Tokens

Get the first token that matches a provided predicate.

Signature

Token.firstWhere(pred: (Token => Boolean)) => Token | Null

Description

Gets the first token, represented as a Token document, that matches a provided predicate function.

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

pred

Predicate function

Yes

Anonymous predicate function that:

The method returns the first Token document for which the predicate returns true.

Return value

One of:

Type Description

Token

First Token document that matches the predicate.

Null

No Token document matches the predicate.

Examples

Token.firstWhere(.document.id == "111")
{
  id: "401670938431586381",
  coll: Token,
  ts: Time("2099-06-25T13:28:27.660Z"),
  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!