【发布时间】:2019-08-13 08:16:14
【问题描述】:
我有 2 个名为 call 和 customers 的文档 我想加入对customers.location._id的呼叫的locationId
通话
"_id": "5d456560221b9147e4af4b97",
"customerId": "5d0a3bbfac9470aea56ad619",
"locationId": "5d11d2c4cba8151f67f735b1",
"startDateTime": "2019-06-21T05:30:00.000Z",
"endDateTime": "2019-06-21T06:00:00.000Z"
}
客户
"_id": "5d0a3bbfac9470aea56ad619",
"locations": [
{
"_id": "5d11d2c4cba8151f67f735b1",
"phone": "9889599999",
"ext": "91",
"address": "sad",
"neighborhood": "sda",
"city": "punetest",
"state": "MH",
"zip": "589365",
"country": "india",
"isBillingAddress": false,
"taxPercentage": 0,
"type": "Residential",
"status": "Active",
"firstName": "A",
"lastName": "B"
},
{
"_id": "5d11e457cba8151f67f735b3",
"phone": "969696999",
"ext": "91",
"address": "",
"neighborhood": "",
"city": "udaipur",
"state": "raj",
"zip": "312563",
"country": "india",
"isBillingAddress": false,
"taxPercentage": 0,
"type": "Residential",
"status": "Deleted",
"firstName": "AB",
"lastName": "CD"
}
],
"createdAt": "2019-06-19T13:42:23.479Z",
"updatedAt": "2019-06-25T13:39:07.597Z"
}
[
{
$lookup: {
from: 'customers.locations',
localField: 'locationId',
foreignField: '_id',
as: 'customers.locations',
},
}
]);
它不工作 我有 2 个名为 call 和客户的文档,我想将 locationId 加入到customers.location._id 的呼叫中
我要输出``` { "_id": "5d456560221b9147e4af4b97", "customerId": "5d0a3bbfac9470aea56ad619", "locationId": "5d11d2c4cba8151f67f735b1", “位置”:{“_id”:“5d11d2c4cba8151f67f735b1”, “电话”:“9889599999”, “分机”:“91”, “地址”:“悲伤”, “邻居”:“sda”, "城市": "punetest", “状态”:“MH”, “邮编”:“589365”, “国家”:“印度”, “isBillingAddress”:假, “税收百分比”:0, “类型”:“住宅”, “状态”:“活动”, “名字”:“A”, “姓氏”:“B”} }
【问题讨论】:
标签: mongodb