Key.where()

Learn: Keys

Get a Set of keys that match a provided predicate.

Signature

Key.where(pred: (Key => Boolean)) => Set<Key>

Description

Gets a Set of keys, represented as Key documents, that match a provided predicate function.

A key is a type of authentication secret used for anonymous access to a Fauna database. Unlike tokens, keys are not associated with an identity.

If Key.where() is the last expression in a query, the first page of the Set is returned. See Pagination.

Parameters

Parameter Type Required Description

pred

Predicate function

Yes

Anonymous predicate function that:

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

Return value

Type Description

Set<Key>

Set of Key documents that match the predicate. If there are no matching documents, the Set is empty.

Examples

Key.where(.data != null)
{
  data: [
    {
      id: "412655134325080576",
      coll: Key,
      ts: Time("2099-07-19T20:53:15.250Z"),
      role: "admin",
      data: {
        desc: "Admin key for prod app database"
      }
    },
    {
      id: "412655134325080577",
      coll: Key,
      ts: Time("2099-07-28T02:25:35.050Z"),
      role: "server",
      data: {
        desc: "Server key for prod app database"
      }
    }
  ]
}
\