TinyBase logoTinyBase

createIndexes

The createIndexes function creates an Indexes object, and is the main entry point into the indexes module.

createIndexes(store: Store): Indexes
TypeDescription
storeStore

The Store for which to register Index definitions.

returnsIndexes

A reference to the new Indexes object.

A given Store can only have one Indexes object associated with it. If you call this function twice on the same Store, your second call will return a reference to the Indexes object created by the first.

Examples

This example creates an Indexes object.

import {createIndexes, createStore} from 'tinybase';

const store = createStore();
const indexes = createIndexes(store);
console.log(indexes.getIndexIds());
// -> []

This example creates an Indexes object, and calls the method a second time for the same Store to return the same object.

import {createIndexes, createStore} from 'tinybase';

const store = createStore();
const indexes1 = createIndexes(store);
const indexes2 = createIndexes(store);
console.log(indexes1 === indexes2);
// -> true

Since

v1.0.0