Collection.where()

Get the Set of accessible collections in the database.

Signature

Collection.where(predicate: () => Boolean)) => Set<CollectionDef>

Collection.where(predicate: (val: Collection) => Boolean)) => Set<CollectionDef>

Description

Each collection in a Fauna database is represented by a collection object. The Collection.where() method gets the Set of accessible collection objects that match the predicate function.

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

Parameters

Parameter Type Required Description

predicate

Function

Yes

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

predicate parameters:

Parameter Type Required Description

val

Collection

Collection object to compare. If omitted, use dot notation to access collection properties.

Return value

Type Description

Set<CollectionDef>

Set representing the collections that match the predicate function. The method returns the empty Set if there are no matching collections.

Examples

Collection.where(.name.includes('Prod'))
{
  data: [
    {
      name: "Product",
      coll: Collection,
      ts: Time("2099-04-10T17:01:11.995Z"),
      ...
    }
  ]
}

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!