setTablesSchema
The setTablesSchema method lets you specify the TablesSchema of the tabular part of the Store.
setTablesSchema(tablesSchema: TablesSchema): this| Type | Description | |
|---|---|---|
tablesSchema | TablesSchema | The |
| returns | this | A reference to the |
Note that this may result in a change to data in the Store, as defaults are applied or as invalid Table, Row, or Cell objects are removed. These changes will fire any listeners to that data, as expected.
When no longer needed, you can also completely remove an existing TablesSchema with the delTablesSchema method.
Example
This example sets the TablesSchema of a Store after it has been created.
import {createStore} from 'tinybase';
const store = createStore().setTablesSchema({
pets: {
species: {type: 'string'},
sold: {type: 'boolean', default: false},
},
});
store.addRow('pets', {species: 'dog', color: 'brown', sold: 'maybe'});
console.log(store.getTables());
// -> {pets: {0: {species: 'dog', sold: false}}}
Since
v3.0.0