I have a collection that I'm performing an aggregation on and I've basically gotten it down to
{array:[1,2,3], value: 1},
{array:[1,2,3], value: 4}
How would I perform an aggregation match to check if the value is in the array? I tried using {$match: {"array: {$in: ["$value"]}}} but it doesn't find anything.
I would want the output (if using the above as an example) to be:
{array:[1,2,3], value:1}
$elemMatch(see docs) rather than$in- you want to test whether a value is an the array, not whether the array is in the value!$unwindgave you the worst possible performance answer you could implement in your code. There are much better alternatives submitted.