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. When no matching collections
exist or are accessible, returns null
.
The predicate function must return a Boolean.
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 document matching the predicate function. |
|
NullCollectionDef |
No collections match the predicate function or all matching collections are inaccessible. |
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!