Pokud neexistují žádné shody, find() vrátí [] , zatímco findOne() vrací null . Buď tedy použijte:
Model.find( {...}, function (err, results) {
if (err) { ... }
if (!results.length) {
// do stuff here
}
}
nebo:
Model.findOne( {...}, function (err, result) {
if (err) { ... }
if (!result) {
// do stuff here
}
}