MongoDB中多表关联查询(

时间:2021-04-23 00:47:43

1.使用aggregate 查看表数据

     
db.getCollection('reports').aggregate([
   {
     $lookup:
       {
         from: "process",
         localField: "sid",
         foreignField: "sid",
         as: "docs"
       }
      },
        {$match:{"industry_info.oid":21,sync:2}},
        {$project:{"docs":1}}
])

 

 

 

 

 

 

 

 

 

 

参考资料:https://www.cnblogs.com/huangxincheng/p/5728791.html