TinyBase

Schema

The Schema type describes the structure of a Store in terms of valid Table Ids and the types of Cell that can exist within them.

{[tableId: Id]: {[cellId: Id]: CellSchema}}

A Schema comprises a JavaScript object describing each Table, in turn a nested JavaScript object containing information about each Cell and its CellSchema. It is provided to the setSchema method.

Example

When applied to a Store, this Schema only allows one Table called pets, in which each Row may contain a string species Cell, and is guaranteed to contain a boolean sold Cell that defaults to false.

const schema: Schema = {
  pets: {
    species: {type: 'string'},
    sold: {type: 'boolean', default: false},
  },
};