Database.create()

Creates a database.

Signature

Database.create(data: {*: any}): <Document>

Description

The Database.create() method creates a database with the provided metadata and settings.

Create a top-level database

To create a top-level database using Database.create(), you must use an authentication secret scoped to the account’s top-level context. You can create a top-level secret using the fauna cloud-login command.

Create a child database

To create a child database using Database.create(), you must use an authentication secret scoped to the parent database.

Parameters

Parameter Type Required Description

data

Object

Yes

Object describing the child database.

data fields

Name Type Required Description

name

String

Yes

Name of the database to create.

  • The name must match the following regular expression: [a-zA-Z_]+[a-zA-Z0-9_]*.

  • The name can’t be a single underscore (_).

  • The name can’t be a reserved word.

  • Because databases are similar to traditional objects, Fauna recommends using a singular name that follows your class and struct formatting convention.

  • See the aliasing section about renaming existing entities.

history_days

Number

Number of days for document retention for the collection.
Default = 0

priority

Number

User-defined priority assigned to the child database.

typechecked

Boolean

Enable type checking:
    true = Enable type checking.
    false = (default) Disable type checking.
If not set for a child database, the child database inherits the typechecked state of the parent database.

data

Object

Metadata for the database.

Return value

Type Description

DatabaseDef

New Database document.

Examples

Database.create({
  name: "childDB",
  typechecked: true,
  priority: 10
})
{
  name: "childDB",
  coll: Database,
  ts: Time("2099-06-24T21:53:40.670Z"),
  typechecked: true,
  priority: 10,
  global_id: "ysjpygonryyr1"
}

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!