Skip to content

Commit 7f7f4b2

Browse files
author
Stefan Aichholzer
committed
Updated documentation, fixed small issue in the example.
1 parent ee19e74 commit 7f7f4b2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@ PostgreSQL client for node.js. Pure JavaScript and native libpq bindings.
2121

2222
Typically you will access the PostgreSQL server through a pool of clients. node-postgres ships with a built in pool to help get you up and running quickly.
2323

24+
To prevent the "leaking" of clients, `done()` must be called at all times to ensure the client is safely released back to the pool.
25+
2426
```javascript
2527
var pg = require('pg');
2628
var conString = "postgres://username:password@localhost/database";
2729

2830
pg.connect(conString, function(err, client, done) {
2931
if(err) {
32+
//Release the client back to the pool
33+
done();
3034
return console.error('error fetching client from pool', err);
3135
}
3236
client.query('SELECT $1::int AS number', ['1'], function(err, result) {
33-
//call `done()` to release the client back to the pool
37+
//Release the client back to the pool
3438
done();
3539

3640
if(err) {
@@ -43,6 +47,7 @@ pg.connect(conString, function(err, client, done) {
4347

4448
```
4549

50+
4651
### Simple
4752

4853
Sometimes you may not want to use a pool of connections. You can easily connect a single client to a postgres instance, run a query, and disconnect.

0 commit comments

Comments
 (0)