Database.where()
Gets a set of Database
collection documents that match a provided predicate.
Signature
Database.where(predicate: () => Boolean)): Set<Database>
Database.where(predicate: (val: DatabaseDef) => Boolean)): Set<Database>
Description
The Database.firstWhere()
method gets a set of Database
collection documents
that match a provided predicate.
If the predicate is true
for a Database
document, the document is included
in the set. Otherwise, the document is excluded.
Scope
The Database
collection only contains documents for the direct child databases
of the database scoped to your authentication secret. You can’t use the
Database
collection to access parent, peer, or other descendant databases.
If you use an authentication secret scoped to an account’s top-level context,
the Database
collection contains documents for the account’s top-level
databases. You can create a top-level secret using the
Fauna CLI's
cloud-login
command.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
predicate |
Yes |
Anonymous function that compares values in each child database document
and returns |
Return value
Type | Description |
---|---|
Set<Database> |
Set representing the databases that match the predicate function. The method returns the empty set if there are no matching databases. |
Examples
Database.where(.name.includes("child"))
{
data: [
{
name: "childDB",
coll: Database,
ts: Time("2099-06-24T21:54:38.890Z"),
global_id: "ysjpykbahyyr1",
priority: 10,
typechecked: true
},
...
]
}
Database.where(childDB => childDB.priority == 10)
{
data: [
{
name: "childDB",
coll: Database,
ts: Time("2099-06-24T21:54:38.890Z"),
typechecked: true,
global_id: "ysjpykbahyyr1",
priority: 10
},
...
]
}
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!