where()

Get a subset of matching Set values.

Lazy loading:

Yes

Signature

where(predicate: () => Boolean | Null): Set

Description

The where() method returns the subset of Set values that match the predicate Function. The predicate Function must return a Boolean or Null.

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

Parameters

Parameter Type Required Description

predicate

Function

Yes

Anonymous Function that compares Set values and returns true for matches, false for mismatches, or Null.

Return value

Type Description

Set<Any>

Set representing the set values that match the predicate function.

Examples

Get all People documents with age less than 80:

Programmer.all().where(.age < 80)
{
  data: [
    {
      id: "346525880200206848",
      coll: Programmer,
      ts: Time("2022-10-25T21:01:21.910Z"),
      first: "Tim",
      last: "Cook",
      born: "1960-11-01",
      age: 62,
      degrees: [
        "BS",
        "MBA"
      ],
      letter: "G"
    }
  ]
}

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!