how to handle find in mongodb if condition fail code example
Example: how to handle find in mongodb if condition fail
collection.findOne({query}, function(err, result) {
if (err) { /* handle err */ }
if (result) {
// we have a result
} else {
// we don't
}
}