mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
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:
@@ -73,6 +73,12 @@ type CarDeleteOne struct {
|
||||
cd *CarDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CarDelete builder.
|
||||
func (cdo *CarDeleteOne) Where(ps ...predicate.Car) *CarDeleteOne {
|
||||
cdo.cd.mutation.Where(ps...)
|
||||
return cdo
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (cdo *CarDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := cdo.cd.Exec(ctx)
|
||||
@@ -88,5 +94,7 @@ func (cdo *CarDeleteOne) Exec(ctx context.Context) error {
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cdo *CarDeleteOne) ExecX(ctx context.Context) {
|
||||
cdo.cd.ExecX(ctx)
|
||||
if err := cdo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,12 @@ type GroupDeleteOne struct {
|
||||
gd *GroupDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the GroupDelete builder.
|
||||
func (gdo *GroupDeleteOne) Where(ps ...predicate.Group) *GroupDeleteOne {
|
||||
gdo.gd.mutation.Where(ps...)
|
||||
return gdo
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (gdo *GroupDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := gdo.gd.Exec(ctx)
|
||||
@@ -88,5 +94,7 @@ func (gdo *GroupDeleteOne) Exec(ctx context.Context) error {
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (gdo *GroupDeleteOne) ExecX(ctx context.Context) {
|
||||
gdo.gd.ExecX(ctx)
|
||||
if err := gdo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user