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-06-18T19:49:25.725Z"),
history_days: 3,
ttl_days: 5,
computed_fields: {
InventoryValue: {
body: "(.quantity * .price)",
signature: "Number"
}
},
constraints: [
{
unique: [
{
field: ".name",
mva: false
},
{
field: ".description",
mva: false
},
{
field: ".categories",
mva: true
}
],
status: "active"
},
{
check: {
name: "posQuantity",
body: "(doc) => doc.quantity >= 0"
}
}
],
document_ttls: true,
migrations: [
{
add: {
field: ".typeConflicts"
}
},
{
add: {
field: ".quantity"
}
},
{
backfill: {
field: ".quantity",
value: "0"
}
},
{
drop: {
field: ".internalDesc"
}
},
{
move_conflicts: {
into: ".typeConflicts"
}
},
{
move: {
field: ".desc",
to: ".description"
}
},
{
split: {
field: ".creationTime",
to: [
".creationTime",
".creationTimeEpoch"
]
}
}
],
indexes: {
byName: {
terms: [
{
field: ".name",
mva: false
}
],
values: [
{
field: ".quantity",
order: "desc",
mva: false
},
{
field: ".categories",
order: "desc",
mva: true
}
],
queryable: true,
status: "complete"
}
},
wildcard: "Any",
fields: {
name: {
signature: "String?"
},
description: {
signature: "String?"
},
price: {
signature: "Double",
default: "0.00"
},
quantity: {
signature: "Int",
default: "0"
},
store: {
signature: "Ref<Store>?"
},
backorderLimit: {
signature: "Int?"
},
backordered: {
signature: "Boolean?"
},
categories: {
signature: "Array<String>?"
},
creationTime: {
signature: "Time",
default: "Time.now()"
},
creationTimeEpoch: {
signature: "Int?"
},
typeConflicts: {
signature: "{ *: Any }?"
}
}
}
Fields
Field | Type | Description |
---|---|---|
|
Name of the collection. |
|
|
The |
|
|
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 See Temporality. |
|
|
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!