gorm删除记录(删除具有级联关系的数据)
删除具有级联关系的数据
参考:https://gorm.io/zh_CN/docs/associations.html#Association-Mode
带 Select 的删除
你可以在删除记录时通过 Select 来删除具有 has one、has many、many2many 关系的记录,例如:
|
|
注意:只有当记录的主键不为空时,关联才会被删除,GORM 会使用这些主键作为条件来删除关联记录
|
|
- Author: mineor
- Link: https://blog.mineor.xyz/posts/Go/gorm_delete/
- License: This work is under a 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议. Kindly fulfill the requirements of the aforementioned License when adapting or creating a derivative of this work.