Monday, 17 April 2017

mongodb error handling whlle using exec

I have ExpressJS ,NodeJs, Mongoose application. I have written mongodb code like below and it works fine.

module.exports.getStudentid = function(id, callback) {

    Student
        .find({ _id: id })
        .populate('marks')       
        .exec(callback);
}

But is it a good code in terms of error handling in NodeJS..Will it pass error to the next layer? How can I improve the above code to use proper error handling?



via Jocket

No comments:

Post a Comment