AccessProvider.firstWhere()

Learn: Access providers

Get the first access provider matching a provided predicate.

Signature

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

Description

Gets the first AccessProvider document that matches a provided predicate function.

AccessProvider documents are FQL versions of a database’s FSL access provider schema. AccessProvider documents have the AccessProvider type. See Access providers.

Staged schema

If a database has staged schema, this method interacts with the database’s staged schema, not the active schema.

Parameters

Parameter Type Required Description

pred

Predicate function

Yes

Anonymous predicate function that:

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

Return value

One of:

Type Description

AccessProvider

First AccessProvider document that matches the predicate.

Null

No AccessProvider document matches the predicate.

Examples

AccessProvider.firstWhere(.issuer == "https://example.com/")
{
  name: "someIssuer",
  coll: AccessProvider,
  ts: Time("2099-06-25T14:57:23.125Z"),
  jwks_uri: "https://example.com/.well-known/jwks.json",
  roles: [
    "customer",
    {
      role: "manager",
      predicate: "(jwt) => jwt!.scope.includes(\"manager\")"
    }
  ],
  audience: "https://db.fauna.com/db/ysjowue14yyr1",
  issuer: "https://example.com/"
}

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!