Models and Schemas
The CRUDRouter can generate and document your routes based on a MongoModel
which is a custom pydantic model passed to it, as well as an output schema representing the JSON result you'll receive.
1 2 3 4 5 |
|
Automatic Output Schema Generation
Omitting the output schema argument when initializing your CRUDRouter leads to the router automatically generating and documenting an output schema for your routes. This process involves automatically excluding any fields that match the primary key in the database since they will be generated server-side.
In Model vs Out Schema¶
The "in" model represents the data stored in your database, while the "out" schema represents the data you'll receive in response to route calls. This allows you to explicitly exclude fields you wish to keep hidden in the response to your requests.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|