Skip to content

Commit

Permalink
improved README.md example code
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-page committed Jun 7, 2016
1 parent 7db595a commit 85bc75a
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand All @@ -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).
Expand Down

0 comments on commit 85bc75a

Please sign in to comment.