任何人都可以帮助我,如何在go-gorm中删除属于该关联?

这是我的简单模型:

type User struct {
   gorm.Model
   Name      string
   FirstName string
}

type Customer struct {
   Notes []Note `gorm:"polymorphic:Owner;"` // other models can have notes as well
}

type Note struct {
    gorm.Model
    User      User `json:"-"`
    UserID    uint
    OwnerID   uint
    OwnerType string
}

对于“有很多”和“多对多”的关联,我可以删除这些关系 . 在这个例子中,这有效:

db.Model(&customer).Association("Notes").Delete(&note)

但是,如果我尝试以下内容:

db.Model(&note).Association("User").Delete(&user)

我收到指针错误:

panic: runtime error: index out of range
... src/github.com/jinzhu/gorm/association.go:242 +0x21ce

存在“用户”和“注释”对象,并且存在关系(UserID在数据库中设置为1) .