I have following structure of documents:
{
"_id" : 12421,
"first" : {
"second" : {
"someFields" : 31241,
"third" : [
{
"wrongFieldName" : {
"something" : 2134214
}
},
{
"wrongFieldName" : {
"something" : 23413
}
}
]
}
}
}
I want to change all
"wrongFieldName" to "rightFieldName":
{
"_id" : 12421,
"first" : {
"second" : {
"someFields" : 31241,
"third" : [
{
"rightFieldName" : {
"something" : 2134214
}
},
{
"rightFieldName" : {
"something" : 23413
}
}
]
}
}
}
I tried to use $rename, but it was thrown an error, because needed fields are in array:
The source field for $rename may not be dynamic: first.second.third.$.wrongFieldName