nef
Proxy-based database
Install
npm install nef --save
Usage
const db = ;dbmoney;console; // 100
Docs
nef(data)
Creates a nef in-memory database. data
is optional and requires _save
function key property.
Each key of the database can be referred to as a collection and it returns
methods.
const nef = ;const db = ;
const db = { console; };
get(key, defaultValue)
Get a key. Use a default value of the key does not exist.
// database powers: flash: 'super speed' money: john: 3 phil: 10 dbpowers; // super speeddbpowers; // laser visiondbmoney; // 3
has(key)
Returns a boolean on whether or not a key exists.
dbposts; // falsedbposts; // true
keys()
Returns an array of the object's properties.
dbusers; // ['phil', 'mike', 'dan']
put(key, fn, defaultValue)
Applies a function to the key value and saves it. Use a default value if the key does not exist.
dbmoney;
remove(key)
Delete a key from the object.
dbusers;
set(key, value)
Set a key to a value.
dbranks;dbranks;dbtickets;dbtickets; // in database: ranks: user1: 1282 user2: 1984 tickets: user1: 123 user2: 752
Plugins
Plugins passes an object to nef to allow such things as persisting data when saving.