From 85bc75a6a4efa401d6fa3f3099dfcaaab6c8119f Mon Sep 17 00:00:00 2001 From: Ben Page Date: Tue, 7 Jun 2016 15:35:48 -0500 Subject: [PATCH] improved README.md example code --- README.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a3db0aa..b176a2b 100644 --- a/README.md +++ b/README.md @@ -31,19 +31,27 @@ var connectionConfig = { //create the pool var pool = new ConnectionPool(poolConfig, connectionConfig); +pool.on('error', function(err) { + console.error(err); +}); + //acquire a connection pool.acquire(function (err, connection) { - if (err) + if (err) { console.error(err); + return; + } - //use the connection as normal + //use the connection as normal var request = new Request('select 42', function(err, rowCount) { - if (err) + if (err) { console.error(err); + return; + } console.log('rowCount: ' + rowCount); - //release the connection back to the pool when finished + //release the connection back to the pool when finished connection.release(); }); @@ -53,10 +61,6 @@ pool.acquire(function (err, connection) { connection.execSql(request); }); - -pool.on('error', function(err) { - console.error(err); -}); ``` When you are finished with the pool, you can drain it (close all connections).