// Code generated by ent, DO NOT EDIT. package ent import ( "context" "tel-commerce/ent/businesscategory" "tel-commerce/ent/predicate" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // BusinessCategoryDelete is the builder for deleting a BusinessCategory entity. type BusinessCategoryDelete struct { config hooks []Hook mutation *BusinessCategoryMutation } // Where appends a list predicates to the BusinessCategoryDelete builder. func (bcd *BusinessCategoryDelete) Where(ps ...predicate.BusinessCategory) *BusinessCategoryDelete { bcd.mutation.Where(ps...) return bcd } // Exec executes the deletion query and returns how many vertices were deleted. func (bcd *BusinessCategoryDelete) 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 *BusinessCategoryDelete) ExecX(ctx context.Context) int { n, err := bcd.Exec(ctx) if err != nil { panic(err) } return n } func (bcd *BusinessCategoryDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(businesscategory.Table, sqlgraph.NewFieldSpec(businesscategory.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 } // BusinessCategoryDeleteOne is the builder for deleting a single BusinessCategory entity. type BusinessCategoryDeleteOne struct { bcd *BusinessCategoryDelete } // Where appends a list predicates to the BusinessCategoryDelete builder. func (bcdo *BusinessCategoryDeleteOne) Where(ps ...predicate.BusinessCategory) *BusinessCategoryDeleteOne { bcdo.bcd.mutation.Where(ps...) return bcdo } // Exec executes the deletion query. func (bcdo *BusinessCategoryDeleteOne) Exec(ctx context.Context) error { n, err := bcdo.bcd.Exec(ctx) switch { case err != nil: return err case n == 0: return &NotFoundError{businesscategory.Label} default: return nil } } // ExecX is like Exec, but panics if an error occurs. func (bcdo *BusinessCategoryDeleteOne) ExecX(ctx context.Context) { if err := bcdo.Exec(ctx); err != nil { panic(err) } }