Schemas and models
Barq stores objects. A schema tells Barq the object name, primary key, and field types.
JavaScript Schema
Section titled “JavaScript Schema”class Task extends Barq.Object<Task> { _id!: Barq.Types.ObjectId; description!: string; done = false;
static schema: Barq.ObjectSchema = { name: 'Task', primaryKey: '_id', properties: { _id: 'objectId', description: 'string', done: { type: 'bool', default: false }, }, };}C++ Schema
Section titled “C++ Schema”struct Dog { std::string name; int64_t age;};
BARQ_SCHEMA(Dog, name, age)- Define the schema before first open.
- Bump
schemaVersionwhen changing a local schema. - Use migrations for local files that already exist.
- Synced schemas must match what the synced clients and server expect.