TinyBase logoTinyBase β

TablesSchema

The TablesSchema type describes the tabular 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 TablesSchema 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 setTablesSchema method.

Example

When applied to a Store, this TablesSchema 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.

import type {TablesSchema} from 'tinybase';

export const tableSchema: TablesSchema = {
  pets: {
    species: {type: 'string'},
    sold: {type: 'boolean', default: false},
  },
};

Since

v1.0.0