Connection-pool for RethinkDB
JavaScript
Clone or download
hden Merge pull request #19 from hden/deps
upgrade dependencies
Latest commit 21db1fc Jan 5, 2017
Permalink
Failed to load latest commit information.
test update dependencies May 14, 2016
.gitignore add travis Jun 19, 2014
.travis.yml upgrade dependencies Jan 5, 2017
CHANGELOG.md update changelog May 14, 2016
LICENSE Initial commit Jan 30, 2014
README.md upgrade dependencies Jan 5, 2017
index.js update dependencies May 14, 2016
package.json upgrade dependencies Jan 5, 2017

README.md

rethinkdb-pool

Build Status NPM version dependencies Status

Connection-pool for RethinkDB

js-standard-style

Installation

npm install --save rethinkdb-pool

Usage

Create pool

var r    = require('rethinkdb')
var Pool = require('rethinkdb-pool')
var pool = Pool(r, {
  host:'localhost',
  port:28015,
  db:'marvel',
  authKey:'hunter2'
})

Run

var query = r.table('foo').limit(100)

// callback
pool.run(query, function (error, list) {
  // no more acquire, no more toArray, yay!!
})

// promise
pool.run(query).then(function (list) {
  // promise, yay
})

Acquire / release resources

pool.acquire(function (error, connection) {
  if (error != null) {
    return handleError(error)
  }
  r.table('aTable').limit(10).run(connection, function (error, cursor) {
    if (error != null) {
      return handleError(error)
    }
    cursor.toArray(function (error, data) {
      if (error != null) {
        return handleError(error)
      }
      console.log(data)
      pool.release(connection)
    })
  })
})