Mongodb中的元素查询有什么价值?

时间:2016-11-14 10:25:17

标签: mongodb collections

我正在研究mongodb聚合查询,但我不知道如何通过加入两个集合从JSON获取数组值,请通过我的下面示例JSON。

COKE Collection

[{
   "name": "Mirinda",
   "_id": "894567894769476948"
 }, {
   "name": "COKE",
   "_id": "857856856879694769"
 }, {
   "name": "PEPSI",
   "_id": "785485686846684684"
}]

COKE Order Collection

{
   "_id": "0908080808031338013101",
   "drink": [{
       "name": "Mirinda",
       "_id": "894567894769476948"
   }, {
       "name": "COKE",
       "_id": "857856856879694769"
   }, {
       "name": "PEPSI",
       "_id": "785485686846684684"
   }]
}

Expected OutPut:

Miranda name and _id should come of Orders collection by passing _id.

以上示例儿子我希望通过加入集合_id来获取名称值,如果您有任何建议,请通过我的帖子告诉我。

0 个答案:

没有答案