我想要实现的SQL
select * from movies left join server on movies.server_id = server.id
下面是我的go 代码,不知道是哪里问题,查询出来的server字段的数据不对
type Server struct {
Id int64 `gorm:"primary_key"`
Domain string
}
type Movie struct {
Id int64 `gorm:"primary_key"`
Count int64
Status int
Name string
ServerId int
Path string
CategoryId int
CreatedAt time.Time `grom:"column:created_at"`
UpdatedAt time.Time `grom:"column:updated_at"`
Server Server `gorm:"foreignkey:id;association_foreignkey:server_id;auto_preload"`
}
// 实际使用查询代码
var movie orm.Movie
d := orm.Db.Find(&movie)