I have following document:
{
"dataset_path":"path_of_dataset",
"project_1":{
"model_1":"path_of_model_1",
"model_2":"path_of_model_2"
}
}
I want to change "project_1" to "renamed_project_1" and "path_of_model_1" to "new_model_1_path". The resultant output should be as follows:
{
"dataset_path":"path_of_dataset",
"renamed_project_1":{
"renamed_model_1":"new_model_1_path",
"model_2":"path_of_model_2"
}
}
Here is what I tried:
db.collection.update_many({'dataset_path': 'path_to_dataset'}, {'$rename': {"project_1": "renamed_project_1"}},
{'$set': {"project_1.model_1": "new_model_1_path"}})
but the above query throws following error:
pymongo.errors.WriteError: Updating the path X would create a conflict at X.