I have a DB like:
{
'a' : [
{ 'name' : 'john',
'phone' : 111111
},
{ 'name' : 'doe',
'phone' : 222222
},
],
'b' : [
{ 'name' : 'john',
'phone' : 111111
},
{ 'name' : 'doe',
'phone' : 222222
},
]
}
now I want to add a new field, “state : 1” to all the entries (like name, phone)
any suggestions on the update clause?
I tried using $set and $addToSet, but I’m not sure about the criteria too
thanks
You need to use the $ positional operator. See the documentation at http://www.mongodb.org/display/DOCS/Updating#Updating-The%24positionaloperator