rpool
RethinkDB connection pool.
Installation
$ npm install --save rpool
API
Create pool
rpool(r, dbOptions, poolOptions) -> Pool
r
- RethinkDB referencedbOptions | dbOptions[]
- RethinkDB optionsurl
: Connection string/array of strings. If present will silentry rewrite connections options(host, port, etc.)host
: the host to connect to (default localhost).port
: the port to connect on (default 28015).db
: the default database (default test).- See RethinkDB docs for additional options.
poolOptions
- Pool optionsmin
: minimum number of connections to keep in pool at any given time. If this is set >= max, the pool will silently set the min to equalmax
. (default 1)max
: maximum number of connections. (default 10)testOnBorrow
: should the pool validate resources before giving them to clients. (default true)acquireTimeoutMillis
: max milliseconds an acquire call will wait for a resource before timing out. (default 10 seconds), if supplied should non-zero positive integer.- See generic-pool docs.
Example:
const r = const rpool = const pool = const pool = const pool = const pool = const pool = const pool =
Acquire / release connections
pool.acquire(priority) -> Promise<#{connection, release}>
priority
: optional priority.
Example:
const r = const rpool = const pool = pool
Run queries
pool.run(query, options) -> Promise<QueryResult>
query
: RethinkDB query or query builder function.options
: Run option.
⚠️ Note: All cursors are automatically converted into arrays.
Example:
const r = const rpool = const pool = pool pool const deleteQuery = rpool