Collection document definition
Learn: Collection schema |
---|
We recommend you use FSL to create and update user-defined collections. See Collection schema. |
A collection document definition is an FQL version of an FSL collection schema.
{
name: "Product",
coll: Collection,
ts: Time("2099-07-30T22:22:32.945Z"),
indexes: {
byCategory: {
terms: [
{
field: ".category",
mva: false
}
],
values: [
{
field: ".name",
order: "asc",
mva: false
},
{
field: ".price",
order: "asc",
mva: false
}
],
queryable: true,
status: "complete"
},
sortedByCategory: {
values: [
{
field: ".category",
order: "asc",
mva: false
}
],
queryable: true,
status: "complete"
},
byName: {
terms: [
{
field: ".name",
mva: false
}
],
queryable: true,
status: "complete"
},
sortedByPriceLowToHigh: {
values: [
{
field: ".price",
order: "asc",
mva: false
},
{
field: ".name",
order: "asc",
mva: false
},
{
field: ".description",
order: "asc",
mva: false
},
{
field: ".stock",
order: "asc",
mva: false
}
],
queryable: true,
status: "complete"
},
sortedByName: {
values: [
{
field: ".name",
order: "asc",
mva: false
},
{
field: ".description",
order: "asc",
mva: false
},
{
field: ".price",
order: "asc",
mva: false
}
],
queryable: true,
status: "complete"
}
},
constraints: [
{
unique: [
{
field: ".name",
mva: false
}
],
status: "active"
},
{
check: {
name: "stockIsValid",
body: "(product) => product.stock >= 0"
}
},
{
check: {
name: "priceIsValid",
body: "(product) => product.price >= 0"
}
}
],
fields: {
name: {
signature: "String"
},
description: {
signature: "String"
},
price: {
signature: "Number"
},
category: {
signature: "Ref<Category>"
},
stock: {
signature: "Int"
}
},
document_ttls: true,
history_days: 0
}
Fields
Field | Type | Read only | Description |
---|---|---|---|
|
Name of the collection. |
||
|
True |
The |
|
|
True |
Timestamp of the most recent document write. |
|
|
Number of days of history to retain for collection documents. When the number of days lapses, document snapshots older than the interval are removed. Does not affect the current version of documents. Defaults to |
||
|
Documents are deleted Defaults to |
||
|
FQL version of the collection schema’s computed fields. See Computed field definitions |
||
|
FQL version of the collection schema’s check and unique constraints. See Check constraints and Unique constraints. |
||
|
Boolean | |
If
|
|
|
FQL version of the collection schema’s migrations block. See Migrations block. |
||
|
FQL version of the collection schema’s index definitions. See Index definitions. |
||
|
FQL version of the collection schema’s wildcard constraint. See Wildcard constraints. |
||
|
FQL version of the collection schema’s field definitions. See Field definitions. |
||
|
Arbitrary user-defined metadata. |
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!