From 7f7f4b2838100a3d59d2cf77323982ec063b5d22 Mon Sep 17 00:00:00 2001 From: Stefan Aichholzer Date: Mon, 1 Sep 2014 09:12:19 +0200 Subject: [PATCH 1/2] Updated documentation, fixed small issue in the example. --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8062c8c33..d4acef443 100644 --- a/README.md +++ b/README.md @@ -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) { @@ -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. From 87cfde3db1e42231a6b751e9f513ab23b8bce7a1 Mon Sep 17 00:00:00 2001 From: Stefan Aichholzer Date: Mon, 1 Sep 2014 09:15:30 +0200 Subject: [PATCH 2/2] Another production use. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d4acef443..302940559 100644 --- a/README.md +++ b/README.md @@ -157,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._