Sample Collection
[
{
items: [
{name: 'apple'}, {name: 'mango'}, {name: 'orange'}
]
},
{
items: [
{name: 'banna'}, {name: 'grapes'}, {name: 'orange'}
]
}
]
I am looking for a query that can determine which document contains at least two of the searched products.
For example..
collection.find({ items: {$in: ['apple', 'mango', 'durian', 'avocado', 'orange']} })
The current query only checks if it contains one of those products. I want to identify documents that have at least two of the searched products in them.