Create
This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics. |
Create( collection, param_object )
Description
The Create
function adds a new document to a collection. The
collection_ref
parameter indicates in what collection the document
should be created, while param_object
has the document data and
optional metadata.
Parameters
Parameter | Type | Definition and Requirements |
---|---|---|
|
String or Reference |
The name, or Reference, of the collection that should have the new
document. A collection Reference can be acquired using the
|
|
Object |
The |
param_object
Field Name | Field Type | Definition and Requirements |
---|---|---|
|
Object |
An object with the fields and values for this document. |
|
Object |
Optional - The permissions for this document. |
|
Array |
|
|
Timestamp |
Optional - A timestamp that indicates the time-to-live for a document,
which is when the document is removed from the collection and can’t be
queried. The document history can continue to be accessed using
the |
Returns
A document with the data and metadata about the results of the operations.
Field Name | Field Type | Definition and Requirements |
---|---|---|
|
Reference |
A reference to the created document. |
|
Object |
The created document data. |
|
Long |
The timestamp, with microsecond resolution, associated with the creation of the document. |
Examples
The following query creates a document by providing a reference to the
collection "spells" and a param_object
with a data
field. The data
field has the user data to be inserted for this document.
{
ref: Ref(Collection("spells"), "302043888864985600"),
ts: 1624310349250000,
data: { name: 'Mountainous Thunder', element: 'air', cost: 15 }
}
The following query creates a document in the posts
collection with a
defined document ID (using the Ref
function):
{
ref: Ref(Collection("Posts"), "1"),
ts: 1624310598180000,
data: { title: 'The first post' }
}
Related
-
Documents documents]