TinyBase

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
rowIdstring
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 called with the Id and value of each Cell.

Example

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

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