A Collection groups documents in a database. In a relational database, a collection is called a table. Depending on your application requirements, you can organize your documents into one collection or several, and collections can be customized to retain document version history for as long as you want.

Collections exist as global values in the Fauna environment.

Each collection includes a definition document that defines the collection name and can optionally define indexes and other metadata. Top-level objects with the names of each collection exist so that operations on the collections and their documents can be performed. The top-level Collection object has methods that can manage collections.

A database may have zero or more user-defined collections, and a collection can have any number of documents.

Fauna provides a set of internal collections that can be used to manage database resources.

See the Collection document definition reference documentation for a description of the collection definition data structure.

Collection persistence

A collection has two configuration fields that control document retention:

  • history_days

  • ttl

Adjust the history_days field to retain more or less history. Setting history_days to null retains history indefinitely. By default, document history is stored for zero days. Increasing retention increases storage utilization.

Set the collection time-to-live (ttl) field to define a time for the removal of documents in a collection. After the interval lapses, the document is removed and ceases to exist as if it never existed. After removal, temporal queries can’t recover the document. In the default case, the document persists indefinitely.


See Indexes for a description of indexes defined on a collection.


Constraints can be defined for controlling reading and writing to documents in a collection.

You can declare any number of unique constraints that define which document field values must be unique in a collection. A unique constraint can define one or more fields that must be unique in combination.

When one or more fields are part of a unique constraint, multiple documents can’t have the same combination of values for the constrained fields.

Constraints aren’t applied retroactively to existing documents. Instead, they’re applied when a new document is created or an existing document is updated.

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email

Thank you for your feedback!