TinyBase logoTinyBase β

getRow

The getRow method returns an object containing the entire data of a single Row in a given Table.

getRow(
  tableId: string,
  rowId: string,
): Row
TypeDescription
tableIdstring

The Id of the Table in the Store.

rowIdstring

The Id of the Row in the Table.

returnsRow

An object containing the entire data of the Row.

Note that this returns a copy of, rather than a reference to the underlying data, so changes made to the returned object are not made to the Store itself.

Examples

This example retrieves the data in a single Row.

import {createStore} from 'tinybase';

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

This example retrieves a Row that does not exist, returning an empty object.

import {createStore} from 'tinybase';

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

Since

v1.0.0