Jul 22, 2022
0
Level 1
Is it possible to create relationship with data in array in MongoDB
I have a collection with Data1 like
{
_id : "1",
total_amount : 5876,
date: "20-Jun-2018"
},
{
_id : "2",
total_amount : 5776,
date: "20-Jun-2018"
}
I want to store these data in another collection Data2 as follows :
{
name : "XYZ",
adjustments : [
{
data1_id : "1",
adjust_amount : 675
},
{
data1_id : "2",
adjust_amount : 6785
}
]
}
Storing this data isn't a problem in an array of Objects form. But is there any way I can create a relationship with the data within the array adjustments?
At the time of listing, I want adjustments with adjust_amount and all the related data.
Please or to participate in this conversation.