set.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

Customer.all().where(.address.state == "DC")
{
  data: [
    {
      id: "<CUSTOMER_DOCUMENT_ID>",
      coll: Customer,
      ts: Time("2099-07-31T13:04:37.440Z"),
      cart: Order("<ORDER_DOCUEMNT_ID>"),
      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!