Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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
```javascript

var 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');

```