Using mongodb session transaction
See original GitHub issueHello,
I want to use transaction based on Umongo document instance, could we use a custom session in the commit method?
The following is the way that I use on the motor without Umongo:
async with await db_client.start_session() as session:
async with session.start_transaction():
session.collection.insert_one({myobject:"objectvalue"})
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
Session.startTransaction() — MongoDB Manual
Starts a multi-document transaction associated with the session. At any given time, you can have at most one open transaction for a session....
Read more >How To Use Transactions in MongoDB - DigitalOcean
Begin by opening two separate MongoDB shell sessions. One will be used to execute commands in the transaction, and the other will allow...
Read more >MongoDB Transactions - How to Use and Manage Them
MongoDB transactions exist within sessions. You create a session using startSession() and follow with session.startTransaction() to stage your transaction ...
Read more >Sessions and Transactions - GitHub Pages
A session is used to group together a series of operations that are related to each other and should be executed with the...
Read more >Getting Started with MongoDB Transactions on Single Nodes ...
Begin by launching two MongoDB shell sessions. One will be used to execute transaction commands, while the other will allow you to see...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Mongo 4 introduces transactions. We use it in our application. To do so we had to override a lot of methods in pymongo driver to pass
session
through all methods. (About 300 LoC.)We did it in a clumsy way. It could probably be achieved more elegantly. Perhaps using context variables.
I’m open to the idea. Just never got the time to do it correctly enough to merge it in umongo.
BTW, thanks @touilleMan for suggesting the use of context variables for this at PyConFR 2019.