Collections
A database’s schema is defined by its collections, which are similar to tables in other databases. To create a collection, create a document of type collection.
Once the collection is defined, it is possible to create documents within the collection using the query API.
A collection cannot be created and used in the same transaction. |
It is possible to rename a collection by updating its name
field.
Renaming a collection changes its ref, 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.
Field | Type | Definition and Requirements |
---|---|---|
name |
String |
Cannot be |
data |
Object |
A JSON object. Optional. |
history_days |
Number |
Document history is retained for at least this many days. Defaults to 30 days. |
ttl_days |
Number |
Documents are deleted this many days after their last write. Optional. |
permissions |
Object |
Optional. |
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
history_days
to null
retain history indefinitely. Increasing
retention increases storage utilization.
By setting a collection’s ttl_days
, documents within the collection
are removed if they have not been updated within the configured TTL.
Was this article helpful?
We're sorry to hear that.
Tell us how we can improve!
documentation@fauna.com
Thank you for your feedback!