I have a storages collection and a products collection.
I need to supplement the information in the arrays with the products of the storages collection with the information obtained from the products collection.
Thanks in advance!
Products collection
[
{
"_id": "6414ac1101f297b14f36ea42",
"name": "Mens Casual Premium Slim Fit T-Shirts",
"image": "https://fakestoreapi.com/img/71-3HjGNDUL._AC_SY879._SX._UX._SY._UY_.jpg",
"category": "Men's clothing",
"manufacturer": "Guleb Inc.",
"manufacturerPrice": 22,
},
{
"_id": "6414ad1601f297b14f36ea53",
"name": "Fjallraven - Foldsack No. 1 Backpack, Fits 15 Laptops",
"image": "https://fakestoreapi.com/img/81fPKd-2AYL._AC_SL1500_.jpg",
"category": "Men's clothing",
"manufacturer": "Guleb Inc.",
"manufacturerPrice": 109,
},
{
"_id": "6414ad2b01f297b14f36ea55",
"name": "Mens Cotton Jacket",
"image": "https://fakestoreapi.com/img/71li-ujtlUL._AC_UX679_.jpg",
"category": "Men's clothing",
"manufacturer": "Guleb Inc.",
"manufacturerPrice": 55,
}
]
Storages collection
[
{
"_id": "641364bf9cb7c37fab3b1f8f",
"name": "Based",
"products": [
{
"buyingPrice": 30,
"sellingPrice": 40,
"totalAmount": 5,
"_id": "6414ac1101f297b14f36ea42"
},
{
"buyingPrice": 120,
"sellingPrice": 140,
"totalAmount": 10,
"_id": "6414ad1601f297b14f36ea53"
}
],
]
Expected output
[
{
"_id": "641364bf9cb7c37fab3b1f8f",
"name": "Based",
"products": [
{
"buyingPrice": 30,
"sellingPrice": 40,
"totalAmount": 5,
"_id": "6414ac1101f297b14f36ea42",
"name": "Mens Casual Premium Slim Fit T-Shirts",
"image": "https://fakestoreapi.com/img/71-3HjGNDUL._AC_SY879._SX._UX._SY._UY_.jpg",
"category": "Men's clothing",
"manufacturer": "Guleb Inc.",
"manufacturerPrice": 22,
},
{
"buyingPrice": 120,
"sellingPrice": 140,
"totalAmount": 10,
"_id": "6414ad1601f297b14f36ea53",
"name": "Fjallraven - Foldsack No. 1 Backpack, Fits 15 Laptops",
"image": "https://fakestoreapi.com/img/81fPKd-2AYL._AC_SL1500_.jpg",
"category": "Men's clothing",
"manufacturer": "Guleb Inc.",
"manufacturerPrice": 109,
}
],
]