天天看點

MongoDB中多表關聯查詢(

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

轉載于:https://www.cnblogs.com/myvic/p/10383910.html