Working with beanie/motor transactions/sessions #692
-
I have been working with beanie for some time and there are a few operations in my code that i would like to run like a transaction to avoid inserting half completed information to certain collections (all or nothing gets in). Is there someone that have worked with this? I have tried a few things using fastapi, beanie and motor but all seem to failure and found no tutorial to replicate. Here is my MongoDbClient that i built to run the necessary Datalayer services
At the current moment I made an object of my mongoclient at the start of my controllers and added the get_db method as a Dependency injection to my fastapi route: Example:
The problem here is that my transaction is been commited before the session.commit_transaction() is run (at the yield database) Could anyone help me out? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Found a way to make it work. Here is a code example
|
Beta Was this translation helpful? Give feedback.
Found a way to make it work. Here is a code example