I'm trying to cascade delete the below structure:
type Action struct {
gorm.Model
Name string
Email string
Halls []Hall `gorm:"foreignKey:ActionID"`
}
type Hall struct {
gorm.Model
Name string
ActionID uint
Stream Stream `gorm:"foreignKey:HallID"`
}
type Stream struct {
ID uint `gorm:"primaryKey"`
HallID uint
Name string
}
db.Select("Halls").Delete(&action) - works fine for selected action and with all related halls.
How can I delete this one and related streams?
Something like:
db.Select("Halls", "Streams").Delete(&action)
db.Select("Streams").Select("Halls").Delete(action)
doesn't work.
Thanks