set.where()

Get the elements of a Set that match a provided predicate.

Loading strategy:

Signature

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

Description

Returns a Set of elements from the calling Set that match a provided predicate function.

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

Parameters

Parameter Type Required Description

predicate

Predicate function

Yes

Anonymous predicate function that:

The method returns a Set of elements for which the predicate returns true.

Return value

Type Description

Set<Generic>

Set containing elements of the calling Set that match the predicate. If there are no matching elements, the Set is empty.

Examples

Customer.all().where(.address.state == "DC")
{
  data: [
    {
      id: "111",
      coll: Customer,
      ts: Time("2099-10-22T21:56:31.260Z"),
      cart: Order("412483941752112205"),
      orders: "hdW...",
      name: "Alice Appleseed",
      email: "alice.appleseed@example.com",
      address: {
        street: "87856 Mendota Court",
        city: "Washington",
        state: "DC",
        postalCode: "20220",
        country: "US"
      }
    },
    ...
  ]
}

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!