My initial one of the document in a collection will be:
{
Canditate:"Clark weg",
Location:"California",
Education:"Graguate"
Match_Tasks:[]
}
I am getting response as a iteration in my code like: 1 st iteration response:
{
Asignee:"[email protected]",
Task_ID:"ObjectID_(2)"
}
After the 1st iteration response, My updated document is like:
{
Canditate:"Clark weg",
Location:"California",
Education:"Graguate"
Match_Tasks:[{Asignee:"[email protected]",
Task_ID's:
[
{ID:"ObjectID_(2)"}
]
}
}
2 nd iteration response:
{
Asignee:"[email protected]",
Task_ID:"ObjectID_(3)"
}
My updated document is like:
{
Canditate:"Clark weg",
Location:"California",
Education:"Graguate"
Match_Tasks:[{Asignee:"[email protected]",
Task_ID's:
[
{ID:"ObjectID_(2)"}
]
},
{Asignee:"[email protected]",
Task_ID's:
[
{ID:"ObjectID_(3)"}
]
}
}
3 rd and 4th reponses: Third response:
{
Asignee:"[email protected]",
Task_ID:"ObjectID_(1)"
}
Fourth response:
{
Asignee:"[email protected]",
Task_ID:"ObjectID_(2)"
}
My updated document after my 3 rd and 4 th response:
{
Canditate:"Clark weg",
Location:"California",
Education:"Graduate"
Match_Tasks:[{Asignee:"[email protected]",
Task_ID's:
[
{ID:"ObjectID_(1)"},
{ID:"ObjectID_(2)"}
]
},
{{Asignee:"[email protected]",
Task_ID's:
[
{ID:"ObjectID_(3)"},
{ID:"ObjectID_(2)"}
]
}
}
I am trying with the pymongo code:
aggregate([{"$match":{"Canditate":"Clark weg"}},{"$set":{"Match_Tasks":{
"$map": {
"input": "$Match_Tasks",
"as": "Match_Tasks",
"in":
{"$cond":[{"$eq":["$Match_Tasks.Asignee",Asignee]},
{"$push":{"Match_Tasks.$.Task_ID's":{"$ID":Task_ID}}},
{"$push":{"Match_Tasks":{"Asignee":email,"Task_ID's":[{"$ID":Task_ID}]}}}]}}}} }])
$mergestep at the end