my collection is as follows :
"_id" : ObjectId("5751f7892ae95d601f40411d"),
"doc" : [
{
"org" : ObjectId("5751f7892ae95d601f40411c"),
"action" : 0,
"_id" : ObjectId("5751f7892ae95d601f40411e")
},
{
"org" : ObjectId("5751952cace204c507fad255"),
"action" : 1,
"_id" : ObjectId("575217ce341cf6512b8dff39")
} ]
I want to update action field in the doc with org:5751952cace204c507fad255 so action will equal 2 I know this has already been answered many times but it's not working for me
Here is what I tried but Collection didn't change:
Model.update(
{
"_id":ObjectId("5751f7892ae95d601f40411d"),
"doc.org":ObjectId("5751952cace204c507fad255")
},
{
"$inc": {
"doc.$.action": 1
}
}
)