modella-level-relations
install
npm install [--save/--save-dev] modella-level-relations
example
var relations = modella = sublevel = store = level = timehat = assert = series = var db = var sub = var User = UserUserUserUser var frank = var charlie =
api
use
On every Model that needs relations, Model.use should be called:
var relations = var store = var level = '/path/to/my/db' var User = UserUser
Important: modella-level-relations
requires level as the modella
backend.
put(from, to, callback)
User
emits pre relation
and relation
events
has(from, to, callback)
User
get(from[, options])
User
each(from[, options], each, end)
User
all(from[, options], fn)
Userallmodel_instance_a {}
one(from[, options], fn)
Todo
options
start
: the relation id key you wish to start the read at.end
: the relation id key you wish to end the read at.reverse
(boolean, default: true): by default, the relations are fetched in reverse order: the last added relation is the first to be fetchedlimit
(number, default: -1): limit the number of results
del(from, to, callback)
User
emits relation
event
delAll(from, callback)
User
count(from, callback)
User
toggle(from, to, callback)
User
relations.put(from, to, callback)
var relations = // `a` -> following -> `b`// `b` -> followers -> `a`
relations.del(from, to, callback)
var relations = // `a` -> !following -> `b`// `b` -> !followers -> `a`
relations.delAll(from, to, callback)
var relations = // `a` -> !following -> all// each -> !followers -> `a`
relations.has(from, to, callback)
var relations = // (`a` -> following -> `b`) && (`b` -> followers -> `a`)
relations.toggle(from, to, callback)
var relations = // `a` -> !following -> `b`// `b` -> !followers -> `a`
license
MIT