Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What are some best practices for Fastapi + Mongodb #34

Open
bengabp opened this issue Aug 26, 2023 · 2 comments
Open

What are some best practices for Fastapi + Mongodb #34

bengabp opened this issue Aug 26, 2023 · 2 comments

Comments

@bengabp
Copy link

bengabp commented Aug 26, 2023

Almost all of of here have used some ORM library like Sqlalchemy which is equivalent to how django does its things. I found myself using mongodb as the main database choice for most of my projects. Also in all company projects that Ive been working on since this year, I have not used any sql database. I usually use pymongo and Its always a hassle to configure everything for every new project. What ive done is create a DBConnection class which has all the collections I need as class attributes and possibly some methods does some db operations.

The problem

As you already figured out, Its nothing close to using an ORM, Are there some libraries that support ODM that i can use in fastapi like Sqlalchemy (when dealing with SQL). I mean relationsips, and most important being able to still my favourite mongodb operation which is the aggregate searches.

@yallxe
Copy link

yallxe commented Aug 29, 2023

If you're looking for an ODM compatible with FastAPI and Pydantic, you would definitively like this one: https://beanie-odm.dev/

Repo: https://github.com/roman-right/beanie

@bengabp
Copy link
Author

bengabp commented Aug 30, 2023

Hi @yallxe Thank you for your recommendation. After i created this issue, I also came across this beanie library and I will definitely check it out and I will try to provide valuable information about it in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants