1113 lines
30 KiB
Go
1113 lines
30 KiB
Go
// Code generated by entc, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"csgowtfd/ent/match"
|
|
"csgowtfd/ent/player"
|
|
"csgowtfd/ent/predicate"
|
|
"csgowtfd/ent/stats"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// StatsUpdate is the builder for updating Stats entities.
|
|
type StatsUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *StatsMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the StatsUpdate builder.
|
|
func (su *StatsUpdate) Where(ps ...predicate.Stats) *StatsUpdate {
|
|
su.mutation.Where(ps...)
|
|
return su
|
|
}
|
|
|
|
// SetTeamID sets the "team_id" field.
|
|
func (su *StatsUpdate) SetTeamID(i int) *StatsUpdate {
|
|
su.mutation.ResetTeamID()
|
|
su.mutation.SetTeamID(i)
|
|
return su
|
|
}
|
|
|
|
// AddTeamID adds i to the "team_id" field.
|
|
func (su *StatsUpdate) AddTeamID(i int) *StatsUpdate {
|
|
su.mutation.AddTeamID(i)
|
|
return su
|
|
}
|
|
|
|
// SetKills sets the "kills" field.
|
|
func (su *StatsUpdate) SetKills(i int) *StatsUpdate {
|
|
su.mutation.ResetKills()
|
|
su.mutation.SetKills(i)
|
|
return su
|
|
}
|
|
|
|
// AddKills adds i to the "kills" field.
|
|
func (su *StatsUpdate) AddKills(i int) *StatsUpdate {
|
|
su.mutation.AddKills(i)
|
|
return su
|
|
}
|
|
|
|
// SetDeaths sets the "deaths" field.
|
|
func (su *StatsUpdate) SetDeaths(i int) *StatsUpdate {
|
|
su.mutation.ResetDeaths()
|
|
su.mutation.SetDeaths(i)
|
|
return su
|
|
}
|
|
|
|
// AddDeaths adds i to the "deaths" field.
|
|
func (su *StatsUpdate) AddDeaths(i int) *StatsUpdate {
|
|
su.mutation.AddDeaths(i)
|
|
return su
|
|
}
|
|
|
|
// SetAssists sets the "assists" field.
|
|
func (su *StatsUpdate) SetAssists(i int) *StatsUpdate {
|
|
su.mutation.ResetAssists()
|
|
su.mutation.SetAssists(i)
|
|
return su
|
|
}
|
|
|
|
// AddAssists adds i to the "assists" field.
|
|
func (su *StatsUpdate) AddAssists(i int) *StatsUpdate {
|
|
su.mutation.AddAssists(i)
|
|
return su
|
|
}
|
|
|
|
// SetHeadshot sets the "headshot" field.
|
|
func (su *StatsUpdate) SetHeadshot(i int) *StatsUpdate {
|
|
su.mutation.ResetHeadshot()
|
|
su.mutation.SetHeadshot(i)
|
|
return su
|
|
}
|
|
|
|
// AddHeadshot adds i to the "headshot" field.
|
|
func (su *StatsUpdate) AddHeadshot(i int) *StatsUpdate {
|
|
su.mutation.AddHeadshot(i)
|
|
return su
|
|
}
|
|
|
|
// SetMvp sets the "mvp" field.
|
|
func (su *StatsUpdate) SetMvp(i int) *StatsUpdate {
|
|
su.mutation.ResetMvp()
|
|
su.mutation.SetMvp(i)
|
|
return su
|
|
}
|
|
|
|
// AddMvp adds i to the "mvp" field.
|
|
func (su *StatsUpdate) AddMvp(i int) *StatsUpdate {
|
|
su.mutation.AddMvp(i)
|
|
return su
|
|
}
|
|
|
|
// SetScore sets the "score" field.
|
|
func (su *StatsUpdate) SetScore(i int) *StatsUpdate {
|
|
su.mutation.ResetScore()
|
|
su.mutation.SetScore(i)
|
|
return su
|
|
}
|
|
|
|
// AddScore adds i to the "score" field.
|
|
func (su *StatsUpdate) AddScore(i int) *StatsUpdate {
|
|
su.mutation.AddScore(i)
|
|
return su
|
|
}
|
|
|
|
// SetExtended sets the "extended" field.
|
|
func (su *StatsUpdate) SetExtended(skkgaaaallllg struct {
|
|
MultiKills struct {
|
|
Duo int "json:\"duo,omitempty\""
|
|
Triple int "json:\"triple,omitempty\""
|
|
Quad int "json:\"quad,omitempty\""
|
|
Pent int "json:\"pent,omitempty\""
|
|
} "json:\"multi_kills,omitempty\""
|
|
Dmg struct {
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Team int "json:\"team,omitempty\""
|
|
UD struct {
|
|
HE int "json:\"he,omitempty\""
|
|
Flames int "json:\"flames,omitempty\""
|
|
Flash int "json:\"flash,omitempty\""
|
|
Decoy int "json:\"decoy,omitempty\""
|
|
Smoke int "json:\"smoke,omitempty\""
|
|
} "json:\"ud,omitempty\""
|
|
HitGroup struct {
|
|
Head int "json:\"head,omitempty\""
|
|
Chest int "json:\"chest,omitempty\""
|
|
Stomach int "json:\"stomach,omitempty\""
|
|
LeftArm int "json:\"left_arm,omitempty\""
|
|
RightArm int "json:\"right_arm,omitempty\""
|
|
LeftLeg int "json:\"left_leg,omitempty\""
|
|
RightLeg int "json:\"right_leg,omitempty\""
|
|
Gear int "json:\"gear,omitempty\""
|
|
} "json:\"hit_group,omitempty\""
|
|
} "json:\"dmg,omitempty\""
|
|
Crosshair string "json:\"crosshair,omitempty\""
|
|
Color int "json:\"color,omitempty\""
|
|
KAST int "json:\"kast,omitempty\""
|
|
Rank struct {
|
|
Old int "json:\"old,omitempty\""
|
|
New int "json:\"new,omitempty\""
|
|
} "json:\"rank,omitempty\""
|
|
Flash struct {
|
|
Duration struct {
|
|
Self float32 "json:\"self,omitempty\""
|
|
Team float32 "json:\"team,omitempty\""
|
|
Enemy float32 "json:\"enemy,omitempty\""
|
|
} "json:\"duration,omitempty\""
|
|
Total struct {
|
|
Team int "json:\"team,omitempty\""
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Self int "json:\"self,omitempty\""
|
|
} "json:\"total,omitempty\""
|
|
} "json:\"flash,omitempty\""
|
|
}) *StatsUpdate {
|
|
su.mutation.SetExtended(skkgaaaallllg)
|
|
return su
|
|
}
|
|
|
|
// SetNillableExtended sets the "extended" field if the given value is not nil.
|
|
func (su *StatsUpdate) SetNillableExtended(skkgaaaallllg *struct {
|
|
MultiKills struct {
|
|
Duo int "json:\"duo,omitempty\""
|
|
Triple int "json:\"triple,omitempty\""
|
|
Quad int "json:\"quad,omitempty\""
|
|
Pent int "json:\"pent,omitempty\""
|
|
} "json:\"multi_kills,omitempty\""
|
|
Dmg struct {
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Team int "json:\"team,omitempty\""
|
|
UD struct {
|
|
HE int "json:\"he,omitempty\""
|
|
Flames int "json:\"flames,omitempty\""
|
|
Flash int "json:\"flash,omitempty\""
|
|
Decoy int "json:\"decoy,omitempty\""
|
|
Smoke int "json:\"smoke,omitempty\""
|
|
} "json:\"ud,omitempty\""
|
|
HitGroup struct {
|
|
Head int "json:\"head,omitempty\""
|
|
Chest int "json:\"chest,omitempty\""
|
|
Stomach int "json:\"stomach,omitempty\""
|
|
LeftArm int "json:\"left_arm,omitempty\""
|
|
RightArm int "json:\"right_arm,omitempty\""
|
|
LeftLeg int "json:\"left_leg,omitempty\""
|
|
RightLeg int "json:\"right_leg,omitempty\""
|
|
Gear int "json:\"gear,omitempty\""
|
|
} "json:\"hit_group,omitempty\""
|
|
} "json:\"dmg,omitempty\""
|
|
Crosshair string "json:\"crosshair,omitempty\""
|
|
Color int "json:\"color,omitempty\""
|
|
KAST int "json:\"kast,omitempty\""
|
|
Rank struct {
|
|
Old int "json:\"old,omitempty\""
|
|
New int "json:\"new,omitempty\""
|
|
} "json:\"rank,omitempty\""
|
|
Flash struct {
|
|
Duration struct {
|
|
Self float32 "json:\"self,omitempty\""
|
|
Team float32 "json:\"team,omitempty\""
|
|
Enemy float32 "json:\"enemy,omitempty\""
|
|
} "json:\"duration,omitempty\""
|
|
Total struct {
|
|
Team int "json:\"team,omitempty\""
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Self int "json:\"self,omitempty\""
|
|
} "json:\"total,omitempty\""
|
|
} "json:\"flash,omitempty\""
|
|
}) *StatsUpdate {
|
|
if skkgaaaallllg != nil {
|
|
su.SetExtended(*skkgaaaallllg)
|
|
}
|
|
return su
|
|
}
|
|
|
|
// ClearExtended clears the value of the "extended" field.
|
|
func (su *StatsUpdate) ClearExtended() *StatsUpdate {
|
|
su.mutation.ClearExtended()
|
|
return su
|
|
}
|
|
|
|
// SetMatchesID sets the "matches" edge to the Match entity by ID.
|
|
func (su *StatsUpdate) SetMatchesID(id int) *StatsUpdate {
|
|
su.mutation.SetMatchesID(id)
|
|
return su
|
|
}
|
|
|
|
// SetNillableMatchesID sets the "matches" edge to the Match entity by ID if the given value is not nil.
|
|
func (su *StatsUpdate) SetNillableMatchesID(id *int) *StatsUpdate {
|
|
if id != nil {
|
|
su = su.SetMatchesID(*id)
|
|
}
|
|
return su
|
|
}
|
|
|
|
// SetMatches sets the "matches" edge to the Match entity.
|
|
func (su *StatsUpdate) SetMatches(m *Match) *StatsUpdate {
|
|
return su.SetMatchesID(m.ID)
|
|
}
|
|
|
|
// SetPlayersID sets the "players" edge to the Player entity by ID.
|
|
func (su *StatsUpdate) SetPlayersID(id int) *StatsUpdate {
|
|
su.mutation.SetPlayersID(id)
|
|
return su
|
|
}
|
|
|
|
// SetNillablePlayersID sets the "players" edge to the Player entity by ID if the given value is not nil.
|
|
func (su *StatsUpdate) SetNillablePlayersID(id *int) *StatsUpdate {
|
|
if id != nil {
|
|
su = su.SetPlayersID(*id)
|
|
}
|
|
return su
|
|
}
|
|
|
|
// SetPlayers sets the "players" edge to the Player entity.
|
|
func (su *StatsUpdate) SetPlayers(p *Player) *StatsUpdate {
|
|
return su.SetPlayersID(p.ID)
|
|
}
|
|
|
|
// Mutation returns the StatsMutation object of the builder.
|
|
func (su *StatsUpdate) Mutation() *StatsMutation {
|
|
return su.mutation
|
|
}
|
|
|
|
// ClearMatches clears the "matches" edge to the Match entity.
|
|
func (su *StatsUpdate) ClearMatches() *StatsUpdate {
|
|
su.mutation.ClearMatches()
|
|
return su
|
|
}
|
|
|
|
// ClearPlayers clears the "players" edge to the Player entity.
|
|
func (su *StatsUpdate) ClearPlayers() *StatsUpdate {
|
|
su.mutation.ClearPlayers()
|
|
return su
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (su *StatsUpdate) Save(ctx context.Context) (int, error) {
|
|
var (
|
|
err error
|
|
affected int
|
|
)
|
|
if len(su.hooks) == 0 {
|
|
affected, err = su.sqlSave(ctx)
|
|
} else {
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*StatsMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
su.mutation = mutation
|
|
affected, err = su.sqlSave(ctx)
|
|
mutation.done = true
|
|
return affected, err
|
|
})
|
|
for i := len(su.hooks) - 1; i >= 0; i-- {
|
|
if su.hooks[i] == nil {
|
|
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
|
}
|
|
mut = su.hooks[i](mut)
|
|
}
|
|
if _, err := mut.Mutate(ctx, su.mutation); err != nil {
|
|
return 0, err
|
|
}
|
|
}
|
|
return affected, err
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (su *StatsUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := su.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (su *StatsUpdate) Exec(ctx context.Context) error {
|
|
_, err := su.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (su *StatsUpdate) ExecX(ctx context.Context) {
|
|
if err := su.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (su *StatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|
_spec := &sqlgraph.UpdateSpec{
|
|
Node: &sqlgraph.NodeSpec{
|
|
Table: stats.Table,
|
|
Columns: stats.Columns,
|
|
ID: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: stats.FieldID,
|
|
},
|
|
},
|
|
}
|
|
if ps := su.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := su.mutation.TeamID(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldTeamID,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.AddedTeamID(); ok {
|
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldTeamID,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Kills(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldKills,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.AddedKills(); ok {
|
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldKills,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Deaths(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldDeaths,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.AddedDeaths(); ok {
|
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldDeaths,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Assists(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldAssists,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.AddedAssists(); ok {
|
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldAssists,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Headshot(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldHeadshot,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.AddedHeadshot(); ok {
|
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldHeadshot,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Mvp(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldMvp,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.AddedMvp(); ok {
|
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldMvp,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Score(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldScore,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.AddedScore(); ok {
|
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldScore,
|
|
})
|
|
}
|
|
if value, ok := su.mutation.Extended(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeJSON,
|
|
Value: value,
|
|
Column: stats.FieldExtended,
|
|
})
|
|
}
|
|
if su.mutation.ExtendedCleared() {
|
|
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
|
Type: field.TypeJSON,
|
|
Column: stats.FieldExtended,
|
|
})
|
|
}
|
|
if su.mutation.MatchesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: stats.MatchesTable,
|
|
Columns: []string{stats.MatchesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: match.FieldID,
|
|
},
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := su.mutation.MatchesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: stats.MatchesTable,
|
|
Columns: []string{stats.MatchesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: match.FieldID,
|
|
},
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if su.mutation.PlayersCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: stats.PlayersTable,
|
|
Columns: []string{stats.PlayersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: player.FieldID,
|
|
},
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := su.mutation.PlayersIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: stats.PlayersTable,
|
|
Columns: []string{stats.PlayersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: player.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, su.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{stats.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{err.Error(), err}
|
|
}
|
|
return 0, err
|
|
}
|
|
return n, nil
|
|
}
|
|
|
|
// StatsUpdateOne is the builder for updating a single Stats entity.
|
|
type StatsUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *StatsMutation
|
|
}
|
|
|
|
// SetTeamID sets the "team_id" field.
|
|
func (suo *StatsUpdateOne) SetTeamID(i int) *StatsUpdateOne {
|
|
suo.mutation.ResetTeamID()
|
|
suo.mutation.SetTeamID(i)
|
|
return suo
|
|
}
|
|
|
|
// AddTeamID adds i to the "team_id" field.
|
|
func (suo *StatsUpdateOne) AddTeamID(i int) *StatsUpdateOne {
|
|
suo.mutation.AddTeamID(i)
|
|
return suo
|
|
}
|
|
|
|
// SetKills sets the "kills" field.
|
|
func (suo *StatsUpdateOne) SetKills(i int) *StatsUpdateOne {
|
|
suo.mutation.ResetKills()
|
|
suo.mutation.SetKills(i)
|
|
return suo
|
|
}
|
|
|
|
// AddKills adds i to the "kills" field.
|
|
func (suo *StatsUpdateOne) AddKills(i int) *StatsUpdateOne {
|
|
suo.mutation.AddKills(i)
|
|
return suo
|
|
}
|
|
|
|
// SetDeaths sets the "deaths" field.
|
|
func (suo *StatsUpdateOne) SetDeaths(i int) *StatsUpdateOne {
|
|
suo.mutation.ResetDeaths()
|
|
suo.mutation.SetDeaths(i)
|
|
return suo
|
|
}
|
|
|
|
// AddDeaths adds i to the "deaths" field.
|
|
func (suo *StatsUpdateOne) AddDeaths(i int) *StatsUpdateOne {
|
|
suo.mutation.AddDeaths(i)
|
|
return suo
|
|
}
|
|
|
|
// SetAssists sets the "assists" field.
|
|
func (suo *StatsUpdateOne) SetAssists(i int) *StatsUpdateOne {
|
|
suo.mutation.ResetAssists()
|
|
suo.mutation.SetAssists(i)
|
|
return suo
|
|
}
|
|
|
|
// AddAssists adds i to the "assists" field.
|
|
func (suo *StatsUpdateOne) AddAssists(i int) *StatsUpdateOne {
|
|
suo.mutation.AddAssists(i)
|
|
return suo
|
|
}
|
|
|
|
// SetHeadshot sets the "headshot" field.
|
|
func (suo *StatsUpdateOne) SetHeadshot(i int) *StatsUpdateOne {
|
|
suo.mutation.ResetHeadshot()
|
|
suo.mutation.SetHeadshot(i)
|
|
return suo
|
|
}
|
|
|
|
// AddHeadshot adds i to the "headshot" field.
|
|
func (suo *StatsUpdateOne) AddHeadshot(i int) *StatsUpdateOne {
|
|
suo.mutation.AddHeadshot(i)
|
|
return suo
|
|
}
|
|
|
|
// SetMvp sets the "mvp" field.
|
|
func (suo *StatsUpdateOne) SetMvp(i int) *StatsUpdateOne {
|
|
suo.mutation.ResetMvp()
|
|
suo.mutation.SetMvp(i)
|
|
return suo
|
|
}
|
|
|
|
// AddMvp adds i to the "mvp" field.
|
|
func (suo *StatsUpdateOne) AddMvp(i int) *StatsUpdateOne {
|
|
suo.mutation.AddMvp(i)
|
|
return suo
|
|
}
|
|
|
|
// SetScore sets the "score" field.
|
|
func (suo *StatsUpdateOne) SetScore(i int) *StatsUpdateOne {
|
|
suo.mutation.ResetScore()
|
|
suo.mutation.SetScore(i)
|
|
return suo
|
|
}
|
|
|
|
// AddScore adds i to the "score" field.
|
|
func (suo *StatsUpdateOne) AddScore(i int) *StatsUpdateOne {
|
|
suo.mutation.AddScore(i)
|
|
return suo
|
|
}
|
|
|
|
// SetExtended sets the "extended" field.
|
|
func (suo *StatsUpdateOne) SetExtended(skkgaaaallllg struct {
|
|
MultiKills struct {
|
|
Duo int "json:\"duo,omitempty\""
|
|
Triple int "json:\"triple,omitempty\""
|
|
Quad int "json:\"quad,omitempty\""
|
|
Pent int "json:\"pent,omitempty\""
|
|
} "json:\"multi_kills,omitempty\""
|
|
Dmg struct {
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Team int "json:\"team,omitempty\""
|
|
UD struct {
|
|
HE int "json:\"he,omitempty\""
|
|
Flames int "json:\"flames,omitempty\""
|
|
Flash int "json:\"flash,omitempty\""
|
|
Decoy int "json:\"decoy,omitempty\""
|
|
Smoke int "json:\"smoke,omitempty\""
|
|
} "json:\"ud,omitempty\""
|
|
HitGroup struct {
|
|
Head int "json:\"head,omitempty\""
|
|
Chest int "json:\"chest,omitempty\""
|
|
Stomach int "json:\"stomach,omitempty\""
|
|
LeftArm int "json:\"left_arm,omitempty\""
|
|
RightArm int "json:\"right_arm,omitempty\""
|
|
LeftLeg int "json:\"left_leg,omitempty\""
|
|
RightLeg int "json:\"right_leg,omitempty\""
|
|
Gear int "json:\"gear,omitempty\""
|
|
} "json:\"hit_group,omitempty\""
|
|
} "json:\"dmg,omitempty\""
|
|
Crosshair string "json:\"crosshair,omitempty\""
|
|
Color int "json:\"color,omitempty\""
|
|
KAST int "json:\"kast,omitempty\""
|
|
Rank struct {
|
|
Old int "json:\"old,omitempty\""
|
|
New int "json:\"new,omitempty\""
|
|
} "json:\"rank,omitempty\""
|
|
Flash struct {
|
|
Duration struct {
|
|
Self float32 "json:\"self,omitempty\""
|
|
Team float32 "json:\"team,omitempty\""
|
|
Enemy float32 "json:\"enemy,omitempty\""
|
|
} "json:\"duration,omitempty\""
|
|
Total struct {
|
|
Team int "json:\"team,omitempty\""
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Self int "json:\"self,omitempty\""
|
|
} "json:\"total,omitempty\""
|
|
} "json:\"flash,omitempty\""
|
|
}) *StatsUpdateOne {
|
|
suo.mutation.SetExtended(skkgaaaallllg)
|
|
return suo
|
|
}
|
|
|
|
// SetNillableExtended sets the "extended" field if the given value is not nil.
|
|
func (suo *StatsUpdateOne) SetNillableExtended(skkgaaaallllg *struct {
|
|
MultiKills struct {
|
|
Duo int "json:\"duo,omitempty\""
|
|
Triple int "json:\"triple,omitempty\""
|
|
Quad int "json:\"quad,omitempty\""
|
|
Pent int "json:\"pent,omitempty\""
|
|
} "json:\"multi_kills,omitempty\""
|
|
Dmg struct {
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Team int "json:\"team,omitempty\""
|
|
UD struct {
|
|
HE int "json:\"he,omitempty\""
|
|
Flames int "json:\"flames,omitempty\""
|
|
Flash int "json:\"flash,omitempty\""
|
|
Decoy int "json:\"decoy,omitempty\""
|
|
Smoke int "json:\"smoke,omitempty\""
|
|
} "json:\"ud,omitempty\""
|
|
HitGroup struct {
|
|
Head int "json:\"head,omitempty\""
|
|
Chest int "json:\"chest,omitempty\""
|
|
Stomach int "json:\"stomach,omitempty\""
|
|
LeftArm int "json:\"left_arm,omitempty\""
|
|
RightArm int "json:\"right_arm,omitempty\""
|
|
LeftLeg int "json:\"left_leg,omitempty\""
|
|
RightLeg int "json:\"right_leg,omitempty\""
|
|
Gear int "json:\"gear,omitempty\""
|
|
} "json:\"hit_group,omitempty\""
|
|
} "json:\"dmg,omitempty\""
|
|
Crosshair string "json:\"crosshair,omitempty\""
|
|
Color int "json:\"color,omitempty\""
|
|
KAST int "json:\"kast,omitempty\""
|
|
Rank struct {
|
|
Old int "json:\"old,omitempty\""
|
|
New int "json:\"new,omitempty\""
|
|
} "json:\"rank,omitempty\""
|
|
Flash struct {
|
|
Duration struct {
|
|
Self float32 "json:\"self,omitempty\""
|
|
Team float32 "json:\"team,omitempty\""
|
|
Enemy float32 "json:\"enemy,omitempty\""
|
|
} "json:\"duration,omitempty\""
|
|
Total struct {
|
|
Team int "json:\"team,omitempty\""
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Self int "json:\"self,omitempty\""
|
|
} "json:\"total,omitempty\""
|
|
} "json:\"flash,omitempty\""
|
|
}) *StatsUpdateOne {
|
|
if skkgaaaallllg != nil {
|
|
suo.SetExtended(*skkgaaaallllg)
|
|
}
|
|
return suo
|
|
}
|
|
|
|
// ClearExtended clears the value of the "extended" field.
|
|
func (suo *StatsUpdateOne) ClearExtended() *StatsUpdateOne {
|
|
suo.mutation.ClearExtended()
|
|
return suo
|
|
}
|
|
|
|
// SetMatchesID sets the "matches" edge to the Match entity by ID.
|
|
func (suo *StatsUpdateOne) SetMatchesID(id int) *StatsUpdateOne {
|
|
suo.mutation.SetMatchesID(id)
|
|
return suo
|
|
}
|
|
|
|
// SetNillableMatchesID sets the "matches" edge to the Match entity by ID if the given value is not nil.
|
|
func (suo *StatsUpdateOne) SetNillableMatchesID(id *int) *StatsUpdateOne {
|
|
if id != nil {
|
|
suo = suo.SetMatchesID(*id)
|
|
}
|
|
return suo
|
|
}
|
|
|
|
// SetMatches sets the "matches" edge to the Match entity.
|
|
func (suo *StatsUpdateOne) SetMatches(m *Match) *StatsUpdateOne {
|
|
return suo.SetMatchesID(m.ID)
|
|
}
|
|
|
|
// SetPlayersID sets the "players" edge to the Player entity by ID.
|
|
func (suo *StatsUpdateOne) SetPlayersID(id int) *StatsUpdateOne {
|
|
suo.mutation.SetPlayersID(id)
|
|
return suo
|
|
}
|
|
|
|
// SetNillablePlayersID sets the "players" edge to the Player entity by ID if the given value is not nil.
|
|
func (suo *StatsUpdateOne) SetNillablePlayersID(id *int) *StatsUpdateOne {
|
|
if id != nil {
|
|
suo = suo.SetPlayersID(*id)
|
|
}
|
|
return suo
|
|
}
|
|
|
|
// SetPlayers sets the "players" edge to the Player entity.
|
|
func (suo *StatsUpdateOne) SetPlayers(p *Player) *StatsUpdateOne {
|
|
return suo.SetPlayersID(p.ID)
|
|
}
|
|
|
|
// Mutation returns the StatsMutation object of the builder.
|
|
func (suo *StatsUpdateOne) Mutation() *StatsMutation {
|
|
return suo.mutation
|
|
}
|
|
|
|
// ClearMatches clears the "matches" edge to the Match entity.
|
|
func (suo *StatsUpdateOne) ClearMatches() *StatsUpdateOne {
|
|
suo.mutation.ClearMatches()
|
|
return suo
|
|
}
|
|
|
|
// ClearPlayers clears the "players" edge to the Player entity.
|
|
func (suo *StatsUpdateOne) ClearPlayers() *StatsUpdateOne {
|
|
suo.mutation.ClearPlayers()
|
|
return suo
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (suo *StatsUpdateOne) Select(field string, fields ...string) *StatsUpdateOne {
|
|
suo.fields = append([]string{field}, fields...)
|
|
return suo
|
|
}
|
|
|
|
// Save executes the query and returns the updated Stats entity.
|
|
func (suo *StatsUpdateOne) Save(ctx context.Context) (*Stats, error) {
|
|
var (
|
|
err error
|
|
node *Stats
|
|
)
|
|
if len(suo.hooks) == 0 {
|
|
node, err = suo.sqlSave(ctx)
|
|
} else {
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*StatsMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
suo.mutation = mutation
|
|
node, err = suo.sqlSave(ctx)
|
|
mutation.done = true
|
|
return node, err
|
|
})
|
|
for i := len(suo.hooks) - 1; i >= 0; i-- {
|
|
if suo.hooks[i] == nil {
|
|
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
|
}
|
|
mut = suo.hooks[i](mut)
|
|
}
|
|
if _, err := mut.Mutate(ctx, suo.mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return node, err
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (suo *StatsUpdateOne) SaveX(ctx context.Context) *Stats {
|
|
node, err := suo.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (suo *StatsUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := suo.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (suo *StatsUpdateOne) ExecX(ctx context.Context) {
|
|
if err := suo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (suo *StatsUpdateOne) sqlSave(ctx context.Context) (_node *Stats, err error) {
|
|
_spec := &sqlgraph.UpdateSpec{
|
|
Node: &sqlgraph.NodeSpec{
|
|
Table: stats.Table,
|
|
Columns: stats.Columns,
|
|
ID: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: stats.FieldID,
|
|
},
|
|
},
|
|
}
|
|
id, ok := suo.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Stats.ID for update")}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := suo.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, stats.FieldID)
|
|
for _, f := range fields {
|
|
if !stats.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != stats.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := suo.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := suo.mutation.TeamID(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldTeamID,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.AddedTeamID(); ok {
|
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldTeamID,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Kills(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldKills,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.AddedKills(); ok {
|
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldKills,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Deaths(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldDeaths,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.AddedDeaths(); ok {
|
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldDeaths,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Assists(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldAssists,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.AddedAssists(); ok {
|
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldAssists,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Headshot(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldHeadshot,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.AddedHeadshot(); ok {
|
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldHeadshot,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Mvp(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldMvp,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.AddedMvp(); ok {
|
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldMvp,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Score(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldScore,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.AddedScore(); ok {
|
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Value: value,
|
|
Column: stats.FieldScore,
|
|
})
|
|
}
|
|
if value, ok := suo.mutation.Extended(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeJSON,
|
|
Value: value,
|
|
Column: stats.FieldExtended,
|
|
})
|
|
}
|
|
if suo.mutation.ExtendedCleared() {
|
|
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
|
Type: field.TypeJSON,
|
|
Column: stats.FieldExtended,
|
|
})
|
|
}
|
|
if suo.mutation.MatchesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: stats.MatchesTable,
|
|
Columns: []string{stats.MatchesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: match.FieldID,
|
|
},
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := suo.mutation.MatchesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: stats.MatchesTable,
|
|
Columns: []string{stats.MatchesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: match.FieldID,
|
|
},
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if suo.mutation.PlayersCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: stats.PlayersTable,
|
|
Columns: []string{stats.PlayersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: player.FieldID,
|
|
},
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := suo.mutation.PlayersIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: stats.PlayersTable,
|
|
Columns: []string{stats.PlayersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: player.FieldID,
|
|
},
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_node = &Stats{config: suo.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{stats.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{err.Error(), err}
|
|
}
|
|
return nil, err
|
|
}
|
|
return _node, nil
|
|
}
|