Storing Data with Team Databases

PixieBrix supports Team Database for storing data across mod runs, browsers, and team members.

A team database is a key-value store. Each record is referenced by a unique key, and stores a JSON object.

Creating a Team Database

To create a Team Database, open the Databases screen from the side nav.

Then, click the Create Database button:

Exporting a Team Database

PixieBrix supports exporting a Team Database as:

  • CSV

  • JSON

To export a database, click the Export button on the Databaseโ€™s detail page:

In the modal, optionally select a date range to export:

Creating/Retrieving/Updating Database Records

Team Database records can be used within PixieBrix mods or with the Developer API

PixieBrix marketplace listing for database bricks:

Schemas

By default, Team 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.

A schema describes the data shape and types that are contained in the Database.

In PixieBrix, database 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:

Copy

{
  "$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:

Copy

{
  "$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

Copy

{
  "$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).

Last updated