$lookup

会把连接后的数据组成一个列表,拆分列表,查询匹配
db.Event.aggregate([
  {'$match':{'system':'Stat'}},
  {
    $lookup:
       {
          from: "Stat",
          localField: "_id",
          foreignField: "eventId",
          as: "inventory_docs"
      },
   },
      { "$unwind": "$inventory_docs" },
      {'$match':{'inventory_docs.city':'北京'}},        
])

你可能感兴趣的:($lookup)