collection.firstWhere()
| Learn: Documents |
|---|
Get the first collection document that matches a provided predicate.
Description
Gets the first collection document that matches a provided predicate function.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
pred |
Yes |
Anonymous predicate function that:
The method returns the first collection document for which the predicate returns true. |
Return value
One of:
| Type | Description |
|---|---|
<Document> |
First collection document that matches the predicate. A document’s data type is taken from its collection’s name. For example,
|
Document doesn’t exist. Returned when no collection document matches the predicate. |