TinyBase logoTinyBase

hasIndex

The hasIndex method returns a boolean indicating whether a given Index exists in the Indexes object.

hasIndex(indexId: Id): boolean
TypeDescription
indexIdId

The Id of a possible Index in the Indexes object.

returnsboolean

Whether an Index with that Id exists.

Example

This example shows two simple Index existence checks.

const indexes = createIndexes(createStore());
indexes.setIndexDefinition('bySpecies', 'pets', 'species');
console.log(indexes.hasIndex('bySpecies'));
// -> true
console.log(indexes.hasIndex('byColor'));
// -> false