Check out v4 of the Fauna CLI
v4 of the Fauna CLI is now in beta. The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start. |
collection.firstWhere()
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. |
Examples
Product.firstWhere(.stock < 20)
{
id: "999",
coll: Product,
ts: Time("2099-07-30T21:56:38.130Z"),
name: "taco pinata",
description: "Giant Taco Pinata",
price: 2399,
stock: 10,
category: Category("123")
}
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!