Summary
In this chapter, we explored GORM, a powerful ORM for Go. We learned where an ORM can be an advantage and where it can be a problem, leaving us prepared to decide what trade-offs we want to accept. We also explored how to use GORM in our projects, from defining models and performing CRUD operations to working with relationships and using advanced features such as transactions and hooks. We also migrated our shopping list API to GORM, simplifying our repository code.
GORM is an amazing tool for simplifying database interactions in Go, especially for projects requiring rapid development or teams that don’t have strong SQL skills. It abstracts away much of the boilerplate and complexity that comes with raw SQL and allows us to focus on our application’s business logic. However, it is important to understand that simplicity comes with a cost, and GORM may not be the best fit for every project.
As part of this book, I also want to replace another piece that...