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| Type | Description | |
|---|---|---|
tableId | string | |
rowId | string | |
cellCallback | CellCallback | The function that should be called for every |
| returns | void | 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