89 lines
2.2 KiB
Go
89 lines
2.2 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/weapon"
|
|
)
|
|
|
|
// WeaponDelete is the builder for deleting a Weapon entity.
|
|
type WeaponDelete struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *WeaponMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the WeaponDelete builder.
|
|
func (wd *WeaponDelete) Where(ps ...predicate.Weapon) *WeaponDelete {
|
|
wd.mutation.Where(ps...)
|
|
return wd
|
|
}
|
|
|
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
|
func (wd *WeaponDelete) Exec(ctx context.Context) (int, error) {
|
|
return withHooks[int, WeaponMutation](ctx, wd.sqlExec, wd.mutation, wd.hooks)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (wd *WeaponDelete) ExecX(ctx context.Context) int {
|
|
n, err := wd.Exec(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return n
|
|
}
|
|
|
|
func (wd *WeaponDelete) sqlExec(ctx context.Context) (int, error) {
|
|
_spec := sqlgraph.NewDeleteSpec(weapon.Table, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt))
|
|
if ps := wd.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
affected, err := sqlgraph.DeleteNodes(ctx, wd.driver, _spec)
|
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
wd.mutation.done = true
|
|
return affected, err
|
|
}
|
|
|
|
// WeaponDeleteOne is the builder for deleting a single Weapon entity.
|
|
type WeaponDeleteOne struct {
|
|
wd *WeaponDelete
|
|
}
|
|
|
|
// Where appends a list predicates to the WeaponDelete builder.
|
|
func (wdo *WeaponDeleteOne) Where(ps ...predicate.Weapon) *WeaponDeleteOne {
|
|
wdo.wd.mutation.Where(ps...)
|
|
return wdo
|
|
}
|
|
|
|
// Exec executes the deletion query.
|
|
func (wdo *WeaponDeleteOne) Exec(ctx context.Context) error {
|
|
n, err := wdo.wd.Exec(ctx)
|
|
switch {
|
|
case err != nil:
|
|
return err
|
|
case n == 0:
|
|
return &NotFoundError{weapon.Label}
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (wdo *WeaponDeleteOne) ExecX(ctx context.Context) {
|
|
if err := wdo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|