0

It seems that I can't find the answer to what appears to be a simple question.

Is the following query valid in Mongoose?

m.find({_id:{$in:A, $nin:B}}, ...);
Chong Lip Phang
  • 8,755
  • 5
  • 65
  • 100
  • Why should you not be able to? But I sense there is a real question behind this. Care to share? Or should we just submit our best guesses to what you really want to know for? How about showing the case where you think you want to use this but it does not work for you. – Neil Lunn Jun 07 '18 at 08:11
  • Well. I just couldn't find anyone doing this before. The closest example I found uses $and to join two {} clauses of _id: https://stackoverflow.com/questions/42225802/mongodb-combine-in-and-nin – Chong Lip Phang Jun 07 '18 at 08:15
  • Can you find `{ "field": { "$gt": 1, "$lt": 3 } }`? You should be able to because it's in the documentation. Same thing. You either don't have a query that works or you're just asking how to AND which is what two operators on the same key does. I'm still thinking you're actually trying to query like this and not getting the result you expect. Therefore "show the documents" and what you "expect to match" but are not. That's a question. – Neil Lunn Jun 07 '18 at 08:16
  • Alright. I guess you answered my question... – Chong Lip Phang Jun 07 '18 at 08:18
  • Tested and confirmed. You can totally combine $nin and $in. – Dom Ramirez Aug 24 '18 at 01:43

0 Answers0