Supported Data Types
Data types are used to define property's type when writting Document schema. Currently, Vasern supports:
- Basic data types includes
string
,int
,double
,datetime
, andreference
using#
followed by schema'sname
. - Each type also has its characteristic
optional using "?"
, andlist using "[]"
To help you better understand about using data types in the schema, we will use Todo use case
as an example. Then explains about data types used.
Todo use case
For now, we will only focus about the schema definition props
in this example.
const TodoSchema = {
name: "Todos",
props: {
name: "string",
note: "?string",
notifyOn: "?datetime",
completed: "boolean",
parent: "#Todos",
assignedTo: "[]#User"
}
}
Basic data types
In the above example, basic data types are:
string
, used byname
,note
datetime
, used bynotifyOn
boolean
, used bycompleted
#
indicatereference
, used byparent
andassignedTo
.
Type characteristic
?
indicatesoptional
, which allow value to beundefined
, used bynote
, andnotifyOn
.[]
indicateslist
, which contains a list of basic types, used byassignedTo
Note: Do not provide optional
for list
, as a list
length starts from 0
What's next
Learn how to write schema and create Vasern instance