TinyBase logoTinyBase

setTablesJson

The setTablesJson method takes a string serialization of all of the Tables in the Store and attempts to update them to that.

setTablesJson(tablesJson: Json): Store
TypeDescription
tablesJsonJson

A string serialization of all of the Tables in the Store.

returnsStore

A reference to the Store.

If the JSON cannot be parsed, this will fail silently. If it can be parsed, it will then be subject to the same validation rules as the setTables method (according to the Tables type, and matching any TablesSchema associated with the Store).

Examples

This example sets the tabular contents of a Store from a serialization.

const store = createStore();
store.setTablesJson('{"pets": {"fido": {"species": "dog"}}}');
console.log(store.getTables());
// -> {pets: {fido: {species: 'dog'}}}

This example attempts to set the tabular contents of a Store from an invalid serialization.

const store = createStore();
store.setTablesJson('{"pets": {"fido": {');
console.log(store.getTables());
// -> {}

Since

v3.0.0