You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pool.query('SELECT $1::text as name', ['brianc'], function (err, res) {
112
112
console.log(res.rows[0].name) // brianc
113
113
})
@@ -123,7 +123,7 @@ clients back to the pool after the query is done.
123
123
pg-pool still and will always support the traditional callback api for acquiring a client. This is the exact API node-postgres has shipped with for years:
124
124
125
125
```js
126
-
constpool=newPool()
126
+
var pool =newPool()
127
127
pool.connect((err, client, done) => {
128
128
if (err) returndone(err)
129
129
@@ -143,8 +143,8 @@ When you are finished with the pool if all the clients are idle the pool will cl
143
143
will shutdown gracefully. If you don't want to wait for the timeout you can end the pool as follows:
144
144
145
145
```js
146
-
constpool=newPool()
147
-
constclient=awaitpool.connect()
146
+
var pool =newPool()
147
+
var client =awaitpool.connect()
148
148
console.log(awaitclient.query('select now()'))
149
149
client.release()
150
150
awaitpool.end()
@@ -159,7 +159,7 @@ The pool should be a __long-lived object__ in your application. Generally you'l
159
159
160
160
// correct usage: create the pool and let it live
161
161
// 'globally' here, controlling access to it through exported methods
162
-
const pool = new pg.Pool()
162
+
var pool = new pg.Pool()
163
163
164
164
// this is the right way to export the query method
// every time we called 'connect' to get a new client?
174
174
// that's a bad thing & results in creating an unbounded
175
175
// number of pools & therefore connections
176
-
const aPool = new pg.Pool()
176
+
var aPool = new pg.Pool()
177
177
return aPool.connect()
178
178
}
179
179
```
@@ -228,7 +228,28 @@ pool
228
228
229
229
```
230
230
231
-
This allows you to do custom bootstrapping and manipulation of clients after they have been successfully connected to the PostgreSQL backend, but before any queries have been issued.
231
+
#### acquire
232
+
233
+
Fired whenever the a client is acquired from the pool
234
+
235
+
Example:
236
+
237
+
This allows you to count the number of clients which have ever been acquired from the pool.
0 commit comments