The document schema for my orders collection is given below:
{
"_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
}
]
}
I have items stored in a different collection whose schema looks like this:
{
"_id": ObjectId("this record's id"),
"title": "this item's title",
"description": "this item's description"
}
My desired output would be:
{
"_id" : ObjectId("Id of this record"),
"location_data" : {
"type" : "main",
"location_id" : ObjectId("this location's id")
},
"item_details" : [
{
"title": "this item's title",
"item_id" : ObjectId("this item's id"),
"qty" : 950
},
{
"title": "this item's title",
"item_id" : ObjectId("this item's id"),
"qty" : 200
}
]
}
In Mongodb doc I haven't found anything to work with array of objects. Any help would be appreciable.
Thanks