1. 程式人生 > >MongoDB中多表關聯查詢(

MongoDB中多表關聯查詢(

數據 div roc lec field style proc agg repo

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

MongoDB中多表關聯查詢(