Fix undefined checks left over from sqlite, use postgres-friendly result.rowCount.
This commit is contained in:
parent
e138b3f8d1
commit
cab17d28c5
@ -9,7 +9,8 @@
|
|||||||
"moment-timezone": "^0.4.0",
|
"moment-timezone": "^0.4.0",
|
||||||
"nodemailer": "^1.3.4",
|
"nodemailer": "^1.3.4",
|
||||||
"pg": "^4.4.2",
|
"pg": "^4.4.2",
|
||||||
"sqlite3": "^3.0.8"
|
"sqlite3": "^3.0.8",
|
||||||
|
"winston": "^2.1.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node server.js"
|
"start": "node server.js"
|
||||||
|
@ -130,7 +130,7 @@ app.post('/core/edit/:id', function(req, res){
|
|||||||
done();
|
done();
|
||||||
|
|
||||||
if(err) { return console.error('error running query', err); }
|
if(err) { return console.error('error running query', err); }
|
||||||
if(typeof result == 'undefined') {
|
if(typeof result.rowCount == 0) {
|
||||||
client.query(
|
client.query(
|
||||||
"INSERT INTO cores (coreid, corename, locationdesc) VALUES ($1, $2, $3);",
|
"INSERT INTO cores (coreid, corename, locationdesc) VALUES ($1, $2, $3);",
|
||||||
[coreId, req.body.deviceName, req.body.locationDesc]
|
[coreId, req.body.deviceName, req.body.locationDesc]
|
||||||
@ -217,7 +217,7 @@ app.post('/', function(req, res){
|
|||||||
pg.connect(conString, function(err, client, done) {
|
pg.connect(conString, function(err, client, done) {
|
||||||
if(err) { return console.error('error fetching client from pool', err); }
|
if(err) { return console.error('error fetching client from pool', err); }
|
||||||
client.query('SELECT corename FROM cores WHERE coreid = $1;', [coreid], function(err, result) {
|
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.
|
// Don't care about this error or empty result set, still need to send email.
|
||||||
result.rows[0].corename = '# No Name #';
|
result.rows[0].corename = '# No Name #';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user