browser-storage-db
v1.0.0
Published
Simple db based on browser localStorage or sessionStorage
Downloads
3
Maintainers
Readme
browser-storage-db
BrowserStorageDB give you posibility to save and find data in localStorage or sessionStorage with basic mongoDB interface.
Examples
set(documents: [Object]): void
import LocalStorageDB from 'browser-storage-db';
const db = new LocalStorageDB('testDB', localStorage);
const initialState = [{ id:'1', name:'foo', desc: 'bar' }, { id:'2', name:'foo2', desc: 'bar2' }];
db.set(initialState);
insert(document: Object): String
import LocalStorageDB from 'browser-storage-db';
const db = new LocalStorageDB('testDB', localStorage);
const document = { name:'foo', desc: 'bar' };
const documentId = db.insert(document);
update(id: String, data: Object): void
import LocalStorageDB from 'browser-storage-db';
const db = new LocalStorageDB('testDB', localStorage);
const documentId = '3d3d4sda3sd';
const document = { name:'foo2', desc: 'bar2' };
db.update(documentId, document);
find(query: Object): [Object]
import LocalStorageDB from 'browser-storage-db';
const db = new LocalStorageDB('testDB', localStorage);
const query = { name: 'foo2' };
const documents = db.find(query);
findOne(query: Object): Object
import LocalStorageDB from 'browser-storage-db';
const db = new LocalStorageDB('testDB', localStorage);
const query = { name: 'foo2' };
const document = db.findOne(query);
To see more complex examples, check out this project's test suite.