In my example i have a login view email or username can send one of two.
User.findOne({ 'email' : email }, function(err, user) {
// awesome user
});
and i need something like this:
User.findOne({ 'email' : email } || {'username' : email}, function(err, user) {
// awesome user
});
Can do using the $or
query operator:
User.findOne({$or: [{'email': email}, {'username': email}]}, function(err, user) {
// awesome user
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With