Files
csgowtfd/ent/roundstats_delete.go

89 lines
2.3 KiB
Go

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