Closed leynier closed 1 year ago
I'm interested in this as well. I am coming from umongo which supports synchronous and async, but I only use it synchronously.
I'm interested in beanie because I'd like to try pydantic, but having to run it async is a bit of a burden for my applications.
My synchronous use case might not be an aim of the project, but I just wanted to mention it.
I thought about PyMongo support, but Beanie uses async generators inside, and this is too tricky to support and sync and async generators depending on the driver. Probably, later I'll refactor it the way when it will support both, but for now, it is not in the todo. Did you try unasync
and others? I didn't but did hear that it works well.
It would be great to see this feature! An alternative ODMantic support both sync (pymongo) and async (motor) engines.
Hey @roman-right With the release of the sync API, can you close this one out?
Thank you @mikeckennedy, you are right.
The sync version is available since 1.13.0
. Here are the migration instructions: https://beanie-odm.dev/tutorial/sync/migrate-from-async/
In some contexts, synchronous operations are required but in others, asynchronous operations are possible and more efficient. For example a CLI with Typer and a RestAPI with FastAPI.
It would be nice to be able from the same code base to use both synchronous and asynchronous operations using PyMongo or Motor depending on the case.
These are some repositories that can help and projects where a similar idea has been applied: