TinyBase logoTinyBase β

forEachCell

The forEachCell method takes a function that it will then call for each Cell in a specified Row.

forEachCell(
  tableId: string,
  rowId: string,
  cellCallback: CellCallback,
): void
TypeDescription
tableIdstring

The Id of the Table containing the Row to iterate over.

rowIdstring

The Id of the Row to iterate over.

cellCallbackCellCallback

The function that should be called for every Cell.

returnsvoid

This has no return value.

This method is useful for iterating over the Cell structure of the Row in a functional style. The cellCallback parameter is a CellCallback function that will be called with the Id and value of each Cell.

Example

This example iterates over each Cell in a Row, and lists its value.

import {createStore} from 'tinybase';

const store = createStore().setTables({
  pets: {fido: {species: 'dog', color: 'brown'}},
});
store.forEachCell('pets', 'fido', (cellId, cell) => {
  console.log(`${cellId}: ${cell}`);
});
// -> 'species: dog'
// -> 'color: brown'

Since

v1.0.0