I have the following JSON:
{
"_id" : ObjectId("57ce1a55899bf934e59edd0d"),
"project_name" : "Coupletones",
"list_users" : [
"testmail"
],
"iterations" : [
{
"iteration_name" : "Iteration1",
"tasks" : [ ]
},
{
"iteration_name" : "Iteration2",
"tasks" : [ ]
},
]
}
I want to be able to push things into to the tasks array associated with Iteration 2. How do I properly query and insert to the correct location? This is what I have so far, but it always inserts into the tasks array associated with Iteration 1.
var ans = collection_projects.update({
"project_name" : project_name,
"list_users" : email,
"iterations.iteration_name": iteration_name,
},
{$addToSet: {"iterations.$.tasks": {
task_name: task_name,
task_description : task_description,
task_assignee: task_assignee,
task_status : -1 } } }
);
I've seen this: MongoDB nested array query but he is only trying to push to one nested array.