localdatastore
v1.1.0
Published
Promise based client/server side storage. Uses IndexedDB/heap based on availability
Downloads
6
Maintainers
Readme
localdatastore
Unified implementation for saving data in browsers. Gracefully degrades from IndexedDB to WebSQL to Heap.
localdatastore is a fast and simple storage library for JavaScript. It improves the offline experience of your web app by using asynchronous storage (IndexedDB or WebSQL) with a simple API.
localdatastore uses Heap in browsers with no IndexedDB or WebSQL support.
To use localdatastore, just drop a single JavaScript file into your page:
<TBD>
<script src="localdatastore.js"></script>
or install with npm:
npm install localdatastore
This module is compatible with browserify and lasso.
Usage Details
var ds = require('localdatastore');
var selectedDataStore = ds.get();
var resolvedDataStore = ds.get(function() {
var ua = window.navigator.userAgent.toLowerCase();
if (ua.indexOf('msie') > -1) {
return 'heap';
} else if (ua.indexOf('safari') > -1 && ua.indexOf('chrome') === -1) {
return 'heap';
}
return 'idb';
});
var resolvedDataStore = ds.get('heap');
var database1 = selectedDataStore.init('DB_NAME_1', meta);
database1.insert();
var database2 = selectedDataStore.init('DB_NAME_2', meta);
database2.insert();
selectedDataStore.destroy('DB_NAME_2');