collection
Define a Collection schema, including index and unique and check constraint fields.
Syntax
[@alias(<aliasId>]
collection <collName> {
[history_days <history days>]
[ttl_days <time to live days>]
[index <index name> <index config block> . . .]
[unique <unique constraint fields> . . .]
[check <name> <predicateBody> . . .]
[compute <name> [: <type>]
<anonymousFunction> . . .]
}
Name
- collName String Required
-
Name of the collection. The collName must match the following regular expression but can’t be a single underscore or reserved word:
[a-zA-Z_]+[a-zA-Z0-9_]*
. A collName should be singular and PascalCased.
Properties
Parameter | Type | Required | Description |
---|---|---|---|
history_days |
Number of days of document history to retain for all documents in the collection. See Temporality. |
||
ttl_days |
Number of days that documents in the collection should be retained. See Temporality. |
||
index |
See |
||
unique |
See |
||
check |
See |
||
compute |
See |
Annotations
Collection aliases are useful when migrating from FQL v4 and you have collection names that violate the FQL v10 naming rules. See System-level reserved Collection names.
Examples
collection Example {
history_days 3
ttl_days 5
index anIndex {
terms [.path.to.field]
values [.field1, desc(.field2), asc(.field3), desc(mva(.field4))]
}
unique [.field1, mva(.arrField)]
check isok ((doc) => doc.ok)
compute p = ((doc) => doc.a + 1)
compute q: Number = (.b - 1)
}
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!