var rethinkdbPool = require('koa-rethinkdb');
var r = require('rethinkdb');
var chan = require('chan');
app.use(rethinkdbPool(options));
app.use(function *(next) {
// get the list of table
var ch1 = chan();
var query1 = r.db('test').tableList().run(this.rethinkdb, ch1);
var list = yield ch1;
// select a few documents
ch2 = chan();
r.db('test').table('foobar').limit(10).run(this.rethinkdb, ch2);
cursor = yield ch2;
result = yield cursor.toArray;
yield next;
// connections are released back to the pool.
});
请发表评论