getRow
Essential
The getRow method returns an object containing the entire data of a single Row in a given Table.
getRow(
tableId: string,
rowId: string,
): RowNote 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