{
"General": {
"Setting": [
{
"Name": {
"MetaData": {
"type": "bool"
}
}
},
{
"Name": {
"MetaData": {
"type": "bool"
}
}
},
{
"Name": {
"MetaData": {
"type": "bool"
}
}
}
]
}
}
i have the above document i need to update General.Setting.[index].Name.MetaData.type to General.Setting.[index].Name.MetaData.Newtype
What I have tried:
i did tried using this query :
1st approach:
doc.forEach( function(d) {
var settingsCollectionJSON = d.General.Setting;
settingsCollectionJSON.forEach( function(temp) {
var settingsCollectionJSONobj = temp.Name.MetaData.Localizable;
db.getCollection('SettingCollection').update(temp, { $rename: { "Name.MetaData.type": "Name.MetaData.Newtype" } })
})
})
2nd approach using $set and $unset.
//db.getCollection('SettingCollection').update(temp, { $set:{'MetaData.0.type':settingsCollectionJSONobj}, $unset: {'MetaData.0.Newtype':1} })
but for both these i'm not getting updated.can i have any solution?