[FEATURE] Detailed stats about player weapon usage and hitgroups (#1)
Reviewed-on: https://git.harting.dev/CSGOWTF/csgowtfd/pulls/1 Co-authored-by: Giovanni Harting <539@idlegandalf.com> Co-committed-by: Giovanni Harting <539@idlegandalf.com>
This commit is contained in:
111
ent/weaponstats_delete.go
Normal file
111
ent/weaponstats_delete.go
Normal file
@@ -0,0 +1,111 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/predicate"
|
||||
"csgowtfd/ent/weaponstats"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// WeaponStatsDelete is the builder for deleting a WeaponStats entity.
|
||||
type WeaponStatsDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *WeaponStatsMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the WeaponStatsDelete builder.
|
||||
func (wsd *WeaponStatsDelete) Where(ps ...predicate.WeaponStats) *WeaponStatsDelete {
|
||||
wsd.mutation.Where(ps...)
|
||||
return wsd
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (wsd *WeaponStatsDelete) Exec(ctx context.Context) (int, error) {
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(wsd.hooks) == 0 {
|
||||
affected, err = wsd.sqlExec(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*WeaponStatsMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
wsd.mutation = mutation
|
||||
affected, err = wsd.sqlExec(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(wsd.hooks) - 1; i >= 0; i-- {
|
||||
if wsd.hooks[i] == nil {
|
||||
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||
}
|
||||
mut = wsd.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, wsd.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (wsd *WeaponStatsDelete) ExecX(ctx context.Context) int {
|
||||
n, err := wsd.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (wsd *WeaponStatsDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := &sqlgraph.DeleteSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: weaponstats.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: weaponstats.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := wsd.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sqlgraph.DeleteNodes(ctx, wsd.driver, _spec)
|
||||
}
|
||||
|
||||
// WeaponStatsDeleteOne is the builder for deleting a single WeaponStats entity.
|
||||
type WeaponStatsDeleteOne struct {
|
||||
wsd *WeaponStatsDelete
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (wsdo *WeaponStatsDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := wsdo.wsd.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{weaponstats.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (wsdo *WeaponStatsDeleteOne) ExecX(ctx context.Context) {
|
||||
wsdo.wsd.ExecX(ctx)
|
||||
}
|
Reference in New Issue
Block a user