How do I change a field name in a collection in mongodb -
{ "_id" : objectid("531df10dc044701691c55acf"), "name" : "jrose", "phonenumbers" : [ { "type" : "home", "value" : "7707446895" }, { "type" : "work", "value" : "7707336895" }], "callerid" : ["7707336895"], "pin" : "7707336895", "usesms" : true }
i want change "value" field "phonenumber" inside of "phonenumbers" array
seems $rename operator doesn't work arrays (at moment).
> db.foo.update({}, {$rename: {'phonenumbers.value': 'phonenumbers.phonenumber'}}) $rename source field invalid
so choice read document, modify in application , rewrite in database.
Comments
Post a Comment