-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
I can see in services/dbhandler.js that we are just swallowing errors if the query returns one. The whole db querying seems a bit peculiar for node. Generally we'd make a query which would then have a callback and inside that callback we would then format the response and call the entire operations callback. A bit like below
var pgQuery = require('pg-query'); // nice wrapper library to pg
function getSomeData(id, callback) {
var query = 'SELECT * FROM myTable WHERE id=$1';
var params = [ id ];
pgQuery(query, params, function(err, rows, results) {
if(err) {
return callback(err);
}
//Format the results somehow...
callback(null, results);
});
}Then somewhere, updateProfile would be called somewhat like this.
function show(req, res, next) {
var id = req.params.id;
db.getSomeData(id, function(err, theData) {
res.status(200).json(theData);
}
}I'm curious as to why we're swallowing errors, is this an oversight or is this done for a reason?
Metadata
Metadata
Assignees
Labels
No labels