我想获得另一个datatable字段以及响应数据,就像mongodb中的join($ lookup)一样,但是它给出了连接表的空输出。这是我的代码。
Releases.aggregate([
{ "$sort": { "release_date": -1 } },
{ "$limit": 10 },
{ "$lookup": {
"from": "companies", // actual schema name Company
"localField": "company_id",
"foreignField": "_id",
"as": "companyinfo"
} },
])
它给出了一个空数组companyinfo,在模式中我创建了“ Company”,但是在数据库中,它会自动用“ companies”来更改它。
这是示例文档
{
"_id": {
"$oid": "xxxxxxxxxxxx"
},
"company_id": "xxxxxxxxxxxxxxxxx",
"heading": "testing",
"description": "testing",
"key_point": "filename",
"release_date": "2018-12-01T00:00:00.000Z",
"datetime": {
"$date": "2018-12-03T14:53:57.031Z"
},
"__v": 0,
}
,我只希望输出字段{标题,描述,key_point,release_date,companyinfo.company_email},有什么想法吗?预先感谢