Check out v4 of the Fauna CLI
v4 of the Fauna CLI is now in beta. The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start. |
Document
Learn: Documents |
---|
You add data to Fauna as JSON-like documents, stored in collections.
Document fields
All documents contain the id
, coll
, ts
, and optional ttl
metadata fields.
Documents in user-defined collections also typically contain user-defined
fields. For example:
{
id: "392886847463751746",
coll: Product,
ts: Time("2099-04-10T16:50:12.850Z"),
ttl: Time("2099-04-15T16:50:12.850Z"),
name: "key limes",
description: "Conventional, 16 oz bag",
price: 299,
stock: 100,
category: Category("401610017107607625")
}
Field | Type | Read-only | Required | Description |
---|---|---|---|---|
|
true |
ID for the document. The ID is a string-encoded, 64-bit unsigned integer in the 253-1 range. The ID is unique within the collection. IDs are assigned at document creation. To create a document with a user-provided
|
||
|
true |
Name of the document’s collection. he |
||
|
true |
Last time the document was created or updated. |
||
|
Time or |
Time-to-live (TTL) for the document. Only present if
set. If not present or set to |
||
|
User-defined document field. Schema method names and schema metadata field names are reserved and can’t be used as a field name but can be used in nested objects. You can enforce typing and constraints for user-defined fields in a collection using collection schema. |
|||
|
true |
A reserved field that contains all user-defined fields and their values. By default, the The You can use the |
Instance methods
You can use the following instance methods to manage a document in FQL.
Method | Description |
---|---|
Delete a collection document. |
|
Test if a collection document exists. |
|
Replace all fields in a collection document. |
|
Replace a collection document using an object that may contain metadata fields. |
|
Update a collection document's fields. |
|
Update a collection document using an object that may contain metadata fields. |
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!