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 🙏

© 2025 – Pkg Stats / Ryan Hefner

fluent-indexed-db

v1.1.1

Published

A fluent implementation of IndexedDB with easy to use api calls.

Readme

Fluent IndexedDB

This package is based on IndexedDB with Promises and provides a fluent way to interact with the database while still returning promises. It also includes the IndexedDB Shim Polyfill for browser compatibility.

Installation

Pull in the package through NPM.

Run npm install fluent-indexed-db

Usage

Open the database and upgrade as per the needs

var database = require('fluent-indexed-db');


database.open('test-db', 4, function (upgradeDB) {
    switch(upgradedatabase.oldVersion) {
        case 0:
            database.createObject(upgradeDB, 'keyVal');
            database.createObject(upgradeDB, 'vehicles');
            database.createObject(upgradeDB, 'people', { keyPath: 'id' });
        case 1:
            database.deleteObject(upgradeDB, 'people');
            database.createObject(upgradeDB, 'drivers', { keyPath: 'id' });
        case 2:
            database.createIndex(upgradeDB, 'drivers', 'experience', 'years_driving');
        case 3:
            database.createIndex(upgradeDB, 'vehicles', 'capacity', 'seats');
    }
});

####Create an entry [database.get(objectStore, create, value)] Create the value bar with the key foo

database.create('keyVal', 'foo', 'bar');

####Read one value [database.get(objectStore, key)] Read the created value under the key foo

database.get('keyval', 'foo').then(function (value) {
    console.log(value);
});

####Read all values [database.all(objectStore, index = null, filter = null)] Read all the values contained in a given store. The index and the filter are both optional.

database.all('vehicles', 'capacity', 8).then(function (values) {
    console.log(values);
});

database.all('vehicles').then(function (values) {
    console.log(values);
});

####Read all values but use a cursor [database.allUsingCursor(objectStore, index = null, filter = null)] You might want to read all the values but one at a time. For that use the cursor.

database.allUsingCursor('vehicles').then(function logVehicle(cursor) {
    if (! cursor) return;
    console.log("Cursor at: ", cursor.value.seats);

    return cursor.continue().then(logVehicle);
}).then(() => {
    console.log("Done cursoring");
});

database.allUsingCursor('vehicles', 'capacity', 8).then(function logVehicle(cursor) {
    if (! cursor) return;
    console.log("Cursor at: ", cursor.value.seats);

    return cursor.continue().then(logVehicle);
}).then(() => {
    console.log("Done cursoring");
});

####Insert multiple values [database.insert(objectStore, values)]

Insert multiple values to the object store. The second argument is an array that contains the values.

database.insert('vehicles', [
    {
        'seats' : 4,
        'registration' : 123456,
        'color': 'blue'
    },
    {
        'seats' : 8,
        'registration' : 654321,
        'color': 'red'
    },
]);

####Clear the data store [database.clear(objectStore)]

This function is useful when you need to truncate the whole data store.

database.clear('vehicles');

####Get the count [database.count(objectStore, filter)]

This function is useful when you need to get the total number of items in the store. The second argument is used to filter the results to meet a certain criteria.

database.count('vehicles').then((count) => {
     console.log(count);
});

####Delete an item from the store [database.deleteKey(objectStore, key)]

When you need to remove an item from the store, call this function with the store and the key as the arguments.

database.deleteKey('keyVal', 'foo');

####Get the current database promise [database.getDatabase()]

When you need to perform any other function not provided by this package, call the getDatabase function and you will receive the current database as a promise.

var dbPromise = database.getDatabase();

dbPromise.then(function (db) {
    var transaction = database.transaction('keyVal', 'readwrite');
    transaction.objectStore('keyVal')
    .put('bar', 'foo');
    
    return transaction.complete;
})

##Support

For any inquiries or support please drop a mail at [email protected]

##License

This Package is licenced under the MIT license.