# rethinkdb-pool

> Connection-pool for RethinkDB

Latest version **1.2.0** (published 2020-12-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install rethinkdb-pool
pnpm add rethinkdb-pool
yarn add rethinkdb-pool
bun add rethinkdb-pool
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2020-12-30 |
| First published | 2014-01-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 22 |
| Author | Hao-kang Den |
| Maintainers | hden |
| Keywords | rethinkdb |

## Links

- npm: https://www.npmjs.com/package/rethinkdb-pool
- Repository: https://github.com/hden/rethinkdb-pool
- Issues: https://github.com/hden/rethinkdb-pool/issues
- npm.io page: https://npm.io/package/rethinkdb-pool

## Dependencies (1)

- [generic-pool](https://npm.io/package/generic-pool.md) 3.7.1

## Recent versions

- 1.2.0 (latest) — 2020-12-30
- 1.1.0 — 2016-05-14
- 1.0.0 — 2016-01-25
- 0.4.0 — 2015-06-10
- 0.2.1 — 2014-12-15
- 0.2.0 — 2014-12-14
- 0.1.2 — 2014-09-02
- 0.1.1 — 2014-09-01
- 0.1.0 — 2014-08-17
- 0.0.5 — 2014-06-19
- 0.0.4 — 2014-06-13
- 0.0.3 — 2014-05-07
- 0.0.1 — 2014-01-30

## README

rethinkdb-pool
==============

[![Build Status](https://travis-ci.org/hden/rethinkdb-pool.svg?branch=master)](https://travis-ci.org/hden/rethinkdb-pool)
[![NPM version](https://badge.fury.io/js/rethinkdb-pool.svg)](http://badge.fury.io/js/rethinkdb-pool)
[![dependencies Status](https://david-dm.org/hden/rethinkdb-pool/status.svg)](https://david-dm.org/hden/rethinkdb-pool)

Connection-pool for RethinkDB

[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

Installation
-----------

    npm install --save rethinkdb-pool

Usage
-----

## Create pool

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

## Run

```js
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

Connection can be acquired by calling the `.acquire()` function, but the responsibility of managing resources can be quite challenging.

See: http://bluebirdjs.com/docs/api/resource-management.html

```js
// Don't do this! Leaks resources!
pool.acquire().then(function (connection) {
  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)
    })
  })
})
```

---
_Source: https://npm.io/package/rethinkdb-pool · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
