These are chat archives for LearnBoost/mongoose

21st
Jul 2018
Berian
@chaiwa-berian
Jul 21 2018 20:14
How do I handle error when MongoDB is down? Tested this endpoint, but it doesn't get hit at all if the request is sent when the database server is down. I am using mongoose
//GET api/silcgroups
exports.getAllSILCGroups = function(req, res){
    SILCGroup.find(req.query, function(err, silcgroups){
        if(err) {
            console.log(err);
            return res.json(err);
        }
        else  return res.json(silcgroups);
    });
};