AccessProvider.firstWhere()

Get the first matching accessible AccessProvider.

Signature

Collection.firstWhere(predicate: () => Boolean)): AccessProvider | NullAccessProvider

Collection.firstWhere(predicate: (val: AccessProvider) => Boolean)): AccessProvider | NullAccessProvider

Description

Each access provider document in a Fauna database is in the AccessProvider collection. This method returns the first accessible provider that matches the predicate function.

Parameters

Parameter Type Required Description

predicate

Function

Anonymous function that returns the first accessible provider that matches the predicate function.

predicate parameters:

Parameter Type Required Description

val

AccessProvider

A provider to compare. If omitted, use dot notation to access provider properties.

Return value

One of:

Type Description

AccessProvider

First accessible document matching the predicate function.

Null

When no provides match the predicate function or all matching providers are inaccessible.

Examples

AccessProvider.firstWhere(.issuer == "https://fauna.auth2.com")
{
  name: "newAccesProvider",
  coll: AccessProvider,
  ts: Time("2023-07-28T03:49:22.120Z"),
  issuer: "https://fauna.auth2.com",
  audience: "https://db.fauna.com/db/ywtfhw4poyynr",
  roles: [
    "mgmtTeam",
    {
      role: "mgmtTeam",
      predicate: "_ => true"
    }
  ],
  jwks_uri: "https://fauna.auth0.com/.well-known/jwks.json",
  data: {
    custom: "some data"
  }
}

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!