I am new to Mongo DB and queries. It will be highly appreciated if someone can help me querying the relevant data. I have 2 collections: Order & ReturnRequest. Order has an array of OrderItems and ReturnRequest has reference to orderID and an array of returnItems. I need to get all the returnItems , but the price of item is in OrderItem array of Order Collection The Order Collection is as below
{
"_Orderid": "d991e92a-766c-054e-9ad8-1c902acc6efc",
"OrderItems": {
"id": "d991e92a46831",
"ProductID": "abc.",
"VendorID": "abv",
"Quantity": "5",
"UnitPrice": "220",
"Currency": "USD"
}
}
The ReturnRequest collection is as below
{
"_returnid": "1qqwerda-766c-054e-9ad8-1c902acc6efc",
"vendorID": "abv",
"orderId": "d991e92a-766c-054e-9ad8-1c902acc6efc"
"ReturnItems": {
"returnItemid": "AAARTY92a46831",
"ProductID": "abc",
"Quantity": "2",
}
}
I need to get the result as
{
"Orderid": "1qqwerda-766c-054e-9ad8-1c902acc6efc",
"vendorID": "abv",
"Currency":"USD",
"ReturnRequestid": "1qqwerda-766c-054e-9ad8-1c902acc6efc",
"ReturnItemid": "AAARTY92a46831",
"ProductID": "abc",
"Quantity": "2",
"Price" :"220"
}
Conditions are to join VendorID, OrderID, ProductID between the said collections