Skip to content

Schemas

A JavaScript schema can be a class schema or an object schema.

class Project extends Barq.Object<Project> {
_id!: Barq.Types.ObjectId;
name!: string;
archived = false;
static schema: Barq.ObjectSchema = {
name: 'Project',
primaryKey: '_id',
properties: {
_id: 'objectId',
name: 'string',
archived: { type: 'bool', default: false },
},
};
}

Open with:

const barq = await Barq.open({
schema: [Project],
});

For local files, bump schemaVersion.

await Barq.open({
schema: [Project],
schemaVersion: 2,
});

Synced schemas should be changed carefully across all clients that use the same synced data.