Overview
⚡ Create CRUD routes with lighting speed ⚡ A dynamic FastAPI router that automatically creates CRUD routes for your Mongodb models
Documentation: https://pierrod.github.io/fastapi-crudrouter-mongodb-doc/
Source Code: https://github.com/pierrod/fastapi-crudrouter-mongodb
Credits :
-
Base projet and idea : awtkns
-
Convert _id to id (for previous versions of Pydantic) : mclate github guide
-
For Pydantic v2 : Stackoverflow
Are you exhausted from constantly rewriting basic CRUD routes? Do you find yourself needing to swiftly prototype features for presentations or hackathons? Well, rejoice! Introducing fastapi-crudrouter-mongodb, your ultimate solution.
As a complement to FastAPI's APIRouter, the FastAPI CRUDRouter for MongoDB 🌱 takes care of the heavy lifting for you. It automatically generates and documents your CRUD routes with minimal effort. Simply provide your model and your database connection, and you're good to go!
Installation¶
$ pip install fastapi-crudrouter-mongodb
---> 100%
Basic Usage¶
I will provide more examples in the future, but for now, here is a basic example of how to use the FastAPI CRUDRouter for Mongodb .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
Advanced Usage¶
fastapi-crudrouter-mongodb offers several functionalities designed to maximize the benefits of your auto-generated CRUD routes. Here are some key highlights:
- Automatic Lookups
- Automatic Embeds
- Ability to provide Custom out schema
- Ability to Disable specific routes
- Ability to Add custom dependencies to specific routes
OpenAPI Support¶
Automatic OpenAPI Documentation
By default, the CRUDRouter automatically documents all generated routes in accordance with the OpenAPI specification.
The default routes generated by the CRUDRouter are displayed in the OpenAPI documentation generated by the system.
The CRUDRouter can dynamically generate comprehensive documentation based on the provided models.