Дима Прусский
2018-04-18 22:48:06 UTC
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
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/e7553ab1-2395-43d7-9a89-b77edbfcf288%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
{
"_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
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/e7553ab1-2395-43d7-9a89-b77edbfcf288%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.