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 == "111")
{
  data: [
    {
      id: "401670938431586381",
      coll: Token,
      ts: Time("2099-08-14T23:54:00.750Z"),
      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!