If I have a data like that in collection 1, Like nested array and object and then I have another collectoin with objects. How can I join these two collections and get the output as complete object with id,full name, its manager and depeartment for each seperate id. I have tried with unwind but i can't get to each single nested manager name and Id as i think if I can't get each single one of it, how can I join it with other collection id. How can I join these? Also, is this even possible?
--Collection 1 {
"ïd": 1,
"name": "Max ",
"managers": [{
"ïd": 2,
"name": "Caroline "
},
{
"ïd": 3,
"name": "Cecilia ",
"managers": [{
"ïd": 4,
"name": "Geraldine ",
"managers": [{
"ïd": 5,
"name": "Ingrid "
},
{
"ïd": 6,
"name": "Jacqueline "
}
]
},
{
"ïd": 7,
"name": "Johannes "
}
]
}
]
}
--Collection 2
[{
"ïd": 1,
"fullName": "Max Born",
"department": "Management"
}, {
"ïd": 2,
"fullName": "Caroline Herschel",
"department": "Management"
}, {
"ïd": 3,
"fullName": "Cecilia Payne-Gaposchkin",
"department": "Management"
}, {
"ïd": 4,
"fullName": "Geraldine Seydoux",
"department": "Sales"
}, {
"ïd": 5,
"fullName": "Ingrid Daubechies",
"department": "Sales"
}, {
"ïd": 6,
"fullName": "Jacqueline K. Barton",
"department": "Sales"
}, {
"ïd": 7,
"fullName": "Johannes Kepler",
"department": "Application Development"
}]
My expected output is like
{
"ïd": 1,
"name": "Max ",
"fullName": "Max Born",
"department": "Management"
},
{ "ïd": 2,
"name": "Caroline ",
"fullName": "Caroline Herschel",
"department": "Management"
}
..... and so on