Team Databases
PixieBrix supports Team Database for storing data across extension runs, browsers, and team members.
A team database is a key-value stores. Each record is referenced by a unique key, and stores a JSON object.
Schemas
By default, databases allow any shape of data to be stored in the database. However, you can also set a schema for the database, and optionally enforce that schema.
Schemas are defined using the JSON Schema standard (the same standard used for defining brick input and output schemas in PixieBrix).
Default Schema
The default schema allows objects of any shape to be stored:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {},
"additionalProperties": true
}
Required Fields
To require fields, use JSON Schema’s required attribute. For example:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"example": {
"type": "string"
}
},
"required": ["example"],
"additionalProperties": true
}
Additional Properties
By default, JSON Schema objects allows additional fields that aren’t defined on the schema. To forbid additional properties, set additionalProperties: false
Forbidding additional properties is useful for preventing errors due to field name typos/misspelled fields
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"example": {
"type": "string"
}
},
"required": ["example"],
"additionalProperties": false
}
Enforcing a Schema
Enforcing a schema applies to new records and updates to existing records
To enforce a schema, toggle the “Enforce schema” toggle on the Database detail screen’s Schema tab:
When using the shallow
, deep
, and deep_append
merge strategies, PixieBrix enforces the schema for the resulting data (i.e., as opposed to the partial data in the update).