findOne
簡単なリクエストをしたいのですが、「サブプロパティ」に条件を設定しようとして問題があります。
私が見つけようとしているモデルは私のbddに存在しますが、私は毎回else
ケースに行きます:
Model.findOne({ email : { value: 'toto@gmail.com' } }, 'username email', function(error, User){
if (error){
console.log('Error query.');
}else if (User){
console.log('User found from email.'); //Expected to go here
}else{
console.log('Any user found.'); //Goes here everytime
}
});
「サブプロパティ」にない他のクエリがうまく機能するので、それは正常だと思います。それを行う方法は何ですか(「サブプロパティ」からモデルを見つける)?