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