0

I have 2 collections say, Collection-1, and Collection-2.

Collection-1
{
"_id" : 1,
"myArray" : [ { Key : "KeyVal", price:40 } ] 
}
Collection-2
{
"_id" : 1,
"myArray" : [ { Key : "KeyVal", quantity:20 } ] 
}

What I am trying is i would like to multiply price and quantity from collection-1 and 2.

To do this, I am joining both the collections using $lookup. I could able to $unwind the Collection-1 to get the key. The Question is How do I get the Key (foreign Key) from the collection 2?

Am I making fundamental mistakes? Suggestions please. Also please share the link if related question is already asked .

Note: The most important concern is i can't change the collection structure. otherwise i could have make the key as _id and i can proceed further.

Ada Pongaya
  • 405
  • 4
  • 18

0 Answers0