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 |
---|---|---|---|---|
|
Yes |
Unique identifier for the document within the collection. The identifier is a string-encoded, 64-bit unsigned integer in the 253-1 range. IDs are assigned on document creation. To create a document with a user-provided
|
||
|
Yes |
true |
Collection of which the document is a member. The |
|
|
Yes |
true |
Document last changed timestamp. Updated only on document write. The timestamp is propagated to all child documents. |
|
|
Time or |
Document time-to-live (TTL), if set. |
||
|
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 document. |
|
Test if a document exists. |
|
Replace all document fields. |
|
Replace document data field contents. |
|
Update document fields. |
|
Update document data field contents. |
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!