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