getRowCount
The getRowCount
method returns the count of the Row
objects in a given Table
.
getRowCount(tableId: string): number
Type | Description | |
---|---|---|
tableId | string | |
returns | number |
While this provides the same result as the length of Ids
array returned from the getRowIds
method, it is somewhat faster, and useful for efficient pagination.
Examples
This example retrieves the number of Row
objects in the Table
.
import {createStore} from 'tinybase';
const store = createStore().setTables({
pets: {
fido: {species: 'dog'},
felix: {species: 'cat'},
},
});
console.log(store.getRowCount('pets'));
// -> 2
This example retrieves the Row
Ids
of a Table
that does not exist, returning zero.
import {createStore} from 'tinybase';
const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
console.log(store.getRowCount('employees'));
// -> 0
Since
v4.1.0