diff --git a/server.js b/server.js index 3227e56..f49fc7c 100644 --- a/server.js +++ b/server.js @@ -96,18 +96,23 @@ app.get('/core/edit/:id', function(req, res){ var coreId = req.params.id; console.log("GET /core/edit/" + coreId + ", " + JSON.stringify(d, 4)); - db.all("select coreName, locationDesc from Cores where coreId = ?;", coreId, function(err, rows){ - if(err !== null) { - console.log(err); - } else { - res.render('core-edit', {values: rows}, function(err, html) { + pg.connect(conString, function(err, client, done) { + if(err) { + return console.error('error fetching client from pool', err); + } + client.query("select corename, locationdesc from cores where coreid = ($1);", [coreId], function(err, result) { + //call `done()` to release the client back to the pool + done(); + + if(err) { return console.error('error running query', err); } + res.render('core-edit', {values: result.rows}, function(err, html) { if(err !== null) { console.log(err); } else { res.send(html); } }); - } + }); }); }); diff --git a/views/core-edit.hbs b/views/core-edit.hbs index 16f3ed5..0d1154f 100644 --- a/views/core-edit.hbs +++ b/views/core-edit.hbs @@ -6,16 +6,16 @@
* Current value is, {{values.0.coreName}}
+ {{#if values.0.corename}} +* Current value is, {{values.0.corename}}
{{/if}}* Current value is, {{values.0.locationDesc}}
+ {{#if values.0.locationdesc}} +* Current value is, {{values.0.locationdesc}}
{{/if}}