diff --git a/package.json b/package.json index 234276b..beafa25 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "moment-timezone": "^0.4.0", "nodemailer": "^1.3.4", "pg": "^4.4.2", - "sqlite3": "^3.0.8" + "sqlite3": "^3.0.8", + "winston": "^2.1.1" }, "scripts": { "start": "node server.js" diff --git a/server.js b/server.js index acd9411..fb07d1b 100644 --- a/server.js +++ b/server.js @@ -130,7 +130,7 @@ app.post('/core/edit/:id', function(req, res){ done(); if(err) { return console.error('error running query', err); } - if(typeof result == 'undefined') { + if(typeof result.rowCount == 0) { client.query( "INSERT INTO cores (coreid, corename, locationdesc) VALUES ($1, $2, $3);", [coreId, req.body.deviceName, req.body.locationDesc] @@ -217,7 +217,7 @@ app.post('/', function(req, res){ pg.connect(conString, function(err, client, done) { if(err) { return console.error('error fetching client from pool', err); } client.query('SELECT corename FROM cores WHERE coreid = $1;', [coreid], function(err, result) { - if ((err) || (typeof result == undefined)) { + if ((err) || (typeof result.rowCount == 0)) { // Don't care about this error or empty result set, still need to send email. result.rows[0].corename = '# No Name #'; }