Gorm Golang orm associations
TownID must be specified as the foreign key. The Place struct gets like this: type Place struct { ID int Name string Description string TownID int Town Town } Now there are different approach to handle this. For example: places := []Place{} db.Find(&places) for i, _ := range places { db.Model(places[i]).Related(&places[i].Town) } This will certainly … Read more