Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/diewland/kvdb
Micro key-value database based on localStorage
https://github.com/diewland/kvdb
Last synced: 2 days ago
JSON representation
Micro key-value database based on localStorage
- Host: GitHub
- URL: https://github.com/diewland/kvdb
- Owner: diewland
- Created: 2016-10-14T09:06:24.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-21T10:10:28.000Z (almost 8 years ago)
- Last Synced: 2024-11-06T23:43:15.794Z (8 days ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# KvDb
[![npm](https://img.shields.io/npm/v/kv-db.svg)](https://www.npmjs.com/package/kv-db)Micro key-value database based on HTML5 localStorage :scream_cat:
### install
```npm install kv-db```### example
```javascriptvar TestDb = new KvDb('TEST_DB');
// C - create
TestDb.set('key1', 'value1');
TestDb.set('key2', 'value2');
TestDb.set('key3', 'value333');
TestDb.set('junk_key', 'some_junk');
// R - remove
TestDb.remove('junk_key');
// U - update
TestDb.set('key3', 'value3');
// D - display
console.log('#', 'key1', TestDb.get('key1'));
console.log('#', 'key2', TestDb.get('key2'));
console.log('#', 'key3', TestDb.get('key3'));
// or
var all = TestDb.all();
for(var i in all){
var o = all[i];
console.log('>', o.k, o.v);
}
// and drop
TestDb.drop('TEST_DB');```