Schema
How schemas work in Basic
Overview
In Basic, we declare schemas in a JSON format as part of the basic.config.ts
or basic.config.js
file that lives in your repository.
It would follow this general format:
The top level requires three parameters:
project_id
This is your project ID, which you can find in the Basic dashboard, or will be auto-generated for you if you had used the CLI to create your project.
version
This will be used for versioning your schema. It should be an integer that starts at 0 and increments by 1 for each new version.
Tables
Letβs double click into the tables to learn how they are declared in the schema.
Each table is declared as an object where the key is the table name and the value is an object with the following two parameters:
type
This refers to the type of database table you are creating. At the moment, Basic only supports collection
, which will operate similarly to MongoDB collections.
fields
Fields are the columns of the table. They will be declared as an object of objects. Learn more about the fields below.
Fields
Each field is declared as an object where the key is the field name and the value is an object with the following 2 parameters:
type
This is the data type of the field. Basic supports the following field types: string
, int
, boolean
, json
, text
.
indexed
This lets you control if the field should be indexed in the userβs client database for local-first benefits. For now, this should always be set to true
.
Example
When put all together, your schema could look like this: