Comparing version 1.0.0 to 1.0.1
26
index.js
@@ -44,11 +44,2 @@ var genericPool = require('generic-pool') | ||
} | ||
client.queryAsync = function (text, values) { | ||
return new this.Promise((resolve, reject) => { | ||
client.query(text, values, function (err, res) { | ||
err ? reject(err) : resolve(res) | ||
}) | ||
}) | ||
}.bind(this) | ||
cb(err, err ? null : client) | ||
@@ -94,12 +85,11 @@ }.bind(this)) | ||
Pool.prototype.query = function (text, values) { | ||
return this.take().then(function (client) { | ||
return client.queryAsync(text, values) | ||
.then(function (res) { | ||
client.release() | ||
return res | ||
}).catch(function (error) { | ||
client.release(error) | ||
throw error | ||
return new this.Promise(function (resolve, reject) { | ||
this.connect(function (err, client, done) { | ||
if (err) return reject(err) | ||
client.query(text, values, function (err, res) { | ||
done(err) | ||
err ? reject(err) : resolve(res) | ||
}) | ||
}) | ||
}) | ||
}.bind(this)) | ||
} | ||
@@ -106,0 +96,0 @@ |
{ | ||
"name": "pg-pool", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Connection pool for node-postgres", | ||
@@ -34,3 +34,3 @@ "main": "index.js", | ||
"mocha": "^2.3.3", | ||
"pg": "4.5.6", | ||
"pg": "5.1.0", | ||
"standard": "7.1.2", | ||
@@ -37,0 +37,0 @@ "standard-format": "2.2.1" |
var expect = require('expect.js') | ||
var co = require('co') | ||
var Promise = require('bluebird') | ||
var _ = require('lodash') | ||
@@ -62,3 +61,3 @@ | ||
expect(pool.pool.availableObjectsCount()).to.be(0) | ||
var res = yield client.queryAsync('select $1::text as name', ['hi']) | ||
var res = yield client.query('select $1::text as name', ['hi']) | ||
expect(res.rows).to.eql([{ name: 'hi' }]) | ||
@@ -73,12 +72,7 @@ client.release() | ||
var pool = new Pool({ poolSize: 9 }) | ||
var count = 0 | ||
while (count < 30) { | ||
count++ | ||
pool.connect().then(function (client) { | ||
client.queryAsync('select $1::text as name', ['hi']).then(function (res) { | ||
client.release() | ||
}) | ||
}) | ||
} | ||
yield Promise.delay(100) | ||
yield _.times(30).map(function * () { | ||
var client = yield pool.connect() | ||
yield client.query('select $1::text as name', ['hi']) | ||
client.release() | ||
}) | ||
expect(pool.pool.getPoolSize()).to.be(9) | ||
@@ -85,0 +79,0 @@ return yield pool.end() |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
12771
7
0
147
188