Tables
The "tables" section is where all your table structures are defined. Tables take the following structure:
{
"name": "table_1",
"columns": [
{
"name": "id",
"type": 103, // int32
"attributes": [
{
"type": 101 // primary_key
}
]
},
{
"name": "name",
"type": 101 // string
},
{
"name": "age",
"type": 103, // int32
"attributes": [
{
"type": 103 // not null
},
{
"type": 105, // min
"value": "A6QBAAA=" //encoded value
}
]
}
]
}
The name is the unique identifier for your table. A table's name must be unique within your database. Please reference the conventions page for more information on naming rules.
The column "name" field is the unique identifier that is used for your column. Column names must only be unique within the table they exist in.
The column "type" field is used to indicate the data type of the column. Data types are passed as an enumerator. See the data types section for more information on supported data types and their enumerator.
Attributes are restraints and behaviors that are applied to a column. These include typical database constraint such as min/max, unique, and not null, but also include functionality like default values and primary keys.
Some attributes need values provided with them. In the JSON, the value is stored as a base64 encoded byte array, prepended with the enumerator of its corresponding data type. For example, if you wish to set a maximum length on a string, then you must provide an int32 value with it. However, if you want to set a column to be not null, then no value needs to be provided. This is shown in the column named "name" below:
{
"name": "name",
"type": 102, // string
"attributes": [
{
"type": 103 // not null
},
{
"type": 108, // max length
"value": "ZxQAAAA="
}
]
}
The above column would be called "name", have a "string" type, be guaranteed not null, and would have a maximum length of 20 characters. The encoded value of 20 as an int32 is ZxQAAAA=, as shown in the value field.
See the attributes conventions section for a list of all attributes, their enumerators, and their restrictions.
Last modified 28d ago