MongoDB.live, free & fully virtual. Register Now MongoDB.live, free & fully virtual. Register Now

How do I search one collection for information contained in a second collection?

I have a collection called Reviews and a collection called Users. Each Review has an ID. Users have a field called “reviewLikes,” which is populated by review IDs. I want to locate Review IDs that match any of the ID numbers in Users.reviewLikes. How in the world can I achieve this. My brain is frying right now. Thank you!

Using the aggregation framework
https://docs.mongodb.com/manual/aggregation/
and in particular the $lookup stage
https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/

1 Like