CreateCollection
CreateCollection( param_object )
Description
The CreateCollection
function is used to create a collection that groups
documents. Once the collection has been created, it is possible to
create documents within the collection. You cannot create a collection
and insert documents into that collection in the same transaction.
Parameters
Argument | Type | Definition and Requirements |
---|---|---|
|
The |
param_object
Field Name | Field Type | Definition and Requirements | ||
---|---|---|---|---|
|
The name of the collection. Collections cannot be named any of the
following reserved words: |
|||
|
Optional - This is user-defined metadata for the collection. It is provided for the developer to store information at the collection level. |
|||
|
Optional - The number of days that document history is retained for in this collection. The default is 30 days. Setting |
|||
|
Optional - The number of days documents are retained for this
collection. Documents which have not been updated within the
configured TTL duration are removed. Setting
|
|||
|
Optional - Provides the ability to enable permissions at the collection level. See collection permissions for additional details. |
Returns
An object containing the fields returned by the CreateCollection
function is described below.
Field Name | Field Type | Definition and Requirements |
---|---|---|
|
The reference is an automatically generated identifier within the database to uniquely identify the collection that was created. |
|
|
The name of the collection that was created. |
|
|
The timestamp, with microsecond resolution, associated with the creation of the collection. |
|
|
The number of days to retain history. |
Examples
The following query creates a collection called "boons" with defaults:
client.query(q.CreateCollection({ name: 'boons' }))
.then((ret) => console.log(ret))
{ ref: Ref(id=boons, collection=Ref(id=collections)),
ts: 1527274777496292,
history_days: 30,
name: 'boons' }
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!