0.0.8 • Published 7 years ago

rauricoste-db-storage v0.0.8

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

Summary

This library provides a database-like storage for the browser using HTML5 storage and databases features. This library has been developped with ES6 features, so you need to use a build tool such as browserify if you run it in an ES6 uncompatible browser.

3 implementations are provided, based on :

Usage

const DbStorage = require("rauricoste-db-storage");
// choose one :
const MyStorageClass = DbStorage.IndexedDbStorage;
const MyStorageClass = DbStorage.LocalStorage;
const MyStorageClass = DbStorage.InMemoryStorage;

const name = "myItems";

const storage = new MyStorageClass(name, options);
if (!storage.isSupported()) {
    throw new Error("DbStorage is not supported !");
}
return storage.save("user", {
    name: "rauricoste"
}).then(() => {
    return storage.get("user");
}).then(item => {
    /*
        item = {
            name: "rauricoste"
        }
    */
}).catch(err => {
    console.error(err);
})

Initialization

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago