Hi I wonder if anyone can help
I am converting the data from a microsoft sql database to mongodb and essentially need to populate the new mongodb type ids from 1 collection to another but they are in nested arrays so in the example below i need a mongodb query to update the e_id field in the targetCollection from the e_id in the sourceCollection
cant seem to think of a sensible way - to avoid loads of unwinds Thanks in anticipation
sourceCollection
{
"name": "Mr 1",
"name_id": 1,
"d": [
{
"d_id": 11,
"d_name": "Mr 1 - d name 1",
"e": [
{
"e_id": { "$oid":"5f3d1993c7260ee923992240"},
"e_oldid": 6,
"e_name": "Mr 1 - d1 - e name 1"
},
{
"e_id": { "$oid":"5f3d1993c7260ee923992241"},
"e_oldid": 5,
"e_name": "Mr 1 - d1 - e name 2"
},
{
"e_id": { "$oid":"5f3d1993c7260ee923992242"},
"e_oldid": 4,
"e_name": "Mr 1 - d1 - e name 3"
},
{
"e_id": { "$oid":"5f3d1993c7260ee923992243"},
"e_oldid": 3,
"e_name": "Mr 1 - d1 - e name 4"
},
{
"e_id": { "$oid":"5f3d1993c7260ee923992244"},
"e_oldid": 2,
"e_name": "Mr 1 - d1 - e name 5"
},
{
"e_id": { "$oid":"5f3d1993c7260ee923992245"},
"e_oldid": 1,
"e_name": "Mr 1 - d1 - e name 6"
}
]
}
]
}
targetCollection
"name": "Mr 1",
"name_id": 1,
"a": [
{
"a_id": 11,
"a_name": "Mr 1 - a name 1",
"b": [
{
"b_id": 111,
"b_name": "Mr 1 - a1 - b name 1",
"c": [
{
"e_id": null,
"e_oldid": 1,
"c_name": "Mr 1 - a1 - b1 - c name 1"
},
{
"e_id": null,
"e_oldid": 2,
"c_name": "Mr 1 - a1 - b1 - c name 2"
},
{
"e_id": null,
"e_oldid": 3,
"c_name": "Mr 1 - a1 - b1 - c name 3"
}
]
},
{
"b_id": 112,
"b_name": "Mr 1 - a1 - b name 2",
"c": [
{
"e_id": null,
"e_oldid": 4,
"c_name": "Mr 1 a1 - b2 - c name 1"
},
{
"e_id": null,
"e_oldid": 5,
"c_name": "Mr 1 a1 - b2 - c name 2"
},
{
"e_id": null,
"e_oldid": 6,
"c_name": "Mr 1 a1 - b2 - c name 3"
}
]
}
]
}
]
}