online-order/ent/businessconfig_delete.go
2023-10-29 02:42:07 +03:30

89 lines
2.4 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"online-order/ent/businessconfig"
"online-order/ent/predicate"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// BusinessConfigDelete is the builder for deleting a BusinessConfig entity.
type BusinessConfigDelete struct {
config
hooks []Hook
mutation *BusinessConfigMutation
}
// Where appends a list predicates to the BusinessConfigDelete builder.
func (bcd *BusinessConfigDelete) Where(ps ...predicate.BusinessConfig) *BusinessConfigDelete {
bcd.mutation.Where(ps...)
return bcd
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (bcd *BusinessConfigDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, bcd.sqlExec, bcd.mutation, bcd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (bcd *BusinessConfigDelete) ExecX(ctx context.Context) int {
n, err := bcd.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (bcd *BusinessConfigDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(businessconfig.Table, sqlgraph.NewFieldSpec(businessconfig.FieldID, field.TypeInt))
if ps := bcd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, bcd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
bcd.mutation.done = true
return affected, err
}
// BusinessConfigDeleteOne is the builder for deleting a single BusinessConfig entity.
type BusinessConfigDeleteOne struct {
bcd *BusinessConfigDelete
}
// Where appends a list predicates to the BusinessConfigDelete builder.
func (bcdo *BusinessConfigDeleteOne) Where(ps ...predicate.BusinessConfig) *BusinessConfigDeleteOne {
bcdo.bcd.mutation.Where(ps...)
return bcdo
}
// Exec executes the deletion query.
func (bcdo *BusinessConfigDeleteOne) Exec(ctx context.Context) error {
n, err := bcdo.bcd.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{businessconfig.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (bcdo *BusinessConfigDeleteOne) ExecX(ctx context.Context) {
if err := bcdo.Exec(ctx); err != nil {
panic(err)
}
}