Function.firstWhere()
Get the first matching accessible user-defined Function document.
Signature
Function.firstWhere(predicate: () => Boolean)): <Function> | Null
Function.firstWhere(predicate: (val: Function) => Boolean)): <Function> | Null
Description
Each user-defined function (UDF) document in a Fauna database is
represented by a function object. Function.firstWhere()
returns the first
accessible function object that matches the predicate function. When
no matching UDF documents exist or all matching UDF documents are
inaccessible, returns null
.
The predicate function must return a Boolean.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
predicate |
Yes |
Anonymous function that compares values in each UDF document and
returns |
Return value
One of:
Type | Description |
---|---|
First accessible UDF document matching the predicate function. See Function document definition. |
|
When no UDF documents match the predicate function or all matching UDF documents are inaccessible. |
Examples
Get the first UDF when at least one matching UDF document exists and is accessible:
{
name: "Double",
coll: Function,
ts: Time("2022-10-25T21:01:19.310Z"),
body: "(x) => x + x"
}
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!