Function.where()

Get the Set of matching accessible user-defined Function documents.

Signature

Function.where(predicate: () => Boolean)): <Function>

Function.where(predicate: (val: Function) => Boolean)): <Function>

Description

Each user-defined function (UDF) document in a Fauna database is represented by a function object. The Function.where() method returns the set of accessible UDF documents that match the predicate function.

If Function.where() is the last value in a query, the first page of the Set is returned.

Parameters

Parameter Type Required Description

predicate

Function

Anonymous Function that compares values in each UDF document and returns true for matches or false for mismatches.

predicate parameters:

Parameter Type Required Description

val

Collection

UDF object to compare. If omitted, use dot notation to access Function properties.

Return value

Type Description

Set<Function>>

Set representing the UDF documents that match the predicate Function. See Function document definition.

Examples

Get the Set of UDF documents that are accessible and match the predicate function:

Function.where(.name.includes('inv'))
{
  data: [
    {
      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!