localforage-indexes
Plugin for localforage to work with indexes in indexedDb localForage.
Requirements
- localforage v1.4.0+
Installation
npm i localforage-indexes
API
createIndex
createIndex(indexName, keyPath[, options[, callback]])
Creates an index on the specified storage Supports promises and callbacks
Promise case:
localforage;
Callback case:
localforage;
getIndex
getIndex(indexName[, callback])
Updates existing index on the specified storage Supports promises and callbacks
Promise case:
localforage;
Callback case:
localforage
updateIndex
updateIndex(indexName, keyPath[, options[, callback]])
Updates existing index on the specified storage Used to change keyPath or options of an index Supports promises and callbacks
Promise case:
localforage;
Callback case:
localforage;
deleteIndex
deleteIndex(indexName[, callback])
Updates existing index on the specified storage Supports promises and callbacks
Promise case:
localforage;
Callback case:
localforage
Methods' arguments
Arguments are the same as of vanilla indexedDb API Details
indexName
- index name, must be unique for the store
keyPath
- path of the field that index is based upon, separated by dot: EXAMPLE.KEY.PATH
options
:
multiEntry
- will make an effect if keyPath resolves to an array. If true multiple index entry will be created for each array element, if false single instance is created. Default: falseunique
- if set to true removes duplicates from index. Default: falsecallback
- Callback function. If one is provided method call won't return a promise. Instead a callback will be called when the indexedDB transaction is finished.
Usage
Warning: Firefox and Safari do not support usage of Promises with indexedDB's transactions
Any transaction passed through native promise will get destroyed. Firefox/Safari transactions can still be used with callbacks.
Intended to use only with indexedDb. Custom driver to be compatible with indexes must inherit from localforage's indexdDb(asyncStorage) driver.
; localforage
Can be used with a single instance of localforage for each indexDb database.
; var forage = localforage; var another_forage = localforage; forage;