TinyBase logoTinyBase

getCell

The getCell method returns the value of a single Cell in a given Row, in a given Table.

getCell(
  tableId: Id,
  rowId: Id,
  cellId: Id,
): CellOrUndefined
TypeDescription
tableIdId

The Id of the Table in the Store.

rowIdId

The Id of the Row in the Table.

cellIdId

The Id of the Cell in the Row.

returnsCellOrUndefined

The value of the Cell, or undefined.

Examples

This example retrieves a single Cell.

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

This example retrieves a Cell that does not exist, returning undefined.

const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
console.log(store.getCell('pets', 'fido', 'color'));
// -> undefined