Collection.create()

Create a collection.

Signature

Collection.create(data: {*: any}): CollectionDef

Description

This method creates a collection definition document with the provided data object.

Parameters

Parameter Type Required Description

data

Object

Yes

Object describing the collection.

data fields

Name Type Required Description

name

String

Yes

Name of the collection to create. The name must match the following regular expression but can’t be a single underscore or reserved word: [a-zA-Z][a-zA-Z0-9_]*.
A name should be singular and PascalCased.
See the aliasing section about renaming existing entities.

history_days

Number

Number of days to retain the document in the collection.
Default = 0

ttl_days

Number

Delete documents ttl_days number of days after their last write.
Default = null, documents are retained indefinitely.

data

Object

Metadata for the collection. Useful for describing a collection beyond its name.

Return value

Type Description

CollectionDef

New collection definition document.

Examples

Collection.create({ name: "Activities" })
{
  name: "Activities",
  coll: Collection,
  ts: Time("2023-02-18T20:49:36.680Z"),
  indexes: {},
  constraints: []
}

See also

definition
Collection document definition to delete a collection.

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!