How do I query referenced objects in MongoDB? - Stack Overflow

PHOTO EMBED

Thu May 21 2020 18:26:52 GMT+0000 (Coordinated Universal Time)

Saved by @salitha.pathi #javascript #mongoshell

db.Foo.aggregate(
  {$unwind: "$bars"},
  {$lookup: {
    from:"bar",
    localField: "bars",
    foreignField: "_id",
    as: "bar"

   }},
   {$match: {
    "bar.testprop": true
   }}
)
content_copyCOPY

https://stackoverflow.com/questions/9621928/how-do-i-query-referenced-objects-in-mongodb