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