Looking at an example from their documentation:
type User struct { gorm.Model Name string CompanyID int Company Company } type Company struct { ID int Name string }
CompanyID
field seems rather redundant. Is it possible to get rid of it using some tags on Company
field instead?
Advertisement
Answer
Changing User
definition like this did the trick:
type User struct { gorm.Model Name string Company Company `gorm:"column:company_id"` }