Chapter 2
Modeling with GORM
Define your data layer the Grit way.
~21 min total3 lessonsAssignment
By the end of this chapter you'll be able to
- Design relational models
- Use AutoMigrate
- Apply constraints and indexes
Lessons
Chapter assignment
Model a small invoice domain
Add three models: Customer (has many Invoices), Invoice (belongs to Customer, has many LineItems), LineItem (belongs to Invoice). Run `grit migrate` and confirm the foreign keys exist via GORM Studio.
See success criteriaLesson 1 takes ~7 min.
Start chapterSpot a typo? Have an idea?
Help us improve this chapter. One click opens a GitHub issue with this chapter's URL pre-filled â suggest a clearer wording, report a bug, or request a new lesson. The course keeps improving thanks to learners like you.
Suggest an improvement on GitHub