getSliceRowIds
The getSliceRowIds method gets the list of Row Ids in a given Slice, within a given Index.
getSliceRowIds(
indexId: string,
sliceId: string,
): Ids| Type | Description | |
|---|---|---|
indexId | string | |
sliceId | string | |
| returns | Ids |
If the identified Index or Slice do not exist (or if the definition references a Table that does not exist) then an empty array is returned.
Example
This example creates a Store, creates an Indexes object, and defines a simple Index. It then uses getSliceRowIds to see the Row Ids in the Slice (and also the Row Ids in Slices that do not exist).
import {createIndexes, createStore} from 'tinybase';
const store = createStore().setTable('pets', {
fido: {species: 'dog'},
felix: {species: 'cat'},
cujo: {species: 'dog'},
});
const indexes = createIndexes(store);
indexes.setIndexDefinition('bySpecies', 'pets', 'species');
console.log(indexes.getSliceRowIds('bySpecies', 'dog'));
// -> ['fido', 'cujo']
console.log(indexes.getSliceRowIds('bySpecies', 'worm'));
// -> []
console.log(indexes.getSliceRowIds('byColor', 'brown'));
// -> []
Since
v1.0.0