You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all - thanks for this beautiful repo!
I noticed that there is no mention of where to store any crud operations in the project structure.
I wonder how you would implement these?
Some implementations I've considered.
No separate crud operations - would lead to duplicated code.
Following @tiangolo's full stack example structure, there is a separate crud folder. I could create a crud folder for each module.
Another implementation I've seen is to declare the crud operations directly in the model's Base class. E.g.:
We try to keep our service functions as clean as possible and let them do one thing only. All the validations should be done one abstraction layer above.
For example, we must be sure username doesn't cause UniqueViolationError before sending it to service.create_profile.
@ignacevau I would avoid adding any methods to your database models (Maybe if they only operate on that specific model it should be ok, but they shouldn't change database state)
As @zhanymkanov said you can make functions and use them to perform CRUD operations, another option is to use class based services.
First of all - thanks for this beautiful repo!
I noticed that there is no mention of where to store any crud operations in the project structure.
I wonder how you would implement these?
Some implementations I've considered.
However, this way you don't get any autocompletion.
So far, we're using a separate crud folder for each module, but I would love to hear any other recommendations.
The text was updated successfully, but these errors were encountered: