Defines and stores json models by indices within a leveldb
npm i -S level-wrangler
var level = require( 'level-party' )( '/tmp/.db' );
var sub = require( 'level-sublevel' )( level );
var db = require( 'level-wrangler' )( sub.sublevel( 'users', {
encoding: 'json'
}));
var users = db.createFactory( 'users', {} );
users.findAll()
.then( res => {
streamify( res.map( user => {
return user.name
}) ).pipe( process.stdout );
})
.catch( ... );
var user = users.create({
username: 'Jack',
password: 'wr4angl1ng'
});
user.save();
user.remove()
.then( ... )
.catch( ... )
Check out the test suite for more use examples.
npm run watch
Test it up
npm test
- non-intrusive-
wrangler
, give it a level instance with whatever plugins you want. - minimal model-schema that allows indexable props
- Pluggable—stuff like validation should be an extended module
- ES6 and babel—yuuup