Token.where()

Get the set of accessible Tokens in the database.

Signature

Token.where(predicate: () => Boolean)): Set<Token>

Token.where(predicate: (val: Token) => Boolean)): Set<Token>

Description

Each Token in a Fauna database is represented by a Token object. The Token.where() method gets the set of accessible Token objects that match the predicate function.

If Token.where() is the last value in a query, the first page of the set is returned.

Parameters

Parameter Type Required Description

predicate

Function

An anonymous function that compares values in each Token document and returns true for matches or false for mismatches.

predicate parameters:

Parameter Type Required Description

val

Token

Token object to compare. If omitted, use dot notation to access Token properties.

Return value

Type Description

Set

Set representing the documents that match the predicate function. If this method is the last value in a query, the method returns the first page of the Set. Returns an empty set if there are no matches.

Examples

Token.where(.document.id == "372696914650464289")
{
  data: [
    {
      id: "373081653342371873",
      coll: Token,
      ts: Time("2023-08-14T23:54:00.750Z"),
      document: People.byId("372696914650464289")
    },
    {
      id: "373081673116418081",
      coll: Token,
      ts: Time("2023-08-14T23:54:19.610Z"),
      document: People.byId("372696914650464289")
    }
  ]
}

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!