In some situations I need to completely overwrite a specific MongoDB collection by doing:
db.collection.remove()db.collection.insert(doc)multiple times.
What if 1. succeeds but somewhere 2. fails?
Is there a way to do a rollback when this fails?
Any other way to go about this?
If your collection isn’t sharded you could: