Skip to content

conversejs/localForage-getItems

 
 

Repository files navigation

@converse/localforage-getitems

This is a fork of localforage-getitems which adds support for the getAll function for IndexedDB.

The upstream pull request is here: localForage#12

The upstream project appears to be unmaintained and hasn't had any changes in 5 years.

Requirements

  • localForage v1.4.0+
    • for earlier versions of localforage, please use the v1.1.x releases

Installation

npm i @converse/localforage-getitems

jsperf links

API

Just like getItem() but you can pass an array with the keys that need to be retrieved.

const keys = ['asdf','asap','async'];

localforage.getItems(keys).then((results) => {
  console.log(results);
  // prints:
  // {
  //   asdf: 'asdf value!',
  //   asap: 'asap value!',
  //   async: 'async value!'
  // }

  console.log(results.asdf);
  console.log(results['asdf']);
  console.log(results[keys[0]]);
  // all the above print 'asdf value!'
});

Invoking getItems() without arguments (or with null as the first argument) will retrieve all the items of the current driver instance.

localforage.getItems().then((results) => { });

// or by using callbacks
localforage.getItems(null, results) => { });

About

Adds getItems method to localForage.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 88.2%
  • TypeScript 11.8%