Schema properties
String
Stores a JSON string.
Example:
name str
@mask
A mask or array of masks. Example:
phone str @mask(["(##) #####-####"])
@minLength
The minimum accepted length.
pin str @minLength(8)
@maxLength
The maximum accepted length.
slug str @maxLength(16)
@placeholder
A placeholder to be shown when no value is present.
code str @placeholder("Example: 123456")
Number and Integer
Stores a JSON number.
Example:
age int // integer numbers only
weight num // floating point numbers
@minimum
Minimum accepted value.
age num @minimum(10)
@maximum
Maximum accepted value.
percentage num @maximum(100)
@exclusiveMinimum
Minimum accepted value (exclusive).
age num @exclusiveMinimum(10)
@exclusiveMaximum
Maximum accepted value (exclusive).
percentage num @exlusiveMaximum(100)
Boolean
Stores a JSON boolean.
Example:
is_active bool
Date
Stores an ISO date string.
Example:
member_since date
Datetime
Stores an ISO date string, exactly like date
. The difference is that time information will also be shown on frontends.
Example:
opened_at datetime
Object
Represents a nested object.
Example:
details {
properties {
weight num
}
}
Reference
Represents a link to a document of another or the same collection. In the database, a ObjectId
BSON object is stored.
Example:
created_by User
@inline
Marks the reference as being inline. This means:
- the referenced document will be deleted when the parent document is deleted
- all nested references will be automatically populated
Example use case: imagine a Post
collection which has an array of Comment
references that can be placed by users. There is no reason why a Comment
should exist without the post it is vinculated with, so it should be marked as inline so the proper cleanup would be done when the post is removed.
File
references are always inline.
Example:
comments []Comment @inline
@purge
Indicates the referenced document should be removed when the parent document is removed.
comments []Comment @purge
@indexes
Used to set which foreign properties should be used as indexes. Setting this property and running aeria -m
will result in collection indexes being created in the database.
Example:
customers []Customer @indexes([
"name",
"phone",
"document",
])
Array
Properties prefixed with an []
are turned into an array. For example, if you wish to have an array of strings, write []str
.
Example:
comments []{
properties {
text str
liked_by []User
}
}
A special syntax is used to add array constraints.
You may specify a range of minimum and maximum allowed array elements like so:
[1..3]
: minimum 1 element, maximum 3 elements[1..]
: minimum 1 element, no maximum limit[@uniqueItems]
: elements can not repeat within the array[1.. @uniqueItems]
: minimum 1 element, no maximum limit, elements can not repeat within the array