Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@ PostgreSQL client for node.js. Pure JavaScript and native libpq bindings.

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.

To prevent the "leaking" of clients, `done()` must be called at all times to ensure the client is safely released back to the pool.

```javascript
var pg = require('pg');
var conString = "postgres://username:password@localhost/database";

pg.connect(conString, function(err, client, done) {
if(err) {
//Release the client back to the pool
done();
return console.error('error fetching client from pool', err);
}
client.query('SELECT $1::int AS number', ['1'], function(err, result) {
//call `done()` to release the client back to the pool
//Release the client back to the pool
done();

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

```


### Simple

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.
Expand Down Expand Up @@ -152,6 +157,7 @@ node-postgres is by design _low level_ with the bare minimum of abstraction. Th
* [Heap](https://heapanalytics.com)
* [zoomsquare](http://www.zoomsquare.com/)
* [WhenToManage](http://www.whentomanage.com)
* [Treatz.me](http://www.treatz.me)

_If you use node-postgres in production and would like your site listed here, fork & add it._

Expand Down