hasSlice
The hasSlice
method returns a boolean indicating whether a given Slice
exists in the Indexes
object.
hasSlice(
indexId: Id,
sliceId: Id,
): boolean
Example
This example shows two simple Index
existence checks.
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.hasSlice('bySpecies', 'dog'));
// -> true
console.log(indexes.hasSlice('bySpecies', 'worm'));
// -> false