TinyBase logoTinyBase

getTable

The getTable method returns an object containing the entire data of a single Table in the Store.

getTable(tableId: string): Table
TypeDescription
tableIdstring

The Id of the Table in the Store.

returnsTable

An object containing the entire data of the Table.

Note 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.

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.

const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
console.log(store.getTable('employees'));
// -> {}