Skip to content
Advertisement

“Update” _id in mongodb document

PS: I only have to do this due to business requirements

I’m able to achieve it using mongosh, but since there are multiple records to be updated, I’m trying to implement a simple python script to automate the task.

Is it possible to do this with pymongodb?

JavaScript

I’m not able to set the new Id in the doc variable in order to insert the new document that will mirror the old one.

Thanks

Advertisement

Answer

Here’s a pymongo equivalent:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement