Remodel
Generator-based query interface for rethinkdb.
A simple wrapper around the excellent rethinkdb lib, with generator support, and some modeling goodness thrown in.
Installation
$ npm install remodel
Example
var r = require('rethinkdb');
var co = require('co');
var remodel = require('./')('localhost');
var User = remodel.create('Users');
co(function *() {
var dbList = yield remodel(r.dbList());
var user = yield User.filter({email: 'a@test.com'});
})();
Usage
var r = require('rethinkdb');
remodel = require('remodel'){
host: 'localhost',
port: 28015,
db: 'test',
authKey: '',
maxPoolSize: 10
});
function *() {
yield remodel.query(r.dbList());
yield remodel.query(r.db('test').tableList());
yield remodel.query(r.db('test').table('Users').insert({email: 'test@test.com'}));
yield remodel.q(r.dbList());
yield remodel(r.dbList());
}
var User = remodel.create('Users');
function *() {
yield User.all();
User.findByEmail = function *(email) {
return yield this.filter({email: email.trim().toLowerCase()});
}
var user = yield User.get(1234);
var users = yield User.filter({email: 'test@test.com'});
var users = yield User.getAll('test@test.com', {index: 'email'});
yield User.between
yield User.count
yield User.filter
yield User.forEach
yield User.get
yield User.getAll
yield User.groupBy
yield User.groupedMapReduce
yield User.indexCreate
yield User.indexList
yield User.indexWait
yield User.info
yield User.insert
yield User.limit
yield User.map
yield User.orderBy
yield User.pluck
yield User.skip
yield User.union
yield User.withFields
yield User.without
}
License
MIT