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