So this is my collection snippet:
{
"_id" : ObjectId("56d82c76c07d41a38d418120"),
"userid" : "a",
"dates" : {
"2/01/2015" : {
"9/10" : {
"ava" : "yes",
"bookibg_id" : "null"
},
"10/11" : {
"ava" : "yes",
"bookibg_id" : "null"
}
},
"3/01/2015" : {
"9/10" : {
"ava" : "yes",
"bookibg_id" : "null"
},
"10/11" : {
"ava" : "yes",
"bookibg_id" : "null"
}
}}}
{
"_id" : ObjectId("56d82c76c07d41a38d418120"),
"userid" : "b",
"dates" : {
"2/01/2015" : {
"9/10" : {
"ava" : "yes",
"bookibg_id" : "null"
},
"10/11" : {
"ava" : "yes",
"bookibg_id" : "null"
}
},
"3/01/2015" : {
"9/10" : {
"ava" : "yes",
"bookibg_id" : "null"
},
"10/11" : {
"ava" : "yes",
"bookibg_id" : "null"
}
}}}
I want to add/push given given snippet into user id:b ,dates fiels: Snippet:
"4/01/2015" : {
"9/10" : {
"ava" : "yes",
"bookibg_id" : "null"
},
"10/11" : {
"ava" : "yes",
"bookibg_id" : "null"
}
}
So I want to add the snippet dates>snippet where userid=b What will be the mongodb query? I searched about $push on mongo docs but it says that the field needs to be an array otherwise it wont happen.