Socket
Socket
Sign inDemoInstall

koa-rethinkdb

Package Overview
Dependencies
3
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    koa-rethinkdb

Koa middleware that gets you a RethinkDB client


Version published
Weekly downloads
7
Maintainers
1
Created
Weekly downloads
 

Readme

Source

koa-rethinkdb

Koa middleware that gets you a RethinkDB client via connection pool.

It handles acquire and release connection automatically.

Installation

npm install --save koa-rethinkdb

Use

var rethinkdbPool = require('koa-rethinkdb');

var options = {
    host:'localhost',
    port:28015,
    db:'marvel',
    authKey:'hunter2'
};

app.use(rethinkdbPool(options, maxConcurrentConnection || 10, minConcurrentConnection || 2, idleTimeoutMillis || 30000));

Better Usage

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.
});

Licence

MIT

Keywords

FAQs

Last updated on 14 Aug 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc