Function.firstWhere()
Get the first matching accessible user-defined Function document.
Signature
Function.firstWhere(predicate: () => Boolean)): <Function> | NullFunctionDef
Function.firstWhere(predicate: (val: Function) => Boolean)): <Function> | NullFunctionDef
Description
Each user-defined function (UDF) document in a Fauna database is
represented by a function object. The Function.firstWhere()
method
returns the first accessible function object that matches the predicate
function.
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: "inventory",
coll: Function,
ts: Time("2099-04-10T17:50:39.955Z"),
role: "server",
body: <<-END
(name) => {
Product.byName(name) {
name: .name,
description: .description,
quantity: .quantity
}
}
END
}
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!