Reputation: 23312
I am writing a MongoDB query, using aggregate
.
I want to find all results that are matches based on given music preferences.
For example, here is a sample of my code
matchingGenres = ["CLASSIC_ROCK", "HEAVY_METAL", "POP"];
dbquery = [
{
$project:{
....
}
},
{
$match: {
$and: [
{genre: ?????}, // match if genre is in the array matchingGenres
...
]
}
]
How do I match only if the documents value for the genre
field is in the array matchingGenres
?
Upvotes: 0
Views: 77