{
"_id" : ObjectId("510902fb7995fe3504000002"),
"name" : "Gym",
"status" : "1",
"whichs" : [
{
"name" : "American",
"status" : "1"
}
]
}
Above is my collection object.. I want to update which.name to "Indian" where which.status = 1.. Please help me with the mongoDB query for doing this..
Andy Refuerzo :
You can try this:\n\ndb.collection.update({\"whichs.status\" : \"1\" }, \n {$set : { \"whichs.$.name\" : \"Indian\"},\n false,\n true);\n\n\nThis finds \"whichs.status\" : \"1\" then sets \"whichs.$.name\" : \"Indian\" for all documents. For more info on the update() method, read here.",
2013-01-30T13:51:38