'Updating data in MongoDB: Move data from one collection to an archive collection

I am new to MongoDB. I am trying to update some existing data in a collection based on a particular id using python. My pseudo code looks something like this:

#Pseudo Code if <my_id> found in my_collection: move the existing data to archive collection insert new data in my_collection

I have tried to use db.update() function but was not able to do so. Can someone throw some light on what might be a good approach in terms of the code.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source