Collection.firstWhere()
Get the first matching accessible collection.
Signature
Collection.firstWhere(predicate: () => Boolean)) => CollectionDef | NullCollectionDef
Collection.firstWhere(predicate: (val: Collection) => Boolean)) => CollectionDef | NullCollectionDef
Description
Each collection in a Fauna database is represented by a collection object. This method returns the first accessible collection object that matches the predicate function.
Staged schema
If a database has staged schema, this method interacts with the database’s staged schema, not the active schema.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
predicate |
Yes |
Anonymous function that compares values in each collection document
and returns |
Return value
One of:
Type | Description |
---|---|
First accessible collection definition matching the predicate function.
Collection definitions are represented as a
|
|
NullCollectionDef |
No collections match the predicate function or all matching collections are inaccessible. |
Examples
Collection.firstWhere(.name.includes('Prod'))
{
name: "Product",
coll: Collection,
ts: Time("2099-04-10T14:13:05.740Z"),
...
}
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!