js-data-localstorage
localStorage adapter for js-data.
Tested on IE9, Chrome 46, Firefox 41 & Safari 7.1 using
Table of contents
Quick Start
npm install --save js-data js-data-localstorage
or bower install --save js-data js-data-localstorage
.
Load js-data-localstorage.js
after js-data.js
.
var adapter = new LocalStorageAdapter();
var store = new JSData.DataStore();
store.registerAdapter('localstorage', adapter, { default: true });
// "store" will now use the localstorage adapter
You can also provide a custom storage medium (it just needs to implement the localStorage
API):
var memory = {};
// Turn js-data-localstorage into an in-memory adapter
var memoryAdapter = new LocalStorageAdapter({
storage: {
getItem: function (key) {
return memory[key];
},
setItem: function (key, value) {
return memory[key] = value;
},
removeItem: function (key) {
delete memory[key];
}
}
});
// Turn js-data-localstorage into a sessionStorage adapter
var sessionAdapter = new LocalStorageAdapter({
storage: sessionStorage
});
Guides and Tutorials
Get started at http://js-data.io
API Reference Docs
Demo
https://js-data-localstorage.firebaseapp.com/
Community
Support
Contributing
License
The MIT License (MIT)
Copyright (c) 2014-2016 js-data-http project authors