Skip to content

Commit efc49d7

Browse files
committed
remove promisify and bind pool.query method
1 parent b510ea7 commit efc49d7

File tree

2 files changed

+2
-28
lines changed

2 files changed

+2
-28
lines changed

index.js

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict'
22

33
const fp = require('fastify-plugin')
4-
const promisify = require('util.promisify')
54
const pg = require('pg')
65

76
function fastifyPostgres (fastify, options, next) {
@@ -11,33 +10,9 @@ function fastifyPostgres (fastify, options, next) {
1110
connect: pool.connect.bind(pool),
1211
pool: pool,
1312
Client: pg.Client,
14-
query: promisify(query)
13+
query: pool.query.bind(pool)
1514
})
1615

17-
function query (text, value, callback) {
18-
if (typeof value === 'function') {
19-
callback = value
20-
value = null
21-
}
22-
23-
pool.connect(onConnect)
24-
25-
function onConnect (err, client, release) {
26-
if (err) return callback(err)
27-
28-
if (value) {
29-
client.query(text, value, onResult)
30-
} else {
31-
client.query(text, onResult)
32-
}
33-
34-
function onResult (err, result) {
35-
release()
36-
callback(err, result)
37-
}
38-
}
39-
}
40-
4116
fastify.addHook('onClose', onClose)
4217

4318
next()

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
"homepage": "https://github.com/fastify/fastify-postgres#readme",
2828
"dependencies": {
2929
"fastify-plugin": "^0.1.1",
30-
"pg": "^7.3.0",
31-
"util.promisify": "^1.0.0"
30+
"pg": "^7.3.0"
3231
},
3332
"devDependencies": {
3433
"fastify": "^0.29.2",

0 commit comments

Comments
 (0)