go项目脚手架
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sorbet/pkg/db/delete_builder.go

18 lines
336 B

package db
import "gorm.io/gorm"
type DeleteBuilder[T any] struct {
Expr
db *gorm.DB
}
func NewDeleteBuilder[T any](db *gorm.DB) *DeleteBuilder[T] {
return &DeleteBuilder[T]{Expr{}, db}
}
func (b *DeleteBuilder[T]) Commit() (int64, error) {
var t T
res := b.db.Scopes(b.Scopes).Delete(&t)
return res.RowsAffected, res.Error
}