Hi!
you probably need to use $unwind on the array so on the next stage you’ll use $lookup for each element
4 things you should keep in mind during aggregations:
- filter as much as you can with $match at the beginning of the pipeline
- $project only the necessary fields before unwinding the lookup (save memory)
- make sure you are not doing a lookup to a massive amount of documents so it will have performance implications
- if it’s a recurring query then you should consider storing all of this data together in the same collection.