TinyBase logoTinyBase

useHasIndex

The useHasIndex primitive returns a boolean indicating whether a given Index exists in the Indexes object, and registers a listener so that any changes to that result will cause an update.

useHasIndex(
  indexId: MaybeAccessor<string>,
  indexesOrIndexesId?: MaybeAccessor<undefined | IndexesOrIndexesId>,
): Accessor<boolean>
TypeDescription
indexIdMaybeAccessor<string>

The Id of a possible Index in the Indexes object.

indexesOrIndexesId?MaybeAccessor<undefined | IndexesOrIndexesId>

The Indexes object to be accessed: omit for the default context Indexes object, provide an Id for a named context Indexes object, or provide an explicit reference.

returnsAccessor<boolean>

Whether an Index with that Id exists.

This primitive follows the same Indexes object resolution rules as the useIndexIds primitive.

Since

v9.1.0