TinyBase

getCellIds

The getCellIds method returns the Ids of every Cell in a given Row, in a given Table.

getCellIds(
  tableId: string,
  rowId: string,
): Ids
TypeDescription
tableIdstring

The Id of the Table in the Store.

rowIdstring

The Id of the Row in the Table.

returnsIds

An array of the Ids of every Cell in the Row.

Note that this returns a copy of, rather than a reference, to the list of Ids, so changes made to the list are not made to the Store itself. Although the order of Ids have no meaning, this method is expected to return them in the order in which each Row was added.

Examples

This example retrieves the Cell Ids in a Row.

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

This example retrieves the Cell Ids of a Cell that does not exist, returning an empty array.

const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
console.log(store.getCellIds('pets', 'felix'));
// -> []