I have following Collections:
[{
name: "apple",
class: [620e112a03914a837dcd7585,620e112a03914a837dcd4325]
},
{
name: "orange",
class: [620e112a03914a837dcd4325,620e112a03914a837dcd7712]
}]
I want to execute the query like
Find all the documents which have name 'apple' and have class '620e112a03914a837dcd4325'
How are we suppose to do this in mongoose/mongodB??
>Solution :
Assuming your model is called Product, you could do it like this:
Product.find({name: 'apple', class: {"$in": ['620e112a03914a837dcd4325']}})