Reputation: 995
{
"_id" : ObjectId("531df10dc044701691c55acf"),
"name" : "jrose",
"phonenumbers" : [
{
"type" : "home",
"value" : "7707446895"
},
{
"type" : "work",
"value" : "7707336895"
}],
"callerId" : ["7707336895"],
"PIN" : "7707336895",
"useSMS" : true
}
I want to change the "value" field to "phonenumber" inside of the "phonenumbers" array
Upvotes: 1
Views: 130
Reputation: 230286
Seems that $rename operator doesn't work with arrays (at the moment).
> db.foo.update({}, {$rename: {'phonenumbers.value': 'phonenumbers.phonenumber'}})
$rename source field invalid
So your only choice is to read the document, modify it in the application and rewrite it in the database.
Upvotes: 1