Continue Postgres conversion in server.js and templates.

This commit is contained in:
jkaplon 2015-10-08 12:05:03 -04:00
parent 0ab6af8e57
commit 45a9a42f2e
2 changed files with 15 additions and 10 deletions

View File

@ -96,18 +96,23 @@ app.get('/core/edit/:id', function(req, res){
var coreId = req.params.id; var coreId = req.params.id;
console.log("GET /core/edit/" + coreId + ", " + JSON.stringify(d, 4)); console.log("GET /core/edit/" + coreId + ", " + JSON.stringify(d, 4));
db.all("select coreName, locationDesc from Cores where coreId = ?;", coreId, function(err, rows){ pg.connect(conString, function(err, client, done) {
if(err !== null) { if(err) {
console.log(err); return console.error('error fetching client from pool', err);
} else { }
res.render('core-edit', {values: rows}, function(err, html) { 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) { if(err !== null) {
console.log(err); console.log(err);
} else { } else {
res.send(html); res.send(html);
} }
}); });
} });
}); });
}); });

View File

@ -6,16 +6,16 @@
<div class="form-group"> <div class="form-group">
{{label "deviceName" "Edit Device Name:"}} {{label "deviceName" "Edit Device Name:"}}
{{input "deviceName" coreName class="form-control"}} {{input "deviceName" coreName class="form-control"}}
{{#if values.0.coreName}} {{#if values.0.corename}}
<p class="bg-info">* Current value is, {{values.0.coreName}}</p> <p class="bg-info">* Current value is, {{values.0.corename}}</p>
{{/if}} {{/if}}
</div> </div>
<div class="form-group"> <div class="form-group">
{{label "locationDesc" "Edit Location:"}} {{label "locationDesc" "Edit Location:"}}
{{input "locationDesc" locationDesc class="form-control"}} {{input "locationDesc" locationDesc class="form-control"}}
{{#if values.0.locationDesc}} {{#if values.0.locationdesc}}
<p class="bg-info">* Current value is, {{values.0.locationDesc}}</p> <p class="bg-info">* Current value is, {{values.0.locationdesc}}</p>
{{/if}} {{/if}}
</div> </div>