Golang Gorm: Is it possible to delete a record via a many2many relationship?

后端 未结 3 2182
不知归路
不知归路 2021-02-20 14:31

I have a many2many structure similar to GORM\'s example:

// User has and belongs to many languages, use `user_languages` as join table
type User struct {
    gor         


        
3条回答
  •  春和景丽
    2021-02-20 14:56

    Also, you can do this by using "replace"

    DB.Model(&user).Association("Languages").Replace(user.Languages)
    

提交回复
热议问题