Here are the Struct relations:
type A struct {
Id int64
RelB []B `gorm:"FOREIGNKEY:Aid;ASSOCIATION_FOREIGNKEY:Id"`
}
type B strcut {
Id int64
Aid int64
RelC []C `gorm:"FOREIGNKEY:Bid;ASSOCIATION_FOREIGNKEY:Id"`
}
type C struct {
Id int64
Bid int64
RelD []D `gorm:"FOREIGNKEY:Cid;ASSOCIATION_FOREIGNKEY:Id"`
}
type D struct {
Id int64
Cid int64
}
I try to find all of these relations with Preload like this:
var result []A
db.Preload("RelB").Preload("RelB.RelC"). // if only three structs relations it works fine so far
Preload("RelB.RelC.RelD"). // it shows errors can not preload field RelD for A
Find(&result)
So, How to relate these four structs with preload? Or there is other better way? Thanks