TinyBase logoTinyBase

getSliceIds

The getSliceIds method gets the list of Slice Ids in an Index.

getSliceIds(indexId: string): Ids
TypeDescription
indexIdstring

The Id of the Index.

returnsIds

The Slice Ids in the Index, or an empty array.

If the identified Index does 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 getSliceIds to see the available Slice Ids in the Index (and also the Slice Ids in an Index that has not been defined).

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.getSliceIds('bySpecies'));
// -> ['dog', 'cat']
console.log(indexes.getSliceIds('byColor'));
// -> []

Since

v1.0.0