I recently started using MongoDB with Mongoose on Nodejs.
When I use the Model.find method with the condition $or and _id , Mongoose does not work properly.
This does not work:
User.find({ $or: [ { '_id': param }, { 'name': param }, { 'nickname': param } ] }, function(err, docs) { if(!err) res.send(docs); });
By the way, if I delete the '_id' part, it works!
User.find({ $or: [ { 'name': param }, { 'nickname': param } ] }, function(err, docs) { if(!err) res.send(docs); });
And in the MongoDB shell, both work correctly.
Younghan Sep 12 2018-11-11T00: 00Z
source share