create()

Create a document in the collection.

Signature

create(data: {*: any}): <Document>

Description

Creates a document in the collection with the provided property values.

Returns the created document.

Parameters

Parameter Type Required Description

data

Object

Yes

Object describing the document properties and values.

data fields

Name Type Required Description

ttl

Time

Timestamp indicating when to remove the document. When the document is removed it ceases to exist and temporal queries can’t recover the document.
Default = null Causes the document to persist indefinitely.

id

Number

By default, the document id value assigned by Fauna. The id can, instead, be assigned a user-defined value. The id is immutable after it is assigned.

Return value

Type Description

Document

New document.

Examples

Letter.create({ name: "Q" })
{
  id: "357102606290518049",
  coll: Letter,
  ts: Time("2023-02-19T14:53:53.940Z"),
  name: "Q"
}

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!