Credential.firstWhere()

Get the first matching accessible Credential.

Signature

Credential.firstWhere(predicate: () => Boolean)) => <Document> | Null

Credential.firstWhere(predicate: (val: Credential) => Boolean)) => <Document> | Null

Description

Each identity in a Fauna database has a Credential document. This method returns the first accessible document that matches the predicate function.

Parameters

Parameter Type Required Description

predicate

Function

Yes

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

predicate parameters:

Parameter Type Required Description

val

Credential

Credential document to compare. If omitted, use dot notation to access Credential properties.

Return value

One of:

Type Description

Credential

First accessible document matching the predicate function.

Null

When no matches are found to the predicate function or all matching documents are inaccessible.

Examples

Credential.firstWhere(.document == Customer.byId("111"))
{
  id: "371153420791316514",
  coll: Credential,
  ts: Time("2099-07-24T17:05:34.890Z"),
  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!