collection.where()
Get the set of matching accessible documents in the collection.
Signature
where(predicate: () => Boolean)): Set<Collection>
where(predicate: (val: Document) => Boolean)): Set<Collection>
Description
Gets the set of accessible document in the collection that match the predicate function.
If where()
is the last value in a query, the first page
of the set is returned.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
predicate |
Yes |
Anonymous function that compares values in each collection document
and returns |
Return value
Type | Description |
---|---|
Set<Document> |
Set of matching accessible documents. |
Examples
Product.where(.stock < 20)
{
data: [
{
id: "<PRODUCT_DOCUMENT_ID>",
coll: Product,
ts: Time("2099-07-30T21:56:38.130Z"),
name: "taco pinata",
description: "Giant Taco Pinata",
price: 2399,
stock: 10,
category: Category("<CATEGORY_DOCUMENT_ID>")
}
]
}
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!