entc/gen: add support for DeleteOne with predicates (#3271)

Also, fixed a bug in DeleteOne.Exec where it was skipping NotFoundError
This commit is contained in:
Ariel Mashraki
2023-01-24 15:10:20 +02:00
committed by GitHub
parent b95c3c5251
commit d66350ae40
143 changed files with 1316 additions and 149 deletions

View File

@@ -73,6 +73,12 @@ type UserDeleteOne struct {
ud *UserDelete
}
// Where appends a list predicates to the UserDelete builder.
func (udo *UserDeleteOne) Where(ps ...predicate.User) *UserDeleteOne {
udo.ud.mutation.Where(ps...)
return udo
}
// Exec executes the deletion query.
func (udo *UserDeleteOne) Exec(ctx context.Context) error {
n, err := udo.ud.Exec(ctx)
@@ -88,5 +94,7 @@ func (udo *UserDeleteOne) Exec(ctx context.Context) error {
// ExecX is like Exec, but panics if an error occurs.
func (udo *UserDeleteOne) ExecX(ctx context.Context) {
udo.ud.ExecX(ctx)
if err := udo.Exec(ctx); err != nil {
panic(err)
}
}