qqdb
v1.0.1
Published
Zero-dependency key value store for short-lived scripts, AKA NSUserDefaults for Node.js
Downloads
2
Readme
qqdb
Zero dependency key-value storage for Node.js. Because sometimes you need that.
Basically, NSUserDefaults for your script. Store and retrieve any JSON-serializable data. 100% synchronous.
install
npm install qqdb
api
constructor(local = false, location?: string)
Creates or loads an existing .qqdb
file.
By default, local
is set to true
, meaning the DB will be stored in your current working directory.
If set to false, the DB will be stored in $HOME
.
If set to false with a location, the location will be used.
If a file already exists, it will be loaded.
get(key: string)
Gets the value at a key. Will return null
if the key does not exist.
set(key: string, value: jsonSerializable) : this
Sets the value (any JSON-serializable thing, like a string, array, object, number, etc.) at the key and then saves the database. Returns the QuickDB instance for chaining.
usage
const QQDB = require('qqdb');
const qdb = new QQDB();
qdb.set('SOME_API_KEY', '0xDEADBEEF');
const key = qdb.get('SOME_API_KEY');
need to set a bunch of vars? try chaining!
qdb.set('key1', 'val1')
.set('key2', 'val2')
.set('key3', 'val3'); // always returns the instance