collection.where()
Get a Set of collection documents that match a provided predicate.
Description
Gets a Set of collection documents that match a provided predicate function.
If this method is the last value in a query, the first page of the Set is returned. See Pagination.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
pred |
Yes |
Anonymous predicate function that: * Accepts a collection document as its only argument. Supports shorthand-syntax. * Returns a Boolean value. The method returns collection documents for which the predicate returns true. |
Return value
Type | Description |
---|---|
Set<Document> |
Set of collection documents that match the predicate. If there are no matching documents, the Set is empty. |
Examples
Product.where(.stock < 20)
{
data: [
{
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!