rows I am trying to update mongodb for each field in an array of records.
The following is an example diagram:
{ "_id" : ObjectId("508710f16dc636ec07000022"), "summary" : "", "uid" : "ABCDEF", "username" : "bigcheese", "name" : "Name of this document", "status_id" : 0, "rows" : [ { "score" : 12, "status_id" : 0, "uid" : 1 }, { "score" : 51, "status_id" : 0, "uid" : 2 } ] }
So far, I have been able to perform one update:
db.mycollection.update({"uid":"ABCDEF","rows.uid":1}, {$set:{"rows.$.status_id":1}},false,false)
However, I am struggling with how to perform an update that will update all array entries to status_id 1 (for example).
Below I will tell you how it should work:
db.mycollection.update({"uid":"ABCDEF"}, {$set:{"rows.$.status_id":1}},false,true)
However, I get the error message:
cannot join array using string field name [$]
I tried for quite some time, no luck. Any pointers?