删除只有一个操作,delete。也是先找到再去删除。 可以删除单条记录,也可以删除多条记录。
var s Student
db.Debug().Delete(&s, "age = ?", 100)
fmt.Println(s)
[15.878ms] [rows:1] DELETE FROM `student` WHERE age = 100
var s Student
db.Debug().Take(&s, "age = ?", 101)
db.Debug().Delete(&s)
[2.060ms] [rows:1] SELECT * FROM `student` WHERE age = 101 LIMIT 1
[4.494ms] [rows:1] DELETE FROM `student` WHERE `student`.`id` = 1