I am trying to update the name of a key inside an object of an array and annoyed due to the inability to make the queries work. I have tried this How rename nested key in array of object in MongoDB? but I still get the same error I was getting earlier
Here is the document:
[
{
"accountCreation": [
{
"startDateTime": "",
"endDateTime": "",
"isDone": "Yes"
}
]
}
]
Here is my query:
db.collection.update({}, $rename:{
"accountCreation.$.isDone":"done",
})
All I am trying to do is rename the isDone key to done. Note that this is just one of the many objects that have this key. I am trying to update all the occurences of the isDone key to done inside the accountCreation
Here is the error I am receiving:
fail to run update: write exception: write errors: [cannot use the part (accountCreation of accountCreation.isDone) to traverse the element