我的orders
集合的文档架构如下:
{
"_id" : ObjectId("Id of this record"),"location_data" : {
"type" : "main","location_id" : ObjectId("this location's id")
},"item_details" : [
{
"item_id" : ObjectId("this item's id"),"qty" : 950
},{
"item_id" : ObjectId("this item's id"),"qty" : 200
}
]
}
我将items
存储在另一个集合中,该集合的模式如下:
{
"_id": ObjectId("this record's id"),"title": "this item's title","description": "this item's description"
}
我想要的输出是:
{
"_id" : ObjectId("Id of this record"),"item_details" : [
{
"title": "this item's title","item_id" : ObjectId("this item's id"),{
"title": "this item's title","qty" : 200
}
]
}
在Mongodb文档中,我没有发现任何可用于对象数组的东西。任何帮助都是可观的。
谢谢