MongoDb lookup when local field in array of documents

Viewed 27

Hey guys i want get populate other collection data with help of lookup . none of the documentations help me get the right output its only give me empty arrays

user collection

[{
_id:'some_id',
name:'some_name',
cart:{
 items:[
  {itemId:'id',quantity:1}
 ]
}
}....]

items collection

[{
_id:'id',
item_name:'name',
price:'60.0',
}....]

I want to get my query result like this :

[{
    _id:'some_id',
    name:'some_name',
    cart:{
     items:[
      {
        itemId:'id',
        quantity:1,
        item:{
         _id:'id',
         item_name:'name',
         price:'60.0'
        },
      }
     ]
    }
    }....]

How can I get this? Please help me

0 Answers
Related