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.

Database.where()

Learn: Databases and multi-tenancy

Get a Set of child databases that match a provided predicate.

Signature

Database.where(pred: (DatabaseDef => Boolean)) => Set<DatabaseDef>

Description

Gets a Set of child databases, represented as Database documents, that match a provided predicate function.

Fauna stores child databases as documents in the parent database’s Database system collection. Database documents have the DatabaseDef type.

If Database.where() is the last expression in a query, the first page of the Set is returned. See Pagination.

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.

Using FQL to create or manage top-level databases is not supported.

Parameters

Parameter Type Required Description

pred

Predicate function

Yes

Anonymous predicate function that:

The method returns a Set of Database documents for which the predicate returns true.

Return value

Type Description

Set<Database>

Set of Database documents that match the predicate. If there are no matching documents, the Set is empty.

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!