getTable
The getTable method returns an object containing the entire data of a single Table in the Store.
getTable(tableId: string): TableNote that this returns a copy of, rather than a reference to the underlying data, so changes made to the returned object are not made to the Store itself.
Examples
This example retrieves the data in a single Table.
import {createStore} from 'tinybase';
const store = createStore().setTables({
pets: {fido: {species: 'dog'}},
species: {dog: {price: 5}},
});
console.log(store.getTable('pets'));
// -> {fido: {species: 'dog'}}
This example retrieves a Table that does not exist, returning an empty object.
import {createStore} from 'tinybase';
const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
console.log(store.getTable('employees'));
// -> {}
Since
v1.0.0