Update README.md
Calling `client.end()` on a client in the pool is folly and should not be done. I mistakenly accepted a pull request with bad documentation.
This commit is contained in:
parent
b3f0687fc7
commit
c4ae79db39
@ -21,6 +21,9 @@ Generally you will access the PostgreSQL server through a pool of clients. A cl
|
|||||||
var pg = require('pg');
|
var pg = require('pg');
|
||||||
var conString = "postgres://username:password@localhost/database";
|
var conString = "postgres://username:password@localhost/database";
|
||||||
|
|
||||||
|
//this starts initializes a connection pool
|
||||||
|
//it will keep idle connections open for a (configurable) 30 seconds
|
||||||
|
//and set a limit of 20 (also configurable)
|
||||||
pg.connect(conString, function(err, client, done) {
|
pg.connect(conString, function(err, client, done) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return console.error('error fetching client from pool', err);
|
return console.error('error fetching client from pool', err);
|
||||||
@ -34,7 +37,6 @@ pg.connect(conString, function(err, client, done) {
|
|||||||
}
|
}
|
||||||
console.log(result.rows[0].number);
|
console.log(result.rows[0].number);
|
||||||
//output: 1
|
//output: 1
|
||||||
client.end();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user