I want to be able to find multiple documents that have three or more matching values ββin an array. Say we have the following documents:
[{ name: 'John', cars: [1, 2, 3, 4] }, { name: 'Jane', cars: [1, 2, 3, 8] }, { name: 'Smith', cars: [1, 8, 10] }]
And we want to find documents that have at least three values ββ(in cars) in the following array:
[1, 2, 3, 4, 5, 6, 7]
Then the results will be as follows:
[{ name: 'John', cars: [1, 2, 3, 4] }, { name: 'Jane', cars: [1, 2, 3, 8] }]
Does anyone know how to achieve this?
find mongodb
Dennis j
source share