0.2.0 • Published 5 years ago

idb-localstorage v0.2.0

Weekly downloads
11
License
Apache-2.0
Repository
-
Last release
5 years ago

LocalStorage compliant Indexed DB storage

Usage

import { Store } from 'idb-localstorage';

const store = new Store('db-name', 'store-name');  
store.setItem('hello', 'world');
store.setItem('foo', 'bar');

NOTE: All methods return Promise

API

get:

// logs: "world"
store.getItem('hello').then(val => console.log(val));

If there is no 'hello' key, then val will be undefined.

keys:

import { keys } from 'idb-keyval';

// logs: ["hello", "foo"]
store.keys().then(keys => console.log(keys));

del:

import { del } from 'idb-keyval';

store.removeItem('hello');

clear:

import { clear } from 'idb-keyval';

store.clear();