TinyBase logoTinyBase


The forEachTable method takes a function that it will then call for each Table in the Store.

forEachTable(tableCallback: TableCallback): void

The function that should be called for every Table.


This has no return value.

This method is useful for iterating over the Table structure of the Store in a functional style. The tableCallback parameter is a TableCallback function that will be called with the Id of each Table, and with a function that can then be used to iterate over each Row of the Table, should you wish.


This example iterates over each Table in a Store, and lists each Row Id within them.

const store = createStore().setTables({
  pets: {fido: {species: 'dog'}},
  species: {dog: {price: 5}},
store.forEachTable((tableId, forEachRow) => {
  forEachRow((rowId) => console.log(`- ${rowId}`));
// -> 'pets'
// -> '- fido'
// -> 'species'
// -> '- dog'