TinyBase logoTinyBase


The setTable method takes an object and sets the entire data of a single Table in the Store.

  tableId: string,
  table: Table,
): Store

The Id of the Table in the Store.


The data of a single Table to be set.


This method will cause listeners to be called for any Table, Row, Cell, or Id changes resulting from it.

Any part of the provided object that is invalid (either according to the Table type, or because it does not match a TablesSchema associated with the Store), will be ignored silently.

Assuming that at least some of the provided Table object is valid, any data that was already present in the Store for that Table will be completely overwritten. If the object is completely invalid, no change will be made to the Store.

The method returns a reference to the Store so that subsequent operations can be chained in a fluent style.


This example sets the data of a single Table.

const store = createStore().setTable('pets', {
  fido: {species: 'dog'},
  felix: {species: 'cat'},
// -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}

This example attempts to set the data of an existing Store with partly invalid, and then completely invalid, Table objects.

const store = createStore().setTables({pets: {fido: {species: 'dog'}}});

store.setTable('pets', {felix: {species: 'cat', bug: []}});
// -> {pets: {felix: {species: 'cat'}}}

store.setTable('pets', {meaning: 42});
// -> {pets: {felix: {species: 'cat'}}}