A database’s schema is defined by its collections, which are similar
to tables in other databases. Collections are containers for holding
documents. To create a collection, use the
Once the collection has been created, it is possible to create documents within the collection using the Fauna Query Language or the GraphQL API.
|A collection cannot be created and used in the same transaction.|
It is possible to rename a collection by updating its
Renaming a collection changes its Reference, but preserves inbound
references to the collection. Documents within the collection remain
associated with the collection.
When a collection is deleted, associated documents become inaccessible and are deleted asynchronously.
Reading or writing collection’s metadata document (not the documents within the collection) requires a key with the server role or better, or equivalent Attribute-based access control (ABAC) permissions.
To learn more about common operations and functions related to collections, see Collection recipes.
|Field||Type||Definition and Requirements|
The name of the collection.
Optional - A JSON object, for storing additional metadata about the collection.
Optional - Document history is retained for at least this many days. When the number of days has elapsed, events older than the specified time window are removed. The current version of a document is retained. Defaults to 30 days.
Optional - Documents are deleted this many days after their last write.
Each collection has two configuration fields that control the retention
of documents. By default, document history is stored for 30 days. Set
history_days to another value to keep more, or less, history. Setting
null retains history indefinitely. Increasing
retention increases storage utilization. See
Billing for storage implications.
By setting a collection’s
ttl_days, documents within the collection
are removed (as if they never existed) if they have not been updated
within the configured number of days.
Removal is handled by a background task, so once a document (including
collections, databases, indexes, keys, roles, and tokens) "expires" due
to the setting in the
For more immediate removal, use the
Is this article helpful?
Tell Fauna how the article can be improved:
Thank you for your feedback!