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
Hello, I’m using this book to study DDD. At the same time, I wanted to incorporate recent trends into my learning, so I started studying with FastAPI and sqlc.
However, since sqlc doesn’t provide object-to-table mapping functionality, I’m unsure how to solve this, and I need help.
In the book, SQLAlchemy’s mapper is used to bind the domain model to the table, and storage changes are accomplished by modifying the aggregate. sqlc is an ORM specialized in generating Go objects from raw SQL, so it doesn’t have the mapping functionality that the book uses.
Would it be appropriate to implement the functionality in the repository to reflect changes in the domain class to the DB, and then call that functionality in the service layer after making changes to the domain class? Or is it impossible to achieve DDD without an ORM that has mapping functionality?
The text was updated successfully, but these errors were encountered:
you can absolutey do ddd without an orm, and you can build a Repository that just uses raw sql. it's more fiddly and boilerplatey, but it is also arguably more explicit and has less magic, so it's a totally valid thing to do.
you can also use an orm that's separate from your domain model -- the django appendix in the book does this -- and the repository's job is to translate from your domain model objectrs, to and from ORM objects, and to use those to load/save to the db.
Thank you for your comment! I was aware that there is an appendix about Django, but I hadn’t checked it yet… I’ll read Appendix D. Repository and Unit of Work Patterns with Django right away!
https://github.com/molpako/Architecture-Patterns-with-Python
Hello, I’m using this book to study DDD. At the same time, I wanted to incorporate recent trends into my learning, so I started studying with FastAPI and sqlc.
However, since sqlc doesn’t provide object-to-table mapping functionality, I’m unsure how to solve this, and I need help.
In the book, SQLAlchemy’s mapper is used to bind the domain model to the table, and storage changes are accomplished by modifying the aggregate. sqlc is an ORM specialized in generating Go objects from raw SQL, so it doesn’t have the mapping functionality that the book uses.
Would it be appropriate to implement the functionality in the repository to reflect changes in the domain class to the DB, and then call that functionality in the service layer after making changes to the domain class? Or is it impossible to achieve DDD without an ORM that has mapping functionality?
The text was updated successfully, but these errors were encountered: