diff options
author | myk bilokonsky <mbilokonsky@gmail.com> | 2017-04-10 00:24:54 +0200 |
---|---|---|
committer | myk bilokonsky <mbilokonsky@gmail.com> | 2017-04-10 00:24:54 +0200 |
commit | b1033e1caa7755abcd616a1c25f7ec4642821382 (patch) | |
tree | 442b4aa019cd7dec70d9581abe0317103f8e8a11 | |
parent | b525b1adf8eb965bcef8c08fe5e67cefd4fe1fe3 (diff) |
removed pool, just have a single default-setting setup now
-rw-r--r-- | index.js | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/index.js b/index.js index 301e69e..e447e52 100644 --- a/index.js +++ b/index.js @@ -21,14 +21,34 @@ var config = { idleTimeoutMillis: 30000, // how long a client is allowed to remain idle before being closed }; -const pool = new pg.Pool(config); +var pg = require('pg'); + +// instantiate a new client +// the client will read connection information from +// the same environment variables used by postgres cli tools +var client = new pg.Client(); + +function cycle() { + // connect to our database + client.connect(function (err) { + if (err) throw err; -pool.query(query, [], function(err, res) { - if(err) { - return console.error('error running query', err); - } + // execute a query on our database + client.query(query, [], function (err, result) { + if(err) { + return console.error('error running query', err); + } - res.rows.forEach(function(row) { - console.dir(row); + res.rows.forEach(function(row) { + console.dir(row); + }); + + // disconnect the client + client.end(function (err) { + if (err) throw err; + }); + }); }); -}); \ No newline at end of file +} + +cycle(); \ No newline at end of file |