FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date. For more details, review the migration guide. Contact support@fauna.com with any questions. |
CreateClass
This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics. |
FQL/functions/Create_Class.adoc
CreateClass( param_object )
create_class( param_object )
CreateClass( param_object )
CreateClass( param_object )
CreateClass( param_object )
Description
This function is deprecated as of Fauna 2.7.0. Use
Fauna 2.7.0 renamed |
The CreateClass
function is used to create a class (now, collection)
which groups instance objects (now, documents). Once a class is created,
it is possible to create instances (now, documents) in the class. You
cannot create a class and insert instances into that class in the same
transaction.
Parameters
Parameter | Type | Definition and Requirements |
---|---|---|
|
Object |
The |
param_object
Field Name | Field Type | Definition and Requirements |
---|---|---|
|
String |
The name of a class (now collection). Cannot be |
|
Object |
Optional - This is user-defined metadata for the class (now, collection). It is provided for the developer to store information at the class (now, collection) level. |
|
Integer |
Optional - The number of days that instance (now, document) history is retained for in this class (now, collection). The default is zero days. Setting See Temporality for details. |
|
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 |
|
Integer |
Optional - The number of days instances (now, documents) are retained
for this class. Once an instance (now, document) is older than
|
|
Object |
Optional - Provides the ability to enable permissions at the class level. See class permissions for more details. |
Returns
An Object with the fields returned by the CreateClass
function:
Field Name | Field Type | Definition and Requirements |
---|---|---|
|
Reference |
A Reference to the created class. |
|
String |
The name of the created class (now, collection). |
|
Long |
The timestamp, with microsecond resolution, associated with the creation of the class (now, collection). |
|
Integer |
The number of days to retain history. |
Examples
The following query creates a class called "boons" with defaults:
{
ref: Collection("boons"),
ts: 1592053895890000,
history_days: 30,
name: 'boons'
}
{'ref': Ref(id=boons, collection=Ref(id=collections)), 'ts': 1592845981190000, 'history_days': 30, 'name': 'boons'}
map[history_days:30 name:boons ref:{boons 0xc0001780c0 0xc0001780c0 <nil>} ts:1603747131750000]
ObjectV(ref: RefV(id = "boons", collection = RefV(id = "collections")),ts: LongV(1603756168550000),history_days: LongV(30),name: StringV(boons))
{
ref: Collection("boons"),
ts: 1624449118600000,
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!