[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:
575
ent/weaponstats_update.go
Normal file
575
ent/weaponstats_update.go
Normal file
@@ -0,0 +1,575 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/predicate"
|
||||
"csgowtfd/ent/stats"
|
||||
"csgowtfd/ent/weaponstats"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// WeaponStatsUpdate is the builder for updating WeaponStats entities.
|
||||
type WeaponStatsUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *WeaponStatsMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the WeaponStatsUpdate builder.
|
||||
func (wsu *WeaponStatsUpdate) Where(ps ...predicate.WeaponStats) *WeaponStatsUpdate {
|
||||
wsu.mutation.Where(ps...)
|
||||
return wsu
|
||||
}
|
||||
|
||||
// SetVictim sets the "victim" field.
|
||||
func (wsu *WeaponStatsUpdate) SetVictim(u uint64) *WeaponStatsUpdate {
|
||||
wsu.mutation.ResetVictim()
|
||||
wsu.mutation.SetVictim(u)
|
||||
return wsu
|
||||
}
|
||||
|
||||
// AddVictim adds u to the "victim" field.
|
||||
func (wsu *WeaponStatsUpdate) AddVictim(u uint64) *WeaponStatsUpdate {
|
||||
wsu.mutation.AddVictim(u)
|
||||
return wsu
|
||||
}
|
||||
|
||||
// SetDmg sets the "dmg" field.
|
||||
func (wsu *WeaponStatsUpdate) SetDmg(u uint) *WeaponStatsUpdate {
|
||||
wsu.mutation.ResetDmg()
|
||||
wsu.mutation.SetDmg(u)
|
||||
return wsu
|
||||
}
|
||||
|
||||
// AddDmg adds u to the "dmg" field.
|
||||
func (wsu *WeaponStatsUpdate) AddDmg(u uint) *WeaponStatsUpdate {
|
||||
wsu.mutation.AddDmg(u)
|
||||
return wsu
|
||||
}
|
||||
|
||||
// SetEqType sets the "eq_type" field.
|
||||
func (wsu *WeaponStatsUpdate) SetEqType(i int) *WeaponStatsUpdate {
|
||||
wsu.mutation.ResetEqType()
|
||||
wsu.mutation.SetEqType(i)
|
||||
return wsu
|
||||
}
|
||||
|
||||
// AddEqType adds i to the "eq_type" field.
|
||||
func (wsu *WeaponStatsUpdate) AddEqType(i int) *WeaponStatsUpdate {
|
||||
wsu.mutation.AddEqType(i)
|
||||
return wsu
|
||||
}
|
||||
|
||||
// SetHitGroup sets the "hit_group" field.
|
||||
func (wsu *WeaponStatsUpdate) SetHitGroup(i int) *WeaponStatsUpdate {
|
||||
wsu.mutation.ResetHitGroup()
|
||||
wsu.mutation.SetHitGroup(i)
|
||||
return wsu
|
||||
}
|
||||
|
||||
// AddHitGroup adds i to the "hit_group" field.
|
||||
func (wsu *WeaponStatsUpdate) AddHitGroup(i int) *WeaponStatsUpdate {
|
||||
wsu.mutation.AddHitGroup(i)
|
||||
return wsu
|
||||
}
|
||||
|
||||
// SetStatID sets the "stat" edge to the Stats entity by ID.
|
||||
func (wsu *WeaponStatsUpdate) SetStatID(id int) *WeaponStatsUpdate {
|
||||
wsu.mutation.SetStatID(id)
|
||||
return wsu
|
||||
}
|
||||
|
||||
// SetNillableStatID sets the "stat" edge to the Stats entity by ID if the given value is not nil.
|
||||
func (wsu *WeaponStatsUpdate) SetNillableStatID(id *int) *WeaponStatsUpdate {
|
||||
if id != nil {
|
||||
wsu = wsu.SetStatID(*id)
|
||||
}
|
||||
return wsu
|
||||
}
|
||||
|
||||
// SetStat sets the "stat" edge to the Stats entity.
|
||||
func (wsu *WeaponStatsUpdate) SetStat(s *Stats) *WeaponStatsUpdate {
|
||||
return wsu.SetStatID(s.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the WeaponStatsMutation object of the builder.
|
||||
func (wsu *WeaponStatsUpdate) Mutation() *WeaponStatsMutation {
|
||||
return wsu.mutation
|
||||
}
|
||||
|
||||
// ClearStat clears the "stat" edge to the Stats entity.
|
||||
func (wsu *WeaponStatsUpdate) ClearStat() *WeaponStatsUpdate {
|
||||
wsu.mutation.ClearStat()
|
||||
return wsu
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (wsu *WeaponStatsUpdate) Save(ctx context.Context) (int, error) {
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(wsu.hooks) == 0 {
|
||||
affected, err = wsu.sqlSave(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)
|
||||
}
|
||||
wsu.mutation = mutation
|
||||
affected, err = wsu.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(wsu.hooks) - 1; i >= 0; i-- {
|
||||
if wsu.hooks[i] == nil {
|
||||
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||
}
|
||||
mut = wsu.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, wsu.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (wsu *WeaponStatsUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := wsu.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (wsu *WeaponStatsUpdate) Exec(ctx context.Context) error {
|
||||
_, err := wsu.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (wsu *WeaponStatsUpdate) ExecX(ctx context.Context) {
|
||||
if err := wsu.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (wsu *WeaponStatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: weaponstats.Table,
|
||||
Columns: weaponstats.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: weaponstats.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := wsu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := wsu.mutation.Victim(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint64,
|
||||
Value: value,
|
||||
Column: weaponstats.FieldVictim,
|
||||
})
|
||||
}
|
||||
if value, ok := wsu.mutation.AddedVictim(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint64,
|
||||
Value: value,
|
||||
Column: weaponstats.FieldVictim,
|
||||
})
|
||||
}
|
||||
if value, ok := wsu.mutation.Dmg(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: weaponstats.FieldDmg,
|
||||
})
|
||||
}
|
||||
if value, ok := wsu.mutation.AddedDmg(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: weaponstats.FieldDmg,
|
||||
})
|
||||
}
|
||||
if value, ok := wsu.mutation.EqType(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: weaponstats.FieldEqType,
|
||||
})
|
||||
}
|
||||
if value, ok := wsu.mutation.AddedEqType(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: weaponstats.FieldEqType,
|
||||
})
|
||||
}
|
||||
if value, ok := wsu.mutation.HitGroup(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: weaponstats.FieldHitGroup,
|
||||
})
|
||||
}
|
||||
if value, ok := wsu.mutation.AddedHitGroup(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: weaponstats.FieldHitGroup,
|
||||
})
|
||||
}
|
||||
if wsu.mutation.StatCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: weaponstats.StatTable,
|
||||
Columns: []string{weaponstats.StatColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: stats.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := wsu.mutation.StatIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: weaponstats.StatTable,
|
||||
Columns: []string{weaponstats.StatColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: stats.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, wsu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{weaponstats.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// WeaponStatsUpdateOne is the builder for updating a single WeaponStats entity.
|
||||
type WeaponStatsUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *WeaponStatsMutation
|
||||
}
|
||||
|
||||
// SetVictim sets the "victim" field.
|
||||
func (wsuo *WeaponStatsUpdateOne) SetVictim(u uint64) *WeaponStatsUpdateOne {
|
||||
wsuo.mutation.ResetVictim()
|
||||
wsuo.mutation.SetVictim(u)
|
||||
return wsuo
|
||||
}
|
||||
|
||||
// AddVictim adds u to the "victim" field.
|
||||
func (wsuo *WeaponStatsUpdateOne) AddVictim(u uint64) *WeaponStatsUpdateOne {
|
||||
wsuo.mutation.AddVictim(u)
|
||||
return wsuo
|
||||
}
|
||||
|
||||
// SetDmg sets the "dmg" field.
|
||||
func (wsuo *WeaponStatsUpdateOne) SetDmg(u uint) *WeaponStatsUpdateOne {
|
||||
wsuo.mutation.ResetDmg()
|
||||
wsuo.mutation.SetDmg(u)
|
||||
return wsuo
|
||||
}
|
||||
|
||||
// AddDmg adds u to the "dmg" field.
|
||||
func (wsuo *WeaponStatsUpdateOne) AddDmg(u uint) *WeaponStatsUpdateOne {
|
||||
wsuo.mutation.AddDmg(u)
|
||||
return wsuo
|
||||
}
|
||||
|
||||
// SetEqType sets the "eq_type" field.
|
||||
func (wsuo *WeaponStatsUpdateOne) SetEqType(i int) *WeaponStatsUpdateOne {
|
||||
wsuo.mutation.ResetEqType()
|
||||
wsuo.mutation.SetEqType(i)
|
||||
return wsuo
|
||||
}
|
||||
|
||||
// AddEqType adds i to the "eq_type" field.
|
||||
func (wsuo *WeaponStatsUpdateOne) AddEqType(i int) *WeaponStatsUpdateOne {
|
||||
wsuo.mutation.AddEqType(i)
|
||||
return wsuo
|
||||
}
|
||||
|
||||
// SetHitGroup sets the "hit_group" field.
|
||||
func (wsuo *WeaponStatsUpdateOne) SetHitGroup(i int) *WeaponStatsUpdateOne {
|
||||
wsuo.mutation.ResetHitGroup()
|
||||
wsuo.mutation.SetHitGroup(i)
|
||||
return wsuo
|
||||
}
|
||||
|
||||
// AddHitGroup adds i to the "hit_group" field.
|
||||
func (wsuo *WeaponStatsUpdateOne) AddHitGroup(i int) *WeaponStatsUpdateOne {
|
||||
wsuo.mutation.AddHitGroup(i)
|
||||
return wsuo
|
||||
}
|
||||
|
||||
// SetStatID sets the "stat" edge to the Stats entity by ID.
|
||||
func (wsuo *WeaponStatsUpdateOne) SetStatID(id int) *WeaponStatsUpdateOne {
|
||||
wsuo.mutation.SetStatID(id)
|
||||
return wsuo
|
||||
}
|
||||
|
||||
// SetNillableStatID sets the "stat" edge to the Stats entity by ID if the given value is not nil.
|
||||
func (wsuo *WeaponStatsUpdateOne) SetNillableStatID(id *int) *WeaponStatsUpdateOne {
|
||||
if id != nil {
|
||||
wsuo = wsuo.SetStatID(*id)
|
||||
}
|
||||
return wsuo
|
||||
}
|
||||
|
||||
// SetStat sets the "stat" edge to the Stats entity.
|
||||
func (wsuo *WeaponStatsUpdateOne) SetStat(s *Stats) *WeaponStatsUpdateOne {
|
||||
return wsuo.SetStatID(s.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the WeaponStatsMutation object of the builder.
|
||||
func (wsuo *WeaponStatsUpdateOne) Mutation() *WeaponStatsMutation {
|
||||
return wsuo.mutation
|
||||
}
|
||||
|
||||
// ClearStat clears the "stat" edge to the Stats entity.
|
||||
func (wsuo *WeaponStatsUpdateOne) ClearStat() *WeaponStatsUpdateOne {
|
||||
wsuo.mutation.ClearStat()
|
||||
return wsuo
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (wsuo *WeaponStatsUpdateOne) Select(field string, fields ...string) *WeaponStatsUpdateOne {
|
||||
wsuo.fields = append([]string{field}, fields...)
|
||||
return wsuo
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated WeaponStats entity.
|
||||
func (wsuo *WeaponStatsUpdateOne) Save(ctx context.Context) (*WeaponStats, error) {
|
||||
var (
|
||||
err error
|
||||
node *WeaponStats
|
||||
)
|
||||
if len(wsuo.hooks) == 0 {
|
||||
node, err = wsuo.sqlSave(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)
|
||||
}
|
||||
wsuo.mutation = mutation
|
||||
node, err = wsuo.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(wsuo.hooks) - 1; i >= 0; i-- {
|
||||
if wsuo.hooks[i] == nil {
|
||||
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||
}
|
||||
mut = wsuo.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, wsuo.mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return node, err
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (wsuo *WeaponStatsUpdateOne) SaveX(ctx context.Context) *WeaponStats {
|
||||
node, err := wsuo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (wsuo *WeaponStatsUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := wsuo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (wsuo *WeaponStatsUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := wsuo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (wsuo *WeaponStatsUpdateOne) sqlSave(ctx context.Context) (_node *WeaponStats, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: weaponstats.Table,
|
||||
Columns: weaponstats.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: weaponstats.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
id, ok := wsuo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing WeaponStats.ID for update")}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := wsuo.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, weaponstats.FieldID)
|
||||
for _, f := range fields {
|
||||
if !weaponstats.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != weaponstats.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := wsuo.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := wsuo.mutation.Victim(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint64,
|
||||
Value: value,
|
||||
Column: weaponstats.FieldVictim,
|
||||
})
|
||||
}
|
||||
if value, ok := wsuo.mutation.AddedVictim(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint64,
|
||||
Value: value,
|
||||
Column: weaponstats.FieldVictim,
|
||||
})
|
||||
}
|
||||
if value, ok := wsuo.mutation.Dmg(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: weaponstats.FieldDmg,
|
||||
})
|
||||
}
|
||||
if value, ok := wsuo.mutation.AddedDmg(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: weaponstats.FieldDmg,
|
||||
})
|
||||
}
|
||||
if value, ok := wsuo.mutation.EqType(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: weaponstats.FieldEqType,
|
||||
})
|
||||
}
|
||||
if value, ok := wsuo.mutation.AddedEqType(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: weaponstats.FieldEqType,
|
||||
})
|
||||
}
|
||||
if value, ok := wsuo.mutation.HitGroup(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: weaponstats.FieldHitGroup,
|
||||
})
|
||||
}
|
||||
if value, ok := wsuo.mutation.AddedHitGroup(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: weaponstats.FieldHitGroup,
|
||||
})
|
||||
}
|
||||
if wsuo.mutation.StatCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: weaponstats.StatTable,
|
||||
Columns: []string{weaponstats.StatColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: stats.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := wsuo.mutation.StatIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: weaponstats.StatTable,
|
||||
Columns: []string{weaponstats.StatColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: stats.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &WeaponStats{config: wsuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, wsuo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{weaponstats.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return _node, nil
|
||||
}
|
Reference in New Issue
Block a user