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.replace()

Learn: Databases and multi-tenancy

Replace a child database's metadata and settings.

Signature

replace(data: { *: Any }) => DatabaseDef

Description

Replaces all fields in a child database's metadata and settings, represented as an Database document, with fields from a provided data object. Fields not present in the data object, excluding the coll and ts metadata fields, are removed.

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

Metadata fields

You can’t use this method to insert or edit the following metadata fields:

  • coll

  • ts

Parameters

Parameter Type Required Description

data

Object

Fields for the Database document. Fields not present, excluding the coll and ts metadata fields, in the object are removed.

For supported document fields, see Database collection.

The object can’t include the following metadata fields:

  • coll

  • ts

Return value

Type Description

DatabaseDef

Database document with replaced fields.

Examples

Database.byName("childDB")!.replace({name: "childDB2"})
{
  name: "childDB2",
  coll: Database,
  ts: Time("2099-06-24T21:54:13.225Z"),
  global_id: "ysjpyeykhyyr4"
}

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!