From fbfbdd0835ddc644913865e44f2d6a3ce42ad2e0 Mon Sep 17 00:00:00 2001 From: jkaplon Date: Sat, 3 Oct 2015 19:03:17 -0400 Subject: [PATCH] Getting data back via postgres connection. --- server.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index eb13f90..aa3d8dc 100644 --- a/server.js +++ b/server.js @@ -40,7 +40,22 @@ pg.connect(conString, function(err, client, done) { if(err) { return console.error('error fetching client from pool', err); } - done(); + + var devIndexQry = + "select al.coreId, max(co.coreName) as coreName, max(co.locationDesc) as locationDesc, mpub.MaxPub, al.status as MaxStatus " + + "from Alerts al " + + "inner join (select coreId, max(published_at) as MaxPub from Alerts group by coreId) mpub on al.coreId = mpub.coreId and al.published_at = mpub.MaxPub " + + "left join Cores co on al.coreId = co.coreId " + + "group by al.coreId, mpub.MaxPub, al.status "; + client.query(devIndexQry, function(err, result) { + //call `done()` to release the client back to the pool + done(); + + if(err) { + return console.error('error running query', err); + } + console.log(result.rows[0].corename); + }); }); db.serialize(function() {