mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
Add support for pool#query without params (#12)
This commit is contained in:
parent
2d446d4953
commit
aa1f10b0c0
4
index.js
4
index.js
@ -84,6 +84,10 @@ Pool.prototype.connect = function (cb) {
|
||||
Pool.prototype.take = Pool.prototype.connect
|
||||
|
||||
Pool.prototype.query = function (text, values, cb) {
|
||||
if (typeof values === 'function') {
|
||||
cb = values
|
||||
values = undefined
|
||||
}
|
||||
return new this.Promise(function (resolve, reject) {
|
||||
this.connect(function (err, client, done) {
|
||||
if (err) return reject(err)
|
||||
|
||||
@ -32,6 +32,16 @@ describe('pool', function () {
|
||||
})
|
||||
})
|
||||
|
||||
it('can run a query with a callback without parameters', function (done) {
|
||||
const pool = new Pool()
|
||||
pool.query('SELECT 1 as num', function (err, res) {
|
||||
expect(res.rows[0]).to.eql({ num: 1 })
|
||||
pool.end(function () {
|
||||
done(err)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('can run a query with a callback', function (done) {
|
||||
const pool = new Pool()
|
||||
pool.query('SELECT $1::text as name', ['brianc'], function (err, res) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user