MongoDB聚合-如何进行深层查找

时间:2019-01-20 14:33:09

标签: database mongodb mongoose aggregation-framework aggregate

我有一个带有eventsIds数组的收集诊所:

clinics : [
 {"_id": "clinicId1",
  "eventsIds" :[
       "eventId1","eventId2"
   ]
  }
]

和事件收集:

{"_id" : "eventId1" : customerId:"customerId1"},
{"_id" : "eventId2" : customerId:"customerId2"},

和客户集合:

{"_id" : "customerId1" : name:"some_name"},
{"_id" : "customerId2" : name:"some_name"},

我需要的是诊所用品:

  clinic: {
    "id":"clinicId1",
    "events":[
      "eventId1":{customer:{"_id" : "customerId1" : name:"some_name"}},
       "eventId2":{customer:{"_id" : "customerId2" : name:"some_name"}}
    ]
  }

我设法进行汇总查找以在诊所项目内创建事件数组,但没有进行第二步来检索客户详细信息

我该如何实现?

谢谢!

0 个答案:

没有答案