Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

indexeddb-wrapper

afirus6MIT0.1.2TypeScript support: included

Creates a key value wrapper around IndexedDB.

readme

indexeddb-wrapper

Installation

npm install --save indexeddb-wrapper

Usage

import indexeddbWrapper from 'indexeddb-wrapper'

const { myStore } = createIndexeDBWrapper({ stores: ['myStore'] }) 

store.set('key', 'value')
    .then(() => store.get('key'))
    .then(console.log)

Warning

Use proper promise error handling to catch common errors like this:

store.get('key').then(console.log).catch(error => {
  if (error.name === 'QuotaExceededError') {
    alert('Failed to save. Not enough storage.');
  }
  throw error;
})

API

Interface: IndexeDBWrapper

stores

stores: object

Defined in index.ts:12

Interface: Store

destroy

destroy: function

Defined in index.ts:8

Type declaration:

▸ (): Promise‹void›


get

get: function

Defined in index.ts:3

Type declaration:

▸ (key: string): Promise‹any›

Parameters:

Name Type
key string

keys

keys: function

Defined in index.ts:4

Type declaration:

▸ (): Promise‹string[]›


purge

purge: function

Defined in index.ts:6

Type declaration:

▸ (): Promise‹void›


remove

remove: function

Defined in index.ts:7

Type declaration:

▸ (key: string): Promise‹void›

Parameters:

Name Type
key string

set

set: function

Defined in index.ts:5

Type declaration:

▸ (key: string, value: any): Promise‹void›

Parameters:

Name Type
key string
value any