npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

indexeddb-crud

v5.3.0

Published

pack complex indexedDB CRUD methods to a friendly simple interface

Readme

indexedDB-CRUD

indexedDB-CRUD packs obscure indexedDB CRUD methods to a really friendly succinct interface. And offer multi-objectStore CRUD handler.

If you want to operate one or more indexedDB objectStore, just DB.open(config).then(successCallback).catch(), and you'll get a indexedDB-crud handler when its DB.open successed.

Hope you keep in mind that:

  • config's format should be correct
  • if you not input storeName explicitly in API, your config's first sotreName will be the default storeName
  • indexedDB object store can only hold JavaScript objects. The objects must have a property with the same name as the key path

Installation

npm install indexeddb-crud --save

yarn add indexeddb-crud

API Overview

first step

Only you open it, you can use these synchronous&asynchronous API.

synchronous API:

asynchronous API

indexeddb-crud support for the ES6 Promises API, so you can use then & catch carefree.

get:

add:

remove:

update:

usage

import

var DB = require('indexeddb-crud');

// or ES6
import DB from 'indexeddb-crud';

API

open(config)

  • initialData is Optional, and it's a array object
  • about initialData, key = 0 is just for demo, we only use key >= 1, so we usually begain at key = 1
  • your config's structure should like this, you must have a key(number type), in this following code key is id)
config = {
  "name": '',
  "version": '',
  "storeConfig": [
    {
      "storeName": '',
      "key": '',
      "storeConfig": [
        // must have key property, number type
      ]
    },
    // one or more storeConfig object
  ]
} 

correct config just like this:

var DBConfig = {
  "name": "JustToDo",
  "version": 23,
  "storeConfig": [
    {
      "storeName": "list",
      "key": "id",
      "initialData": [
        { "id": 0, "event": "JustDemo", "finished": true } // just for demo, not actual use
      ]
    }
  ]
};

If you need more than 1 ObjectStore:

var DBConfig = {
  "name": "JustToDo",
  "version": 23,
  "storeConfig": [
    {
      "storeName": "list",
      "key": "id",
      "initialData": [
        { "id": 1, "event": "JustDemo", "finished": true }
      ]
    },
    {
      "storeName": "aphorism",
      "key": "id",
      "initialData": [
        {
          "id": 1,
          "content": "You're better than that"
        },
        {
          "id": 2,
          "content": "Yesterday You Said Tomorrow"
        }
      ]
    }
  ]
}

e.g. successCallback:

function addEvents() {
  querySelector('#test').addEventlistener('click', clickHandler, false);
}
function clickHandler() {
  console.log('test');
}

DB.open(config).then(addEvents);

getLength(storeName?)

// If you have only 1 objectSotre, suggest use the default storeName
var randomIndex = Math.floor(DB.getLength() * Math.random());

// or pass storeName explicitly
var storeName = 'list';
var randomIndex = Math.floor(DB.getLength(storeName) * Math.random());

getNewKey(storeName?)

// If you have only 1 objectSotre, suggest use the default storeName
DB.getNewKey();

// or pass storeName explicitly
var storeName = 'list';
DB.getNewKey(storeName);

You will need it in addItem().

getItem(key, storeName?)

function doSomething(data) {
  console.log(data);
}

// If you have only 1 objectSotre, suggest use the default storeName 
DB.getItem(1).then(doSomething);

// or pass storeName explicitly
var storeName = 'list';
DB.getItem(1, storeName).then(doSomething);
  • the key should be a number, which matched to db's id

getConditionItem(condition, whether, storeName?)

  • whether is Boolean type
  • condition should be a boolean-condition, for example:
var DBConfig = {
  "name": "JustToDo",
  "version": 23,
  "storeConfig": [
    {
      "storeName": "list",
      "key": "id",
      "initialData": [
        { "id": 0, "event": "JustDemo", "finished": true } // just for demo, not actual use
      ]
    }
  ]
};

// If you have only 1 objectSotre, suggest use the default storeName 
DB.getConditionItem('finished', false).then(doSomething);

// or pass storeName explicitly
var storeName = 'list';
DB.getConditionItem('finished', false,storeName).then(doSomething);

getAll(storeName?)

function doSomething(dataArr) {
  console.log(dataArr);
}

// If you have only 1 objectSotre, suggest use the default storeName 
DB.getAll(doSomething);

// or pass storeName explicitly
var storeName = 'list';
DB.getAll(doSomething, storeName);

addItem(data, storeName?)

  • data's structure should at least contains number type key.

e.g.

var data = { 
  "id": DB.getNewKey(storeName), 
  "event": 'play soccer', 
  "finished": false 
};

// If you have only 1 objectSotre, suggest use the default storeName
DB.addItem(data);

// or pass storeName explicitly
var storeName = 'list';
DB.addItem(data, storeName);

removeItem(key, storeName?)

  • the key should be number type, which matched to db's key.
// If you have only 1 objectSotre, suggest use the default storeName 
DB.removeItem(1).then(doSomething);

// or pass storeName explicitly
var storeName = 'list';
DB.removeItem(1, storeName).then(doSomething);

removeConditionItem(condition, whether, storeName?)

  • whether is Boolean
  • condition should be a boolean-condition, for example:
var DBConfig = {
  "name": "JustToDo",
  "version": 23,
  "storeConfig": [
    {
      "storeName": "list",
      "key": "id",
      "initialData": [
        { "id": 0, "event": "JustDemo", "finished": true } // just for demo, not actual use
      ]
    }
  ]
};

// If you have only 1 objectSotre, suggest use the default storeName 
DB.removeConditionItem('true').then(successCallback);

// or pass storeName explicitly
var storeName = 'list';
DB.removeConditionItem('true', storeName).then(successCallback);

clear(storeName?)

// If you have only 1 objectSotre, suggest use the default storeName
DB.clear().then(doSomething);

// or pass storeName explicitly
var storeName = 'list';
DB.clear(storeName).then(doSomething);

updateItem(newData, storeName?)

var DBConfig = {
  "name": "JustToDo",
  "version": 23,
  "storeConfig": [
    {
      "storeName": "list",
      "key": "id",
      "initialData": [
        { "id": 0, "event": "JustDemo", "finished": true } // just for demo, not actual use
      ]
    }
  ]
};

// If you have only 1 objectSotre, suggest use the default storeName
DB.updateItem(newData).then(doSomething);

// or pass storeName explicitly
var storeName = 'list';
DB.updateItem(newData, storeName).then(doSomething);

example

a simple todolist web-app, storage data in indexedDB (use indexeddb-crud to handler 2 different objectStores): https://github.com/RayJune/JustToDo/blob/gh-pages/src/scripts/main.js

author

RayJune: a CS university student from Fuzhou, Fujian, China

License

MIT