keyvaluedb
Key Value database middleware for node and the browser.
Install
Node
npm i keyvaluedb
Usage
Either a specific database class can be initialized, or the defaultDB
function can be used to attempt to find a DB that works in your runtime environment.
const { defaultDB, memoryDB, chromeStorageDB } = require('keyvaluedb')
const db = defaultDB()
await db.set('key', 'value')
await db.get('key') // value
await db.setMany({1: 1, 2: 2})
await db.getMany([1, 2]) // {1: 1, 2: 2}
Then you are free to make use of the promised based get
, set
, setMany
and getMany
functions. See tests for examples.
Mixin
To use as an es6 class mixin, first use object-to-class.
const o2c = require('object-to-class')
const MemoryDB = o2c(memoryDB, 'MemoryDB')
class MyDB extends MemoryDB {}
let mydb = new MyDB()
mydb instanceof MemoryDB // true
License
MIT Copyright isysd public@iramiller.com