From 978232dd0a5c9a9af0893f9840930caf9418513d Mon Sep 17 00:00:00 2001 From: Giovanni Harting <539@idlegandalf.com> Date: Sun, 31 Oct 2021 08:40:02 +0100 Subject: [PATCH] added spray patterns --- csgo/demo_loader.go | 16 +- csgo/demo_parser.go | 164 +- ent/client.go | 473 +- ent/config.go | 5 +- ent/ent.go | 10 +- ent/hook/hook.go | 37 +- ent/match.go | 6 +- ent/match/match.go | 8 +- ent/match/where.go | 2 +- ent/match_create.go | 16 +- ent/match_query.go | 18 +- ent/match_update.go | 66 +- ent/{stats.go => matchplayer.go} | 318 +- .../stats.go => matchplayer/matchplayer.go} | 42 +- ent/{stats => matchplayer}/where.go | 1483 +-- ent/matchplayer_create.go | 1046 +++ ent/matchplayer_delete.go | 111 + ent/matchplayer_query.go | 1267 +++ ent/matchplayer_update.go | 3619 ++++++++ ent/migrate/schema.go | 175 +- ent/mutation.go | 7958 +++++++++-------- ent/player.go | 38 +- ent/player/player.go | 17 +- ent/player/where.go | 293 +- ent/player_create.go | 82 +- ent/player_query.go | 18 +- ent/player_update.go | 348 +- ent/predicate/predicate.go | 11 +- ent/roundstats.go | 38 +- ent/roundstats/roundstats.go | 20 +- ent/roundstats/where.go | 16 +- ent/roundstats_create.go | 30 +- ent/roundstats_query.go | 56 +- ent/roundstats_update.go | 82 +- ent/schema/match.go | 2 +- ent/schema/{stats.go => matchplayer.go} | 14 +- ent/schema/player.go | 5 +- ent/schema/roundstats.go | 2 +- ent/schema/spray.go | 27 + ent/schema/weapon.go | 29 + ent/schema/weaponstats.go | 29 - ent/spray.go | 151 + ent/spray/spray.go | 53 + ent/spray/where.go | 319 + ent/spray_create.go | 277 + ent/{stats_delete.go => spray_delete.go} | 36 +- ent/{stats_query.go => spray_query.go} | 557 +- ent/spray_update.go | 439 + ent/stats_create.go | 989 -- ent/stats_update.go | 3344 ------- ent/tx.go | 15 +- ent/{weaponstats.go => weapon.go} | 114 +- .../weaponstats.go => weapon/weapon.go} | 26 +- ent/{weaponstats => weapon}/where.go | 202 +- ent/weapon_create.go | 311 + ent/weapon_delete.go | 111 + ent/weapon_query.go | 1016 +++ ent/weapon_update.go | 575 ++ ent/weaponstats_create.go | 311 - ent/weaponstats_delete.go | 111 - ent/weaponstats_query.go | 1016 --- ent/weaponstats_update.go | 575 -- go.mod | 4 +- go.sum | 18 +- main.go | 95 +- utils/utils.go | 46 +- 66 files changed, 16805 insertions(+), 11903 deletions(-) rename ent/{stats.go => matchplayer.go} (59%) rename ent/{stats/stats.go => matchplayer/matchplayer.go} (83%) rename ent/{stats => matchplayer}/where.go (60%) create mode 100644 ent/matchplayer_create.go create mode 100644 ent/matchplayer_delete.go create mode 100644 ent/matchplayer_query.go create mode 100644 ent/matchplayer_update.go rename ent/schema/{stats.go => matchplayer.go} (82%) create mode 100644 ent/schema/spray.go create mode 100644 ent/schema/weapon.go delete mode 100644 ent/schema/weaponstats.go create mode 100644 ent/spray.go create mode 100644 ent/spray/spray.go create mode 100644 ent/spray/where.go create mode 100644 ent/spray_create.go rename ent/{stats_delete.go => spray_delete.go} (68%) rename ent/{stats_query.go => spray_query.go} (52%) create mode 100644 ent/spray_update.go delete mode 100644 ent/stats_create.go delete mode 100644 ent/stats_update.go rename ent/{weaponstats.go => weapon.go} (51%) rename ent/{weaponstats/weaponstats.go => weapon/weapon.go} (73%) rename ent/{weaponstats => weapon}/where.go (63%) create mode 100644 ent/weapon_create.go create mode 100644 ent/weapon_delete.go create mode 100644 ent/weapon_query.go create mode 100644 ent/weapon_update.go delete mode 100644 ent/weaponstats_create.go delete mode 100644 ent/weaponstats_delete.go delete mode 100644 ent/weaponstats_query.go delete mode 100644 ent/weaponstats_update.go diff --git a/csgo/demo_loader.go b/csgo/demo_loader.go index 12bf08c..0d91e74 100644 --- a/csgo/demo_loader.go +++ b/csgo/demo_loader.go @@ -62,7 +62,7 @@ func SteamId2AccountId(steamId uint64) uint32 { return uint32(steamId - 76561197960265728) } -func playerStatsFromRound(round *protobuf.CMsgGCCStrike15V2_MatchmakingServerRoundStats, p *ent.Player) (int32, int32, int32, int32, int32, int32) { +func playerStatsFromRound(round *protobuf.CMsgGCCStrike15V2_MatchmakingServerRoundStats, p *ent.Player) (kills int32, deaths int32, assists int32, headshots int32, score int32, mvps int32) { for i, acc := range round.GetReservation().GetAccountIds() { if AccountId2SteamId(acc) == p.ID { return round.GetKills()[i], round.GetDeaths()[i], round.GetAssists()[i], round.GetEnemyHeadshots()[i], round.GetScores()[i], round.GetMvps()[i] @@ -431,7 +431,7 @@ func (d *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) { } kills, deaths, assists, hs, score, mvp := playerStatsFromRound(lastRound, mPlayer) - err := d.db.Stats.Create(). + err := d.db.MatchPlayer.Create(). SetMatches(tMatch). SetPlayers(mPlayer). SetTeamID(teamId). @@ -451,15 +451,21 @@ func (d *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) { } } - // clear cache for player + // clear cache or regen values player for _, p := range players { err = d.cache.Delete(context.Background(), fmt.Sprintf(utils.SideMetaCacheKey, p.ID)) if err != nil { log.Warningf("[DL] Unable to delete cache key %s: %v", fmt.Sprintf(utils.SideMetaCacheKey, p.ID), err) } - err = d.cache.Delete(context.Background(), fmt.Sprintf(utils.MatchMetaCacheKey, p.ID)) + + w, l, t, err := utils.GetWinLossTieForPlayer(p) if err != nil { - log.Warningf("[DL] Unable to delete cache key %s: %v", fmt.Sprintf(utils.MatchMetaCacheKey, p.ID), err) + log.Warningf("[DL] Failure to calculate WinLossTie for player %d: %v", p.ID, err) + continue + } + err = p.Update().SetWins(w).SetTies(t).SetLooses(l).Exec(context.Background()) + if err != nil { + log.Warningf("[DL] Failure to save WinLossTie for player %d: %v", p.ID, err) } } diff --git a/csgo/demo_parser.go b/csgo/demo_parser.go index f67a6dc..e4b670f 100644 --- a/csgo/demo_parser.go +++ b/csgo/demo_parser.go @@ -1,13 +1,16 @@ package csgo import ( + "bytes" "compress/bzip2" "context" "csgowtfd/ent" "csgowtfd/ent/match" + "csgowtfd/ent/matchplayer" "csgowtfd/ent/player" - "csgowtfd/ent/stats" + "encoding/gob" "fmt" + "github.com/golang/geo/r2" "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs" "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/common" "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events" @@ -29,10 +32,79 @@ type DemoParser struct { db *ent.Client } +type Encounter struct { + Spotted uint64 + TimeToReact float32 + FirstFrag bool + Spray []*Spray + CrosshairMovement r2.Point + Time time.Duration +} + +type Sprays struct { + Sprayer uint64 + Sprays []*Spray + Weapon int +} + +type Spray struct { + Time time.Duration + Spray [][]float32 +} + type DemoNotFoundError struct { error } +func (s *Sprays) Add(currentTime time.Duration, sprayPoint []float32, timeout int, maxLength int) { + sprayFound := false + for _, sp := range s.Sprays { + if currentTime.Milliseconds()-sp.Time.Milliseconds() <= int64(timeout) { + sprayFound = true + if len(sp.Spray) < maxLength+1 { + sp.Spray = append(sp.Spray, []float32{ + sprayPoint[0] - sp.Spray[0][0], + sprayPoint[1] - sp.Spray[0][1], + }) + } + } + } + if !sprayFound { + s.Sprays = append(s.Sprays, &Spray{ + Time: currentTime, + Spray: [][]float32{sprayPoint}, + }) + } +} + +func (s *Sprays) Avg() (avg [][]float32) { + var ( + total int + ) + + total++ + for _, sp := range s.Sprays { + for i, r2p := range sp.Spray { + if i == 0 { + continue + } + if len(avg) <= i-1 { + avg = append(avg, r2p) + } else { + avg[i-1][0] += r2p[0] + avg[i-1][1] += r2p[1] + } + } + } + + for i, r2p := range avg { + avg[i][0] = r2p[0] / float32(total) + avg[i][1] = r2p[1] / float32(total) + } + + return +} + func (p *DemoParser) Setup(db *ent.Client, worker int) error { p.demoQueue = make(chan *Demo, 1000) p.db = db @@ -51,10 +123,10 @@ func (p *DemoParser) ParseDemo(demo *Demo) error { } } -func (p *DemoParser) downloadDecompressReplay(demo *Demo) (io.Reader, error) { - log.Debugf("[DP] Downloading replay for %d", demo.MatchId) +func (d *Demo) download() (io.Reader, error) { + log.Debugf("[DP] Downloading replay for %d", d.MatchId) - r, err := http.Get(demo.Url) + r, err := http.Get(d.Url) if err != nil { return nil, err } @@ -65,8 +137,8 @@ func (p *DemoParser) downloadDecompressReplay(demo *Demo) (io.Reader, error) { return bzip2.NewReader(r.Body), nil } -func (p *DemoParser) getDBPlayer(demo *Demo, demoPlayer *common.Player) (*ent.Stats, error) { - tMatchPlayer, err := p.db.Stats.Query().WithMatches(func(q *ent.MatchQuery) { +func (p *DemoParser) getDBPlayer(demo *Demo, demoPlayer *common.Player) (*ent.MatchPlayer, error) { + tMatchPlayer, err := p.db.MatchPlayer.Query().WithMatches(func(q *ent.MatchQuery) { q.Where(match.ID(demo.MatchId)) }).WithPlayers(func(q *ent.PlayerQuery) { q.Where(player.ID(demoPlayer.SteamID64)) @@ -78,7 +150,7 @@ func (p *DemoParser) getDBPlayer(demo *Demo, demoPlayer *common.Player) (*ent.St return tMatchPlayer, nil } -func (p *DemoParser) getMatchPlayerBySteamID(stats []*ent.Stats, steamId uint64) *ent.Stats { +func (p *DemoParser) getMatchPlayerBySteamID(stats []*ent.MatchPlayer, steamId uint64) *ent.MatchPlayer { for _, tStats := range stats { tPLayer, err := tStats.Edges.PlayersOrErr() if err != nil { @@ -112,7 +184,7 @@ func (p *DemoParser) parseWorker() { } startTime := time.Now() - fDemo, err := p.downloadDecompressReplay(demo) + fDemo, err := demo.download() if err != nil { if _, ok := err.(DemoNotFoundError); ok { if tMatch.Date.Before(time.Now().UTC().AddDate(0, 0, -30)) { @@ -146,8 +218,47 @@ func (p *DemoParser) parseWorker() { Bank int Spent int }, 0) + encounters := make([]*Encounter, 0) + spays := make([]*Sprays, 0) demoParser := demoinfocs.NewParser(fDemo) + // onPlayerSpotted + demoParser.RegisterEventHandler(func(e events.PlayerSpottersChanged) { + gs := demoParser.GameState() + if !gs.IsMatchStarted() { + return + } + + encounters = append(encounters, &Encounter{ + Spotted: e.Spotted.SteamID64, + Time: demoParser.CurrentTime(), + }) + }) + + // onWeaponFire + demoParser.RegisterEventHandler(func(e events.WeaponFire) { + gs := demoParser.GameState() + if !gs.IsMatchStarted() { + return + } + + playerWeaponFound := false + for _, spray := range spays { + if e.Shooter.SteamID64 == spray.Sprayer && int(e.Weapon.Type) == spray.Weapon { + playerWeaponFound = true + spray.Add(demoParser.CurrentTime(), []float32{e.Shooter.ViewDirectionX(), e.Shooter.ViewDirectionY()}, 500, 10) + } + } + + if !playerWeaponFound { + spays = append(spays, &Sprays{ + Sprayer: e.Shooter.SteamID64, + Sprays: []*Spray{{demoParser.CurrentTime(), [][]float32{{e.Shooter.ViewDirectionX(), e.Shooter.ViewDirectionY()}}}}, + Weapon: int(e.Weapon.Type), + }) + } + }) + // onPlayerHurt demoParser.RegisterEventHandler(func(e events.PlayerHurt) { if e.Attacker == nil || e.Player == nil || e.Weapon == nil || !demoParser.GameState().IsMatchStarted() { @@ -244,22 +355,22 @@ func (p *DemoParser) parseWorker() { tMatchPlayer.Crosshair = demoPlayer.CrosshairCode() switch demoPlayer.Color() { case common.Yellow: - tMatchPlayer.Color = stats.ColorYellow + tMatchPlayer.Color = matchplayer.ColorYellow break case common.Green: - tMatchPlayer.Color = stats.ColorGreen + tMatchPlayer.Color = matchplayer.ColorGreen break case common.Purple: - tMatchPlayer.Color = stats.ColorPurple + tMatchPlayer.Color = matchplayer.ColorPurple break case common.Blue: - tMatchPlayer.Color = stats.ColorBlue + tMatchPlayer.Color = matchplayer.ColorBlue break case common.Orange: - tMatchPlayer.Color = stats.ColorOrange + tMatchPlayer.Color = matchplayer.ColorOrange break default: - tMatchPlayer.Color = stats.ColorGrey + tMatchPlayer.Color = matchplayer.ColorGrey } } } @@ -289,7 +400,7 @@ func (p *DemoParser) parseWorker() { for _, tMatchPlayer := range tStats { if tMatchPlayer.Color == "" { - tMatchPlayer.Color = stats.ColorGrey + tMatchPlayer.Color = matchplayer.ColorGrey } nMatchPLayer, err := tMatchPlayer.Update(). @@ -318,18 +429,37 @@ func (p *DemoParser) parseWorker() { } for _, eqDmg := range eqMap[tMatchPlayer.PlayerStats] { - err := p.db.WeaponStats.Create().SetStat(nMatchPLayer).SetDmg(eqDmg.Dmg).SetVictim(eqDmg.To).SetHitGroup(eqDmg.HitGroup).SetEqType(eqDmg.Eq).Exec(context.Background()) + err := p.db.Weapon.Create().SetStat(nMatchPLayer).SetDmg(eqDmg.Dmg).SetVictim(eqDmg.To).SetHitGroup(eqDmg.HitGroup).SetEqType(eqDmg.Eq).Exec(context.Background()) if err != nil { log.Errorf("[DP] Unable to create WeaponStat: %v", err) } } for _, eco := range ecoMap[tMatchPlayer.PlayerStats] { - err := p.db.RoundStats.Create().SetStat(nMatchPLayer).SetRound(uint(eco.Round)).SetBank(uint(eco.Bank)).SetEquipment(uint(eco.EqV)).SetSpent(uint(eco.Spent)).Exec(context.Background()) + err := p.db.RoundStats.Create().SetMatchPlayer(nMatchPLayer).SetRound(uint(eco.Round)).SetBank(uint(eco.Bank)).SetEquipment(uint(eco.EqV)).SetSpent(uint(eco.Spent)).Exec(context.Background()) if err != nil { log.Errorf("[DP] Unable to create RoundStat: %v", err) } } + + for _, spray := range spays { + if spray.Sprayer == nMatchPLayer.PlayerStats { + if sprayAvg := spray.Avg(); len(sprayAvg) >= 5 { + sprayBuf := new(bytes.Buffer) + enc := gob.NewEncoder(sprayBuf) + err = enc.Encode(sprayAvg) + if err != nil { + log.Warningf("[DP] Failure to encode spray %v as bytes: %v", spray, err) + continue + } + + err = p.db.Spray.Create().SetMatchPlayers(nMatchPLayer).SetWeapon(spray.Weapon).SetSpray(sprayBuf.Bytes()).Exec(context.Background()) + if err != nil { + log.Warningf("[DP] Failure adding spray to database: %v", err) + } + } + } + } } log.Infof("[DP] parsed match %d (took %s/%s)", demo.MatchId, downloadTime, time.Since(startTime)) diff --git a/ent/client.go b/ent/client.go index 4e06d84..dc2edbb 100644 --- a/ent/client.go +++ b/ent/client.go @@ -10,10 +10,11 @@ import ( "csgowtfd/ent/migrate" "csgowtfd/ent/match" + "csgowtfd/ent/matchplayer" "csgowtfd/ent/player" "csgowtfd/ent/roundstats" - "csgowtfd/ent/stats" - "csgowtfd/ent/weaponstats" + "csgowtfd/ent/spray" + "csgowtfd/ent/weapon" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" @@ -27,14 +28,16 @@ type Client struct { Schema *migrate.Schema // Match is the client for interacting with the Match builders. Match *MatchClient + // MatchPlayer is the client for interacting with the MatchPlayer builders. + MatchPlayer *MatchPlayerClient // Player is the client for interacting with the Player builders. Player *PlayerClient // RoundStats is the client for interacting with the RoundStats builders. RoundStats *RoundStatsClient - // Stats is the client for interacting with the Stats builders. - Stats *StatsClient - // WeaponStats is the client for interacting with the WeaponStats builders. - WeaponStats *WeaponStatsClient + // Spray is the client for interacting with the Spray builders. + Spray *SprayClient + // Weapon is the client for interacting with the Weapon builders. + Weapon *WeaponClient } // NewClient creates a new client configured with the given options. @@ -49,10 +52,11 @@ func NewClient(opts ...Option) *Client { func (c *Client) init() { c.Schema = migrate.NewSchema(c.driver) c.Match = NewMatchClient(c.config) + c.MatchPlayer = NewMatchPlayerClient(c.config) c.Player = NewPlayerClient(c.config) c.RoundStats = NewRoundStatsClient(c.config) - c.Stats = NewStatsClient(c.config) - c.WeaponStats = NewWeaponStatsClient(c.config) + c.Spray = NewSprayClient(c.config) + c.Weapon = NewWeaponClient(c.config) } // Open opens a database/sql.DB specified by the driver name and @@ -87,10 +91,11 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { ctx: ctx, config: cfg, Match: NewMatchClient(cfg), + MatchPlayer: NewMatchPlayerClient(cfg), Player: NewPlayerClient(cfg), RoundStats: NewRoundStatsClient(cfg), - Stats: NewStatsClient(cfg), - WeaponStats: NewWeaponStatsClient(cfg), + Spray: NewSprayClient(cfg), + Weapon: NewWeaponClient(cfg), }, nil } @@ -110,10 +115,11 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) return &Tx{ config: cfg, Match: NewMatchClient(cfg), + MatchPlayer: NewMatchPlayerClient(cfg), Player: NewPlayerClient(cfg), RoundStats: NewRoundStatsClient(cfg), - Stats: NewStatsClient(cfg), - WeaponStats: NewWeaponStatsClient(cfg), + Spray: NewSprayClient(cfg), + Weapon: NewWeaponClient(cfg), }, nil } @@ -144,10 +150,11 @@ func (c *Client) Close() error { // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { c.Match.Use(hooks...) + c.MatchPlayer.Use(hooks...) c.Player.Use(hooks...) c.RoundStats.Use(hooks...) - c.Stats.Use(hooks...) - c.WeaponStats.Use(hooks...) + c.Spray.Use(hooks...) + c.Weapon.Use(hooks...) } // MatchClient is a client for the Match schema. @@ -236,13 +243,13 @@ func (c *MatchClient) GetX(ctx context.Context, id uint64) *Match { } // QueryStats queries the stats edge of a Match. -func (c *MatchClient) QueryStats(m *Match) *StatsQuery { - query := &StatsQuery{config: c.config} +func (c *MatchClient) QueryStats(m *Match) *MatchPlayerQuery { + query := &MatchPlayerQuery{config: c.config} query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { id := m.ID step := sqlgraph.NewStep( sqlgraph.From(match.Table, match.FieldID, id), - sqlgraph.To(stats.Table, stats.FieldID), + sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, match.StatsTable, match.StatsColumn), ) fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) @@ -272,6 +279,176 @@ func (c *MatchClient) Hooks() []Hook { return c.hooks.Match } +// MatchPlayerClient is a client for the MatchPlayer schema. +type MatchPlayerClient struct { + config +} + +// NewMatchPlayerClient returns a client for the MatchPlayer from the given config. +func NewMatchPlayerClient(c config) *MatchPlayerClient { + return &MatchPlayerClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `matchplayer.Hooks(f(g(h())))`. +func (c *MatchPlayerClient) Use(hooks ...Hook) { + c.hooks.MatchPlayer = append(c.hooks.MatchPlayer, hooks...) +} + +// Create returns a create builder for MatchPlayer. +func (c *MatchPlayerClient) Create() *MatchPlayerCreate { + mutation := newMatchPlayerMutation(c.config, OpCreate) + return &MatchPlayerCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of MatchPlayer entities. +func (c *MatchPlayerClient) CreateBulk(builders ...*MatchPlayerCreate) *MatchPlayerCreateBulk { + return &MatchPlayerCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for MatchPlayer. +func (c *MatchPlayerClient) Update() *MatchPlayerUpdate { + mutation := newMatchPlayerMutation(c.config, OpUpdate) + return &MatchPlayerUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *MatchPlayerClient) UpdateOne(mp *MatchPlayer) *MatchPlayerUpdateOne { + mutation := newMatchPlayerMutation(c.config, OpUpdateOne, withMatchPlayer(mp)) + return &MatchPlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *MatchPlayerClient) UpdateOneID(id int) *MatchPlayerUpdateOne { + mutation := newMatchPlayerMutation(c.config, OpUpdateOne, withMatchPlayerID(id)) + return &MatchPlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for MatchPlayer. +func (c *MatchPlayerClient) Delete() *MatchPlayerDelete { + mutation := newMatchPlayerMutation(c.config, OpDelete) + return &MatchPlayerDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a delete builder for the given entity. +func (c *MatchPlayerClient) DeleteOne(mp *MatchPlayer) *MatchPlayerDeleteOne { + return c.DeleteOneID(mp.ID) +} + +// DeleteOneID returns a delete builder for the given id. +func (c *MatchPlayerClient) DeleteOneID(id int) *MatchPlayerDeleteOne { + builder := c.Delete().Where(matchplayer.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &MatchPlayerDeleteOne{builder} +} + +// Query returns a query builder for MatchPlayer. +func (c *MatchPlayerClient) Query() *MatchPlayerQuery { + return &MatchPlayerQuery{ + config: c.config, + } +} + +// Get returns a MatchPlayer entity by its id. +func (c *MatchPlayerClient) Get(ctx context.Context, id int) (*MatchPlayer, error) { + return c.Query().Where(matchplayer.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *MatchPlayerClient) GetX(ctx context.Context, id int) *MatchPlayer { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryMatches queries the matches edge of a MatchPlayer. +func (c *MatchPlayerClient) QueryMatches(mp *MatchPlayer) *MatchQuery { + query := &MatchQuery{config: c.config} + query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { + id := mp.ID + step := sqlgraph.NewStep( + sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), + sqlgraph.To(match.Table, match.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.MatchesTable, matchplayer.MatchesColumn), + ) + fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryPlayers queries the players edge of a MatchPlayer. +func (c *MatchPlayerClient) QueryPlayers(mp *MatchPlayer) *PlayerQuery { + query := &PlayerQuery{config: c.config} + query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { + id := mp.ID + step := sqlgraph.NewStep( + sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), + sqlgraph.To(player.Table, player.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.PlayersTable, matchplayer.PlayersColumn), + ) + fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryWeaponStats queries the weapon_stats edge of a MatchPlayer. +func (c *MatchPlayerClient) QueryWeaponStats(mp *MatchPlayer) *WeaponQuery { + query := &WeaponQuery{config: c.config} + query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { + id := mp.ID + step := sqlgraph.NewStep( + sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), + sqlgraph.To(weapon.Table, weapon.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.WeaponStatsTable, matchplayer.WeaponStatsColumn), + ) + fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryRoundStats queries the round_stats edge of a MatchPlayer. +func (c *MatchPlayerClient) QueryRoundStats(mp *MatchPlayer) *RoundStatsQuery { + query := &RoundStatsQuery{config: c.config} + query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { + id := mp.ID + step := sqlgraph.NewStep( + sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), + sqlgraph.To(roundstats.Table, roundstats.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.RoundStatsTable, matchplayer.RoundStatsColumn), + ) + fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QuerySpray queries the spray edge of a MatchPlayer. +func (c *MatchPlayerClient) QuerySpray(mp *MatchPlayer) *SprayQuery { + query := &SprayQuery{config: c.config} + query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { + id := mp.ID + step := sqlgraph.NewStep( + sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), + sqlgraph.To(spray.Table, spray.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.SprayTable, matchplayer.SprayColumn), + ) + fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *MatchPlayerClient) Hooks() []Hook { + return c.hooks.MatchPlayer +} + // PlayerClient is a client for the Player schema. type PlayerClient struct { config @@ -358,13 +535,13 @@ func (c *PlayerClient) GetX(ctx context.Context, id uint64) *Player { } // QueryStats queries the stats edge of a Player. -func (c *PlayerClient) QueryStats(pl *Player) *StatsQuery { - query := &StatsQuery{config: c.config} +func (c *PlayerClient) QueryStats(pl *Player) *MatchPlayerQuery { + query := &MatchPlayerQuery{config: c.config} query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { id := pl.ID step := sqlgraph.NewStep( sqlgraph.From(player.Table, player.FieldID, id), - sqlgraph.To(stats.Table, stats.FieldID), + sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, player.StatsTable, player.StatsColumn), ) fromV = sqlgraph.Neighbors(pl.driver.Dialect(), step) @@ -479,15 +656,15 @@ func (c *RoundStatsClient) GetX(ctx context.Context, id int) *RoundStats { return obj } -// QueryStat queries the stat edge of a RoundStats. -func (c *RoundStatsClient) QueryStat(rs *RoundStats) *StatsQuery { - query := &StatsQuery{config: c.config} +// QueryMatchPlayer queries the match_player edge of a RoundStats. +func (c *RoundStatsClient) QueryMatchPlayer(rs *RoundStats) *MatchPlayerQuery { + query := &MatchPlayerQuery{config: c.config} query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { id := rs.ID step := sqlgraph.NewStep( sqlgraph.From(roundstats.Table, roundstats.FieldID, id), - sqlgraph.To(stats.Table, stats.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, roundstats.StatTable, roundstats.StatColumn), + sqlgraph.To(matchplayer.Table, matchplayer.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, roundstats.MatchPlayerTable, roundstats.MatchPlayerColumn), ) fromV = sqlgraph.Neighbors(rs.driver.Dialect(), step) return fromV, nil @@ -500,84 +677,84 @@ func (c *RoundStatsClient) Hooks() []Hook { return c.hooks.RoundStats } -// StatsClient is a client for the Stats schema. -type StatsClient struct { +// SprayClient is a client for the Spray schema. +type SprayClient struct { config } -// NewStatsClient returns a client for the Stats from the given config. -func NewStatsClient(c config) *StatsClient { - return &StatsClient{config: c} +// NewSprayClient returns a client for the Spray from the given config. +func NewSprayClient(c config) *SprayClient { + return &SprayClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `stats.Hooks(f(g(h())))`. -func (c *StatsClient) Use(hooks ...Hook) { - c.hooks.Stats = append(c.hooks.Stats, hooks...) +// A call to `Use(f, g, h)` equals to `spray.Hooks(f(g(h())))`. +func (c *SprayClient) Use(hooks ...Hook) { + c.hooks.Spray = append(c.hooks.Spray, hooks...) } -// Create returns a create builder for Stats. -func (c *StatsClient) Create() *StatsCreate { - mutation := newStatsMutation(c.config, OpCreate) - return &StatsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +// Create returns a create builder for Spray. +func (c *SprayClient) Create() *SprayCreate { + mutation := newSprayMutation(c.config, OpCreate) + return &SprayCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } -// CreateBulk returns a builder for creating a bulk of Stats entities. -func (c *StatsClient) CreateBulk(builders ...*StatsCreate) *StatsCreateBulk { - return &StatsCreateBulk{config: c.config, builders: builders} +// CreateBulk returns a builder for creating a bulk of Spray entities. +func (c *SprayClient) CreateBulk(builders ...*SprayCreate) *SprayCreateBulk { + return &SprayCreateBulk{config: c.config, builders: builders} } -// Update returns an update builder for Stats. -func (c *StatsClient) Update() *StatsUpdate { - mutation := newStatsMutation(c.config, OpUpdate) - return &StatsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +// Update returns an update builder for Spray. +func (c *SprayClient) Update() *SprayUpdate { + mutation := newSprayMutation(c.config, OpUpdate) + return &SprayUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. -func (c *StatsClient) UpdateOne(s *Stats) *StatsUpdateOne { - mutation := newStatsMutation(c.config, OpUpdateOne, withStats(s)) - return &StatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +func (c *SprayClient) UpdateOne(s *Spray) *SprayUpdateOne { + mutation := newSprayMutation(c.config, OpUpdateOne, withSpray(s)) + return &SprayUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. -func (c *StatsClient) UpdateOneID(id int) *StatsUpdateOne { - mutation := newStatsMutation(c.config, OpUpdateOne, withStatsID(id)) - return &StatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +func (c *SprayClient) UpdateOneID(id int) *SprayUpdateOne { + mutation := newSprayMutation(c.config, OpUpdateOne, withSprayID(id)) + return &SprayUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } -// Delete returns a delete builder for Stats. -func (c *StatsClient) Delete() *StatsDelete { - mutation := newStatsMutation(c.config, OpDelete) - return &StatsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +// Delete returns a delete builder for Spray. +func (c *SprayClient) Delete() *SprayDelete { + mutation := newSprayMutation(c.config, OpDelete) + return &SprayDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a delete builder for the given entity. -func (c *StatsClient) DeleteOne(s *Stats) *StatsDeleteOne { +func (c *SprayClient) DeleteOne(s *Spray) *SprayDeleteOne { return c.DeleteOneID(s.ID) } // DeleteOneID returns a delete builder for the given id. -func (c *StatsClient) DeleteOneID(id int) *StatsDeleteOne { - builder := c.Delete().Where(stats.ID(id)) +func (c *SprayClient) DeleteOneID(id int) *SprayDeleteOne { + builder := c.Delete().Where(spray.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne - return &StatsDeleteOne{builder} + return &SprayDeleteOne{builder} } -// Query returns a query builder for Stats. -func (c *StatsClient) Query() *StatsQuery { - return &StatsQuery{ +// Query returns a query builder for Spray. +func (c *SprayClient) Query() *SprayQuery { + return &SprayQuery{ config: c.config, } } -// Get returns a Stats entity by its id. -func (c *StatsClient) Get(ctx context.Context, id int) (*Stats, error) { - return c.Query().Where(stats.ID(id)).Only(ctx) +// Get returns a Spray entity by its id. +func (c *SprayClient) Get(ctx context.Context, id int) (*Spray, error) { + return c.Query().Where(spray.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. -func (c *StatsClient) GetX(ctx context.Context, id int) *Stats { +func (c *SprayClient) GetX(ctx context.Context, id int) *Spray { obj, err := c.Get(ctx, id) if err != nil { panic(err) @@ -585,63 +762,15 @@ func (c *StatsClient) GetX(ctx context.Context, id int) *Stats { return obj } -// QueryMatches queries the matches edge of a Stats. -func (c *StatsClient) QueryMatches(s *Stats) *MatchQuery { - query := &MatchQuery{config: c.config} +// QueryMatchPlayers queries the match_players edge of a Spray. +func (c *SprayClient) QueryMatchPlayers(s *Spray) *MatchPlayerQuery { + query := &MatchPlayerQuery{config: c.config} query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { id := s.ID step := sqlgraph.NewStep( - sqlgraph.From(stats.Table, stats.FieldID, id), - sqlgraph.To(match.Table, match.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, stats.MatchesTable, stats.MatchesColumn), - ) - fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryPlayers queries the players edge of a Stats. -func (c *StatsClient) QueryPlayers(s *Stats) *PlayerQuery { - query := &PlayerQuery{config: c.config} - query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { - id := s.ID - step := sqlgraph.NewStep( - sqlgraph.From(stats.Table, stats.FieldID, id), - sqlgraph.To(player.Table, player.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, stats.PlayersTable, stats.PlayersColumn), - ) - fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryWeaponStats queries the weapon_stats edge of a Stats. -func (c *StatsClient) QueryWeaponStats(s *Stats) *WeaponStatsQuery { - query := &WeaponStatsQuery{config: c.config} - query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { - id := s.ID - step := sqlgraph.NewStep( - sqlgraph.From(stats.Table, stats.FieldID, id), - sqlgraph.To(weaponstats.Table, weaponstats.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, stats.WeaponStatsTable, stats.WeaponStatsColumn), - ) - fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryRoundStats queries the round_stats edge of a Stats. -func (c *StatsClient) QueryRoundStats(s *Stats) *RoundStatsQuery { - query := &RoundStatsQuery{config: c.config} - query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { - id := s.ID - step := sqlgraph.NewStep( - sqlgraph.From(stats.Table, stats.FieldID, id), - sqlgraph.To(roundstats.Table, roundstats.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, stats.RoundStatsTable, stats.RoundStatsColumn), + sqlgraph.From(spray.Table, spray.FieldID, id), + sqlgraph.To(matchplayer.Table, matchplayer.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, spray.MatchPlayersTable, spray.MatchPlayersColumn), ) fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) return fromV, nil @@ -650,88 +779,88 @@ func (c *StatsClient) QueryRoundStats(s *Stats) *RoundStatsQuery { } // Hooks returns the client hooks. -func (c *StatsClient) Hooks() []Hook { - return c.hooks.Stats +func (c *SprayClient) Hooks() []Hook { + return c.hooks.Spray } -// WeaponStatsClient is a client for the WeaponStats schema. -type WeaponStatsClient struct { +// WeaponClient is a client for the Weapon schema. +type WeaponClient struct { config } -// NewWeaponStatsClient returns a client for the WeaponStats from the given config. -func NewWeaponStatsClient(c config) *WeaponStatsClient { - return &WeaponStatsClient{config: c} +// NewWeaponClient returns a client for the Weapon from the given config. +func NewWeaponClient(c config) *WeaponClient { + return &WeaponClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `weaponstats.Hooks(f(g(h())))`. -func (c *WeaponStatsClient) Use(hooks ...Hook) { - c.hooks.WeaponStats = append(c.hooks.WeaponStats, hooks...) +// A call to `Use(f, g, h)` equals to `weapon.Hooks(f(g(h())))`. +func (c *WeaponClient) Use(hooks ...Hook) { + c.hooks.Weapon = append(c.hooks.Weapon, hooks...) } -// Create returns a create builder for WeaponStats. -func (c *WeaponStatsClient) Create() *WeaponStatsCreate { - mutation := newWeaponStatsMutation(c.config, OpCreate) - return &WeaponStatsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +// Create returns a create builder for Weapon. +func (c *WeaponClient) Create() *WeaponCreate { + mutation := newWeaponMutation(c.config, OpCreate) + return &WeaponCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } -// CreateBulk returns a builder for creating a bulk of WeaponStats entities. -func (c *WeaponStatsClient) CreateBulk(builders ...*WeaponStatsCreate) *WeaponStatsCreateBulk { - return &WeaponStatsCreateBulk{config: c.config, builders: builders} +// CreateBulk returns a builder for creating a bulk of Weapon entities. +func (c *WeaponClient) CreateBulk(builders ...*WeaponCreate) *WeaponCreateBulk { + return &WeaponCreateBulk{config: c.config, builders: builders} } -// Update returns an update builder for WeaponStats. -func (c *WeaponStatsClient) Update() *WeaponStatsUpdate { - mutation := newWeaponStatsMutation(c.config, OpUpdate) - return &WeaponStatsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +// Update returns an update builder for Weapon. +func (c *WeaponClient) Update() *WeaponUpdate { + mutation := newWeaponMutation(c.config, OpUpdate) + return &WeaponUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. -func (c *WeaponStatsClient) UpdateOne(ws *WeaponStats) *WeaponStatsUpdateOne { - mutation := newWeaponStatsMutation(c.config, OpUpdateOne, withWeaponStats(ws)) - return &WeaponStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +func (c *WeaponClient) UpdateOne(w *Weapon) *WeaponUpdateOne { + mutation := newWeaponMutation(c.config, OpUpdateOne, withWeapon(w)) + return &WeaponUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. -func (c *WeaponStatsClient) UpdateOneID(id int) *WeaponStatsUpdateOne { - mutation := newWeaponStatsMutation(c.config, OpUpdateOne, withWeaponStatsID(id)) - return &WeaponStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +func (c *WeaponClient) UpdateOneID(id int) *WeaponUpdateOne { + mutation := newWeaponMutation(c.config, OpUpdateOne, withWeaponID(id)) + return &WeaponUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } -// Delete returns a delete builder for WeaponStats. -func (c *WeaponStatsClient) Delete() *WeaponStatsDelete { - mutation := newWeaponStatsMutation(c.config, OpDelete) - return &WeaponStatsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +// Delete returns a delete builder for Weapon. +func (c *WeaponClient) Delete() *WeaponDelete { + mutation := newWeaponMutation(c.config, OpDelete) + return &WeaponDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a delete builder for the given entity. -func (c *WeaponStatsClient) DeleteOne(ws *WeaponStats) *WeaponStatsDeleteOne { - return c.DeleteOneID(ws.ID) +func (c *WeaponClient) DeleteOne(w *Weapon) *WeaponDeleteOne { + return c.DeleteOneID(w.ID) } // DeleteOneID returns a delete builder for the given id. -func (c *WeaponStatsClient) DeleteOneID(id int) *WeaponStatsDeleteOne { - builder := c.Delete().Where(weaponstats.ID(id)) +func (c *WeaponClient) DeleteOneID(id int) *WeaponDeleteOne { + builder := c.Delete().Where(weapon.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne - return &WeaponStatsDeleteOne{builder} + return &WeaponDeleteOne{builder} } -// Query returns a query builder for WeaponStats. -func (c *WeaponStatsClient) Query() *WeaponStatsQuery { - return &WeaponStatsQuery{ +// Query returns a query builder for Weapon. +func (c *WeaponClient) Query() *WeaponQuery { + return &WeaponQuery{ config: c.config, } } -// Get returns a WeaponStats entity by its id. -func (c *WeaponStatsClient) Get(ctx context.Context, id int) (*WeaponStats, error) { - return c.Query().Where(weaponstats.ID(id)).Only(ctx) +// Get returns a Weapon entity by its id. +func (c *WeaponClient) Get(ctx context.Context, id int) (*Weapon, error) { + return c.Query().Where(weapon.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. -func (c *WeaponStatsClient) GetX(ctx context.Context, id int) *WeaponStats { +func (c *WeaponClient) GetX(ctx context.Context, id int) *Weapon { obj, err := c.Get(ctx, id) if err != nil { panic(err) @@ -739,23 +868,23 @@ func (c *WeaponStatsClient) GetX(ctx context.Context, id int) *WeaponStats { return obj } -// QueryStat queries the stat edge of a WeaponStats. -func (c *WeaponStatsClient) QueryStat(ws *WeaponStats) *StatsQuery { - query := &StatsQuery{config: c.config} +// QueryStat queries the stat edge of a Weapon. +func (c *WeaponClient) QueryStat(w *Weapon) *MatchPlayerQuery { + query := &MatchPlayerQuery{config: c.config} query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { - id := ws.ID + id := w.ID step := sqlgraph.NewStep( - sqlgraph.From(weaponstats.Table, weaponstats.FieldID, id), - sqlgraph.To(stats.Table, stats.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, weaponstats.StatTable, weaponstats.StatColumn), + sqlgraph.From(weapon.Table, weapon.FieldID, id), + sqlgraph.To(matchplayer.Table, matchplayer.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, weapon.StatTable, weapon.StatColumn), ) - fromV = sqlgraph.Neighbors(ws.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(w.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. -func (c *WeaponStatsClient) Hooks() []Hook { - return c.hooks.WeaponStats +func (c *WeaponClient) Hooks() []Hook { + return c.hooks.Weapon } diff --git a/ent/config.go b/ent/config.go index da373c0..9a94c69 100644 --- a/ent/config.go +++ b/ent/config.go @@ -25,10 +25,11 @@ type config struct { // hooks per client, for fast access. type hooks struct { Match []ent.Hook + MatchPlayer []ent.Hook Player []ent.Hook RoundStats []ent.Hook - Stats []ent.Hook - WeaponStats []ent.Hook + Spray []ent.Hook + Weapon []ent.Hook } // Options applies the options on the config object. diff --git a/ent/ent.go b/ent/ent.go index e4b99ff..5a5291c 100644 --- a/ent/ent.go +++ b/ent/ent.go @@ -4,10 +4,11 @@ package ent import ( "csgowtfd/ent/match" + "csgowtfd/ent/matchplayer" "csgowtfd/ent/player" "csgowtfd/ent/roundstats" - "csgowtfd/ent/stats" - "csgowtfd/ent/weaponstats" + "csgowtfd/ent/spray" + "csgowtfd/ent/weapon" "errors" "fmt" @@ -34,10 +35,11 @@ type OrderFunc func(*sql.Selector) func columnChecker(table string) func(string) error { checks := map[string]func(string) bool{ match.Table: match.ValidColumn, + matchplayer.Table: matchplayer.ValidColumn, player.Table: player.ValidColumn, roundstats.Table: roundstats.ValidColumn, - stats.Table: stats.ValidColumn, - weaponstats.Table: weaponstats.ValidColumn, + spray.Table: spray.ValidColumn, + weapon.Table: weapon.ValidColumn, } check, ok := checks[table] if !ok { diff --git a/ent/hook/hook.go b/ent/hook/hook.go index ff299a5..f61fd96 100644 --- a/ent/hook/hook.go +++ b/ent/hook/hook.go @@ -21,6 +21,19 @@ func (f MatchFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error return f(ctx, mv) } +// The MatchPlayerFunc type is an adapter to allow the use of ordinary +// function as MatchPlayer mutator. +type MatchPlayerFunc func(context.Context, *ent.MatchPlayerMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f MatchPlayerFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + mv, ok := m.(*ent.MatchPlayerMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MatchPlayerMutation", m) + } + return f(ctx, mv) +} + // The PlayerFunc type is an adapter to allow the use of ordinary // function as Player mutator. type PlayerFunc func(context.Context, *ent.PlayerMutation) (ent.Value, error) @@ -47,28 +60,28 @@ func (f RoundStatsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, return f(ctx, mv) } -// The StatsFunc type is an adapter to allow the use of ordinary -// function as Stats mutator. -type StatsFunc func(context.Context, *ent.StatsMutation) (ent.Value, error) +// The SprayFunc type is an adapter to allow the use of ordinary +// function as Spray mutator. +type SprayFunc func(context.Context, *ent.SprayMutation) (ent.Value, error) // Mutate calls f(ctx, m). -func (f StatsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - mv, ok := m.(*ent.StatsMutation) +func (f SprayFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + mv, ok := m.(*ent.SprayMutation) if !ok { - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.StatsMutation", m) + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SprayMutation", m) } return f(ctx, mv) } -// The WeaponStatsFunc type is an adapter to allow the use of ordinary -// function as WeaponStats mutator. -type WeaponStatsFunc func(context.Context, *ent.WeaponStatsMutation) (ent.Value, error) +// The WeaponFunc type is an adapter to allow the use of ordinary +// function as Weapon mutator. +type WeaponFunc func(context.Context, *ent.WeaponMutation) (ent.Value, error) // Mutate calls f(ctx, m). -func (f WeaponStatsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - mv, ok := m.(*ent.WeaponStatsMutation) +func (f WeaponFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + mv, ok := m.(*ent.WeaponMutation) if !ok { - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.WeaponStatsMutation", m) + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.WeaponMutation", m) } return f(ctx, mv) } diff --git a/ent/match.go b/ent/match.go index caebedb..7da5a87 100644 --- a/ent/match.go +++ b/ent/match.go @@ -48,7 +48,7 @@ type Match struct { // MatchEdges holds the relations/edges for other nodes in the graph. type MatchEdges struct { // Stats holds the value of the stats edge. - Stats []*Stats `json:"stats,omitempty"` + Stats []*MatchPlayer `json:"stats,omitempty"` // Players holds the value of the players edge. Players []*Player `json:"players,omitempty"` // loadedTypes holds the information for reporting if a @@ -58,7 +58,7 @@ type MatchEdges struct { // StatsOrErr returns the Stats value or an error if the edge // was not loaded in eager-loading. -func (e MatchEdges) StatsOrErr() ([]*Stats, error) { +func (e MatchEdges) StatsOrErr() ([]*MatchPlayer, error) { if e.loadedTypes[0] { return e.Stats, nil } @@ -186,7 +186,7 @@ func (m *Match) assignValues(columns []string, values []interface{}) error { } // QueryStats queries the "stats" edge of the Match entity. -func (m *Match) QueryStats() *StatsQuery { +func (m *Match) QueryStats() *MatchPlayerQuery { return (&MatchClient{config: m.config}).QueryStats(m) } diff --git a/ent/match/match.go b/ent/match/match.go index b0ac166..bcae620 100644 --- a/ent/match/match.go +++ b/ent/match/match.go @@ -38,10 +38,10 @@ const ( // Table holds the table name of the match in the database. Table = "matches" // StatsTable is the table that holds the stats relation/edge. - StatsTable = "stats" - // StatsInverseTable is the table name for the Stats entity. - // It exists in this package in order to avoid circular dependency with the "stats" package. - StatsInverseTable = "stats" + StatsTable = "match_players" + // StatsInverseTable is the table name for the MatchPlayer entity. + // It exists in this package in order to avoid circular dependency with the "matchplayer" package. + StatsInverseTable = "match_players" // StatsColumn is the table column denoting the stats relation/edge. StatsColumn = "match_stats" // PlayersTable is the table that holds the players relation/edge. The primary key declared below. diff --git a/ent/match/where.go b/ent/match/where.go index 61015ab..6b374ba 100644 --- a/ent/match/where.go +++ b/ent/match/where.go @@ -1049,7 +1049,7 @@ func HasStats() predicate.Match { } // HasStatsWith applies the HasEdge predicate on the "stats" edge with a given conditions (other predicates). -func HasStatsWith(preds ...predicate.Stats) predicate.Match { +func HasStatsWith(preds ...predicate.MatchPlayer) predicate.Match { return predicate.Match(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), diff --git a/ent/match_create.go b/ent/match_create.go index 1e42f94..5d4a4ed 100644 --- a/ent/match_create.go +++ b/ent/match_create.go @@ -5,8 +5,8 @@ package ent import ( "context" "csgowtfd/ent/match" + "csgowtfd/ent/matchplayer" "csgowtfd/ent/player" - "csgowtfd/ent/stats" "errors" "fmt" "time" @@ -140,17 +140,17 @@ func (mc *MatchCreate) SetID(u uint64) *MatchCreate { return mc } -// AddStatIDs adds the "stats" edge to the Stats entity by IDs. +// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs. func (mc *MatchCreate) AddStatIDs(ids ...int) *MatchCreate { mc.mutation.AddStatIDs(ids...) return mc } -// AddStats adds the "stats" edges to the Stats entity. -func (mc *MatchCreate) AddStats(s ...*Stats) *MatchCreate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +// AddStats adds the "stats" edges to the MatchPlayer entity. +func (mc *MatchCreate) AddStats(m ...*MatchPlayer) *MatchCreate { + ids := make([]int, len(m)) + for i := range m { + ids[i] = m[i].ID } return mc.AddStatIDs(ids...) } @@ -426,7 +426,7 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) { Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } diff --git a/ent/match_query.go b/ent/match_query.go index f68ae38..af83f58 100644 --- a/ent/match_query.go +++ b/ent/match_query.go @@ -5,9 +5,9 @@ package ent import ( "context" "csgowtfd/ent/match" + "csgowtfd/ent/matchplayer" "csgowtfd/ent/player" "csgowtfd/ent/predicate" - "csgowtfd/ent/stats" "database/sql/driver" "errors" "fmt" @@ -28,7 +28,7 @@ type MatchQuery struct { fields []string predicates []predicate.Match // eager-loading edges. - withStats *StatsQuery + withStats *MatchPlayerQuery withPlayers *PlayerQuery modifiers []func(s *sql.Selector) // intermediate query (i.e. traversal path). @@ -68,8 +68,8 @@ func (mq *MatchQuery) Order(o ...OrderFunc) *MatchQuery { } // QueryStats chains the current query on the "stats" edge. -func (mq *MatchQuery) QueryStats() *StatsQuery { - query := &StatsQuery{config: mq.config} +func (mq *MatchQuery) QueryStats() *MatchPlayerQuery { + query := &MatchPlayerQuery{config: mq.config} query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := mq.prepareQuery(ctx); err != nil { return nil, err @@ -80,7 +80,7 @@ func (mq *MatchQuery) QueryStats() *StatsQuery { } step := sqlgraph.NewStep( sqlgraph.From(match.Table, match.FieldID, selector), - sqlgraph.To(stats.Table, stats.FieldID), + sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, match.StatsTable, match.StatsColumn), ) fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) @@ -302,8 +302,8 @@ func (mq *MatchQuery) Clone() *MatchQuery { // WithStats tells the query-builder to eager-load the nodes that are connected to // the "stats" edge. The optional arguments are used to configure the query builder of the edge. -func (mq *MatchQuery) WithStats(opts ...func(*StatsQuery)) *MatchQuery { - query := &StatsQuery{config: mq.config} +func (mq *MatchQuery) WithStats(opts ...func(*MatchPlayerQuery)) *MatchQuery { + query := &MatchPlayerQuery{config: mq.config} for _, opt := range opts { opt(query) } @@ -421,9 +421,9 @@ func (mq *MatchQuery) sqlAll(ctx context.Context) ([]*Match, error) { for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] - nodes[i].Edges.Stats = []*Stats{} + nodes[i].Edges.Stats = []*MatchPlayer{} } - query.Where(predicate.Stats(func(s *sql.Selector) { + query.Where(predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.InValues(match.StatsColumn, fks...)) })) neighbors, err := query.All(ctx) diff --git a/ent/match_update.go b/ent/match_update.go index b01c5c1..cf1f9ec 100644 --- a/ent/match_update.go +++ b/ent/match_update.go @@ -5,9 +5,9 @@ package ent import ( "context" "csgowtfd/ent/match" + "csgowtfd/ent/matchplayer" "csgowtfd/ent/player" "csgowtfd/ent/predicate" - "csgowtfd/ent/stats" "fmt" "time" @@ -188,17 +188,17 @@ func (mu *MatchUpdate) SetNillableGamebanPresent(b *bool) *MatchUpdate { return mu } -// AddStatIDs adds the "stats" edge to the Stats entity by IDs. +// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs. func (mu *MatchUpdate) AddStatIDs(ids ...int) *MatchUpdate { mu.mutation.AddStatIDs(ids...) return mu } -// AddStats adds the "stats" edges to the Stats entity. -func (mu *MatchUpdate) AddStats(s ...*Stats) *MatchUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +// AddStats adds the "stats" edges to the MatchPlayer entity. +func (mu *MatchUpdate) AddStats(m ...*MatchPlayer) *MatchUpdate { + ids := make([]int, len(m)) + for i := range m { + ids[i] = m[i].ID } return mu.AddStatIDs(ids...) } @@ -223,23 +223,23 @@ func (mu *MatchUpdate) Mutation() *MatchMutation { return mu.mutation } -// ClearStats clears all "stats" edges to the Stats entity. +// ClearStats clears all "stats" edges to the MatchPlayer entity. func (mu *MatchUpdate) ClearStats() *MatchUpdate { mu.mutation.ClearStats() return mu } -// RemoveStatIDs removes the "stats" edge to Stats entities by IDs. +// RemoveStatIDs removes the "stats" edge to MatchPlayer entities by IDs. func (mu *MatchUpdate) RemoveStatIDs(ids ...int) *MatchUpdate { mu.mutation.RemoveStatIDs(ids...) return mu } -// RemoveStats removes "stats" edges to Stats entities. -func (mu *MatchUpdate) RemoveStats(s ...*Stats) *MatchUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +// RemoveStats removes "stats" edges to MatchPlayer entities. +func (mu *MatchUpdate) RemoveStats(m ...*MatchPlayer) *MatchUpdate { + ids := make([]int, len(m)) + for i := range m { + ids[i] = m[i].ID } return mu.RemoveStatIDs(ids...) } @@ -478,7 +478,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) { Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } @@ -494,7 +494,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) { Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } @@ -513,7 +513,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) { Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } @@ -754,17 +754,17 @@ func (muo *MatchUpdateOne) SetNillableGamebanPresent(b *bool) *MatchUpdateOne { return muo } -// AddStatIDs adds the "stats" edge to the Stats entity by IDs. +// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs. func (muo *MatchUpdateOne) AddStatIDs(ids ...int) *MatchUpdateOne { muo.mutation.AddStatIDs(ids...) return muo } -// AddStats adds the "stats" edges to the Stats entity. -func (muo *MatchUpdateOne) AddStats(s ...*Stats) *MatchUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +// AddStats adds the "stats" edges to the MatchPlayer entity. +func (muo *MatchUpdateOne) AddStats(m ...*MatchPlayer) *MatchUpdateOne { + ids := make([]int, len(m)) + for i := range m { + ids[i] = m[i].ID } return muo.AddStatIDs(ids...) } @@ -789,23 +789,23 @@ func (muo *MatchUpdateOne) Mutation() *MatchMutation { return muo.mutation } -// ClearStats clears all "stats" edges to the Stats entity. +// ClearStats clears all "stats" edges to the MatchPlayer entity. func (muo *MatchUpdateOne) ClearStats() *MatchUpdateOne { muo.mutation.ClearStats() return muo } -// RemoveStatIDs removes the "stats" edge to Stats entities by IDs. +// RemoveStatIDs removes the "stats" edge to MatchPlayer entities by IDs. func (muo *MatchUpdateOne) RemoveStatIDs(ids ...int) *MatchUpdateOne { muo.mutation.RemoveStatIDs(ids...) return muo } -// RemoveStats removes "stats" edges to Stats entities. -func (muo *MatchUpdateOne) RemoveStats(s ...*Stats) *MatchUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +// RemoveStats removes "stats" edges to MatchPlayer entities. +func (muo *MatchUpdateOne) RemoveStats(m ...*MatchPlayer) *MatchUpdateOne { + ids := make([]int, len(m)) + for i := range m { + ids[i] = m[i].ID } return muo.RemoveStatIDs(ids...) } @@ -1068,7 +1068,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } @@ -1084,7 +1084,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } @@ -1103,7 +1103,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } diff --git a/ent/stats.go b/ent/matchplayer.go similarity index 59% rename from ent/stats.go rename to ent/matchplayer.go index 36ccace..b916e43 100644 --- a/ent/stats.go +++ b/ent/matchplayer.go @@ -4,16 +4,16 @@ package ent import ( "csgowtfd/ent/match" + "csgowtfd/ent/matchplayer" "csgowtfd/ent/player" - "csgowtfd/ent/stats" "fmt" "strings" "entgo.io/ent/dialect/sql" ) -// Stats is the model entity for the Stats schema. -type Stats struct { +// MatchPlayer is the model entity for the MatchPlayer schema. +type MatchPlayer struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` @@ -60,7 +60,7 @@ type Stats struct { // Crosshair holds the value of the "crosshair" field. Crosshair string `json:"crosshair,omitempty"` // Color holds the value of the "color" field. - Color stats.Color `json:"color,omitempty"` + Color matchplayer.Color `json:"color,omitempty"` // Kast holds the value of the "kast" field. Kast int `json:"kast,omitempty"` // FlashDurationSelf holds the value of the "flash_duration_self" field. @@ -79,29 +79,33 @@ type Stats struct { MatchStats uint64 `json:"match_stats,omitempty"` // PlayerStats holds the value of the "player_stats" field. PlayerStats uint64 `json:"player_stats,omitempty"` + // FlashAssists holds the value of the "flash_assists" field. + FlashAssists int `json:"flash_assists,omitempty"` // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the StatsQuery when eager-loading is set. - Edges StatsEdges `json:"edges"` + // The values are being populated by the MatchPlayerQuery when eager-loading is set. + Edges MatchPlayerEdges `json:"edges"` } -// StatsEdges holds the relations/edges for other nodes in the graph. -type StatsEdges struct { +// MatchPlayerEdges holds the relations/edges for other nodes in the graph. +type MatchPlayerEdges struct { // Matches holds the value of the matches edge. Matches *Match `json:"matches,omitempty"` // Players holds the value of the players edge. Players *Player `json:"players,omitempty"` // WeaponStats holds the value of the weapon_stats edge. - WeaponStats []*WeaponStats `json:"weapon_stats,omitempty"` + WeaponStats []*Weapon `json:"weapon_stats,omitempty"` // RoundStats holds the value of the round_stats edge. RoundStats []*RoundStats `json:"round_stats,omitempty"` + // Spray holds the value of the spray edge. + Spray []*Spray `json:"spray,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [4]bool + loadedTypes [5]bool } // MatchesOrErr returns the Matches value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. -func (e StatsEdges) MatchesOrErr() (*Match, error) { +func (e MatchPlayerEdges) MatchesOrErr() (*Match, error) { if e.loadedTypes[0] { if e.Matches == nil { // The edge matches was loaded in eager-loading, @@ -115,7 +119,7 @@ func (e StatsEdges) MatchesOrErr() (*Match, error) { // PlayersOrErr returns the Players value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. -func (e StatsEdges) PlayersOrErr() (*Player, error) { +func (e MatchPlayerEdges) PlayersOrErr() (*Player, error) { if e.loadedTypes[1] { if e.Players == nil { // The edge players was loaded in eager-loading, @@ -129,7 +133,7 @@ func (e StatsEdges) PlayersOrErr() (*Player, error) { // WeaponStatsOrErr returns the WeaponStats value or an error if the edge // was not loaded in eager-loading. -func (e StatsEdges) WeaponStatsOrErr() ([]*WeaponStats, error) { +func (e MatchPlayerEdges) WeaponStatsOrErr() ([]*Weapon, error) { if e.loadedTypes[2] { return e.WeaponStats, nil } @@ -138,350 +142,372 @@ func (e StatsEdges) WeaponStatsOrErr() ([]*WeaponStats, error) { // RoundStatsOrErr returns the RoundStats value or an error if the edge // was not loaded in eager-loading. -func (e StatsEdges) RoundStatsOrErr() ([]*RoundStats, error) { +func (e MatchPlayerEdges) RoundStatsOrErr() ([]*RoundStats, error) { if e.loadedTypes[3] { return e.RoundStats, nil } return nil, &NotLoadedError{edge: "round_stats"} } +// SprayOrErr returns the Spray value or an error if the edge +// was not loaded in eager-loading. +func (e MatchPlayerEdges) SprayOrErr() ([]*Spray, error) { + if e.loadedTypes[4] { + return e.Spray, nil + } + return nil, &NotLoadedError{edge: "spray"} +} + // scanValues returns the types for scanning values from sql.Rows. -func (*Stats) scanValues(columns []string) ([]interface{}, error) { +func (*MatchPlayer) scanValues(columns []string) ([]interface{}, error) { values := make([]interface{}, len(columns)) for i := range columns { switch columns[i] { - case stats.FieldFlashDurationSelf, stats.FieldFlashDurationTeam, stats.FieldFlashDurationEnemy: + case matchplayer.FieldFlashDurationSelf, matchplayer.FieldFlashDurationTeam, matchplayer.FieldFlashDurationEnemy: values[i] = new(sql.NullFloat64) - case stats.FieldID, stats.FieldTeamID, stats.FieldKills, stats.FieldDeaths, stats.FieldAssists, stats.FieldHeadshot, stats.FieldMvp, stats.FieldScore, stats.FieldRankNew, stats.FieldRankOld, stats.FieldMk2, stats.FieldMk3, stats.FieldMk4, stats.FieldMk5, stats.FieldDmgEnemy, stats.FieldDmgTeam, stats.FieldUdHe, stats.FieldUdFlames, stats.FieldUdFlash, stats.FieldUdDecoy, stats.FieldUdSmoke, stats.FieldKast, stats.FieldFlashTotalSelf, stats.FieldFlashTotalTeam, stats.FieldFlashTotalEnemy, stats.FieldMatchStats, stats.FieldPlayerStats: + case matchplayer.FieldID, matchplayer.FieldTeamID, matchplayer.FieldKills, matchplayer.FieldDeaths, matchplayer.FieldAssists, matchplayer.FieldHeadshot, matchplayer.FieldMvp, matchplayer.FieldScore, matchplayer.FieldRankNew, matchplayer.FieldRankOld, matchplayer.FieldMk2, matchplayer.FieldMk3, matchplayer.FieldMk4, matchplayer.FieldMk5, matchplayer.FieldDmgEnemy, matchplayer.FieldDmgTeam, matchplayer.FieldUdHe, matchplayer.FieldUdFlames, matchplayer.FieldUdFlash, matchplayer.FieldUdDecoy, matchplayer.FieldUdSmoke, matchplayer.FieldKast, matchplayer.FieldFlashTotalSelf, matchplayer.FieldFlashTotalTeam, matchplayer.FieldFlashTotalEnemy, matchplayer.FieldMatchStats, matchplayer.FieldPlayerStats, matchplayer.FieldFlashAssists: values[i] = new(sql.NullInt64) - case stats.FieldCrosshair, stats.FieldColor: + case matchplayer.FieldCrosshair, matchplayer.FieldColor: values[i] = new(sql.NullString) default: - return nil, fmt.Errorf("unexpected column %q for type Stats", columns[i]) + return nil, fmt.Errorf("unexpected column %q for type MatchPlayer", columns[i]) } } return values, nil } // assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the Stats fields. -func (s *Stats) assignValues(columns []string, values []interface{}) error { +// to the MatchPlayer fields. +func (mp *MatchPlayer) assignValues(columns []string, values []interface{}) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } for i := range columns { switch columns[i] { - case stats.FieldID: + case matchplayer.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - s.ID = int(value.Int64) - case stats.FieldTeamID: + mp.ID = int(value.Int64) + case matchplayer.FieldTeamID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field team_id", values[i]) } else if value.Valid { - s.TeamID = int(value.Int64) + mp.TeamID = int(value.Int64) } - case stats.FieldKills: + case matchplayer.FieldKills: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field kills", values[i]) } else if value.Valid { - s.Kills = int(value.Int64) + mp.Kills = int(value.Int64) } - case stats.FieldDeaths: + case matchplayer.FieldDeaths: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field deaths", values[i]) } else if value.Valid { - s.Deaths = int(value.Int64) + mp.Deaths = int(value.Int64) } - case stats.FieldAssists: + case matchplayer.FieldAssists: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field assists", values[i]) } else if value.Valid { - s.Assists = int(value.Int64) + mp.Assists = int(value.Int64) } - case stats.FieldHeadshot: + case matchplayer.FieldHeadshot: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field headshot", values[i]) } else if value.Valid { - s.Headshot = int(value.Int64) + mp.Headshot = int(value.Int64) } - case stats.FieldMvp: + case matchplayer.FieldMvp: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field mvp", values[i]) } else if value.Valid { - s.Mvp = uint(value.Int64) + mp.Mvp = uint(value.Int64) } - case stats.FieldScore: + case matchplayer.FieldScore: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field score", values[i]) } else if value.Valid { - s.Score = int(value.Int64) + mp.Score = int(value.Int64) } - case stats.FieldRankNew: + case matchplayer.FieldRankNew: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field rank_new", values[i]) } else if value.Valid { - s.RankNew = int(value.Int64) + mp.RankNew = int(value.Int64) } - case stats.FieldRankOld: + case matchplayer.FieldRankOld: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field rank_old", values[i]) } else if value.Valid { - s.RankOld = int(value.Int64) + mp.RankOld = int(value.Int64) } - case stats.FieldMk2: + case matchplayer.FieldMk2: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field mk_2", values[i]) } else if value.Valid { - s.Mk2 = uint(value.Int64) + mp.Mk2 = uint(value.Int64) } - case stats.FieldMk3: + case matchplayer.FieldMk3: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field mk_3", values[i]) } else if value.Valid { - s.Mk3 = uint(value.Int64) + mp.Mk3 = uint(value.Int64) } - case stats.FieldMk4: + case matchplayer.FieldMk4: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field mk_4", values[i]) } else if value.Valid { - s.Mk4 = uint(value.Int64) + mp.Mk4 = uint(value.Int64) } - case stats.FieldMk5: + case matchplayer.FieldMk5: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field mk_5", values[i]) } else if value.Valid { - s.Mk5 = uint(value.Int64) + mp.Mk5 = uint(value.Int64) } - case stats.FieldDmgEnemy: + case matchplayer.FieldDmgEnemy: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field dmg_enemy", values[i]) } else if value.Valid { - s.DmgEnemy = uint(value.Int64) + mp.DmgEnemy = uint(value.Int64) } - case stats.FieldDmgTeam: + case matchplayer.FieldDmgTeam: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field dmg_team", values[i]) } else if value.Valid { - s.DmgTeam = uint(value.Int64) + mp.DmgTeam = uint(value.Int64) } - case stats.FieldUdHe: + case matchplayer.FieldUdHe: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field ud_he", values[i]) } else if value.Valid { - s.UdHe = uint(value.Int64) + mp.UdHe = uint(value.Int64) } - case stats.FieldUdFlames: + case matchplayer.FieldUdFlames: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field ud_flames", values[i]) } else if value.Valid { - s.UdFlames = uint(value.Int64) + mp.UdFlames = uint(value.Int64) } - case stats.FieldUdFlash: + case matchplayer.FieldUdFlash: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field ud_flash", values[i]) } else if value.Valid { - s.UdFlash = uint(value.Int64) + mp.UdFlash = uint(value.Int64) } - case stats.FieldUdDecoy: + case matchplayer.FieldUdDecoy: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field ud_decoy", values[i]) } else if value.Valid { - s.UdDecoy = uint(value.Int64) + mp.UdDecoy = uint(value.Int64) } - case stats.FieldUdSmoke: + case matchplayer.FieldUdSmoke: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field ud_smoke", values[i]) } else if value.Valid { - s.UdSmoke = uint(value.Int64) + mp.UdSmoke = uint(value.Int64) } - case stats.FieldCrosshair: + case matchplayer.FieldCrosshair: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field crosshair", values[i]) } else if value.Valid { - s.Crosshair = value.String + mp.Crosshair = value.String } - case stats.FieldColor: + case matchplayer.FieldColor: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field color", values[i]) } else if value.Valid { - s.Color = stats.Color(value.String) + mp.Color = matchplayer.Color(value.String) } - case stats.FieldKast: + case matchplayer.FieldKast: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field kast", values[i]) } else if value.Valid { - s.Kast = int(value.Int64) + mp.Kast = int(value.Int64) } - case stats.FieldFlashDurationSelf: + case matchplayer.FieldFlashDurationSelf: if value, ok := values[i].(*sql.NullFloat64); !ok { return fmt.Errorf("unexpected type %T for field flash_duration_self", values[i]) } else if value.Valid { - s.FlashDurationSelf = float32(value.Float64) + mp.FlashDurationSelf = float32(value.Float64) } - case stats.FieldFlashDurationTeam: + case matchplayer.FieldFlashDurationTeam: if value, ok := values[i].(*sql.NullFloat64); !ok { return fmt.Errorf("unexpected type %T for field flash_duration_team", values[i]) } else if value.Valid { - s.FlashDurationTeam = float32(value.Float64) + mp.FlashDurationTeam = float32(value.Float64) } - case stats.FieldFlashDurationEnemy: + case matchplayer.FieldFlashDurationEnemy: if value, ok := values[i].(*sql.NullFloat64); !ok { return fmt.Errorf("unexpected type %T for field flash_duration_enemy", values[i]) } else if value.Valid { - s.FlashDurationEnemy = float32(value.Float64) + mp.FlashDurationEnemy = float32(value.Float64) } - case stats.FieldFlashTotalSelf: + case matchplayer.FieldFlashTotalSelf: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field flash_total_self", values[i]) } else if value.Valid { - s.FlashTotalSelf = uint(value.Int64) + mp.FlashTotalSelf = uint(value.Int64) } - case stats.FieldFlashTotalTeam: + case matchplayer.FieldFlashTotalTeam: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field flash_total_team", values[i]) } else if value.Valid { - s.FlashTotalTeam = uint(value.Int64) + mp.FlashTotalTeam = uint(value.Int64) } - case stats.FieldFlashTotalEnemy: + case matchplayer.FieldFlashTotalEnemy: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field flash_total_enemy", values[i]) } else if value.Valid { - s.FlashTotalEnemy = uint(value.Int64) + mp.FlashTotalEnemy = uint(value.Int64) } - case stats.FieldMatchStats: + case matchplayer.FieldMatchStats: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field match_stats", values[i]) } else if value.Valid { - s.MatchStats = uint64(value.Int64) + mp.MatchStats = uint64(value.Int64) } - case stats.FieldPlayerStats: + case matchplayer.FieldPlayerStats: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field player_stats", values[i]) } else if value.Valid { - s.PlayerStats = uint64(value.Int64) + mp.PlayerStats = uint64(value.Int64) + } + case matchplayer.FieldFlashAssists: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field flash_assists", values[i]) + } else if value.Valid { + mp.FlashAssists = int(value.Int64) } } } return nil } -// QueryMatches queries the "matches" edge of the Stats entity. -func (s *Stats) QueryMatches() *MatchQuery { - return (&StatsClient{config: s.config}).QueryMatches(s) +// QueryMatches queries the "matches" edge of the MatchPlayer entity. +func (mp *MatchPlayer) QueryMatches() *MatchQuery { + return (&MatchPlayerClient{config: mp.config}).QueryMatches(mp) } -// QueryPlayers queries the "players" edge of the Stats entity. -func (s *Stats) QueryPlayers() *PlayerQuery { - return (&StatsClient{config: s.config}).QueryPlayers(s) +// QueryPlayers queries the "players" edge of the MatchPlayer entity. +func (mp *MatchPlayer) QueryPlayers() *PlayerQuery { + return (&MatchPlayerClient{config: mp.config}).QueryPlayers(mp) } -// QueryWeaponStats queries the "weapon_stats" edge of the Stats entity. -func (s *Stats) QueryWeaponStats() *WeaponStatsQuery { - return (&StatsClient{config: s.config}).QueryWeaponStats(s) +// QueryWeaponStats queries the "weapon_stats" edge of the MatchPlayer entity. +func (mp *MatchPlayer) QueryWeaponStats() *WeaponQuery { + return (&MatchPlayerClient{config: mp.config}).QueryWeaponStats(mp) } -// QueryRoundStats queries the "round_stats" edge of the Stats entity. -func (s *Stats) QueryRoundStats() *RoundStatsQuery { - return (&StatsClient{config: s.config}).QueryRoundStats(s) +// QueryRoundStats queries the "round_stats" edge of the MatchPlayer entity. +func (mp *MatchPlayer) QueryRoundStats() *RoundStatsQuery { + return (&MatchPlayerClient{config: mp.config}).QueryRoundStats(mp) } -// Update returns a builder for updating this Stats. -// Note that you need to call Stats.Unwrap() before calling this method if this Stats +// QuerySpray queries the "spray" edge of the MatchPlayer entity. +func (mp *MatchPlayer) QuerySpray() *SprayQuery { + return (&MatchPlayerClient{config: mp.config}).QuerySpray(mp) +} + +// Update returns a builder for updating this MatchPlayer. +// Note that you need to call MatchPlayer.Unwrap() before calling this method if this MatchPlayer // was returned from a transaction, and the transaction was committed or rolled back. -func (s *Stats) Update() *StatsUpdateOne { - return (&StatsClient{config: s.config}).UpdateOne(s) +func (mp *MatchPlayer) Update() *MatchPlayerUpdateOne { + return (&MatchPlayerClient{config: mp.config}).UpdateOne(mp) } -// Unwrap unwraps the Stats entity that was returned from a transaction after it was closed, +// Unwrap unwraps the MatchPlayer entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (s *Stats) Unwrap() *Stats { - tx, ok := s.config.driver.(*txDriver) +func (mp *MatchPlayer) Unwrap() *MatchPlayer { + tx, ok := mp.config.driver.(*txDriver) if !ok { - panic("ent: Stats is not a transactional entity") + panic("ent: MatchPlayer is not a transactional entity") } - s.config.driver = tx.drv - return s + mp.config.driver = tx.drv + return mp } // String implements the fmt.Stringer. -func (s *Stats) String() string { +func (mp *MatchPlayer) String() string { var builder strings.Builder - builder.WriteString("Stats(") - builder.WriteString(fmt.Sprintf("id=%v", s.ID)) + builder.WriteString("MatchPlayer(") + builder.WriteString(fmt.Sprintf("id=%v", mp.ID)) builder.WriteString(", team_id=") - builder.WriteString(fmt.Sprintf("%v", s.TeamID)) + builder.WriteString(fmt.Sprintf("%v", mp.TeamID)) builder.WriteString(", kills=") - builder.WriteString(fmt.Sprintf("%v", s.Kills)) + builder.WriteString(fmt.Sprintf("%v", mp.Kills)) builder.WriteString(", deaths=") - builder.WriteString(fmt.Sprintf("%v", s.Deaths)) + builder.WriteString(fmt.Sprintf("%v", mp.Deaths)) builder.WriteString(", assists=") - builder.WriteString(fmt.Sprintf("%v", s.Assists)) + builder.WriteString(fmt.Sprintf("%v", mp.Assists)) builder.WriteString(", headshot=") - builder.WriteString(fmt.Sprintf("%v", s.Headshot)) + builder.WriteString(fmt.Sprintf("%v", mp.Headshot)) builder.WriteString(", mvp=") - builder.WriteString(fmt.Sprintf("%v", s.Mvp)) + builder.WriteString(fmt.Sprintf("%v", mp.Mvp)) builder.WriteString(", score=") - builder.WriteString(fmt.Sprintf("%v", s.Score)) + builder.WriteString(fmt.Sprintf("%v", mp.Score)) builder.WriteString(", rank_new=") - builder.WriteString(fmt.Sprintf("%v", s.RankNew)) + builder.WriteString(fmt.Sprintf("%v", mp.RankNew)) builder.WriteString(", rank_old=") - builder.WriteString(fmt.Sprintf("%v", s.RankOld)) + builder.WriteString(fmt.Sprintf("%v", mp.RankOld)) builder.WriteString(", mk_2=") - builder.WriteString(fmt.Sprintf("%v", s.Mk2)) + builder.WriteString(fmt.Sprintf("%v", mp.Mk2)) builder.WriteString(", mk_3=") - builder.WriteString(fmt.Sprintf("%v", s.Mk3)) + builder.WriteString(fmt.Sprintf("%v", mp.Mk3)) builder.WriteString(", mk_4=") - builder.WriteString(fmt.Sprintf("%v", s.Mk4)) + builder.WriteString(fmt.Sprintf("%v", mp.Mk4)) builder.WriteString(", mk_5=") - builder.WriteString(fmt.Sprintf("%v", s.Mk5)) + builder.WriteString(fmt.Sprintf("%v", mp.Mk5)) builder.WriteString(", dmg_enemy=") - builder.WriteString(fmt.Sprintf("%v", s.DmgEnemy)) + builder.WriteString(fmt.Sprintf("%v", mp.DmgEnemy)) builder.WriteString(", dmg_team=") - builder.WriteString(fmt.Sprintf("%v", s.DmgTeam)) + builder.WriteString(fmt.Sprintf("%v", mp.DmgTeam)) builder.WriteString(", ud_he=") - builder.WriteString(fmt.Sprintf("%v", s.UdHe)) + builder.WriteString(fmt.Sprintf("%v", mp.UdHe)) builder.WriteString(", ud_flames=") - builder.WriteString(fmt.Sprintf("%v", s.UdFlames)) + builder.WriteString(fmt.Sprintf("%v", mp.UdFlames)) builder.WriteString(", ud_flash=") - builder.WriteString(fmt.Sprintf("%v", s.UdFlash)) + builder.WriteString(fmt.Sprintf("%v", mp.UdFlash)) builder.WriteString(", ud_decoy=") - builder.WriteString(fmt.Sprintf("%v", s.UdDecoy)) + builder.WriteString(fmt.Sprintf("%v", mp.UdDecoy)) builder.WriteString(", ud_smoke=") - builder.WriteString(fmt.Sprintf("%v", s.UdSmoke)) + builder.WriteString(fmt.Sprintf("%v", mp.UdSmoke)) builder.WriteString(", crosshair=") - builder.WriteString(s.Crosshair) + builder.WriteString(mp.Crosshair) builder.WriteString(", color=") - builder.WriteString(fmt.Sprintf("%v", s.Color)) + builder.WriteString(fmt.Sprintf("%v", mp.Color)) builder.WriteString(", kast=") - builder.WriteString(fmt.Sprintf("%v", s.Kast)) + builder.WriteString(fmt.Sprintf("%v", mp.Kast)) builder.WriteString(", flash_duration_self=") - builder.WriteString(fmt.Sprintf("%v", s.FlashDurationSelf)) + builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationSelf)) builder.WriteString(", flash_duration_team=") - builder.WriteString(fmt.Sprintf("%v", s.FlashDurationTeam)) + builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationTeam)) builder.WriteString(", flash_duration_enemy=") - builder.WriteString(fmt.Sprintf("%v", s.FlashDurationEnemy)) + builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationEnemy)) builder.WriteString(", flash_total_self=") - builder.WriteString(fmt.Sprintf("%v", s.FlashTotalSelf)) + builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalSelf)) builder.WriteString(", flash_total_team=") - builder.WriteString(fmt.Sprintf("%v", s.FlashTotalTeam)) + builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalTeam)) builder.WriteString(", flash_total_enemy=") - builder.WriteString(fmt.Sprintf("%v", s.FlashTotalEnemy)) + builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalEnemy)) builder.WriteString(", match_stats=") - builder.WriteString(fmt.Sprintf("%v", s.MatchStats)) + builder.WriteString(fmt.Sprintf("%v", mp.MatchStats)) builder.WriteString(", player_stats=") - builder.WriteString(fmt.Sprintf("%v", s.PlayerStats)) + builder.WriteString(fmt.Sprintf("%v", mp.PlayerStats)) + builder.WriteString(", flash_assists=") + builder.WriteString(fmt.Sprintf("%v", mp.FlashAssists)) builder.WriteByte(')') return builder.String() } -// StatsSlice is a parsable slice of Stats. -type StatsSlice []*Stats +// MatchPlayers is a parsable slice of MatchPlayer. +type MatchPlayers []*MatchPlayer -func (s StatsSlice) config(cfg config) { - for _i := range s { - s[_i].config = cfg +func (mp MatchPlayers) config(cfg config) { + for _i := range mp { + mp[_i].config = cfg } } diff --git a/ent/stats/stats.go b/ent/matchplayer/matchplayer.go similarity index 83% rename from ent/stats/stats.go rename to ent/matchplayer/matchplayer.go index 4e9e33e..4732e85 100644 --- a/ent/stats/stats.go +++ b/ent/matchplayer/matchplayer.go @@ -1,14 +1,14 @@ // Code generated by entc, DO NOT EDIT. -package stats +package matchplayer import ( "fmt" ) const ( - // Label holds the string label denoting the stats type in the database. - Label = "stats" + // Label holds the string label denoting the matchplayer type in the database. + Label = "match_player" // FieldID holds the string denoting the id field in the database. FieldID = "id" // FieldTeamID holds the string denoting the team_id field in the database. @@ -73,6 +73,8 @@ const ( FieldMatchStats = "match_stats" // FieldPlayerStats holds the string denoting the player_stats field in the database. FieldPlayerStats = "player_stats" + // FieldFlashAssists holds the string denoting the flash_assists field in the database. + FieldFlashAssists = "flash_assists" // EdgeMatches holds the string denoting the matches edge name in mutations. EdgeMatches = "matches" // EdgePlayers holds the string denoting the players edge name in mutations. @@ -81,39 +83,48 @@ const ( EdgeWeaponStats = "weapon_stats" // EdgeRoundStats holds the string denoting the round_stats edge name in mutations. EdgeRoundStats = "round_stats" - // Table holds the table name of the stats in the database. - Table = "stats" + // EdgeSpray holds the string denoting the spray edge name in mutations. + EdgeSpray = "spray" + // Table holds the table name of the matchplayer in the database. + Table = "match_players" // MatchesTable is the table that holds the matches relation/edge. - MatchesTable = "stats" + MatchesTable = "match_players" // MatchesInverseTable is the table name for the Match entity. // It exists in this package in order to avoid circular dependency with the "match" package. MatchesInverseTable = "matches" // MatchesColumn is the table column denoting the matches relation/edge. MatchesColumn = "match_stats" // PlayersTable is the table that holds the players relation/edge. - PlayersTable = "stats" + PlayersTable = "match_players" // PlayersInverseTable is the table name for the Player entity. // It exists in this package in order to avoid circular dependency with the "player" package. PlayersInverseTable = "players" // PlayersColumn is the table column denoting the players relation/edge. PlayersColumn = "player_stats" // WeaponStatsTable is the table that holds the weapon_stats relation/edge. - WeaponStatsTable = "weapon_stats" - // WeaponStatsInverseTable is the table name for the WeaponStats entity. - // It exists in this package in order to avoid circular dependency with the "weaponstats" package. - WeaponStatsInverseTable = "weapon_stats" + WeaponStatsTable = "weapons" + // WeaponStatsInverseTable is the table name for the Weapon entity. + // It exists in this package in order to avoid circular dependency with the "weapon" package. + WeaponStatsInverseTable = "weapons" // WeaponStatsColumn is the table column denoting the weapon_stats relation/edge. - WeaponStatsColumn = "stats_weapon_stats" + WeaponStatsColumn = "match_player_weapon_stats" // RoundStatsTable is the table that holds the round_stats relation/edge. RoundStatsTable = "round_stats" // RoundStatsInverseTable is the table name for the RoundStats entity. // It exists in this package in order to avoid circular dependency with the "roundstats" package. RoundStatsInverseTable = "round_stats" // RoundStatsColumn is the table column denoting the round_stats relation/edge. - RoundStatsColumn = "stats_round_stats" + RoundStatsColumn = "match_player_round_stats" + // SprayTable is the table that holds the spray relation/edge. + SprayTable = "sprays" + // SprayInverseTable is the table name for the Spray entity. + // It exists in this package in order to avoid circular dependency with the "spray" package. + SprayInverseTable = "sprays" + // SprayColumn is the table column denoting the spray relation/edge. + SprayColumn = "match_player_spray" ) -// Columns holds all SQL columns for stats fields. +// Columns holds all SQL columns for matchplayer fields. var Columns = []string{ FieldID, FieldTeamID, @@ -147,6 +158,7 @@ var Columns = []string{ FieldFlashTotalEnemy, FieldMatchStats, FieldPlayerStats, + FieldFlashAssists, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -182,6 +194,6 @@ func ColorValidator(c Color) error { case ColorGreen, ColorYellow, ColorPurple, ColorBlue, ColorOrange, ColorGrey: return nil default: - return fmt.Errorf("stats: invalid enum value for color field: %q", c) + return fmt.Errorf("matchplayer: invalid enum value for color field: %q", c) } } diff --git a/ent/stats/where.go b/ent/matchplayer/where.go similarity index 60% rename from ent/stats/where.go rename to ent/matchplayer/where.go index bd8a6b5..0cbd3ff 100644 --- a/ent/stats/where.go +++ b/ent/matchplayer/where.go @@ -1,6 +1,6 @@ // Code generated by entc, DO NOT EDIT. -package stats +package matchplayer import ( "csgowtfd/ent/predicate" @@ -10,29 +10,29 @@ import ( ) // ID filters vertices based on their ID field. -func ID(id int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func ID(id int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldID), id)) }) } // IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func IDEQ(id int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldID), id)) }) } // IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func IDNEQ(id int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldID), id)) }) } // IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func IDIn(ids ...int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(ids) == 0 { @@ -48,8 +48,8 @@ func IDIn(ids ...int) predicate.Stats { } // IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func IDNotIn(ids ...int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(ids) == 0 { @@ -65,264 +65,271 @@ func IDNotIn(ids ...int) predicate.Stats { } // IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func IDGT(id int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldID), id)) }) } // IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func IDGTE(id int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldID), id)) }) } // IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func IDLT(id int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldID), id)) }) } // IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func IDLTE(id int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldID), id)) }) } // TeamID applies equality check predicate on the "team_id" field. It's identical to TeamIDEQ. -func TeamID(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func TeamID(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldTeamID), v)) }) } // Kills applies equality check predicate on the "kills" field. It's identical to KillsEQ. -func Kills(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Kills(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldKills), v)) }) } // Deaths applies equality check predicate on the "deaths" field. It's identical to DeathsEQ. -func Deaths(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Deaths(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldDeaths), v)) }) } // Assists applies equality check predicate on the "assists" field. It's identical to AssistsEQ. -func Assists(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Assists(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldAssists), v)) }) } // Headshot applies equality check predicate on the "headshot" field. It's identical to HeadshotEQ. -func Headshot(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Headshot(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldHeadshot), v)) }) } // Mvp applies equality check predicate on the "mvp" field. It's identical to MvpEQ. -func Mvp(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mvp(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldMvp), v)) }) } // Score applies equality check predicate on the "score" field. It's identical to ScoreEQ. -func Score(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Score(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldScore), v)) }) } // RankNew applies equality check predicate on the "rank_new" field. It's identical to RankNewEQ. -func RankNew(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankNew(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldRankNew), v)) }) } // RankOld applies equality check predicate on the "rank_old" field. It's identical to RankOldEQ. -func RankOld(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankOld(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldRankOld), v)) }) } // Mk2 applies equality check predicate on the "mk_2" field. It's identical to Mk2EQ. -func Mk2(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk2(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldMk2), v)) }) } // Mk3 applies equality check predicate on the "mk_3" field. It's identical to Mk3EQ. -func Mk3(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk3(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldMk3), v)) }) } // Mk4 applies equality check predicate on the "mk_4" field. It's identical to Mk4EQ. -func Mk4(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk4(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldMk4), v)) }) } // Mk5 applies equality check predicate on the "mk_5" field. It's identical to Mk5EQ. -func Mk5(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk5(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldMk5), v)) }) } // DmgEnemy applies equality check predicate on the "dmg_enemy" field. It's identical to DmgEnemyEQ. -func DmgEnemy(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgEnemy(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldDmgEnemy), v)) }) } // DmgTeam applies equality check predicate on the "dmg_team" field. It's identical to DmgTeamEQ. -func DmgTeam(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgTeam(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldDmgTeam), v)) }) } // UdHe applies equality check predicate on the "ud_he" field. It's identical to UdHeEQ. -func UdHe(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdHe(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldUdHe), v)) }) } // UdFlames applies equality check predicate on the "ud_flames" field. It's identical to UdFlamesEQ. -func UdFlames(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlames(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldUdFlames), v)) }) } // UdFlash applies equality check predicate on the "ud_flash" field. It's identical to UdFlashEQ. -func UdFlash(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlash(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldUdFlash), v)) }) } // UdDecoy applies equality check predicate on the "ud_decoy" field. It's identical to UdDecoyEQ. -func UdDecoy(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdDecoy(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldUdDecoy), v)) }) } // UdSmoke applies equality check predicate on the "ud_smoke" field. It's identical to UdSmokeEQ. -func UdSmoke(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdSmoke(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldUdSmoke), v)) }) } // Crosshair applies equality check predicate on the "crosshair" field. It's identical to CrosshairEQ. -func Crosshair(v string) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Crosshair(v string) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldCrosshair), v)) }) } // Kast applies equality check predicate on the "kast" field. It's identical to KastEQ. -func Kast(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Kast(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldKast), v)) }) } // FlashDurationSelf applies equality check predicate on the "flash_duration_self" field. It's identical to FlashDurationSelfEQ. -func FlashDurationSelf(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationSelf(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldFlashDurationSelf), v)) }) } // FlashDurationTeam applies equality check predicate on the "flash_duration_team" field. It's identical to FlashDurationTeamEQ. -func FlashDurationTeam(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationTeam(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldFlashDurationTeam), v)) }) } // FlashDurationEnemy applies equality check predicate on the "flash_duration_enemy" field. It's identical to FlashDurationEnemyEQ. -func FlashDurationEnemy(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationEnemy(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldFlashDurationEnemy), v)) }) } // FlashTotalSelf applies equality check predicate on the "flash_total_self" field. It's identical to FlashTotalSelfEQ. -func FlashTotalSelf(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalSelf(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldFlashTotalSelf), v)) }) } // FlashTotalTeam applies equality check predicate on the "flash_total_team" field. It's identical to FlashTotalTeamEQ. -func FlashTotalTeam(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalTeam(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldFlashTotalTeam), v)) }) } // FlashTotalEnemy applies equality check predicate on the "flash_total_enemy" field. It's identical to FlashTotalEnemyEQ. -func FlashTotalEnemy(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalEnemy(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldFlashTotalEnemy), v)) }) } // MatchStats applies equality check predicate on the "match_stats" field. It's identical to MatchStatsEQ. -func MatchStats(v uint64) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func MatchStats(v uint64) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldMatchStats), v)) }) } // PlayerStats applies equality check predicate on the "player_stats" field. It's identical to PlayerStatsEQ. -func PlayerStats(v uint64) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func PlayerStats(v uint64) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldPlayerStats), v)) }) } +// FlashAssists applies equality check predicate on the "flash_assists" field. It's identical to FlashAssistsEQ. +func FlashAssists(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldFlashAssists), v)) + }) +} + // TeamIDEQ applies the EQ predicate on the "team_id" field. -func TeamIDEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func TeamIDEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldTeamID), v)) }) } // TeamIDNEQ applies the NEQ predicate on the "team_id" field. -func TeamIDNEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func TeamIDNEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldTeamID), v)) }) } // TeamIDIn applies the In predicate on the "team_id" field. -func TeamIDIn(vs ...int) predicate.Stats { +func TeamIDIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -334,12 +341,12 @@ func TeamIDIn(vs ...int) predicate.Stats { } // TeamIDNotIn applies the NotIn predicate on the "team_id" field. -func TeamIDNotIn(vs ...int) predicate.Stats { +func TeamIDNotIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -351,54 +358,54 @@ func TeamIDNotIn(vs ...int) predicate.Stats { } // TeamIDGT applies the GT predicate on the "team_id" field. -func TeamIDGT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func TeamIDGT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldTeamID), v)) }) } // TeamIDGTE applies the GTE predicate on the "team_id" field. -func TeamIDGTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func TeamIDGTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldTeamID), v)) }) } // TeamIDLT applies the LT predicate on the "team_id" field. -func TeamIDLT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func TeamIDLT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldTeamID), v)) }) } // TeamIDLTE applies the LTE predicate on the "team_id" field. -func TeamIDLTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func TeamIDLTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldTeamID), v)) }) } // KillsEQ applies the EQ predicate on the "kills" field. -func KillsEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func KillsEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldKills), v)) }) } // KillsNEQ applies the NEQ predicate on the "kills" field. -func KillsNEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func KillsNEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldKills), v)) }) } // KillsIn applies the In predicate on the "kills" field. -func KillsIn(vs ...int) predicate.Stats { +func KillsIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -410,12 +417,12 @@ func KillsIn(vs ...int) predicate.Stats { } // KillsNotIn applies the NotIn predicate on the "kills" field. -func KillsNotIn(vs ...int) predicate.Stats { +func KillsNotIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -427,54 +434,54 @@ func KillsNotIn(vs ...int) predicate.Stats { } // KillsGT applies the GT predicate on the "kills" field. -func KillsGT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func KillsGT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldKills), v)) }) } // KillsGTE applies the GTE predicate on the "kills" field. -func KillsGTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func KillsGTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldKills), v)) }) } // KillsLT applies the LT predicate on the "kills" field. -func KillsLT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func KillsLT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldKills), v)) }) } // KillsLTE applies the LTE predicate on the "kills" field. -func KillsLTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func KillsLTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldKills), v)) }) } // DeathsEQ applies the EQ predicate on the "deaths" field. -func DeathsEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DeathsEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldDeaths), v)) }) } // DeathsNEQ applies the NEQ predicate on the "deaths" field. -func DeathsNEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DeathsNEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldDeaths), v)) }) } // DeathsIn applies the In predicate on the "deaths" field. -func DeathsIn(vs ...int) predicate.Stats { +func DeathsIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -486,12 +493,12 @@ func DeathsIn(vs ...int) predicate.Stats { } // DeathsNotIn applies the NotIn predicate on the "deaths" field. -func DeathsNotIn(vs ...int) predicate.Stats { +func DeathsNotIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -503,54 +510,54 @@ func DeathsNotIn(vs ...int) predicate.Stats { } // DeathsGT applies the GT predicate on the "deaths" field. -func DeathsGT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DeathsGT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldDeaths), v)) }) } // DeathsGTE applies the GTE predicate on the "deaths" field. -func DeathsGTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DeathsGTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldDeaths), v)) }) } // DeathsLT applies the LT predicate on the "deaths" field. -func DeathsLT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DeathsLT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldDeaths), v)) }) } // DeathsLTE applies the LTE predicate on the "deaths" field. -func DeathsLTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DeathsLTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldDeaths), v)) }) } // AssistsEQ applies the EQ predicate on the "assists" field. -func AssistsEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func AssistsEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldAssists), v)) }) } // AssistsNEQ applies the NEQ predicate on the "assists" field. -func AssistsNEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func AssistsNEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldAssists), v)) }) } // AssistsIn applies the In predicate on the "assists" field. -func AssistsIn(vs ...int) predicate.Stats { +func AssistsIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -562,12 +569,12 @@ func AssistsIn(vs ...int) predicate.Stats { } // AssistsNotIn applies the NotIn predicate on the "assists" field. -func AssistsNotIn(vs ...int) predicate.Stats { +func AssistsNotIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -579,54 +586,54 @@ func AssistsNotIn(vs ...int) predicate.Stats { } // AssistsGT applies the GT predicate on the "assists" field. -func AssistsGT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func AssistsGT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldAssists), v)) }) } // AssistsGTE applies the GTE predicate on the "assists" field. -func AssistsGTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func AssistsGTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldAssists), v)) }) } // AssistsLT applies the LT predicate on the "assists" field. -func AssistsLT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func AssistsLT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldAssists), v)) }) } // AssistsLTE applies the LTE predicate on the "assists" field. -func AssistsLTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func AssistsLTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldAssists), v)) }) } // HeadshotEQ applies the EQ predicate on the "headshot" field. -func HeadshotEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func HeadshotEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldHeadshot), v)) }) } // HeadshotNEQ applies the NEQ predicate on the "headshot" field. -func HeadshotNEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func HeadshotNEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldHeadshot), v)) }) } // HeadshotIn applies the In predicate on the "headshot" field. -func HeadshotIn(vs ...int) predicate.Stats { +func HeadshotIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -638,12 +645,12 @@ func HeadshotIn(vs ...int) predicate.Stats { } // HeadshotNotIn applies the NotIn predicate on the "headshot" field. -func HeadshotNotIn(vs ...int) predicate.Stats { +func HeadshotNotIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -655,54 +662,54 @@ func HeadshotNotIn(vs ...int) predicate.Stats { } // HeadshotGT applies the GT predicate on the "headshot" field. -func HeadshotGT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func HeadshotGT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldHeadshot), v)) }) } // HeadshotGTE applies the GTE predicate on the "headshot" field. -func HeadshotGTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func HeadshotGTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldHeadshot), v)) }) } // HeadshotLT applies the LT predicate on the "headshot" field. -func HeadshotLT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func HeadshotLT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldHeadshot), v)) }) } // HeadshotLTE applies the LTE predicate on the "headshot" field. -func HeadshotLTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func HeadshotLTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldHeadshot), v)) }) } // MvpEQ applies the EQ predicate on the "mvp" field. -func MvpEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func MvpEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldMvp), v)) }) } // MvpNEQ applies the NEQ predicate on the "mvp" field. -func MvpNEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func MvpNEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldMvp), v)) }) } // MvpIn applies the In predicate on the "mvp" field. -func MvpIn(vs ...uint) predicate.Stats { +func MvpIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -714,12 +721,12 @@ func MvpIn(vs ...uint) predicate.Stats { } // MvpNotIn applies the NotIn predicate on the "mvp" field. -func MvpNotIn(vs ...uint) predicate.Stats { +func MvpNotIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -731,54 +738,54 @@ func MvpNotIn(vs ...uint) predicate.Stats { } // MvpGT applies the GT predicate on the "mvp" field. -func MvpGT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func MvpGT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldMvp), v)) }) } // MvpGTE applies the GTE predicate on the "mvp" field. -func MvpGTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func MvpGTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldMvp), v)) }) } // MvpLT applies the LT predicate on the "mvp" field. -func MvpLT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func MvpLT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldMvp), v)) }) } // MvpLTE applies the LTE predicate on the "mvp" field. -func MvpLTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func MvpLTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldMvp), v)) }) } // ScoreEQ applies the EQ predicate on the "score" field. -func ScoreEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func ScoreEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldScore), v)) }) } // ScoreNEQ applies the NEQ predicate on the "score" field. -func ScoreNEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func ScoreNEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldScore), v)) }) } // ScoreIn applies the In predicate on the "score" field. -func ScoreIn(vs ...int) predicate.Stats { +func ScoreIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -790,12 +797,12 @@ func ScoreIn(vs ...int) predicate.Stats { } // ScoreNotIn applies the NotIn predicate on the "score" field. -func ScoreNotIn(vs ...int) predicate.Stats { +func ScoreNotIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -807,54 +814,54 @@ func ScoreNotIn(vs ...int) predicate.Stats { } // ScoreGT applies the GT predicate on the "score" field. -func ScoreGT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func ScoreGT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldScore), v)) }) } // ScoreGTE applies the GTE predicate on the "score" field. -func ScoreGTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func ScoreGTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldScore), v)) }) } // ScoreLT applies the LT predicate on the "score" field. -func ScoreLT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func ScoreLT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldScore), v)) }) } // ScoreLTE applies the LTE predicate on the "score" field. -func ScoreLTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func ScoreLTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldScore), v)) }) } // RankNewEQ applies the EQ predicate on the "rank_new" field. -func RankNewEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankNewEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldRankNew), v)) }) } // RankNewNEQ applies the NEQ predicate on the "rank_new" field. -func RankNewNEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankNewNEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldRankNew), v)) }) } // RankNewIn applies the In predicate on the "rank_new" field. -func RankNewIn(vs ...int) predicate.Stats { +func RankNewIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -866,12 +873,12 @@ func RankNewIn(vs ...int) predicate.Stats { } // RankNewNotIn applies the NotIn predicate on the "rank_new" field. -func RankNewNotIn(vs ...int) predicate.Stats { +func RankNewNotIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -883,68 +890,68 @@ func RankNewNotIn(vs ...int) predicate.Stats { } // RankNewGT applies the GT predicate on the "rank_new" field. -func RankNewGT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankNewGT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldRankNew), v)) }) } // RankNewGTE applies the GTE predicate on the "rank_new" field. -func RankNewGTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankNewGTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldRankNew), v)) }) } // RankNewLT applies the LT predicate on the "rank_new" field. -func RankNewLT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankNewLT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldRankNew), v)) }) } // RankNewLTE applies the LTE predicate on the "rank_new" field. -func RankNewLTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankNewLTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldRankNew), v)) }) } // RankNewIsNil applies the IsNil predicate on the "rank_new" field. -func RankNewIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankNewIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldRankNew))) }) } // RankNewNotNil applies the NotNil predicate on the "rank_new" field. -func RankNewNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankNewNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldRankNew))) }) } // RankOldEQ applies the EQ predicate on the "rank_old" field. -func RankOldEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankOldEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldRankOld), v)) }) } // RankOldNEQ applies the NEQ predicate on the "rank_old" field. -func RankOldNEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankOldNEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldRankOld), v)) }) } // RankOldIn applies the In predicate on the "rank_old" field. -func RankOldIn(vs ...int) predicate.Stats { +func RankOldIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -956,12 +963,12 @@ func RankOldIn(vs ...int) predicate.Stats { } // RankOldNotIn applies the NotIn predicate on the "rank_old" field. -func RankOldNotIn(vs ...int) predicate.Stats { +func RankOldNotIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -973,68 +980,68 @@ func RankOldNotIn(vs ...int) predicate.Stats { } // RankOldGT applies the GT predicate on the "rank_old" field. -func RankOldGT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankOldGT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldRankOld), v)) }) } // RankOldGTE applies the GTE predicate on the "rank_old" field. -func RankOldGTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankOldGTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldRankOld), v)) }) } // RankOldLT applies the LT predicate on the "rank_old" field. -func RankOldLT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankOldLT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldRankOld), v)) }) } // RankOldLTE applies the LTE predicate on the "rank_old" field. -func RankOldLTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankOldLTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldRankOld), v)) }) } // RankOldIsNil applies the IsNil predicate on the "rank_old" field. -func RankOldIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankOldIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldRankOld))) }) } // RankOldNotNil applies the NotNil predicate on the "rank_old" field. -func RankOldNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func RankOldNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldRankOld))) }) } // Mk2EQ applies the EQ predicate on the "mk_2" field. -func Mk2EQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk2EQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldMk2), v)) }) } // Mk2NEQ applies the NEQ predicate on the "mk_2" field. -func Mk2NEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk2NEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldMk2), v)) }) } // Mk2In applies the In predicate on the "mk_2" field. -func Mk2In(vs ...uint) predicate.Stats { +func Mk2In(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1046,12 +1053,12 @@ func Mk2In(vs ...uint) predicate.Stats { } // Mk2NotIn applies the NotIn predicate on the "mk_2" field. -func Mk2NotIn(vs ...uint) predicate.Stats { +func Mk2NotIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1063,68 +1070,68 @@ func Mk2NotIn(vs ...uint) predicate.Stats { } // Mk2GT applies the GT predicate on the "mk_2" field. -func Mk2GT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk2GT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldMk2), v)) }) } // Mk2GTE applies the GTE predicate on the "mk_2" field. -func Mk2GTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk2GTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldMk2), v)) }) } // Mk2LT applies the LT predicate on the "mk_2" field. -func Mk2LT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk2LT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldMk2), v)) }) } // Mk2LTE applies the LTE predicate on the "mk_2" field. -func Mk2LTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk2LTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldMk2), v)) }) } // Mk2IsNil applies the IsNil predicate on the "mk_2" field. -func Mk2IsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk2IsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldMk2))) }) } // Mk2NotNil applies the NotNil predicate on the "mk_2" field. -func Mk2NotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk2NotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldMk2))) }) } // Mk3EQ applies the EQ predicate on the "mk_3" field. -func Mk3EQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk3EQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldMk3), v)) }) } // Mk3NEQ applies the NEQ predicate on the "mk_3" field. -func Mk3NEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk3NEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldMk3), v)) }) } // Mk3In applies the In predicate on the "mk_3" field. -func Mk3In(vs ...uint) predicate.Stats { +func Mk3In(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1136,12 +1143,12 @@ func Mk3In(vs ...uint) predicate.Stats { } // Mk3NotIn applies the NotIn predicate on the "mk_3" field. -func Mk3NotIn(vs ...uint) predicate.Stats { +func Mk3NotIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1153,68 +1160,68 @@ func Mk3NotIn(vs ...uint) predicate.Stats { } // Mk3GT applies the GT predicate on the "mk_3" field. -func Mk3GT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk3GT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldMk3), v)) }) } // Mk3GTE applies the GTE predicate on the "mk_3" field. -func Mk3GTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk3GTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldMk3), v)) }) } // Mk3LT applies the LT predicate on the "mk_3" field. -func Mk3LT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk3LT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldMk3), v)) }) } // Mk3LTE applies the LTE predicate on the "mk_3" field. -func Mk3LTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk3LTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldMk3), v)) }) } // Mk3IsNil applies the IsNil predicate on the "mk_3" field. -func Mk3IsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk3IsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldMk3))) }) } // Mk3NotNil applies the NotNil predicate on the "mk_3" field. -func Mk3NotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk3NotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldMk3))) }) } // Mk4EQ applies the EQ predicate on the "mk_4" field. -func Mk4EQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk4EQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldMk4), v)) }) } // Mk4NEQ applies the NEQ predicate on the "mk_4" field. -func Mk4NEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk4NEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldMk4), v)) }) } // Mk4In applies the In predicate on the "mk_4" field. -func Mk4In(vs ...uint) predicate.Stats { +func Mk4In(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1226,12 +1233,12 @@ func Mk4In(vs ...uint) predicate.Stats { } // Mk4NotIn applies the NotIn predicate on the "mk_4" field. -func Mk4NotIn(vs ...uint) predicate.Stats { +func Mk4NotIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1243,68 +1250,68 @@ func Mk4NotIn(vs ...uint) predicate.Stats { } // Mk4GT applies the GT predicate on the "mk_4" field. -func Mk4GT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk4GT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldMk4), v)) }) } // Mk4GTE applies the GTE predicate on the "mk_4" field. -func Mk4GTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk4GTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldMk4), v)) }) } // Mk4LT applies the LT predicate on the "mk_4" field. -func Mk4LT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk4LT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldMk4), v)) }) } // Mk4LTE applies the LTE predicate on the "mk_4" field. -func Mk4LTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk4LTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldMk4), v)) }) } // Mk4IsNil applies the IsNil predicate on the "mk_4" field. -func Mk4IsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk4IsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldMk4))) }) } // Mk4NotNil applies the NotNil predicate on the "mk_4" field. -func Mk4NotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk4NotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldMk4))) }) } // Mk5EQ applies the EQ predicate on the "mk_5" field. -func Mk5EQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk5EQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldMk5), v)) }) } // Mk5NEQ applies the NEQ predicate on the "mk_5" field. -func Mk5NEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk5NEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldMk5), v)) }) } // Mk5In applies the In predicate on the "mk_5" field. -func Mk5In(vs ...uint) predicate.Stats { +func Mk5In(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1316,12 +1323,12 @@ func Mk5In(vs ...uint) predicate.Stats { } // Mk5NotIn applies the NotIn predicate on the "mk_5" field. -func Mk5NotIn(vs ...uint) predicate.Stats { +func Mk5NotIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1333,68 +1340,68 @@ func Mk5NotIn(vs ...uint) predicate.Stats { } // Mk5GT applies the GT predicate on the "mk_5" field. -func Mk5GT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk5GT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldMk5), v)) }) } // Mk5GTE applies the GTE predicate on the "mk_5" field. -func Mk5GTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk5GTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldMk5), v)) }) } // Mk5LT applies the LT predicate on the "mk_5" field. -func Mk5LT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk5LT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldMk5), v)) }) } // Mk5LTE applies the LTE predicate on the "mk_5" field. -func Mk5LTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk5LTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldMk5), v)) }) } // Mk5IsNil applies the IsNil predicate on the "mk_5" field. -func Mk5IsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk5IsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldMk5))) }) } // Mk5NotNil applies the NotNil predicate on the "mk_5" field. -func Mk5NotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Mk5NotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldMk5))) }) } // DmgEnemyEQ applies the EQ predicate on the "dmg_enemy" field. -func DmgEnemyEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgEnemyEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldDmgEnemy), v)) }) } // DmgEnemyNEQ applies the NEQ predicate on the "dmg_enemy" field. -func DmgEnemyNEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgEnemyNEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldDmgEnemy), v)) }) } // DmgEnemyIn applies the In predicate on the "dmg_enemy" field. -func DmgEnemyIn(vs ...uint) predicate.Stats { +func DmgEnemyIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1406,12 +1413,12 @@ func DmgEnemyIn(vs ...uint) predicate.Stats { } // DmgEnemyNotIn applies the NotIn predicate on the "dmg_enemy" field. -func DmgEnemyNotIn(vs ...uint) predicate.Stats { +func DmgEnemyNotIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1423,68 +1430,68 @@ func DmgEnemyNotIn(vs ...uint) predicate.Stats { } // DmgEnemyGT applies the GT predicate on the "dmg_enemy" field. -func DmgEnemyGT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgEnemyGT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldDmgEnemy), v)) }) } // DmgEnemyGTE applies the GTE predicate on the "dmg_enemy" field. -func DmgEnemyGTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgEnemyGTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldDmgEnemy), v)) }) } // DmgEnemyLT applies the LT predicate on the "dmg_enemy" field. -func DmgEnemyLT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgEnemyLT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldDmgEnemy), v)) }) } // DmgEnemyLTE applies the LTE predicate on the "dmg_enemy" field. -func DmgEnemyLTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgEnemyLTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldDmgEnemy), v)) }) } // DmgEnemyIsNil applies the IsNil predicate on the "dmg_enemy" field. -func DmgEnemyIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgEnemyIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldDmgEnemy))) }) } // DmgEnemyNotNil applies the NotNil predicate on the "dmg_enemy" field. -func DmgEnemyNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgEnemyNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldDmgEnemy))) }) } // DmgTeamEQ applies the EQ predicate on the "dmg_team" field. -func DmgTeamEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgTeamEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldDmgTeam), v)) }) } // DmgTeamNEQ applies the NEQ predicate on the "dmg_team" field. -func DmgTeamNEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgTeamNEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldDmgTeam), v)) }) } // DmgTeamIn applies the In predicate on the "dmg_team" field. -func DmgTeamIn(vs ...uint) predicate.Stats { +func DmgTeamIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1496,12 +1503,12 @@ func DmgTeamIn(vs ...uint) predicate.Stats { } // DmgTeamNotIn applies the NotIn predicate on the "dmg_team" field. -func DmgTeamNotIn(vs ...uint) predicate.Stats { +func DmgTeamNotIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1513,68 +1520,68 @@ func DmgTeamNotIn(vs ...uint) predicate.Stats { } // DmgTeamGT applies the GT predicate on the "dmg_team" field. -func DmgTeamGT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgTeamGT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldDmgTeam), v)) }) } // DmgTeamGTE applies the GTE predicate on the "dmg_team" field. -func DmgTeamGTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgTeamGTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldDmgTeam), v)) }) } // DmgTeamLT applies the LT predicate on the "dmg_team" field. -func DmgTeamLT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgTeamLT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldDmgTeam), v)) }) } // DmgTeamLTE applies the LTE predicate on the "dmg_team" field. -func DmgTeamLTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgTeamLTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldDmgTeam), v)) }) } // DmgTeamIsNil applies the IsNil predicate on the "dmg_team" field. -func DmgTeamIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgTeamIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldDmgTeam))) }) } // DmgTeamNotNil applies the NotNil predicate on the "dmg_team" field. -func DmgTeamNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func DmgTeamNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldDmgTeam))) }) } // UdHeEQ applies the EQ predicate on the "ud_he" field. -func UdHeEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdHeEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldUdHe), v)) }) } // UdHeNEQ applies the NEQ predicate on the "ud_he" field. -func UdHeNEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdHeNEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldUdHe), v)) }) } // UdHeIn applies the In predicate on the "ud_he" field. -func UdHeIn(vs ...uint) predicate.Stats { +func UdHeIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1586,12 +1593,12 @@ func UdHeIn(vs ...uint) predicate.Stats { } // UdHeNotIn applies the NotIn predicate on the "ud_he" field. -func UdHeNotIn(vs ...uint) predicate.Stats { +func UdHeNotIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1603,68 +1610,68 @@ func UdHeNotIn(vs ...uint) predicate.Stats { } // UdHeGT applies the GT predicate on the "ud_he" field. -func UdHeGT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdHeGT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldUdHe), v)) }) } // UdHeGTE applies the GTE predicate on the "ud_he" field. -func UdHeGTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdHeGTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldUdHe), v)) }) } // UdHeLT applies the LT predicate on the "ud_he" field. -func UdHeLT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdHeLT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldUdHe), v)) }) } // UdHeLTE applies the LTE predicate on the "ud_he" field. -func UdHeLTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdHeLTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldUdHe), v)) }) } // UdHeIsNil applies the IsNil predicate on the "ud_he" field. -func UdHeIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdHeIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldUdHe))) }) } // UdHeNotNil applies the NotNil predicate on the "ud_he" field. -func UdHeNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdHeNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldUdHe))) }) } // UdFlamesEQ applies the EQ predicate on the "ud_flames" field. -func UdFlamesEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlamesEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldUdFlames), v)) }) } // UdFlamesNEQ applies the NEQ predicate on the "ud_flames" field. -func UdFlamesNEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlamesNEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldUdFlames), v)) }) } // UdFlamesIn applies the In predicate on the "ud_flames" field. -func UdFlamesIn(vs ...uint) predicate.Stats { +func UdFlamesIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1676,12 +1683,12 @@ func UdFlamesIn(vs ...uint) predicate.Stats { } // UdFlamesNotIn applies the NotIn predicate on the "ud_flames" field. -func UdFlamesNotIn(vs ...uint) predicate.Stats { +func UdFlamesNotIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1693,68 +1700,68 @@ func UdFlamesNotIn(vs ...uint) predicate.Stats { } // UdFlamesGT applies the GT predicate on the "ud_flames" field. -func UdFlamesGT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlamesGT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldUdFlames), v)) }) } // UdFlamesGTE applies the GTE predicate on the "ud_flames" field. -func UdFlamesGTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlamesGTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldUdFlames), v)) }) } // UdFlamesLT applies the LT predicate on the "ud_flames" field. -func UdFlamesLT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlamesLT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldUdFlames), v)) }) } // UdFlamesLTE applies the LTE predicate on the "ud_flames" field. -func UdFlamesLTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlamesLTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldUdFlames), v)) }) } // UdFlamesIsNil applies the IsNil predicate on the "ud_flames" field. -func UdFlamesIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlamesIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldUdFlames))) }) } // UdFlamesNotNil applies the NotNil predicate on the "ud_flames" field. -func UdFlamesNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlamesNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldUdFlames))) }) } // UdFlashEQ applies the EQ predicate on the "ud_flash" field. -func UdFlashEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlashEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldUdFlash), v)) }) } // UdFlashNEQ applies the NEQ predicate on the "ud_flash" field. -func UdFlashNEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlashNEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldUdFlash), v)) }) } // UdFlashIn applies the In predicate on the "ud_flash" field. -func UdFlashIn(vs ...uint) predicate.Stats { +func UdFlashIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1766,12 +1773,12 @@ func UdFlashIn(vs ...uint) predicate.Stats { } // UdFlashNotIn applies the NotIn predicate on the "ud_flash" field. -func UdFlashNotIn(vs ...uint) predicate.Stats { +func UdFlashNotIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1783,68 +1790,68 @@ func UdFlashNotIn(vs ...uint) predicate.Stats { } // UdFlashGT applies the GT predicate on the "ud_flash" field. -func UdFlashGT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlashGT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldUdFlash), v)) }) } // UdFlashGTE applies the GTE predicate on the "ud_flash" field. -func UdFlashGTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlashGTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldUdFlash), v)) }) } // UdFlashLT applies the LT predicate on the "ud_flash" field. -func UdFlashLT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlashLT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldUdFlash), v)) }) } // UdFlashLTE applies the LTE predicate on the "ud_flash" field. -func UdFlashLTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlashLTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldUdFlash), v)) }) } // UdFlashIsNil applies the IsNil predicate on the "ud_flash" field. -func UdFlashIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlashIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldUdFlash))) }) } // UdFlashNotNil applies the NotNil predicate on the "ud_flash" field. -func UdFlashNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdFlashNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldUdFlash))) }) } // UdDecoyEQ applies the EQ predicate on the "ud_decoy" field. -func UdDecoyEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdDecoyEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldUdDecoy), v)) }) } // UdDecoyNEQ applies the NEQ predicate on the "ud_decoy" field. -func UdDecoyNEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdDecoyNEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldUdDecoy), v)) }) } // UdDecoyIn applies the In predicate on the "ud_decoy" field. -func UdDecoyIn(vs ...uint) predicate.Stats { +func UdDecoyIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1856,12 +1863,12 @@ func UdDecoyIn(vs ...uint) predicate.Stats { } // UdDecoyNotIn applies the NotIn predicate on the "ud_decoy" field. -func UdDecoyNotIn(vs ...uint) predicate.Stats { +func UdDecoyNotIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1873,68 +1880,68 @@ func UdDecoyNotIn(vs ...uint) predicate.Stats { } // UdDecoyGT applies the GT predicate on the "ud_decoy" field. -func UdDecoyGT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdDecoyGT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldUdDecoy), v)) }) } // UdDecoyGTE applies the GTE predicate on the "ud_decoy" field. -func UdDecoyGTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdDecoyGTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldUdDecoy), v)) }) } // UdDecoyLT applies the LT predicate on the "ud_decoy" field. -func UdDecoyLT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdDecoyLT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldUdDecoy), v)) }) } // UdDecoyLTE applies the LTE predicate on the "ud_decoy" field. -func UdDecoyLTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdDecoyLTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldUdDecoy), v)) }) } // UdDecoyIsNil applies the IsNil predicate on the "ud_decoy" field. -func UdDecoyIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdDecoyIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldUdDecoy))) }) } // UdDecoyNotNil applies the NotNil predicate on the "ud_decoy" field. -func UdDecoyNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdDecoyNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldUdDecoy))) }) } // UdSmokeEQ applies the EQ predicate on the "ud_smoke" field. -func UdSmokeEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdSmokeEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldUdSmoke), v)) }) } // UdSmokeNEQ applies the NEQ predicate on the "ud_smoke" field. -func UdSmokeNEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdSmokeNEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldUdSmoke), v)) }) } // UdSmokeIn applies the In predicate on the "ud_smoke" field. -func UdSmokeIn(vs ...uint) predicate.Stats { +func UdSmokeIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1946,12 +1953,12 @@ func UdSmokeIn(vs ...uint) predicate.Stats { } // UdSmokeNotIn applies the NotIn predicate on the "ud_smoke" field. -func UdSmokeNotIn(vs ...uint) predicate.Stats { +func UdSmokeNotIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -1963,68 +1970,68 @@ func UdSmokeNotIn(vs ...uint) predicate.Stats { } // UdSmokeGT applies the GT predicate on the "ud_smoke" field. -func UdSmokeGT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdSmokeGT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldUdSmoke), v)) }) } // UdSmokeGTE applies the GTE predicate on the "ud_smoke" field. -func UdSmokeGTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdSmokeGTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldUdSmoke), v)) }) } // UdSmokeLT applies the LT predicate on the "ud_smoke" field. -func UdSmokeLT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdSmokeLT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldUdSmoke), v)) }) } // UdSmokeLTE applies the LTE predicate on the "ud_smoke" field. -func UdSmokeLTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdSmokeLTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldUdSmoke), v)) }) } // UdSmokeIsNil applies the IsNil predicate on the "ud_smoke" field. -func UdSmokeIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdSmokeIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldUdSmoke))) }) } // UdSmokeNotNil applies the NotNil predicate on the "ud_smoke" field. -func UdSmokeNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func UdSmokeNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldUdSmoke))) }) } // CrosshairEQ applies the EQ predicate on the "crosshair" field. -func CrosshairEQ(v string) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func CrosshairEQ(v string) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldCrosshair), v)) }) } // CrosshairNEQ applies the NEQ predicate on the "crosshair" field. -func CrosshairNEQ(v string) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func CrosshairNEQ(v string) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldCrosshair), v)) }) } // CrosshairIn applies the In predicate on the "crosshair" field. -func CrosshairIn(vs ...string) predicate.Stats { +func CrosshairIn(vs ...string) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2036,12 +2043,12 @@ func CrosshairIn(vs ...string) predicate.Stats { } // CrosshairNotIn applies the NotIn predicate on the "crosshair" field. -func CrosshairNotIn(vs ...string) predicate.Stats { +func CrosshairNotIn(vs ...string) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2053,103 +2060,103 @@ func CrosshairNotIn(vs ...string) predicate.Stats { } // CrosshairGT applies the GT predicate on the "crosshair" field. -func CrosshairGT(v string) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func CrosshairGT(v string) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldCrosshair), v)) }) } // CrosshairGTE applies the GTE predicate on the "crosshair" field. -func CrosshairGTE(v string) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func CrosshairGTE(v string) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldCrosshair), v)) }) } // CrosshairLT applies the LT predicate on the "crosshair" field. -func CrosshairLT(v string) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func CrosshairLT(v string) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldCrosshair), v)) }) } // CrosshairLTE applies the LTE predicate on the "crosshair" field. -func CrosshairLTE(v string) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func CrosshairLTE(v string) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldCrosshair), v)) }) } // CrosshairContains applies the Contains predicate on the "crosshair" field. -func CrosshairContains(v string) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func CrosshairContains(v string) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.Contains(s.C(FieldCrosshair), v)) }) } // CrosshairHasPrefix applies the HasPrefix predicate on the "crosshair" field. -func CrosshairHasPrefix(v string) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func CrosshairHasPrefix(v string) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.HasPrefix(s.C(FieldCrosshair), v)) }) } // CrosshairHasSuffix applies the HasSuffix predicate on the "crosshair" field. -func CrosshairHasSuffix(v string) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func CrosshairHasSuffix(v string) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.HasSuffix(s.C(FieldCrosshair), v)) }) } // CrosshairIsNil applies the IsNil predicate on the "crosshair" field. -func CrosshairIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func CrosshairIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldCrosshair))) }) } // CrosshairNotNil applies the NotNil predicate on the "crosshair" field. -func CrosshairNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func CrosshairNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldCrosshair))) }) } // CrosshairEqualFold applies the EqualFold predicate on the "crosshair" field. -func CrosshairEqualFold(v string) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func CrosshairEqualFold(v string) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EqualFold(s.C(FieldCrosshair), v)) }) } // CrosshairContainsFold applies the ContainsFold predicate on the "crosshair" field. -func CrosshairContainsFold(v string) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func CrosshairContainsFold(v string) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.ContainsFold(s.C(FieldCrosshair), v)) }) } // ColorEQ applies the EQ predicate on the "color" field. -func ColorEQ(v Color) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func ColorEQ(v Color) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldColor), v)) }) } // ColorNEQ applies the NEQ predicate on the "color" field. -func ColorNEQ(v Color) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func ColorNEQ(v Color) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldColor), v)) }) } // ColorIn applies the In predicate on the "color" field. -func ColorIn(vs ...Color) predicate.Stats { +func ColorIn(vs ...Color) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2161,12 +2168,12 @@ func ColorIn(vs ...Color) predicate.Stats { } // ColorNotIn applies the NotIn predicate on the "color" field. -func ColorNotIn(vs ...Color) predicate.Stats { +func ColorNotIn(vs ...Color) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2178,40 +2185,40 @@ func ColorNotIn(vs ...Color) predicate.Stats { } // ColorIsNil applies the IsNil predicate on the "color" field. -func ColorIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func ColorIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldColor))) }) } // ColorNotNil applies the NotNil predicate on the "color" field. -func ColorNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func ColorNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldColor))) }) } // KastEQ applies the EQ predicate on the "kast" field. -func KastEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func KastEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldKast), v)) }) } // KastNEQ applies the NEQ predicate on the "kast" field. -func KastNEQ(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func KastNEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldKast), v)) }) } // KastIn applies the In predicate on the "kast" field. -func KastIn(vs ...int) predicate.Stats { +func KastIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2223,12 +2230,12 @@ func KastIn(vs ...int) predicate.Stats { } // KastNotIn applies the NotIn predicate on the "kast" field. -func KastNotIn(vs ...int) predicate.Stats { +func KastNotIn(vs ...int) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2240,68 +2247,68 @@ func KastNotIn(vs ...int) predicate.Stats { } // KastGT applies the GT predicate on the "kast" field. -func KastGT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func KastGT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldKast), v)) }) } // KastGTE applies the GTE predicate on the "kast" field. -func KastGTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func KastGTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldKast), v)) }) } // KastLT applies the LT predicate on the "kast" field. -func KastLT(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func KastLT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldKast), v)) }) } // KastLTE applies the LTE predicate on the "kast" field. -func KastLTE(v int) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func KastLTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldKast), v)) }) } // KastIsNil applies the IsNil predicate on the "kast" field. -func KastIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func KastIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldKast))) }) } // KastNotNil applies the NotNil predicate on the "kast" field. -func KastNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func KastNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldKast))) }) } // FlashDurationSelfEQ applies the EQ predicate on the "flash_duration_self" field. -func FlashDurationSelfEQ(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationSelfEQ(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldFlashDurationSelf), v)) }) } // FlashDurationSelfNEQ applies the NEQ predicate on the "flash_duration_self" field. -func FlashDurationSelfNEQ(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationSelfNEQ(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldFlashDurationSelf), v)) }) } // FlashDurationSelfIn applies the In predicate on the "flash_duration_self" field. -func FlashDurationSelfIn(vs ...float32) predicate.Stats { +func FlashDurationSelfIn(vs ...float32) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2313,12 +2320,12 @@ func FlashDurationSelfIn(vs ...float32) predicate.Stats { } // FlashDurationSelfNotIn applies the NotIn predicate on the "flash_duration_self" field. -func FlashDurationSelfNotIn(vs ...float32) predicate.Stats { +func FlashDurationSelfNotIn(vs ...float32) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2330,68 +2337,68 @@ func FlashDurationSelfNotIn(vs ...float32) predicate.Stats { } // FlashDurationSelfGT applies the GT predicate on the "flash_duration_self" field. -func FlashDurationSelfGT(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationSelfGT(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldFlashDurationSelf), v)) }) } // FlashDurationSelfGTE applies the GTE predicate on the "flash_duration_self" field. -func FlashDurationSelfGTE(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationSelfGTE(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldFlashDurationSelf), v)) }) } // FlashDurationSelfLT applies the LT predicate on the "flash_duration_self" field. -func FlashDurationSelfLT(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationSelfLT(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldFlashDurationSelf), v)) }) } // FlashDurationSelfLTE applies the LTE predicate on the "flash_duration_self" field. -func FlashDurationSelfLTE(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationSelfLTE(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldFlashDurationSelf), v)) }) } // FlashDurationSelfIsNil applies the IsNil predicate on the "flash_duration_self" field. -func FlashDurationSelfIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationSelfIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldFlashDurationSelf))) }) } // FlashDurationSelfNotNil applies the NotNil predicate on the "flash_duration_self" field. -func FlashDurationSelfNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationSelfNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldFlashDurationSelf))) }) } // FlashDurationTeamEQ applies the EQ predicate on the "flash_duration_team" field. -func FlashDurationTeamEQ(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationTeamEQ(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldFlashDurationTeam), v)) }) } // FlashDurationTeamNEQ applies the NEQ predicate on the "flash_duration_team" field. -func FlashDurationTeamNEQ(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationTeamNEQ(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldFlashDurationTeam), v)) }) } // FlashDurationTeamIn applies the In predicate on the "flash_duration_team" field. -func FlashDurationTeamIn(vs ...float32) predicate.Stats { +func FlashDurationTeamIn(vs ...float32) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2403,12 +2410,12 @@ func FlashDurationTeamIn(vs ...float32) predicate.Stats { } // FlashDurationTeamNotIn applies the NotIn predicate on the "flash_duration_team" field. -func FlashDurationTeamNotIn(vs ...float32) predicate.Stats { +func FlashDurationTeamNotIn(vs ...float32) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2420,68 +2427,68 @@ func FlashDurationTeamNotIn(vs ...float32) predicate.Stats { } // FlashDurationTeamGT applies the GT predicate on the "flash_duration_team" field. -func FlashDurationTeamGT(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationTeamGT(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldFlashDurationTeam), v)) }) } // FlashDurationTeamGTE applies the GTE predicate on the "flash_duration_team" field. -func FlashDurationTeamGTE(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationTeamGTE(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldFlashDurationTeam), v)) }) } // FlashDurationTeamLT applies the LT predicate on the "flash_duration_team" field. -func FlashDurationTeamLT(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationTeamLT(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldFlashDurationTeam), v)) }) } // FlashDurationTeamLTE applies the LTE predicate on the "flash_duration_team" field. -func FlashDurationTeamLTE(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationTeamLTE(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldFlashDurationTeam), v)) }) } // FlashDurationTeamIsNil applies the IsNil predicate on the "flash_duration_team" field. -func FlashDurationTeamIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationTeamIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldFlashDurationTeam))) }) } // FlashDurationTeamNotNil applies the NotNil predicate on the "flash_duration_team" field. -func FlashDurationTeamNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationTeamNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldFlashDurationTeam))) }) } // FlashDurationEnemyEQ applies the EQ predicate on the "flash_duration_enemy" field. -func FlashDurationEnemyEQ(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationEnemyEQ(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldFlashDurationEnemy), v)) }) } // FlashDurationEnemyNEQ applies the NEQ predicate on the "flash_duration_enemy" field. -func FlashDurationEnemyNEQ(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationEnemyNEQ(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldFlashDurationEnemy), v)) }) } // FlashDurationEnemyIn applies the In predicate on the "flash_duration_enemy" field. -func FlashDurationEnemyIn(vs ...float32) predicate.Stats { +func FlashDurationEnemyIn(vs ...float32) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2493,12 +2500,12 @@ func FlashDurationEnemyIn(vs ...float32) predicate.Stats { } // FlashDurationEnemyNotIn applies the NotIn predicate on the "flash_duration_enemy" field. -func FlashDurationEnemyNotIn(vs ...float32) predicate.Stats { +func FlashDurationEnemyNotIn(vs ...float32) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2510,68 +2517,68 @@ func FlashDurationEnemyNotIn(vs ...float32) predicate.Stats { } // FlashDurationEnemyGT applies the GT predicate on the "flash_duration_enemy" field. -func FlashDurationEnemyGT(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationEnemyGT(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldFlashDurationEnemy), v)) }) } // FlashDurationEnemyGTE applies the GTE predicate on the "flash_duration_enemy" field. -func FlashDurationEnemyGTE(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationEnemyGTE(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldFlashDurationEnemy), v)) }) } // FlashDurationEnemyLT applies the LT predicate on the "flash_duration_enemy" field. -func FlashDurationEnemyLT(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationEnemyLT(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldFlashDurationEnemy), v)) }) } // FlashDurationEnemyLTE applies the LTE predicate on the "flash_duration_enemy" field. -func FlashDurationEnemyLTE(v float32) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationEnemyLTE(v float32) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldFlashDurationEnemy), v)) }) } // FlashDurationEnemyIsNil applies the IsNil predicate on the "flash_duration_enemy" field. -func FlashDurationEnemyIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationEnemyIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldFlashDurationEnemy))) }) } // FlashDurationEnemyNotNil applies the NotNil predicate on the "flash_duration_enemy" field. -func FlashDurationEnemyNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashDurationEnemyNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldFlashDurationEnemy))) }) } // FlashTotalSelfEQ applies the EQ predicate on the "flash_total_self" field. -func FlashTotalSelfEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalSelfEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldFlashTotalSelf), v)) }) } // FlashTotalSelfNEQ applies the NEQ predicate on the "flash_total_self" field. -func FlashTotalSelfNEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalSelfNEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldFlashTotalSelf), v)) }) } // FlashTotalSelfIn applies the In predicate on the "flash_total_self" field. -func FlashTotalSelfIn(vs ...uint) predicate.Stats { +func FlashTotalSelfIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2583,12 +2590,12 @@ func FlashTotalSelfIn(vs ...uint) predicate.Stats { } // FlashTotalSelfNotIn applies the NotIn predicate on the "flash_total_self" field. -func FlashTotalSelfNotIn(vs ...uint) predicate.Stats { +func FlashTotalSelfNotIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2600,68 +2607,68 @@ func FlashTotalSelfNotIn(vs ...uint) predicate.Stats { } // FlashTotalSelfGT applies the GT predicate on the "flash_total_self" field. -func FlashTotalSelfGT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalSelfGT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldFlashTotalSelf), v)) }) } // FlashTotalSelfGTE applies the GTE predicate on the "flash_total_self" field. -func FlashTotalSelfGTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalSelfGTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldFlashTotalSelf), v)) }) } // FlashTotalSelfLT applies the LT predicate on the "flash_total_self" field. -func FlashTotalSelfLT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalSelfLT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldFlashTotalSelf), v)) }) } // FlashTotalSelfLTE applies the LTE predicate on the "flash_total_self" field. -func FlashTotalSelfLTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalSelfLTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldFlashTotalSelf), v)) }) } // FlashTotalSelfIsNil applies the IsNil predicate on the "flash_total_self" field. -func FlashTotalSelfIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalSelfIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldFlashTotalSelf))) }) } // FlashTotalSelfNotNil applies the NotNil predicate on the "flash_total_self" field. -func FlashTotalSelfNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalSelfNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldFlashTotalSelf))) }) } // FlashTotalTeamEQ applies the EQ predicate on the "flash_total_team" field. -func FlashTotalTeamEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalTeamEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldFlashTotalTeam), v)) }) } // FlashTotalTeamNEQ applies the NEQ predicate on the "flash_total_team" field. -func FlashTotalTeamNEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalTeamNEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldFlashTotalTeam), v)) }) } // FlashTotalTeamIn applies the In predicate on the "flash_total_team" field. -func FlashTotalTeamIn(vs ...uint) predicate.Stats { +func FlashTotalTeamIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2673,12 +2680,12 @@ func FlashTotalTeamIn(vs ...uint) predicate.Stats { } // FlashTotalTeamNotIn applies the NotIn predicate on the "flash_total_team" field. -func FlashTotalTeamNotIn(vs ...uint) predicate.Stats { +func FlashTotalTeamNotIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2690,68 +2697,68 @@ func FlashTotalTeamNotIn(vs ...uint) predicate.Stats { } // FlashTotalTeamGT applies the GT predicate on the "flash_total_team" field. -func FlashTotalTeamGT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalTeamGT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldFlashTotalTeam), v)) }) } // FlashTotalTeamGTE applies the GTE predicate on the "flash_total_team" field. -func FlashTotalTeamGTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalTeamGTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldFlashTotalTeam), v)) }) } // FlashTotalTeamLT applies the LT predicate on the "flash_total_team" field. -func FlashTotalTeamLT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalTeamLT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldFlashTotalTeam), v)) }) } // FlashTotalTeamLTE applies the LTE predicate on the "flash_total_team" field. -func FlashTotalTeamLTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalTeamLTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldFlashTotalTeam), v)) }) } // FlashTotalTeamIsNil applies the IsNil predicate on the "flash_total_team" field. -func FlashTotalTeamIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalTeamIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldFlashTotalTeam))) }) } // FlashTotalTeamNotNil applies the NotNil predicate on the "flash_total_team" field. -func FlashTotalTeamNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalTeamNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldFlashTotalTeam))) }) } // FlashTotalEnemyEQ applies the EQ predicate on the "flash_total_enemy" field. -func FlashTotalEnemyEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalEnemyEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldFlashTotalEnemy), v)) }) } // FlashTotalEnemyNEQ applies the NEQ predicate on the "flash_total_enemy" field. -func FlashTotalEnemyNEQ(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalEnemyNEQ(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldFlashTotalEnemy), v)) }) } // FlashTotalEnemyIn applies the In predicate on the "flash_total_enemy" field. -func FlashTotalEnemyIn(vs ...uint) predicate.Stats { +func FlashTotalEnemyIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2763,12 +2770,12 @@ func FlashTotalEnemyIn(vs ...uint) predicate.Stats { } // FlashTotalEnemyNotIn applies the NotIn predicate on the "flash_total_enemy" field. -func FlashTotalEnemyNotIn(vs ...uint) predicate.Stats { +func FlashTotalEnemyNotIn(vs ...uint) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2780,68 +2787,68 @@ func FlashTotalEnemyNotIn(vs ...uint) predicate.Stats { } // FlashTotalEnemyGT applies the GT predicate on the "flash_total_enemy" field. -func FlashTotalEnemyGT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalEnemyGT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldFlashTotalEnemy), v)) }) } // FlashTotalEnemyGTE applies the GTE predicate on the "flash_total_enemy" field. -func FlashTotalEnemyGTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalEnemyGTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldFlashTotalEnemy), v)) }) } // FlashTotalEnemyLT applies the LT predicate on the "flash_total_enemy" field. -func FlashTotalEnemyLT(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalEnemyLT(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldFlashTotalEnemy), v)) }) } // FlashTotalEnemyLTE applies the LTE predicate on the "flash_total_enemy" field. -func FlashTotalEnemyLTE(v uint) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalEnemyLTE(v uint) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldFlashTotalEnemy), v)) }) } // FlashTotalEnemyIsNil applies the IsNil predicate on the "flash_total_enemy" field. -func FlashTotalEnemyIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalEnemyIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldFlashTotalEnemy))) }) } // FlashTotalEnemyNotNil applies the NotNil predicate on the "flash_total_enemy" field. -func FlashTotalEnemyNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func FlashTotalEnemyNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldFlashTotalEnemy))) }) } // MatchStatsEQ applies the EQ predicate on the "match_stats" field. -func MatchStatsEQ(v uint64) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func MatchStatsEQ(v uint64) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldMatchStats), v)) }) } // MatchStatsNEQ applies the NEQ predicate on the "match_stats" field. -func MatchStatsNEQ(v uint64) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func MatchStatsNEQ(v uint64) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldMatchStats), v)) }) } // MatchStatsIn applies the In predicate on the "match_stats" field. -func MatchStatsIn(vs ...uint64) predicate.Stats { +func MatchStatsIn(vs ...uint64) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2853,12 +2860,12 @@ func MatchStatsIn(vs ...uint64) predicate.Stats { } // MatchStatsNotIn applies the NotIn predicate on the "match_stats" field. -func MatchStatsNotIn(vs ...uint64) predicate.Stats { +func MatchStatsNotIn(vs ...uint64) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2870,40 +2877,40 @@ func MatchStatsNotIn(vs ...uint64) predicate.Stats { } // MatchStatsIsNil applies the IsNil predicate on the "match_stats" field. -func MatchStatsIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func MatchStatsIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldMatchStats))) }) } // MatchStatsNotNil applies the NotNil predicate on the "match_stats" field. -func MatchStatsNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func MatchStatsNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldMatchStats))) }) } // PlayerStatsEQ applies the EQ predicate on the "player_stats" field. -func PlayerStatsEQ(v uint64) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func PlayerStatsEQ(v uint64) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldPlayerStats), v)) }) } // PlayerStatsNEQ applies the NEQ predicate on the "player_stats" field. -func PlayerStatsNEQ(v uint64) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func PlayerStatsNEQ(v uint64) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldPlayerStats), v)) }) } // PlayerStatsIn applies the In predicate on the "player_stats" field. -func PlayerStatsIn(vs ...uint64) predicate.Stats { +func PlayerStatsIn(vs ...uint64) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2915,12 +2922,12 @@ func PlayerStatsIn(vs ...uint64) predicate.Stats { } // PlayerStatsNotIn applies the NotIn predicate on the "player_stats" field. -func PlayerStatsNotIn(vs ...uint64) predicate.Stats { +func PlayerStatsNotIn(vs ...uint64) predicate.MatchPlayer { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.Stats(func(s *sql.Selector) { + return predicate.MatchPlayer(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -2932,22 +2939,112 @@ func PlayerStatsNotIn(vs ...uint64) predicate.Stats { } // PlayerStatsIsNil applies the IsNil predicate on the "player_stats" field. -func PlayerStatsIsNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func PlayerStatsIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.IsNull(s.C(FieldPlayerStats))) }) } // PlayerStatsNotNil applies the NotNil predicate on the "player_stats" field. -func PlayerStatsNotNil() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func PlayerStatsNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.NotNull(s.C(FieldPlayerStats))) }) } +// FlashAssistsEQ applies the EQ predicate on the "flash_assists" field. +func FlashAssistsEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldFlashAssists), v)) + }) +} + +// FlashAssistsNEQ applies the NEQ predicate on the "flash_assists" field. +func FlashAssistsNEQ(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldFlashAssists), v)) + }) +} + +// FlashAssistsIn applies the In predicate on the "flash_assists" field. +func FlashAssistsIn(vs ...int) predicate.MatchPlayer { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.MatchPlayer(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldFlashAssists), v...)) + }) +} + +// FlashAssistsNotIn applies the NotIn predicate on the "flash_assists" field. +func FlashAssistsNotIn(vs ...int) predicate.MatchPlayer { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.MatchPlayer(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldFlashAssists), v...)) + }) +} + +// FlashAssistsGT applies the GT predicate on the "flash_assists" field. +func FlashAssistsGT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldFlashAssists), v)) + }) +} + +// FlashAssistsGTE applies the GTE predicate on the "flash_assists" field. +func FlashAssistsGTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldFlashAssists), v)) + }) +} + +// FlashAssistsLT applies the LT predicate on the "flash_assists" field. +func FlashAssistsLT(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldFlashAssists), v)) + }) +} + +// FlashAssistsLTE applies the LTE predicate on the "flash_assists" field. +func FlashAssistsLTE(v int) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldFlashAssists), v)) + }) +} + +// FlashAssistsIsNil applies the IsNil predicate on the "flash_assists" field. +func FlashAssistsIsNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldFlashAssists))) + }) +} + +// FlashAssistsNotNil applies the NotNil predicate on the "flash_assists" field. +func FlashAssistsNotNil() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldFlashAssists))) + }) +} + // HasMatches applies the HasEdge predicate on the "matches" edge. -func HasMatches() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func HasMatches() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(MatchesTable, FieldID), @@ -2958,8 +3055,8 @@ func HasMatches() predicate.Stats { } // HasMatchesWith applies the HasEdge predicate on the "matches" edge with a given conditions (other predicates). -func HasMatchesWith(preds ...predicate.Match) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func HasMatchesWith(preds ...predicate.Match) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(MatchesInverseTable, FieldID), @@ -2974,8 +3071,8 @@ func HasMatchesWith(preds ...predicate.Match) predicate.Stats { } // HasPlayers applies the HasEdge predicate on the "players" edge. -func HasPlayers() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func HasPlayers() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(PlayersTable, FieldID), @@ -2986,8 +3083,8 @@ func HasPlayers() predicate.Stats { } // HasPlayersWith applies the HasEdge predicate on the "players" edge with a given conditions (other predicates). -func HasPlayersWith(preds ...predicate.Player) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func HasPlayersWith(preds ...predicate.Player) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(PlayersInverseTable, FieldID), @@ -3002,8 +3099,8 @@ func HasPlayersWith(preds ...predicate.Player) predicate.Stats { } // HasWeaponStats applies the HasEdge predicate on the "weapon_stats" edge. -func HasWeaponStats() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func HasWeaponStats() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(WeaponStatsTable, FieldID), @@ -3014,8 +3111,8 @@ func HasWeaponStats() predicate.Stats { } // HasWeaponStatsWith applies the HasEdge predicate on the "weapon_stats" edge with a given conditions (other predicates). -func HasWeaponStatsWith(preds ...predicate.WeaponStats) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func HasWeaponStatsWith(preds ...predicate.Weapon) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(WeaponStatsInverseTable, FieldID), @@ -3030,8 +3127,8 @@ func HasWeaponStatsWith(preds ...predicate.WeaponStats) predicate.Stats { } // HasRoundStats applies the HasEdge predicate on the "round_stats" edge. -func HasRoundStats() predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func HasRoundStats() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(RoundStatsTable, FieldID), @@ -3042,8 +3139,8 @@ func HasRoundStats() predicate.Stats { } // HasRoundStatsWith applies the HasEdge predicate on the "round_stats" edge with a given conditions (other predicates). -func HasRoundStatsWith(preds ...predicate.RoundStats) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func HasRoundStatsWith(preds ...predicate.RoundStats) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(RoundStatsInverseTable, FieldID), @@ -3057,9 +3154,37 @@ func HasRoundStatsWith(preds ...predicate.RoundStats) predicate.Stats { }) } +// HasSpray applies the HasEdge predicate on the "spray" edge. +func HasSpray() predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(SprayTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, SprayTable, SprayColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasSprayWith applies the HasEdge predicate on the "spray" edge with a given conditions (other predicates). +func HasSprayWith(preds ...predicate.Spray) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(SprayInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, SprayTable, SprayColumn), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. -func And(predicates ...predicate.Stats) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func And(predicates ...predicate.MatchPlayer) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s1 := s.Clone().SetP(nil) for _, p := range predicates { p(s1) @@ -3069,8 +3194,8 @@ func And(predicates ...predicate.Stats) predicate.Stats { } // Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.Stats) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Or(predicates ...predicate.MatchPlayer) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { s1 := s.Clone().SetP(nil) for i, p := range predicates { if i > 0 { @@ -3083,8 +3208,8 @@ func Or(predicates ...predicate.Stats) predicate.Stats { } // Not applies the not operator on the given predicate. -func Not(p predicate.Stats) predicate.Stats { - return predicate.Stats(func(s *sql.Selector) { +func Not(p predicate.MatchPlayer) predicate.MatchPlayer { + return predicate.MatchPlayer(func(s *sql.Selector) { p(s.Not()) }) } diff --git a/ent/matchplayer_create.go b/ent/matchplayer_create.go new file mode 100644 index 0000000..47e8138 --- /dev/null +++ b/ent/matchplayer_create.go @@ -0,0 +1,1046 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "csgowtfd/ent/match" + "csgowtfd/ent/matchplayer" + "csgowtfd/ent/player" + "csgowtfd/ent/roundstats" + "csgowtfd/ent/spray" + "csgowtfd/ent/weapon" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// MatchPlayerCreate is the builder for creating a MatchPlayer entity. +type MatchPlayerCreate struct { + config + mutation *MatchPlayerMutation + hooks []Hook +} + +// SetTeamID sets the "team_id" field. +func (mpc *MatchPlayerCreate) SetTeamID(i int) *MatchPlayerCreate { + mpc.mutation.SetTeamID(i) + return mpc +} + +// SetKills sets the "kills" field. +func (mpc *MatchPlayerCreate) SetKills(i int) *MatchPlayerCreate { + mpc.mutation.SetKills(i) + return mpc +} + +// SetDeaths sets the "deaths" field. +func (mpc *MatchPlayerCreate) SetDeaths(i int) *MatchPlayerCreate { + mpc.mutation.SetDeaths(i) + return mpc +} + +// SetAssists sets the "assists" field. +func (mpc *MatchPlayerCreate) SetAssists(i int) *MatchPlayerCreate { + mpc.mutation.SetAssists(i) + return mpc +} + +// SetHeadshot sets the "headshot" field. +func (mpc *MatchPlayerCreate) SetHeadshot(i int) *MatchPlayerCreate { + mpc.mutation.SetHeadshot(i) + return mpc +} + +// SetMvp sets the "mvp" field. +func (mpc *MatchPlayerCreate) SetMvp(u uint) *MatchPlayerCreate { + mpc.mutation.SetMvp(u) + return mpc +} + +// SetScore sets the "score" field. +func (mpc *MatchPlayerCreate) SetScore(i int) *MatchPlayerCreate { + mpc.mutation.SetScore(i) + return mpc +} + +// SetRankNew sets the "rank_new" field. +func (mpc *MatchPlayerCreate) SetRankNew(i int) *MatchPlayerCreate { + mpc.mutation.SetRankNew(i) + return mpc +} + +// SetNillableRankNew sets the "rank_new" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableRankNew(i *int) *MatchPlayerCreate { + if i != nil { + mpc.SetRankNew(*i) + } + return mpc +} + +// SetRankOld sets the "rank_old" field. +func (mpc *MatchPlayerCreate) SetRankOld(i int) *MatchPlayerCreate { + mpc.mutation.SetRankOld(i) + return mpc +} + +// SetNillableRankOld sets the "rank_old" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableRankOld(i *int) *MatchPlayerCreate { + if i != nil { + mpc.SetRankOld(*i) + } + return mpc +} + +// SetMk2 sets the "mk_2" field. +func (mpc *MatchPlayerCreate) SetMk2(u uint) *MatchPlayerCreate { + mpc.mutation.SetMk2(u) + return mpc +} + +// SetNillableMk2 sets the "mk_2" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableMk2(u *uint) *MatchPlayerCreate { + if u != nil { + mpc.SetMk2(*u) + } + return mpc +} + +// SetMk3 sets the "mk_3" field. +func (mpc *MatchPlayerCreate) SetMk3(u uint) *MatchPlayerCreate { + mpc.mutation.SetMk3(u) + return mpc +} + +// SetNillableMk3 sets the "mk_3" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableMk3(u *uint) *MatchPlayerCreate { + if u != nil { + mpc.SetMk3(*u) + } + return mpc +} + +// SetMk4 sets the "mk_4" field. +func (mpc *MatchPlayerCreate) SetMk4(u uint) *MatchPlayerCreate { + mpc.mutation.SetMk4(u) + return mpc +} + +// SetNillableMk4 sets the "mk_4" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableMk4(u *uint) *MatchPlayerCreate { + if u != nil { + mpc.SetMk4(*u) + } + return mpc +} + +// SetMk5 sets the "mk_5" field. +func (mpc *MatchPlayerCreate) SetMk5(u uint) *MatchPlayerCreate { + mpc.mutation.SetMk5(u) + return mpc +} + +// SetNillableMk5 sets the "mk_5" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableMk5(u *uint) *MatchPlayerCreate { + if u != nil { + mpc.SetMk5(*u) + } + return mpc +} + +// SetDmgEnemy sets the "dmg_enemy" field. +func (mpc *MatchPlayerCreate) SetDmgEnemy(u uint) *MatchPlayerCreate { + mpc.mutation.SetDmgEnemy(u) + return mpc +} + +// SetNillableDmgEnemy sets the "dmg_enemy" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableDmgEnemy(u *uint) *MatchPlayerCreate { + if u != nil { + mpc.SetDmgEnemy(*u) + } + return mpc +} + +// SetDmgTeam sets the "dmg_team" field. +func (mpc *MatchPlayerCreate) SetDmgTeam(u uint) *MatchPlayerCreate { + mpc.mutation.SetDmgTeam(u) + return mpc +} + +// SetNillableDmgTeam sets the "dmg_team" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableDmgTeam(u *uint) *MatchPlayerCreate { + if u != nil { + mpc.SetDmgTeam(*u) + } + return mpc +} + +// SetUdHe sets the "ud_he" field. +func (mpc *MatchPlayerCreate) SetUdHe(u uint) *MatchPlayerCreate { + mpc.mutation.SetUdHe(u) + return mpc +} + +// SetNillableUdHe sets the "ud_he" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableUdHe(u *uint) *MatchPlayerCreate { + if u != nil { + mpc.SetUdHe(*u) + } + return mpc +} + +// SetUdFlames sets the "ud_flames" field. +func (mpc *MatchPlayerCreate) SetUdFlames(u uint) *MatchPlayerCreate { + mpc.mutation.SetUdFlames(u) + return mpc +} + +// SetNillableUdFlames sets the "ud_flames" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableUdFlames(u *uint) *MatchPlayerCreate { + if u != nil { + mpc.SetUdFlames(*u) + } + return mpc +} + +// SetUdFlash sets the "ud_flash" field. +func (mpc *MatchPlayerCreate) SetUdFlash(u uint) *MatchPlayerCreate { + mpc.mutation.SetUdFlash(u) + return mpc +} + +// SetNillableUdFlash sets the "ud_flash" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableUdFlash(u *uint) *MatchPlayerCreate { + if u != nil { + mpc.SetUdFlash(*u) + } + return mpc +} + +// SetUdDecoy sets the "ud_decoy" field. +func (mpc *MatchPlayerCreate) SetUdDecoy(u uint) *MatchPlayerCreate { + mpc.mutation.SetUdDecoy(u) + return mpc +} + +// SetNillableUdDecoy sets the "ud_decoy" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableUdDecoy(u *uint) *MatchPlayerCreate { + if u != nil { + mpc.SetUdDecoy(*u) + } + return mpc +} + +// SetUdSmoke sets the "ud_smoke" field. +func (mpc *MatchPlayerCreate) SetUdSmoke(u uint) *MatchPlayerCreate { + mpc.mutation.SetUdSmoke(u) + return mpc +} + +// SetNillableUdSmoke sets the "ud_smoke" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableUdSmoke(u *uint) *MatchPlayerCreate { + if u != nil { + mpc.SetUdSmoke(*u) + } + return mpc +} + +// SetCrosshair sets the "crosshair" field. +func (mpc *MatchPlayerCreate) SetCrosshair(s string) *MatchPlayerCreate { + mpc.mutation.SetCrosshair(s) + return mpc +} + +// SetNillableCrosshair sets the "crosshair" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableCrosshair(s *string) *MatchPlayerCreate { + if s != nil { + mpc.SetCrosshair(*s) + } + return mpc +} + +// SetColor sets the "color" field. +func (mpc *MatchPlayerCreate) SetColor(m matchplayer.Color) *MatchPlayerCreate { + mpc.mutation.SetColor(m) + return mpc +} + +// SetNillableColor sets the "color" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableColor(m *matchplayer.Color) *MatchPlayerCreate { + if m != nil { + mpc.SetColor(*m) + } + return mpc +} + +// SetKast sets the "kast" field. +func (mpc *MatchPlayerCreate) SetKast(i int) *MatchPlayerCreate { + mpc.mutation.SetKast(i) + return mpc +} + +// SetNillableKast sets the "kast" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableKast(i *int) *MatchPlayerCreate { + if i != nil { + mpc.SetKast(*i) + } + return mpc +} + +// SetFlashDurationSelf sets the "flash_duration_self" field. +func (mpc *MatchPlayerCreate) SetFlashDurationSelf(f float32) *MatchPlayerCreate { + mpc.mutation.SetFlashDurationSelf(f) + return mpc +} + +// SetNillableFlashDurationSelf sets the "flash_duration_self" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableFlashDurationSelf(f *float32) *MatchPlayerCreate { + if f != nil { + mpc.SetFlashDurationSelf(*f) + } + return mpc +} + +// SetFlashDurationTeam sets the "flash_duration_team" field. +func (mpc *MatchPlayerCreate) SetFlashDurationTeam(f float32) *MatchPlayerCreate { + mpc.mutation.SetFlashDurationTeam(f) + return mpc +} + +// SetNillableFlashDurationTeam sets the "flash_duration_team" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableFlashDurationTeam(f *float32) *MatchPlayerCreate { + if f != nil { + mpc.SetFlashDurationTeam(*f) + } + return mpc +} + +// SetFlashDurationEnemy sets the "flash_duration_enemy" field. +func (mpc *MatchPlayerCreate) SetFlashDurationEnemy(f float32) *MatchPlayerCreate { + mpc.mutation.SetFlashDurationEnemy(f) + return mpc +} + +// SetNillableFlashDurationEnemy sets the "flash_duration_enemy" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableFlashDurationEnemy(f *float32) *MatchPlayerCreate { + if f != nil { + mpc.SetFlashDurationEnemy(*f) + } + return mpc +} + +// SetFlashTotalSelf sets the "flash_total_self" field. +func (mpc *MatchPlayerCreate) SetFlashTotalSelf(u uint) *MatchPlayerCreate { + mpc.mutation.SetFlashTotalSelf(u) + return mpc +} + +// SetNillableFlashTotalSelf sets the "flash_total_self" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableFlashTotalSelf(u *uint) *MatchPlayerCreate { + if u != nil { + mpc.SetFlashTotalSelf(*u) + } + return mpc +} + +// SetFlashTotalTeam sets the "flash_total_team" field. +func (mpc *MatchPlayerCreate) SetFlashTotalTeam(u uint) *MatchPlayerCreate { + mpc.mutation.SetFlashTotalTeam(u) + return mpc +} + +// SetNillableFlashTotalTeam sets the "flash_total_team" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableFlashTotalTeam(u *uint) *MatchPlayerCreate { + if u != nil { + mpc.SetFlashTotalTeam(*u) + } + return mpc +} + +// SetFlashTotalEnemy sets the "flash_total_enemy" field. +func (mpc *MatchPlayerCreate) SetFlashTotalEnemy(u uint) *MatchPlayerCreate { + mpc.mutation.SetFlashTotalEnemy(u) + return mpc +} + +// SetNillableFlashTotalEnemy sets the "flash_total_enemy" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableFlashTotalEnemy(u *uint) *MatchPlayerCreate { + if u != nil { + mpc.SetFlashTotalEnemy(*u) + } + return mpc +} + +// SetMatchStats sets the "match_stats" field. +func (mpc *MatchPlayerCreate) SetMatchStats(u uint64) *MatchPlayerCreate { + mpc.mutation.SetMatchStats(u) + return mpc +} + +// SetNillableMatchStats sets the "match_stats" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableMatchStats(u *uint64) *MatchPlayerCreate { + if u != nil { + mpc.SetMatchStats(*u) + } + return mpc +} + +// SetPlayerStats sets the "player_stats" field. +func (mpc *MatchPlayerCreate) SetPlayerStats(u uint64) *MatchPlayerCreate { + mpc.mutation.SetPlayerStats(u) + return mpc +} + +// SetNillablePlayerStats sets the "player_stats" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillablePlayerStats(u *uint64) *MatchPlayerCreate { + if u != nil { + mpc.SetPlayerStats(*u) + } + return mpc +} + +// SetFlashAssists sets the "flash_assists" field. +func (mpc *MatchPlayerCreate) SetFlashAssists(i int) *MatchPlayerCreate { + mpc.mutation.SetFlashAssists(i) + return mpc +} + +// SetNillableFlashAssists sets the "flash_assists" field if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableFlashAssists(i *int) *MatchPlayerCreate { + if i != nil { + mpc.SetFlashAssists(*i) + } + return mpc +} + +// SetMatchesID sets the "matches" edge to the Match entity by ID. +func (mpc *MatchPlayerCreate) SetMatchesID(id uint64) *MatchPlayerCreate { + mpc.mutation.SetMatchesID(id) + return mpc +} + +// SetNillableMatchesID sets the "matches" edge to the Match entity by ID if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillableMatchesID(id *uint64) *MatchPlayerCreate { + if id != nil { + mpc = mpc.SetMatchesID(*id) + } + return mpc +} + +// SetMatches sets the "matches" edge to the Match entity. +func (mpc *MatchPlayerCreate) SetMatches(m *Match) *MatchPlayerCreate { + return mpc.SetMatchesID(m.ID) +} + +// SetPlayersID sets the "players" edge to the Player entity by ID. +func (mpc *MatchPlayerCreate) SetPlayersID(id uint64) *MatchPlayerCreate { + mpc.mutation.SetPlayersID(id) + return mpc +} + +// SetNillablePlayersID sets the "players" edge to the Player entity by ID if the given value is not nil. +func (mpc *MatchPlayerCreate) SetNillablePlayersID(id *uint64) *MatchPlayerCreate { + if id != nil { + mpc = mpc.SetPlayersID(*id) + } + return mpc +} + +// SetPlayers sets the "players" edge to the Player entity. +func (mpc *MatchPlayerCreate) SetPlayers(p *Player) *MatchPlayerCreate { + return mpc.SetPlayersID(p.ID) +} + +// AddWeaponStatIDs adds the "weapon_stats" edge to the Weapon entity by IDs. +func (mpc *MatchPlayerCreate) AddWeaponStatIDs(ids ...int) *MatchPlayerCreate { + mpc.mutation.AddWeaponStatIDs(ids...) + return mpc +} + +// AddWeaponStats adds the "weapon_stats" edges to the Weapon entity. +func (mpc *MatchPlayerCreate) AddWeaponStats(w ...*Weapon) *MatchPlayerCreate { + ids := make([]int, len(w)) + for i := range w { + ids[i] = w[i].ID + } + return mpc.AddWeaponStatIDs(ids...) +} + +// AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by IDs. +func (mpc *MatchPlayerCreate) AddRoundStatIDs(ids ...int) *MatchPlayerCreate { + mpc.mutation.AddRoundStatIDs(ids...) + return mpc +} + +// AddRoundStats adds the "round_stats" edges to the RoundStats entity. +func (mpc *MatchPlayerCreate) AddRoundStats(r ...*RoundStats) *MatchPlayerCreate { + ids := make([]int, len(r)) + for i := range r { + ids[i] = r[i].ID + } + return mpc.AddRoundStatIDs(ids...) +} + +// AddSprayIDs adds the "spray" edge to the Spray entity by IDs. +func (mpc *MatchPlayerCreate) AddSprayIDs(ids ...int) *MatchPlayerCreate { + mpc.mutation.AddSprayIDs(ids...) + return mpc +} + +// AddSpray adds the "spray" edges to the Spray entity. +func (mpc *MatchPlayerCreate) AddSpray(s ...*Spray) *MatchPlayerCreate { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return mpc.AddSprayIDs(ids...) +} + +// Mutation returns the MatchPlayerMutation object of the builder. +func (mpc *MatchPlayerCreate) Mutation() *MatchPlayerMutation { + return mpc.mutation +} + +// Save creates the MatchPlayer in the database. +func (mpc *MatchPlayerCreate) Save(ctx context.Context) (*MatchPlayer, error) { + var ( + err error + node *MatchPlayer + ) + if len(mpc.hooks) == 0 { + if err = mpc.check(); err != nil { + return nil, err + } + node, err = mpc.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*MatchPlayerMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err = mpc.check(); err != nil { + return nil, err + } + mpc.mutation = mutation + if node, err = mpc.sqlSave(ctx); err != nil { + return nil, err + } + mutation.id = &node.ID + mutation.done = true + return node, err + }) + for i := len(mpc.hooks) - 1; i >= 0; i-- { + if mpc.hooks[i] == nil { + return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = mpc.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, mpc.mutation); err != nil { + return nil, err + } + } + return node, err +} + +// SaveX calls Save and panics if Save returns an error. +func (mpc *MatchPlayerCreate) SaveX(ctx context.Context) *MatchPlayer { + v, err := mpc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mpc *MatchPlayerCreate) Exec(ctx context.Context) error { + _, err := mpc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mpc *MatchPlayerCreate) ExecX(ctx context.Context) { + if err := mpc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mpc *MatchPlayerCreate) check() error { + if _, ok := mpc.mutation.TeamID(); !ok { + return &ValidationError{Name: "team_id", err: errors.New(`ent: missing required field "team_id"`)} + } + if _, ok := mpc.mutation.Kills(); !ok { + return &ValidationError{Name: "kills", err: errors.New(`ent: missing required field "kills"`)} + } + if _, ok := mpc.mutation.Deaths(); !ok { + return &ValidationError{Name: "deaths", err: errors.New(`ent: missing required field "deaths"`)} + } + if _, ok := mpc.mutation.Assists(); !ok { + return &ValidationError{Name: "assists", err: errors.New(`ent: missing required field "assists"`)} + } + if _, ok := mpc.mutation.Headshot(); !ok { + return &ValidationError{Name: "headshot", err: errors.New(`ent: missing required field "headshot"`)} + } + if _, ok := mpc.mutation.Mvp(); !ok { + return &ValidationError{Name: "mvp", err: errors.New(`ent: missing required field "mvp"`)} + } + if _, ok := mpc.mutation.Score(); !ok { + return &ValidationError{Name: "score", err: errors.New(`ent: missing required field "score"`)} + } + if v, ok := mpc.mutation.Color(); ok { + if err := matchplayer.ColorValidator(v); err != nil { + return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "color": %w`, err)} + } + } + return nil +} + +func (mpc *MatchPlayerCreate) sqlSave(ctx context.Context) (*MatchPlayer, error) { + _node, _spec := mpc.createSpec() + if err := sqlgraph.CreateNode(ctx, mpc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + return _node, nil +} + +func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec) { + var ( + _node = &MatchPlayer{config: mpc.config} + _spec = &sqlgraph.CreateSpec{ + Table: matchplayer.Table, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldID, + }, + } + ) + if value, ok := mpc.mutation.TeamID(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldTeamID, + }) + _node.TeamID = value + } + if value, ok := mpc.mutation.Kills(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldKills, + }) + _node.Kills = value + } + if value, ok := mpc.mutation.Deaths(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldDeaths, + }) + _node.Deaths = value + } + if value, ok := mpc.mutation.Assists(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldAssists, + }) + _node.Assists = value + } + if value, ok := mpc.mutation.Headshot(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldHeadshot, + }) + _node.Headshot = value + } + if value, ok := mpc.mutation.Mvp(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMvp, + }) + _node.Mvp = value + } + if value, ok := mpc.mutation.Score(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldScore, + }) + _node.Score = value + } + if value, ok := mpc.mutation.RankNew(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldRankNew, + }) + _node.RankNew = value + } + if value, ok := mpc.mutation.RankOld(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldRankOld, + }) + _node.RankOld = value + } + if value, ok := mpc.mutation.Mk2(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk2, + }) + _node.Mk2 = value + } + if value, ok := mpc.mutation.Mk3(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk3, + }) + _node.Mk3 = value + } + if value, ok := mpc.mutation.Mk4(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk4, + }) + _node.Mk4 = value + } + if value, ok := mpc.mutation.Mk5(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk5, + }) + _node.Mk5 = value + } + if value, ok := mpc.mutation.DmgEnemy(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldDmgEnemy, + }) + _node.DmgEnemy = value + } + if value, ok := mpc.mutation.DmgTeam(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldDmgTeam, + }) + _node.DmgTeam = value + } + if value, ok := mpc.mutation.UdHe(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdHe, + }) + _node.UdHe = value + } + if value, ok := mpc.mutation.UdFlames(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdFlames, + }) + _node.UdFlames = value + } + if value, ok := mpc.mutation.UdFlash(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdFlash, + }) + _node.UdFlash = value + } + if value, ok := mpc.mutation.UdDecoy(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdDecoy, + }) + _node.UdDecoy = value + } + if value, ok := mpc.mutation.UdSmoke(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdSmoke, + }) + _node.UdSmoke = value + } + if value, ok := mpc.mutation.Crosshair(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: matchplayer.FieldCrosshair, + }) + _node.Crosshair = value + } + if value, ok := mpc.mutation.Color(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeEnum, + Value: value, + Column: matchplayer.FieldColor, + }) + _node.Color = value + } + if value, ok := mpc.mutation.Kast(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldKast, + }) + _node.Kast = value + } + if value, ok := mpc.mutation.FlashDurationSelf(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: matchplayer.FieldFlashDurationSelf, + }) + _node.FlashDurationSelf = value + } + if value, ok := mpc.mutation.FlashDurationTeam(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: matchplayer.FieldFlashDurationTeam, + }) + _node.FlashDurationTeam = value + } + if value, ok := mpc.mutation.FlashDurationEnemy(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: matchplayer.FieldFlashDurationEnemy, + }) + _node.FlashDurationEnemy = value + } + if value, ok := mpc.mutation.FlashTotalSelf(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldFlashTotalSelf, + }) + _node.FlashTotalSelf = value + } + if value, ok := mpc.mutation.FlashTotalTeam(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldFlashTotalTeam, + }) + _node.FlashTotalTeam = value + } + if value, ok := mpc.mutation.FlashTotalEnemy(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldFlashTotalEnemy, + }) + _node.FlashTotalEnemy = value + } + if value, ok := mpc.mutation.FlashAssists(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldFlashAssists, + }) + _node.FlashAssists = value + } + if nodes := mpc.mutation.MatchesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: matchplayer.MatchesTable, + Columns: []string{matchplayer.MatchesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Column: match.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.MatchStats = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := mpc.mutation.PlayersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: matchplayer.PlayersTable, + Columns: []string{matchplayer.PlayersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Column: player.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.PlayerStats = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := mpc.mutation.WeaponStatsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.WeaponStatsTable, + Columns: []string{matchplayer.WeaponStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weapon.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := mpc.mutation.RoundStatsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.RoundStatsTable, + Columns: []string{matchplayer.RoundStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: roundstats.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := mpc.mutation.SprayIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.SprayTable, + Columns: []string{matchplayer.SprayColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: spray.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// MatchPlayerCreateBulk is the builder for creating many MatchPlayer entities in bulk. +type MatchPlayerCreateBulk struct { + config + builders []*MatchPlayerCreate +} + +// Save creates the MatchPlayer entities in the database. +func (mpcb *MatchPlayerCreateBulk) Save(ctx context.Context) ([]*MatchPlayer, error) { + specs := make([]*sqlgraph.CreateSpec, len(mpcb.builders)) + nodes := make([]*MatchPlayer, len(mpcb.builders)) + mutators := make([]Mutator, len(mpcb.builders)) + for i := range mpcb.builders { + func(i int, root context.Context) { + builder := mpcb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*MatchPlayerMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + nodes[i], specs[i] = builder.createSpec() + var err error + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, mpcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, mpcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, mpcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (mpcb *MatchPlayerCreateBulk) SaveX(ctx context.Context) []*MatchPlayer { + v, err := mpcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mpcb *MatchPlayerCreateBulk) Exec(ctx context.Context) error { + _, err := mpcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mpcb *MatchPlayerCreateBulk) ExecX(ctx context.Context) { + if err := mpcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/matchplayer_delete.go b/ent/matchplayer_delete.go new file mode 100644 index 0000000..1f0199d --- /dev/null +++ b/ent/matchplayer_delete.go @@ -0,0 +1,111 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "csgowtfd/ent/matchplayer" + "csgowtfd/ent/predicate" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// MatchPlayerDelete is the builder for deleting a MatchPlayer entity. +type MatchPlayerDelete struct { + config + hooks []Hook + mutation *MatchPlayerMutation +} + +// Where appends a list predicates to the MatchPlayerDelete builder. +func (mpd *MatchPlayerDelete) Where(ps ...predicate.MatchPlayer) *MatchPlayerDelete { + mpd.mutation.Where(ps...) + return mpd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (mpd *MatchPlayerDelete) Exec(ctx context.Context) (int, error) { + var ( + err error + affected int + ) + if len(mpd.hooks) == 0 { + affected, err = mpd.sqlExec(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*MatchPlayerMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + mpd.mutation = mutation + affected, err = mpd.sqlExec(ctx) + mutation.done = true + return affected, err + }) + for i := len(mpd.hooks) - 1; i >= 0; i-- { + if mpd.hooks[i] == nil { + return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = mpd.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, mpd.mutation); err != nil { + return 0, err + } + } + return affected, err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mpd *MatchPlayerDelete) ExecX(ctx context.Context) int { + n, err := mpd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (mpd *MatchPlayerDelete) sqlExec(ctx context.Context) (int, error) { + _spec := &sqlgraph.DeleteSpec{ + Node: &sqlgraph.NodeSpec{ + Table: matchplayer.Table, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldID, + }, + }, + } + if ps := mpd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return sqlgraph.DeleteNodes(ctx, mpd.driver, _spec) +} + +// MatchPlayerDeleteOne is the builder for deleting a single MatchPlayer entity. +type MatchPlayerDeleteOne struct { + mpd *MatchPlayerDelete +} + +// Exec executes the deletion query. +func (mpdo *MatchPlayerDeleteOne) Exec(ctx context.Context) error { + n, err := mpdo.mpd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{matchplayer.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (mpdo *MatchPlayerDeleteOne) ExecX(ctx context.Context) { + mpdo.mpd.ExecX(ctx) +} diff --git a/ent/matchplayer_query.go b/ent/matchplayer_query.go new file mode 100644 index 0000000..8aed82e --- /dev/null +++ b/ent/matchplayer_query.go @@ -0,0 +1,1267 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "csgowtfd/ent/match" + "csgowtfd/ent/matchplayer" + "csgowtfd/ent/player" + "csgowtfd/ent/predicate" + "csgowtfd/ent/roundstats" + "csgowtfd/ent/spray" + "csgowtfd/ent/weapon" + "database/sql/driver" + "errors" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// MatchPlayerQuery is the builder for querying MatchPlayer entities. +type MatchPlayerQuery struct { + config + limit *int + offset *int + unique *bool + order []OrderFunc + fields []string + predicates []predicate.MatchPlayer + // eager-loading edges. + withMatches *MatchQuery + withPlayers *PlayerQuery + withWeaponStats *WeaponQuery + withRoundStats *RoundStatsQuery + withSpray *SprayQuery + modifiers []func(s *sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the MatchPlayerQuery builder. +func (mpq *MatchPlayerQuery) Where(ps ...predicate.MatchPlayer) *MatchPlayerQuery { + mpq.predicates = append(mpq.predicates, ps...) + return mpq +} + +// Limit adds a limit step to the query. +func (mpq *MatchPlayerQuery) Limit(limit int) *MatchPlayerQuery { + mpq.limit = &limit + return mpq +} + +// Offset adds an offset step to the query. +func (mpq *MatchPlayerQuery) Offset(offset int) *MatchPlayerQuery { + mpq.offset = &offset + return mpq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (mpq *MatchPlayerQuery) Unique(unique bool) *MatchPlayerQuery { + mpq.unique = &unique + return mpq +} + +// Order adds an order step to the query. +func (mpq *MatchPlayerQuery) Order(o ...OrderFunc) *MatchPlayerQuery { + mpq.order = append(mpq.order, o...) + return mpq +} + +// QueryMatches chains the current query on the "matches" edge. +func (mpq *MatchPlayerQuery) QueryMatches() *MatchQuery { + query := &MatchQuery{config: mpq.config} + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mpq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mpq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(matchplayer.Table, matchplayer.FieldID, selector), + sqlgraph.To(match.Table, match.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.MatchesTable, matchplayer.MatchesColumn), + ) + fromU = sqlgraph.SetNeighbors(mpq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryPlayers chains the current query on the "players" edge. +func (mpq *MatchPlayerQuery) QueryPlayers() *PlayerQuery { + query := &PlayerQuery{config: mpq.config} + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mpq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mpq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(matchplayer.Table, matchplayer.FieldID, selector), + sqlgraph.To(player.Table, player.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.PlayersTable, matchplayer.PlayersColumn), + ) + fromU = sqlgraph.SetNeighbors(mpq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryWeaponStats chains the current query on the "weapon_stats" edge. +func (mpq *MatchPlayerQuery) QueryWeaponStats() *WeaponQuery { + query := &WeaponQuery{config: mpq.config} + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mpq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mpq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(matchplayer.Table, matchplayer.FieldID, selector), + sqlgraph.To(weapon.Table, weapon.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.WeaponStatsTable, matchplayer.WeaponStatsColumn), + ) + fromU = sqlgraph.SetNeighbors(mpq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryRoundStats chains the current query on the "round_stats" edge. +func (mpq *MatchPlayerQuery) QueryRoundStats() *RoundStatsQuery { + query := &RoundStatsQuery{config: mpq.config} + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mpq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mpq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(matchplayer.Table, matchplayer.FieldID, selector), + sqlgraph.To(roundstats.Table, roundstats.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.RoundStatsTable, matchplayer.RoundStatsColumn), + ) + fromU = sqlgraph.SetNeighbors(mpq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QuerySpray chains the current query on the "spray" edge. +func (mpq *MatchPlayerQuery) QuerySpray() *SprayQuery { + query := &SprayQuery{config: mpq.config} + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mpq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mpq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(matchplayer.Table, matchplayer.FieldID, selector), + sqlgraph.To(spray.Table, spray.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.SprayTable, matchplayer.SprayColumn), + ) + fromU = sqlgraph.SetNeighbors(mpq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first MatchPlayer entity from the query. +// Returns a *NotFoundError when no MatchPlayer was found. +func (mpq *MatchPlayerQuery) First(ctx context.Context) (*MatchPlayer, error) { + nodes, err := mpq.Limit(1).All(ctx) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{matchplayer.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (mpq *MatchPlayerQuery) FirstX(ctx context.Context) *MatchPlayer { + node, err := mpq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first MatchPlayer ID from the query. +// Returns a *NotFoundError when no MatchPlayer ID was found. +func (mpq *MatchPlayerQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = mpq.Limit(1).IDs(ctx); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{matchplayer.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (mpq *MatchPlayerQuery) FirstIDX(ctx context.Context) int { + id, err := mpq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single MatchPlayer entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when exactly one MatchPlayer entity is not found. +// Returns a *NotFoundError when no MatchPlayer entities are found. +func (mpq *MatchPlayerQuery) Only(ctx context.Context) (*MatchPlayer, error) { + nodes, err := mpq.Limit(2).All(ctx) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{matchplayer.Label} + default: + return nil, &NotSingularError{matchplayer.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (mpq *MatchPlayerQuery) OnlyX(ctx context.Context) *MatchPlayer { + node, err := mpq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only MatchPlayer ID in the query. +// Returns a *NotSingularError when exactly one MatchPlayer ID is not found. +// Returns a *NotFoundError when no entities are found. +func (mpq *MatchPlayerQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = mpq.Limit(2).IDs(ctx); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{matchplayer.Label} + default: + err = &NotSingularError{matchplayer.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (mpq *MatchPlayerQuery) OnlyIDX(ctx context.Context) int { + id, err := mpq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of MatchPlayers. +func (mpq *MatchPlayerQuery) All(ctx context.Context) ([]*MatchPlayer, error) { + if err := mpq.prepareQuery(ctx); err != nil { + return nil, err + } + return mpq.sqlAll(ctx) +} + +// AllX is like All, but panics if an error occurs. +func (mpq *MatchPlayerQuery) AllX(ctx context.Context) []*MatchPlayer { + nodes, err := mpq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of MatchPlayer IDs. +func (mpq *MatchPlayerQuery) IDs(ctx context.Context) ([]int, error) { + var ids []int + if err := mpq.Select(matchplayer.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (mpq *MatchPlayerQuery) IDsX(ctx context.Context) []int { + ids, err := mpq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (mpq *MatchPlayerQuery) Count(ctx context.Context) (int, error) { + if err := mpq.prepareQuery(ctx); err != nil { + return 0, err + } + return mpq.sqlCount(ctx) +} + +// CountX is like Count, but panics if an error occurs. +func (mpq *MatchPlayerQuery) CountX(ctx context.Context) int { + count, err := mpq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (mpq *MatchPlayerQuery) Exist(ctx context.Context) (bool, error) { + if err := mpq.prepareQuery(ctx); err != nil { + return false, err + } + return mpq.sqlExist(ctx) +} + +// ExistX is like Exist, but panics if an error occurs. +func (mpq *MatchPlayerQuery) ExistX(ctx context.Context) bool { + exist, err := mpq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the MatchPlayerQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (mpq *MatchPlayerQuery) Clone() *MatchPlayerQuery { + if mpq == nil { + return nil + } + return &MatchPlayerQuery{ + config: mpq.config, + limit: mpq.limit, + offset: mpq.offset, + order: append([]OrderFunc{}, mpq.order...), + predicates: append([]predicate.MatchPlayer{}, mpq.predicates...), + withMatches: mpq.withMatches.Clone(), + withPlayers: mpq.withPlayers.Clone(), + withWeaponStats: mpq.withWeaponStats.Clone(), + withRoundStats: mpq.withRoundStats.Clone(), + withSpray: mpq.withSpray.Clone(), + // clone intermediate query. + sql: mpq.sql.Clone(), + path: mpq.path, + } +} + +// WithMatches tells the query-builder to eager-load the nodes that are connected to +// the "matches" edge. The optional arguments are used to configure the query builder of the edge. +func (mpq *MatchPlayerQuery) WithMatches(opts ...func(*MatchQuery)) *MatchPlayerQuery { + query := &MatchQuery{config: mpq.config} + for _, opt := range opts { + opt(query) + } + mpq.withMatches = query + return mpq +} + +// WithPlayers tells the query-builder to eager-load the nodes that are connected to +// the "players" edge. The optional arguments are used to configure the query builder of the edge. +func (mpq *MatchPlayerQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchPlayerQuery { + query := &PlayerQuery{config: mpq.config} + for _, opt := range opts { + opt(query) + } + mpq.withPlayers = query + return mpq +} + +// WithWeaponStats tells the query-builder to eager-load the nodes that are connected to +// the "weapon_stats" edge. The optional arguments are used to configure the query builder of the edge. +func (mpq *MatchPlayerQuery) WithWeaponStats(opts ...func(*WeaponQuery)) *MatchPlayerQuery { + query := &WeaponQuery{config: mpq.config} + for _, opt := range opts { + opt(query) + } + mpq.withWeaponStats = query + return mpq +} + +// WithRoundStats tells the query-builder to eager-load the nodes that are connected to +// the "round_stats" edge. The optional arguments are used to configure the query builder of the edge. +func (mpq *MatchPlayerQuery) WithRoundStats(opts ...func(*RoundStatsQuery)) *MatchPlayerQuery { + query := &RoundStatsQuery{config: mpq.config} + for _, opt := range opts { + opt(query) + } + mpq.withRoundStats = query + return mpq +} + +// WithSpray tells the query-builder to eager-load the nodes that are connected to +// the "spray" edge. The optional arguments are used to configure the query builder of the edge. +func (mpq *MatchPlayerQuery) WithSpray(opts ...func(*SprayQuery)) *MatchPlayerQuery { + query := &SprayQuery{config: mpq.config} + for _, opt := range opts { + opt(query) + } + mpq.withSpray = query + return mpq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// TeamID int `json:"team_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.MatchPlayer.Query(). +// GroupBy(matchplayer.FieldTeamID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +// +func (mpq *MatchPlayerQuery) GroupBy(field string, fields ...string) *MatchPlayerGroupBy { + group := &MatchPlayerGroupBy{config: mpq.config} + group.fields = append([]string{field}, fields...) + group.path = func(ctx context.Context) (prev *sql.Selector, err error) { + if err := mpq.prepareQuery(ctx); err != nil { + return nil, err + } + return mpq.sqlQuery(ctx), nil + } + return group +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// TeamID int `json:"team_id,omitempty"` +// } +// +// client.MatchPlayer.Query(). +// Select(matchplayer.FieldTeamID). +// Scan(ctx, &v) +// +func (mpq *MatchPlayerQuery) Select(fields ...string) *MatchPlayerSelect { + mpq.fields = append(mpq.fields, fields...) + return &MatchPlayerSelect{MatchPlayerQuery: mpq} +} + +func (mpq *MatchPlayerQuery) prepareQuery(ctx context.Context) error { + for _, f := range mpq.fields { + if !matchplayer.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if mpq.path != nil { + prev, err := mpq.path(ctx) + if err != nil { + return err + } + mpq.sql = prev + } + return nil +} + +func (mpq *MatchPlayerQuery) sqlAll(ctx context.Context) ([]*MatchPlayer, error) { + var ( + nodes = []*MatchPlayer{} + _spec = mpq.querySpec() + loadedTypes = [5]bool{ + mpq.withMatches != nil, + mpq.withPlayers != nil, + mpq.withWeaponStats != nil, + mpq.withRoundStats != nil, + mpq.withSpray != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]interface{}, error) { + node := &MatchPlayer{config: mpq.config} + nodes = append(nodes, node) + return node.scanValues(columns) + } + _spec.Assign = func(columns []string, values []interface{}) error { + if len(nodes) == 0 { + return fmt.Errorf("ent: Assign called without calling ScanValues") + } + node := nodes[len(nodes)-1] + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(mpq.modifiers) > 0 { + _spec.Modifiers = mpq.modifiers + } + if err := sqlgraph.QueryNodes(ctx, mpq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + + if query := mpq.withMatches; query != nil { + ids := make([]uint64, 0, len(nodes)) + nodeids := make(map[uint64][]*MatchPlayer) + for i := range nodes { + fk := nodes[i].MatchStats + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + query.Where(match.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return nil, err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return nil, fmt.Errorf(`unexpected foreign-key "match_stats" returned %v`, n.ID) + } + for i := range nodes { + nodes[i].Edges.Matches = n + } + } + } + + if query := mpq.withPlayers; query != nil { + ids := make([]uint64, 0, len(nodes)) + nodeids := make(map[uint64][]*MatchPlayer) + for i := range nodes { + fk := nodes[i].PlayerStats + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + query.Where(player.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return nil, err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return nil, fmt.Errorf(`unexpected foreign-key "player_stats" returned %v`, n.ID) + } + for i := range nodes { + nodes[i].Edges.Players = n + } + } + } + + if query := mpq.withWeaponStats; query != nil { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*MatchPlayer) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + nodes[i].Edges.WeaponStats = []*Weapon{} + } + query.withFKs = true + query.Where(predicate.Weapon(func(s *sql.Selector) { + s.Where(sql.InValues(matchplayer.WeaponStatsColumn, fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return nil, err + } + for _, n := range neighbors { + fk := n.match_player_weapon_stats + if fk == nil { + return nil, fmt.Errorf(`foreign-key "match_player_weapon_stats" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return nil, fmt.Errorf(`unexpected foreign-key "match_player_weapon_stats" returned %v for node %v`, *fk, n.ID) + } + node.Edges.WeaponStats = append(node.Edges.WeaponStats, n) + } + } + + if query := mpq.withRoundStats; query != nil { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*MatchPlayer) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + nodes[i].Edges.RoundStats = []*RoundStats{} + } + query.withFKs = true + query.Where(predicate.RoundStats(func(s *sql.Selector) { + s.Where(sql.InValues(matchplayer.RoundStatsColumn, fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return nil, err + } + for _, n := range neighbors { + fk := n.match_player_round_stats + if fk == nil { + return nil, fmt.Errorf(`foreign-key "match_player_round_stats" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return nil, fmt.Errorf(`unexpected foreign-key "match_player_round_stats" returned %v for node %v`, *fk, n.ID) + } + node.Edges.RoundStats = append(node.Edges.RoundStats, n) + } + } + + if query := mpq.withSpray; query != nil { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*MatchPlayer) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + nodes[i].Edges.Spray = []*Spray{} + } + query.withFKs = true + query.Where(predicate.Spray(func(s *sql.Selector) { + s.Where(sql.InValues(matchplayer.SprayColumn, fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return nil, err + } + for _, n := range neighbors { + fk := n.match_player_spray + if fk == nil { + return nil, fmt.Errorf(`foreign-key "match_player_spray" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return nil, fmt.Errorf(`unexpected foreign-key "match_player_spray" returned %v for node %v`, *fk, n.ID) + } + node.Edges.Spray = append(node.Edges.Spray, n) + } + } + + return nodes, nil +} + +func (mpq *MatchPlayerQuery) sqlCount(ctx context.Context) (int, error) { + _spec := mpq.querySpec() + if len(mpq.modifiers) > 0 { + _spec.Modifiers = mpq.modifiers + } + return sqlgraph.CountNodes(ctx, mpq.driver, _spec) +} + +func (mpq *MatchPlayerQuery) sqlExist(ctx context.Context) (bool, error) { + n, err := mpq.sqlCount(ctx) + if err != nil { + return false, fmt.Errorf("ent: check existence: %w", err) + } + return n > 0, nil +} + +func (mpq *MatchPlayerQuery) querySpec() *sqlgraph.QuerySpec { + _spec := &sqlgraph.QuerySpec{ + Node: &sqlgraph.NodeSpec{ + Table: matchplayer.Table, + Columns: matchplayer.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldID, + }, + }, + From: mpq.sql, + Unique: true, + } + if unique := mpq.unique; unique != nil { + _spec.Unique = *unique + } + if fields := mpq.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, matchplayer.FieldID) + for i := range fields { + if fields[i] != matchplayer.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := mpq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := mpq.limit; limit != nil { + _spec.Limit = *limit + } + if offset := mpq.offset; offset != nil { + _spec.Offset = *offset + } + if ps := mpq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (mpq *MatchPlayerQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(mpq.driver.Dialect()) + t1 := builder.Table(matchplayer.Table) + columns := mpq.fields + if len(columns) == 0 { + columns = matchplayer.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if mpq.sql != nil { + selector = mpq.sql + selector.Select(selector.Columns(columns...)...) + } + for _, m := range mpq.modifiers { + m(selector) + } + for _, p := range mpq.predicates { + p(selector) + } + for _, p := range mpq.order { + p(selector) + } + if offset := mpq.offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := mpq.limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (mpq *MatchPlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchPlayerSelect { + mpq.modifiers = append(mpq.modifiers, modifiers...) + return mpq.Select() +} + +// MatchPlayerGroupBy is the group-by builder for MatchPlayer entities. +type MatchPlayerGroupBy struct { + config + fields []string + fns []AggregateFunc + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (mpgb *MatchPlayerGroupBy) Aggregate(fns ...AggregateFunc) *MatchPlayerGroupBy { + mpgb.fns = append(mpgb.fns, fns...) + return mpgb +} + +// Scan applies the group-by query and scans the result into the given value. +func (mpgb *MatchPlayerGroupBy) Scan(ctx context.Context, v interface{}) error { + query, err := mpgb.path(ctx) + if err != nil { + return err + } + mpgb.sql = query + return mpgb.sqlScan(ctx, v) +} + +// ScanX is like Scan, but panics if an error occurs. +func (mpgb *MatchPlayerGroupBy) ScanX(ctx context.Context, v interface{}) { + if err := mpgb.Scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from group-by. +// It is only allowed when executing a group-by query with one field. +func (mpgb *MatchPlayerGroupBy) Strings(ctx context.Context) ([]string, error) { + if len(mpgb.fields) > 1 { + return nil, errors.New("ent: MatchPlayerGroupBy.Strings is not achievable when grouping more than 1 field") + } + var v []string + if err := mpgb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (mpgb *MatchPlayerGroupBy) StringsX(ctx context.Context) []string { + v, err := mpgb.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (mpgb *MatchPlayerGroupBy) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = mpgb.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{matchplayer.Label} + default: + err = fmt.Errorf("ent: MatchPlayerGroupBy.Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (mpgb *MatchPlayerGroupBy) StringX(ctx context.Context) string { + v, err := mpgb.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from group-by. +// It is only allowed when executing a group-by query with one field. +func (mpgb *MatchPlayerGroupBy) Ints(ctx context.Context) ([]int, error) { + if len(mpgb.fields) > 1 { + return nil, errors.New("ent: MatchPlayerGroupBy.Ints is not achievable when grouping more than 1 field") + } + var v []int + if err := mpgb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (mpgb *MatchPlayerGroupBy) IntsX(ctx context.Context) []int { + v, err := mpgb.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (mpgb *MatchPlayerGroupBy) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = mpgb.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{matchplayer.Label} + default: + err = fmt.Errorf("ent: MatchPlayerGroupBy.Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (mpgb *MatchPlayerGroupBy) IntX(ctx context.Context) int { + v, err := mpgb.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from group-by. +// It is only allowed when executing a group-by query with one field. +func (mpgb *MatchPlayerGroupBy) Float64s(ctx context.Context) ([]float64, error) { + if len(mpgb.fields) > 1 { + return nil, errors.New("ent: MatchPlayerGroupBy.Float64s is not achievable when grouping more than 1 field") + } + var v []float64 + if err := mpgb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (mpgb *MatchPlayerGroupBy) Float64sX(ctx context.Context) []float64 { + v, err := mpgb.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (mpgb *MatchPlayerGroupBy) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = mpgb.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{matchplayer.Label} + default: + err = fmt.Errorf("ent: MatchPlayerGroupBy.Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (mpgb *MatchPlayerGroupBy) Float64X(ctx context.Context) float64 { + v, err := mpgb.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from group-by. +// It is only allowed when executing a group-by query with one field. +func (mpgb *MatchPlayerGroupBy) Bools(ctx context.Context) ([]bool, error) { + if len(mpgb.fields) > 1 { + return nil, errors.New("ent: MatchPlayerGroupBy.Bools is not achievable when grouping more than 1 field") + } + var v []bool + if err := mpgb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (mpgb *MatchPlayerGroupBy) BoolsX(ctx context.Context) []bool { + v, err := mpgb.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (mpgb *MatchPlayerGroupBy) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = mpgb.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{matchplayer.Label} + default: + err = fmt.Errorf("ent: MatchPlayerGroupBy.Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (mpgb *MatchPlayerGroupBy) BoolX(ctx context.Context) bool { + v, err := mpgb.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +func (mpgb *MatchPlayerGroupBy) sqlScan(ctx context.Context, v interface{}) error { + for _, f := range mpgb.fields { + if !matchplayer.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} + } + } + selector := mpgb.sqlQuery() + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := mpgb.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +func (mpgb *MatchPlayerGroupBy) sqlQuery() *sql.Selector { + selector := mpgb.sql.Select() + aggregation := make([]string, 0, len(mpgb.fns)) + for _, fn := range mpgb.fns { + aggregation = append(aggregation, fn(selector)) + } + // If no columns were selected in a custom aggregation function, the default + // selection is the fields used for "group-by", and the aggregation functions. + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(mpgb.fields)+len(mpgb.fns)) + for _, f := range mpgb.fields { + columns = append(columns, selector.C(f)) + } + for _, c := range aggregation { + columns = append(columns, c) + } + selector.Select(columns...) + } + return selector.GroupBy(selector.Columns(mpgb.fields...)...) +} + +// MatchPlayerSelect is the builder for selecting fields of MatchPlayer entities. +type MatchPlayerSelect struct { + *MatchPlayerQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector +} + +// Scan applies the selector query and scans the result into the given value. +func (mps *MatchPlayerSelect) Scan(ctx context.Context, v interface{}) error { + if err := mps.prepareQuery(ctx); err != nil { + return err + } + mps.sql = mps.MatchPlayerQuery.sqlQuery(ctx) + return mps.sqlScan(ctx, v) +} + +// ScanX is like Scan, but panics if an error occurs. +func (mps *MatchPlayerSelect) ScanX(ctx context.Context, v interface{}) { + if err := mps.Scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from a selector. It is only allowed when selecting one field. +func (mps *MatchPlayerSelect) Strings(ctx context.Context) ([]string, error) { + if len(mps.fields) > 1 { + return nil, errors.New("ent: MatchPlayerSelect.Strings is not achievable when selecting more than 1 field") + } + var v []string + if err := mps.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (mps *MatchPlayerSelect) StringsX(ctx context.Context) []string { + v, err := mps.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a selector. It is only allowed when selecting one field. +func (mps *MatchPlayerSelect) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = mps.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{matchplayer.Label} + default: + err = fmt.Errorf("ent: MatchPlayerSelect.Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (mps *MatchPlayerSelect) StringX(ctx context.Context) string { + v, err := mps.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from a selector. It is only allowed when selecting one field. +func (mps *MatchPlayerSelect) Ints(ctx context.Context) ([]int, error) { + if len(mps.fields) > 1 { + return nil, errors.New("ent: MatchPlayerSelect.Ints is not achievable when selecting more than 1 field") + } + var v []int + if err := mps.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (mps *MatchPlayerSelect) IntsX(ctx context.Context) []int { + v, err := mps.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a selector. It is only allowed when selecting one field. +func (mps *MatchPlayerSelect) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = mps.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{matchplayer.Label} + default: + err = fmt.Errorf("ent: MatchPlayerSelect.Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (mps *MatchPlayerSelect) IntX(ctx context.Context) int { + v, err := mps.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. +func (mps *MatchPlayerSelect) Float64s(ctx context.Context) ([]float64, error) { + if len(mps.fields) > 1 { + return nil, errors.New("ent: MatchPlayerSelect.Float64s is not achievable when selecting more than 1 field") + } + var v []float64 + if err := mps.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (mps *MatchPlayerSelect) Float64sX(ctx context.Context) []float64 { + v, err := mps.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. +func (mps *MatchPlayerSelect) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = mps.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{matchplayer.Label} + default: + err = fmt.Errorf("ent: MatchPlayerSelect.Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (mps *MatchPlayerSelect) Float64X(ctx context.Context) float64 { + v, err := mps.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from a selector. It is only allowed when selecting one field. +func (mps *MatchPlayerSelect) Bools(ctx context.Context) ([]bool, error) { + if len(mps.fields) > 1 { + return nil, errors.New("ent: MatchPlayerSelect.Bools is not achievable when selecting more than 1 field") + } + var v []bool + if err := mps.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (mps *MatchPlayerSelect) BoolsX(ctx context.Context) []bool { + v, err := mps.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a selector. It is only allowed when selecting one field. +func (mps *MatchPlayerSelect) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = mps.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{matchplayer.Label} + default: + err = fmt.Errorf("ent: MatchPlayerSelect.Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (mps *MatchPlayerSelect) BoolX(ctx context.Context) bool { + v, err := mps.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +func (mps *MatchPlayerSelect) sqlScan(ctx context.Context, v interface{}) error { + rows := &sql.Rows{} + query, args := mps.sql.Query() + if err := mps.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (mps *MatchPlayerSelect) Modify(modifiers ...func(s *sql.Selector)) *MatchPlayerSelect { + mps.modifiers = append(mps.modifiers, modifiers...) + return mps +} diff --git a/ent/matchplayer_update.go b/ent/matchplayer_update.go new file mode 100644 index 0000000..7745b59 --- /dev/null +++ b/ent/matchplayer_update.go @@ -0,0 +1,3619 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "csgowtfd/ent/match" + "csgowtfd/ent/matchplayer" + "csgowtfd/ent/player" + "csgowtfd/ent/predicate" + "csgowtfd/ent/roundstats" + "csgowtfd/ent/spray" + "csgowtfd/ent/weapon" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// MatchPlayerUpdate is the builder for updating MatchPlayer entities. +type MatchPlayerUpdate struct { + config + hooks []Hook + mutation *MatchPlayerMutation +} + +// Where appends a list predicates to the MatchPlayerUpdate builder. +func (mpu *MatchPlayerUpdate) Where(ps ...predicate.MatchPlayer) *MatchPlayerUpdate { + mpu.mutation.Where(ps...) + return mpu +} + +// SetTeamID sets the "team_id" field. +func (mpu *MatchPlayerUpdate) SetTeamID(i int) *MatchPlayerUpdate { + mpu.mutation.ResetTeamID() + mpu.mutation.SetTeamID(i) + return mpu +} + +// AddTeamID adds i to the "team_id" field. +func (mpu *MatchPlayerUpdate) AddTeamID(i int) *MatchPlayerUpdate { + mpu.mutation.AddTeamID(i) + return mpu +} + +// SetKills sets the "kills" field. +func (mpu *MatchPlayerUpdate) SetKills(i int) *MatchPlayerUpdate { + mpu.mutation.ResetKills() + mpu.mutation.SetKills(i) + return mpu +} + +// AddKills adds i to the "kills" field. +func (mpu *MatchPlayerUpdate) AddKills(i int) *MatchPlayerUpdate { + mpu.mutation.AddKills(i) + return mpu +} + +// SetDeaths sets the "deaths" field. +func (mpu *MatchPlayerUpdate) SetDeaths(i int) *MatchPlayerUpdate { + mpu.mutation.ResetDeaths() + mpu.mutation.SetDeaths(i) + return mpu +} + +// AddDeaths adds i to the "deaths" field. +func (mpu *MatchPlayerUpdate) AddDeaths(i int) *MatchPlayerUpdate { + mpu.mutation.AddDeaths(i) + return mpu +} + +// SetAssists sets the "assists" field. +func (mpu *MatchPlayerUpdate) SetAssists(i int) *MatchPlayerUpdate { + mpu.mutation.ResetAssists() + mpu.mutation.SetAssists(i) + return mpu +} + +// AddAssists adds i to the "assists" field. +func (mpu *MatchPlayerUpdate) AddAssists(i int) *MatchPlayerUpdate { + mpu.mutation.AddAssists(i) + return mpu +} + +// SetHeadshot sets the "headshot" field. +func (mpu *MatchPlayerUpdate) SetHeadshot(i int) *MatchPlayerUpdate { + mpu.mutation.ResetHeadshot() + mpu.mutation.SetHeadshot(i) + return mpu +} + +// AddHeadshot adds i to the "headshot" field. +func (mpu *MatchPlayerUpdate) AddHeadshot(i int) *MatchPlayerUpdate { + mpu.mutation.AddHeadshot(i) + return mpu +} + +// SetMvp sets the "mvp" field. +func (mpu *MatchPlayerUpdate) SetMvp(u uint) *MatchPlayerUpdate { + mpu.mutation.ResetMvp() + mpu.mutation.SetMvp(u) + return mpu +} + +// AddMvp adds u to the "mvp" field. +func (mpu *MatchPlayerUpdate) AddMvp(u uint) *MatchPlayerUpdate { + mpu.mutation.AddMvp(u) + return mpu +} + +// SetScore sets the "score" field. +func (mpu *MatchPlayerUpdate) SetScore(i int) *MatchPlayerUpdate { + mpu.mutation.ResetScore() + mpu.mutation.SetScore(i) + return mpu +} + +// AddScore adds i to the "score" field. +func (mpu *MatchPlayerUpdate) AddScore(i int) *MatchPlayerUpdate { + mpu.mutation.AddScore(i) + return mpu +} + +// SetRankNew sets the "rank_new" field. +func (mpu *MatchPlayerUpdate) SetRankNew(i int) *MatchPlayerUpdate { + mpu.mutation.ResetRankNew() + mpu.mutation.SetRankNew(i) + return mpu +} + +// SetNillableRankNew sets the "rank_new" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableRankNew(i *int) *MatchPlayerUpdate { + if i != nil { + mpu.SetRankNew(*i) + } + return mpu +} + +// AddRankNew adds i to the "rank_new" field. +func (mpu *MatchPlayerUpdate) AddRankNew(i int) *MatchPlayerUpdate { + mpu.mutation.AddRankNew(i) + return mpu +} + +// ClearRankNew clears the value of the "rank_new" field. +func (mpu *MatchPlayerUpdate) ClearRankNew() *MatchPlayerUpdate { + mpu.mutation.ClearRankNew() + return mpu +} + +// SetRankOld sets the "rank_old" field. +func (mpu *MatchPlayerUpdate) SetRankOld(i int) *MatchPlayerUpdate { + mpu.mutation.ResetRankOld() + mpu.mutation.SetRankOld(i) + return mpu +} + +// SetNillableRankOld sets the "rank_old" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableRankOld(i *int) *MatchPlayerUpdate { + if i != nil { + mpu.SetRankOld(*i) + } + return mpu +} + +// AddRankOld adds i to the "rank_old" field. +func (mpu *MatchPlayerUpdate) AddRankOld(i int) *MatchPlayerUpdate { + mpu.mutation.AddRankOld(i) + return mpu +} + +// ClearRankOld clears the value of the "rank_old" field. +func (mpu *MatchPlayerUpdate) ClearRankOld() *MatchPlayerUpdate { + mpu.mutation.ClearRankOld() + return mpu +} + +// SetMk2 sets the "mk_2" field. +func (mpu *MatchPlayerUpdate) SetMk2(u uint) *MatchPlayerUpdate { + mpu.mutation.ResetMk2() + mpu.mutation.SetMk2(u) + return mpu +} + +// SetNillableMk2 sets the "mk_2" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableMk2(u *uint) *MatchPlayerUpdate { + if u != nil { + mpu.SetMk2(*u) + } + return mpu +} + +// AddMk2 adds u to the "mk_2" field. +func (mpu *MatchPlayerUpdate) AddMk2(u uint) *MatchPlayerUpdate { + mpu.mutation.AddMk2(u) + return mpu +} + +// ClearMk2 clears the value of the "mk_2" field. +func (mpu *MatchPlayerUpdate) ClearMk2() *MatchPlayerUpdate { + mpu.mutation.ClearMk2() + return mpu +} + +// SetMk3 sets the "mk_3" field. +func (mpu *MatchPlayerUpdate) SetMk3(u uint) *MatchPlayerUpdate { + mpu.mutation.ResetMk3() + mpu.mutation.SetMk3(u) + return mpu +} + +// SetNillableMk3 sets the "mk_3" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableMk3(u *uint) *MatchPlayerUpdate { + if u != nil { + mpu.SetMk3(*u) + } + return mpu +} + +// AddMk3 adds u to the "mk_3" field. +func (mpu *MatchPlayerUpdate) AddMk3(u uint) *MatchPlayerUpdate { + mpu.mutation.AddMk3(u) + return mpu +} + +// ClearMk3 clears the value of the "mk_3" field. +func (mpu *MatchPlayerUpdate) ClearMk3() *MatchPlayerUpdate { + mpu.mutation.ClearMk3() + return mpu +} + +// SetMk4 sets the "mk_4" field. +func (mpu *MatchPlayerUpdate) SetMk4(u uint) *MatchPlayerUpdate { + mpu.mutation.ResetMk4() + mpu.mutation.SetMk4(u) + return mpu +} + +// SetNillableMk4 sets the "mk_4" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableMk4(u *uint) *MatchPlayerUpdate { + if u != nil { + mpu.SetMk4(*u) + } + return mpu +} + +// AddMk4 adds u to the "mk_4" field. +func (mpu *MatchPlayerUpdate) AddMk4(u uint) *MatchPlayerUpdate { + mpu.mutation.AddMk4(u) + return mpu +} + +// ClearMk4 clears the value of the "mk_4" field. +func (mpu *MatchPlayerUpdate) ClearMk4() *MatchPlayerUpdate { + mpu.mutation.ClearMk4() + return mpu +} + +// SetMk5 sets the "mk_5" field. +func (mpu *MatchPlayerUpdate) SetMk5(u uint) *MatchPlayerUpdate { + mpu.mutation.ResetMk5() + mpu.mutation.SetMk5(u) + return mpu +} + +// SetNillableMk5 sets the "mk_5" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableMk5(u *uint) *MatchPlayerUpdate { + if u != nil { + mpu.SetMk5(*u) + } + return mpu +} + +// AddMk5 adds u to the "mk_5" field. +func (mpu *MatchPlayerUpdate) AddMk5(u uint) *MatchPlayerUpdate { + mpu.mutation.AddMk5(u) + return mpu +} + +// ClearMk5 clears the value of the "mk_5" field. +func (mpu *MatchPlayerUpdate) ClearMk5() *MatchPlayerUpdate { + mpu.mutation.ClearMk5() + return mpu +} + +// SetDmgEnemy sets the "dmg_enemy" field. +func (mpu *MatchPlayerUpdate) SetDmgEnemy(u uint) *MatchPlayerUpdate { + mpu.mutation.ResetDmgEnemy() + mpu.mutation.SetDmgEnemy(u) + return mpu +} + +// SetNillableDmgEnemy sets the "dmg_enemy" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableDmgEnemy(u *uint) *MatchPlayerUpdate { + if u != nil { + mpu.SetDmgEnemy(*u) + } + return mpu +} + +// AddDmgEnemy adds u to the "dmg_enemy" field. +func (mpu *MatchPlayerUpdate) AddDmgEnemy(u uint) *MatchPlayerUpdate { + mpu.mutation.AddDmgEnemy(u) + return mpu +} + +// ClearDmgEnemy clears the value of the "dmg_enemy" field. +func (mpu *MatchPlayerUpdate) ClearDmgEnemy() *MatchPlayerUpdate { + mpu.mutation.ClearDmgEnemy() + return mpu +} + +// SetDmgTeam sets the "dmg_team" field. +func (mpu *MatchPlayerUpdate) SetDmgTeam(u uint) *MatchPlayerUpdate { + mpu.mutation.ResetDmgTeam() + mpu.mutation.SetDmgTeam(u) + return mpu +} + +// SetNillableDmgTeam sets the "dmg_team" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableDmgTeam(u *uint) *MatchPlayerUpdate { + if u != nil { + mpu.SetDmgTeam(*u) + } + return mpu +} + +// AddDmgTeam adds u to the "dmg_team" field. +func (mpu *MatchPlayerUpdate) AddDmgTeam(u uint) *MatchPlayerUpdate { + mpu.mutation.AddDmgTeam(u) + return mpu +} + +// ClearDmgTeam clears the value of the "dmg_team" field. +func (mpu *MatchPlayerUpdate) ClearDmgTeam() *MatchPlayerUpdate { + mpu.mutation.ClearDmgTeam() + return mpu +} + +// SetUdHe sets the "ud_he" field. +func (mpu *MatchPlayerUpdate) SetUdHe(u uint) *MatchPlayerUpdate { + mpu.mutation.ResetUdHe() + mpu.mutation.SetUdHe(u) + return mpu +} + +// SetNillableUdHe sets the "ud_he" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableUdHe(u *uint) *MatchPlayerUpdate { + if u != nil { + mpu.SetUdHe(*u) + } + return mpu +} + +// AddUdHe adds u to the "ud_he" field. +func (mpu *MatchPlayerUpdate) AddUdHe(u uint) *MatchPlayerUpdate { + mpu.mutation.AddUdHe(u) + return mpu +} + +// ClearUdHe clears the value of the "ud_he" field. +func (mpu *MatchPlayerUpdate) ClearUdHe() *MatchPlayerUpdate { + mpu.mutation.ClearUdHe() + return mpu +} + +// SetUdFlames sets the "ud_flames" field. +func (mpu *MatchPlayerUpdate) SetUdFlames(u uint) *MatchPlayerUpdate { + mpu.mutation.ResetUdFlames() + mpu.mutation.SetUdFlames(u) + return mpu +} + +// SetNillableUdFlames sets the "ud_flames" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableUdFlames(u *uint) *MatchPlayerUpdate { + if u != nil { + mpu.SetUdFlames(*u) + } + return mpu +} + +// AddUdFlames adds u to the "ud_flames" field. +func (mpu *MatchPlayerUpdate) AddUdFlames(u uint) *MatchPlayerUpdate { + mpu.mutation.AddUdFlames(u) + return mpu +} + +// ClearUdFlames clears the value of the "ud_flames" field. +func (mpu *MatchPlayerUpdate) ClearUdFlames() *MatchPlayerUpdate { + mpu.mutation.ClearUdFlames() + return mpu +} + +// SetUdFlash sets the "ud_flash" field. +func (mpu *MatchPlayerUpdate) SetUdFlash(u uint) *MatchPlayerUpdate { + mpu.mutation.ResetUdFlash() + mpu.mutation.SetUdFlash(u) + return mpu +} + +// SetNillableUdFlash sets the "ud_flash" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableUdFlash(u *uint) *MatchPlayerUpdate { + if u != nil { + mpu.SetUdFlash(*u) + } + return mpu +} + +// AddUdFlash adds u to the "ud_flash" field. +func (mpu *MatchPlayerUpdate) AddUdFlash(u uint) *MatchPlayerUpdate { + mpu.mutation.AddUdFlash(u) + return mpu +} + +// ClearUdFlash clears the value of the "ud_flash" field. +func (mpu *MatchPlayerUpdate) ClearUdFlash() *MatchPlayerUpdate { + mpu.mutation.ClearUdFlash() + return mpu +} + +// SetUdDecoy sets the "ud_decoy" field. +func (mpu *MatchPlayerUpdate) SetUdDecoy(u uint) *MatchPlayerUpdate { + mpu.mutation.ResetUdDecoy() + mpu.mutation.SetUdDecoy(u) + return mpu +} + +// SetNillableUdDecoy sets the "ud_decoy" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableUdDecoy(u *uint) *MatchPlayerUpdate { + if u != nil { + mpu.SetUdDecoy(*u) + } + return mpu +} + +// AddUdDecoy adds u to the "ud_decoy" field. +func (mpu *MatchPlayerUpdate) AddUdDecoy(u uint) *MatchPlayerUpdate { + mpu.mutation.AddUdDecoy(u) + return mpu +} + +// ClearUdDecoy clears the value of the "ud_decoy" field. +func (mpu *MatchPlayerUpdate) ClearUdDecoy() *MatchPlayerUpdate { + mpu.mutation.ClearUdDecoy() + return mpu +} + +// SetUdSmoke sets the "ud_smoke" field. +func (mpu *MatchPlayerUpdate) SetUdSmoke(u uint) *MatchPlayerUpdate { + mpu.mutation.ResetUdSmoke() + mpu.mutation.SetUdSmoke(u) + return mpu +} + +// SetNillableUdSmoke sets the "ud_smoke" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableUdSmoke(u *uint) *MatchPlayerUpdate { + if u != nil { + mpu.SetUdSmoke(*u) + } + return mpu +} + +// AddUdSmoke adds u to the "ud_smoke" field. +func (mpu *MatchPlayerUpdate) AddUdSmoke(u uint) *MatchPlayerUpdate { + mpu.mutation.AddUdSmoke(u) + return mpu +} + +// ClearUdSmoke clears the value of the "ud_smoke" field. +func (mpu *MatchPlayerUpdate) ClearUdSmoke() *MatchPlayerUpdate { + mpu.mutation.ClearUdSmoke() + return mpu +} + +// SetCrosshair sets the "crosshair" field. +func (mpu *MatchPlayerUpdate) SetCrosshair(s string) *MatchPlayerUpdate { + mpu.mutation.SetCrosshair(s) + return mpu +} + +// SetNillableCrosshair sets the "crosshair" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableCrosshair(s *string) *MatchPlayerUpdate { + if s != nil { + mpu.SetCrosshair(*s) + } + return mpu +} + +// ClearCrosshair clears the value of the "crosshair" field. +func (mpu *MatchPlayerUpdate) ClearCrosshair() *MatchPlayerUpdate { + mpu.mutation.ClearCrosshair() + return mpu +} + +// SetColor sets the "color" field. +func (mpu *MatchPlayerUpdate) SetColor(m matchplayer.Color) *MatchPlayerUpdate { + mpu.mutation.SetColor(m) + return mpu +} + +// SetNillableColor sets the "color" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableColor(m *matchplayer.Color) *MatchPlayerUpdate { + if m != nil { + mpu.SetColor(*m) + } + return mpu +} + +// ClearColor clears the value of the "color" field. +func (mpu *MatchPlayerUpdate) ClearColor() *MatchPlayerUpdate { + mpu.mutation.ClearColor() + return mpu +} + +// SetKast sets the "kast" field. +func (mpu *MatchPlayerUpdate) SetKast(i int) *MatchPlayerUpdate { + mpu.mutation.ResetKast() + mpu.mutation.SetKast(i) + return mpu +} + +// SetNillableKast sets the "kast" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableKast(i *int) *MatchPlayerUpdate { + if i != nil { + mpu.SetKast(*i) + } + return mpu +} + +// AddKast adds i to the "kast" field. +func (mpu *MatchPlayerUpdate) AddKast(i int) *MatchPlayerUpdate { + mpu.mutation.AddKast(i) + return mpu +} + +// ClearKast clears the value of the "kast" field. +func (mpu *MatchPlayerUpdate) ClearKast() *MatchPlayerUpdate { + mpu.mutation.ClearKast() + return mpu +} + +// SetFlashDurationSelf sets the "flash_duration_self" field. +func (mpu *MatchPlayerUpdate) SetFlashDurationSelf(f float32) *MatchPlayerUpdate { + mpu.mutation.ResetFlashDurationSelf() + mpu.mutation.SetFlashDurationSelf(f) + return mpu +} + +// SetNillableFlashDurationSelf sets the "flash_duration_self" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableFlashDurationSelf(f *float32) *MatchPlayerUpdate { + if f != nil { + mpu.SetFlashDurationSelf(*f) + } + return mpu +} + +// AddFlashDurationSelf adds f to the "flash_duration_self" field. +func (mpu *MatchPlayerUpdate) AddFlashDurationSelf(f float32) *MatchPlayerUpdate { + mpu.mutation.AddFlashDurationSelf(f) + return mpu +} + +// ClearFlashDurationSelf clears the value of the "flash_duration_self" field. +func (mpu *MatchPlayerUpdate) ClearFlashDurationSelf() *MatchPlayerUpdate { + mpu.mutation.ClearFlashDurationSelf() + return mpu +} + +// SetFlashDurationTeam sets the "flash_duration_team" field. +func (mpu *MatchPlayerUpdate) SetFlashDurationTeam(f float32) *MatchPlayerUpdate { + mpu.mutation.ResetFlashDurationTeam() + mpu.mutation.SetFlashDurationTeam(f) + return mpu +} + +// SetNillableFlashDurationTeam sets the "flash_duration_team" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableFlashDurationTeam(f *float32) *MatchPlayerUpdate { + if f != nil { + mpu.SetFlashDurationTeam(*f) + } + return mpu +} + +// AddFlashDurationTeam adds f to the "flash_duration_team" field. +func (mpu *MatchPlayerUpdate) AddFlashDurationTeam(f float32) *MatchPlayerUpdate { + mpu.mutation.AddFlashDurationTeam(f) + return mpu +} + +// ClearFlashDurationTeam clears the value of the "flash_duration_team" field. +func (mpu *MatchPlayerUpdate) ClearFlashDurationTeam() *MatchPlayerUpdate { + mpu.mutation.ClearFlashDurationTeam() + return mpu +} + +// SetFlashDurationEnemy sets the "flash_duration_enemy" field. +func (mpu *MatchPlayerUpdate) SetFlashDurationEnemy(f float32) *MatchPlayerUpdate { + mpu.mutation.ResetFlashDurationEnemy() + mpu.mutation.SetFlashDurationEnemy(f) + return mpu +} + +// SetNillableFlashDurationEnemy sets the "flash_duration_enemy" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableFlashDurationEnemy(f *float32) *MatchPlayerUpdate { + if f != nil { + mpu.SetFlashDurationEnemy(*f) + } + return mpu +} + +// AddFlashDurationEnemy adds f to the "flash_duration_enemy" field. +func (mpu *MatchPlayerUpdate) AddFlashDurationEnemy(f float32) *MatchPlayerUpdate { + mpu.mutation.AddFlashDurationEnemy(f) + return mpu +} + +// ClearFlashDurationEnemy clears the value of the "flash_duration_enemy" field. +func (mpu *MatchPlayerUpdate) ClearFlashDurationEnemy() *MatchPlayerUpdate { + mpu.mutation.ClearFlashDurationEnemy() + return mpu +} + +// SetFlashTotalSelf sets the "flash_total_self" field. +func (mpu *MatchPlayerUpdate) SetFlashTotalSelf(u uint) *MatchPlayerUpdate { + mpu.mutation.ResetFlashTotalSelf() + mpu.mutation.SetFlashTotalSelf(u) + return mpu +} + +// SetNillableFlashTotalSelf sets the "flash_total_self" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableFlashTotalSelf(u *uint) *MatchPlayerUpdate { + if u != nil { + mpu.SetFlashTotalSelf(*u) + } + return mpu +} + +// AddFlashTotalSelf adds u to the "flash_total_self" field. +func (mpu *MatchPlayerUpdate) AddFlashTotalSelf(u uint) *MatchPlayerUpdate { + mpu.mutation.AddFlashTotalSelf(u) + return mpu +} + +// ClearFlashTotalSelf clears the value of the "flash_total_self" field. +func (mpu *MatchPlayerUpdate) ClearFlashTotalSelf() *MatchPlayerUpdate { + mpu.mutation.ClearFlashTotalSelf() + return mpu +} + +// SetFlashTotalTeam sets the "flash_total_team" field. +func (mpu *MatchPlayerUpdate) SetFlashTotalTeam(u uint) *MatchPlayerUpdate { + mpu.mutation.ResetFlashTotalTeam() + mpu.mutation.SetFlashTotalTeam(u) + return mpu +} + +// SetNillableFlashTotalTeam sets the "flash_total_team" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableFlashTotalTeam(u *uint) *MatchPlayerUpdate { + if u != nil { + mpu.SetFlashTotalTeam(*u) + } + return mpu +} + +// AddFlashTotalTeam adds u to the "flash_total_team" field. +func (mpu *MatchPlayerUpdate) AddFlashTotalTeam(u uint) *MatchPlayerUpdate { + mpu.mutation.AddFlashTotalTeam(u) + return mpu +} + +// ClearFlashTotalTeam clears the value of the "flash_total_team" field. +func (mpu *MatchPlayerUpdate) ClearFlashTotalTeam() *MatchPlayerUpdate { + mpu.mutation.ClearFlashTotalTeam() + return mpu +} + +// SetFlashTotalEnemy sets the "flash_total_enemy" field. +func (mpu *MatchPlayerUpdate) SetFlashTotalEnemy(u uint) *MatchPlayerUpdate { + mpu.mutation.ResetFlashTotalEnemy() + mpu.mutation.SetFlashTotalEnemy(u) + return mpu +} + +// SetNillableFlashTotalEnemy sets the "flash_total_enemy" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableFlashTotalEnemy(u *uint) *MatchPlayerUpdate { + if u != nil { + mpu.SetFlashTotalEnemy(*u) + } + return mpu +} + +// AddFlashTotalEnemy adds u to the "flash_total_enemy" field. +func (mpu *MatchPlayerUpdate) AddFlashTotalEnemy(u uint) *MatchPlayerUpdate { + mpu.mutation.AddFlashTotalEnemy(u) + return mpu +} + +// ClearFlashTotalEnemy clears the value of the "flash_total_enemy" field. +func (mpu *MatchPlayerUpdate) ClearFlashTotalEnemy() *MatchPlayerUpdate { + mpu.mutation.ClearFlashTotalEnemy() + return mpu +} + +// SetMatchStats sets the "match_stats" field. +func (mpu *MatchPlayerUpdate) SetMatchStats(u uint64) *MatchPlayerUpdate { + mpu.mutation.SetMatchStats(u) + return mpu +} + +// SetNillableMatchStats sets the "match_stats" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableMatchStats(u *uint64) *MatchPlayerUpdate { + if u != nil { + mpu.SetMatchStats(*u) + } + return mpu +} + +// ClearMatchStats clears the value of the "match_stats" field. +func (mpu *MatchPlayerUpdate) ClearMatchStats() *MatchPlayerUpdate { + mpu.mutation.ClearMatchStats() + return mpu +} + +// SetPlayerStats sets the "player_stats" field. +func (mpu *MatchPlayerUpdate) SetPlayerStats(u uint64) *MatchPlayerUpdate { + mpu.mutation.SetPlayerStats(u) + return mpu +} + +// SetNillablePlayerStats sets the "player_stats" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillablePlayerStats(u *uint64) *MatchPlayerUpdate { + if u != nil { + mpu.SetPlayerStats(*u) + } + return mpu +} + +// ClearPlayerStats clears the value of the "player_stats" field. +func (mpu *MatchPlayerUpdate) ClearPlayerStats() *MatchPlayerUpdate { + mpu.mutation.ClearPlayerStats() + return mpu +} + +// SetFlashAssists sets the "flash_assists" field. +func (mpu *MatchPlayerUpdate) SetFlashAssists(i int) *MatchPlayerUpdate { + mpu.mutation.ResetFlashAssists() + mpu.mutation.SetFlashAssists(i) + return mpu +} + +// SetNillableFlashAssists sets the "flash_assists" field if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableFlashAssists(i *int) *MatchPlayerUpdate { + if i != nil { + mpu.SetFlashAssists(*i) + } + return mpu +} + +// AddFlashAssists adds i to the "flash_assists" field. +func (mpu *MatchPlayerUpdate) AddFlashAssists(i int) *MatchPlayerUpdate { + mpu.mutation.AddFlashAssists(i) + return mpu +} + +// ClearFlashAssists clears the value of the "flash_assists" field. +func (mpu *MatchPlayerUpdate) ClearFlashAssists() *MatchPlayerUpdate { + mpu.mutation.ClearFlashAssists() + return mpu +} + +// SetMatchesID sets the "matches" edge to the Match entity by ID. +func (mpu *MatchPlayerUpdate) SetMatchesID(id uint64) *MatchPlayerUpdate { + mpu.mutation.SetMatchesID(id) + return mpu +} + +// SetNillableMatchesID sets the "matches" edge to the Match entity by ID if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillableMatchesID(id *uint64) *MatchPlayerUpdate { + if id != nil { + mpu = mpu.SetMatchesID(*id) + } + return mpu +} + +// SetMatches sets the "matches" edge to the Match entity. +func (mpu *MatchPlayerUpdate) SetMatches(m *Match) *MatchPlayerUpdate { + return mpu.SetMatchesID(m.ID) +} + +// SetPlayersID sets the "players" edge to the Player entity by ID. +func (mpu *MatchPlayerUpdate) SetPlayersID(id uint64) *MatchPlayerUpdate { + mpu.mutation.SetPlayersID(id) + return mpu +} + +// SetNillablePlayersID sets the "players" edge to the Player entity by ID if the given value is not nil. +func (mpu *MatchPlayerUpdate) SetNillablePlayersID(id *uint64) *MatchPlayerUpdate { + if id != nil { + mpu = mpu.SetPlayersID(*id) + } + return mpu +} + +// SetPlayers sets the "players" edge to the Player entity. +func (mpu *MatchPlayerUpdate) SetPlayers(p *Player) *MatchPlayerUpdate { + return mpu.SetPlayersID(p.ID) +} + +// AddWeaponStatIDs adds the "weapon_stats" edge to the Weapon entity by IDs. +func (mpu *MatchPlayerUpdate) AddWeaponStatIDs(ids ...int) *MatchPlayerUpdate { + mpu.mutation.AddWeaponStatIDs(ids...) + return mpu +} + +// AddWeaponStats adds the "weapon_stats" edges to the Weapon entity. +func (mpu *MatchPlayerUpdate) AddWeaponStats(w ...*Weapon) *MatchPlayerUpdate { + ids := make([]int, len(w)) + for i := range w { + ids[i] = w[i].ID + } + return mpu.AddWeaponStatIDs(ids...) +} + +// AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by IDs. +func (mpu *MatchPlayerUpdate) AddRoundStatIDs(ids ...int) *MatchPlayerUpdate { + mpu.mutation.AddRoundStatIDs(ids...) + return mpu +} + +// AddRoundStats adds the "round_stats" edges to the RoundStats entity. +func (mpu *MatchPlayerUpdate) AddRoundStats(r ...*RoundStats) *MatchPlayerUpdate { + ids := make([]int, len(r)) + for i := range r { + ids[i] = r[i].ID + } + return mpu.AddRoundStatIDs(ids...) +} + +// AddSprayIDs adds the "spray" edge to the Spray entity by IDs. +func (mpu *MatchPlayerUpdate) AddSprayIDs(ids ...int) *MatchPlayerUpdate { + mpu.mutation.AddSprayIDs(ids...) + return mpu +} + +// AddSpray adds the "spray" edges to the Spray entity. +func (mpu *MatchPlayerUpdate) AddSpray(s ...*Spray) *MatchPlayerUpdate { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return mpu.AddSprayIDs(ids...) +} + +// Mutation returns the MatchPlayerMutation object of the builder. +func (mpu *MatchPlayerUpdate) Mutation() *MatchPlayerMutation { + return mpu.mutation +} + +// ClearMatches clears the "matches" edge to the Match entity. +func (mpu *MatchPlayerUpdate) ClearMatches() *MatchPlayerUpdate { + mpu.mutation.ClearMatches() + return mpu +} + +// ClearPlayers clears the "players" edge to the Player entity. +func (mpu *MatchPlayerUpdate) ClearPlayers() *MatchPlayerUpdate { + mpu.mutation.ClearPlayers() + return mpu +} + +// ClearWeaponStats clears all "weapon_stats" edges to the Weapon entity. +func (mpu *MatchPlayerUpdate) ClearWeaponStats() *MatchPlayerUpdate { + mpu.mutation.ClearWeaponStats() + return mpu +} + +// RemoveWeaponStatIDs removes the "weapon_stats" edge to Weapon entities by IDs. +func (mpu *MatchPlayerUpdate) RemoveWeaponStatIDs(ids ...int) *MatchPlayerUpdate { + mpu.mutation.RemoveWeaponStatIDs(ids...) + return mpu +} + +// RemoveWeaponStats removes "weapon_stats" edges to Weapon entities. +func (mpu *MatchPlayerUpdate) RemoveWeaponStats(w ...*Weapon) *MatchPlayerUpdate { + ids := make([]int, len(w)) + for i := range w { + ids[i] = w[i].ID + } + return mpu.RemoveWeaponStatIDs(ids...) +} + +// ClearRoundStats clears all "round_stats" edges to the RoundStats entity. +func (mpu *MatchPlayerUpdate) ClearRoundStats() *MatchPlayerUpdate { + mpu.mutation.ClearRoundStats() + return mpu +} + +// RemoveRoundStatIDs removes the "round_stats" edge to RoundStats entities by IDs. +func (mpu *MatchPlayerUpdate) RemoveRoundStatIDs(ids ...int) *MatchPlayerUpdate { + mpu.mutation.RemoveRoundStatIDs(ids...) + return mpu +} + +// RemoveRoundStats removes "round_stats" edges to RoundStats entities. +func (mpu *MatchPlayerUpdate) RemoveRoundStats(r ...*RoundStats) *MatchPlayerUpdate { + ids := make([]int, len(r)) + for i := range r { + ids[i] = r[i].ID + } + return mpu.RemoveRoundStatIDs(ids...) +} + +// ClearSpray clears all "spray" edges to the Spray entity. +func (mpu *MatchPlayerUpdate) ClearSpray() *MatchPlayerUpdate { + mpu.mutation.ClearSpray() + return mpu +} + +// RemoveSprayIDs removes the "spray" edge to Spray entities by IDs. +func (mpu *MatchPlayerUpdate) RemoveSprayIDs(ids ...int) *MatchPlayerUpdate { + mpu.mutation.RemoveSprayIDs(ids...) + return mpu +} + +// RemoveSpray removes "spray" edges to Spray entities. +func (mpu *MatchPlayerUpdate) RemoveSpray(s ...*Spray) *MatchPlayerUpdate { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return mpu.RemoveSprayIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (mpu *MatchPlayerUpdate) Save(ctx context.Context) (int, error) { + var ( + err error + affected int + ) + if len(mpu.hooks) == 0 { + if err = mpu.check(); err != nil { + return 0, err + } + affected, err = mpu.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*MatchPlayerMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err = mpu.check(); err != nil { + return 0, err + } + mpu.mutation = mutation + affected, err = mpu.sqlSave(ctx) + mutation.done = true + return affected, err + }) + for i := len(mpu.hooks) - 1; i >= 0; i-- { + if mpu.hooks[i] == nil { + return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = mpu.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, mpu.mutation); err != nil { + return 0, err + } + } + return affected, err +} + +// SaveX is like Save, but panics if an error occurs. +func (mpu *MatchPlayerUpdate) SaveX(ctx context.Context) int { + affected, err := mpu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (mpu *MatchPlayerUpdate) Exec(ctx context.Context) error { + _, err := mpu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mpu *MatchPlayerUpdate) ExecX(ctx context.Context) { + if err := mpu.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mpu *MatchPlayerUpdate) check() error { + if v, ok := mpu.mutation.Color(); ok { + if err := matchplayer.ColorValidator(v); err != nil { + return &ValidationError{Name: "color", err: fmt.Errorf("ent: validator failed for field \"color\": %w", err)} + } + } + return nil +} + +func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: matchplayer.Table, + Columns: matchplayer.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldID, + }, + }, + } + if ps := mpu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := mpu.mutation.TeamID(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldTeamID, + }) + } + if value, ok := mpu.mutation.AddedTeamID(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldTeamID, + }) + } + if value, ok := mpu.mutation.Kills(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldKills, + }) + } + if value, ok := mpu.mutation.AddedKills(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldKills, + }) + } + if value, ok := mpu.mutation.Deaths(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldDeaths, + }) + } + if value, ok := mpu.mutation.AddedDeaths(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldDeaths, + }) + } + if value, ok := mpu.mutation.Assists(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldAssists, + }) + } + if value, ok := mpu.mutation.AddedAssists(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldAssists, + }) + } + if value, ok := mpu.mutation.Headshot(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldHeadshot, + }) + } + if value, ok := mpu.mutation.AddedHeadshot(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldHeadshot, + }) + } + if value, ok := mpu.mutation.Mvp(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMvp, + }) + } + if value, ok := mpu.mutation.AddedMvp(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMvp, + }) + } + if value, ok := mpu.mutation.Score(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldScore, + }) + } + if value, ok := mpu.mutation.AddedScore(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldScore, + }) + } + if value, ok := mpu.mutation.RankNew(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldRankNew, + }) + } + if value, ok := mpu.mutation.AddedRankNew(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldRankNew, + }) + } + if mpu.mutation.RankNewCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldRankNew, + }) + } + if value, ok := mpu.mutation.RankOld(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldRankOld, + }) + } + if value, ok := mpu.mutation.AddedRankOld(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldRankOld, + }) + } + if mpu.mutation.RankOldCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldRankOld, + }) + } + if value, ok := mpu.mutation.Mk2(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk2, + }) + } + if value, ok := mpu.mutation.AddedMk2(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk2, + }) + } + if mpu.mutation.Mk2Cleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldMk2, + }) + } + if value, ok := mpu.mutation.Mk3(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk3, + }) + } + if value, ok := mpu.mutation.AddedMk3(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk3, + }) + } + if mpu.mutation.Mk3Cleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldMk3, + }) + } + if value, ok := mpu.mutation.Mk4(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk4, + }) + } + if value, ok := mpu.mutation.AddedMk4(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk4, + }) + } + if mpu.mutation.Mk4Cleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldMk4, + }) + } + if value, ok := mpu.mutation.Mk5(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk5, + }) + } + if value, ok := mpu.mutation.AddedMk5(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk5, + }) + } + if mpu.mutation.Mk5Cleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldMk5, + }) + } + if value, ok := mpu.mutation.DmgEnemy(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldDmgEnemy, + }) + } + if value, ok := mpu.mutation.AddedDmgEnemy(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldDmgEnemy, + }) + } + if mpu.mutation.DmgEnemyCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldDmgEnemy, + }) + } + if value, ok := mpu.mutation.DmgTeam(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldDmgTeam, + }) + } + if value, ok := mpu.mutation.AddedDmgTeam(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldDmgTeam, + }) + } + if mpu.mutation.DmgTeamCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldDmgTeam, + }) + } + if value, ok := mpu.mutation.UdHe(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdHe, + }) + } + if value, ok := mpu.mutation.AddedUdHe(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdHe, + }) + } + if mpu.mutation.UdHeCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldUdHe, + }) + } + if value, ok := mpu.mutation.UdFlames(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdFlames, + }) + } + if value, ok := mpu.mutation.AddedUdFlames(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdFlames, + }) + } + if mpu.mutation.UdFlamesCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldUdFlames, + }) + } + if value, ok := mpu.mutation.UdFlash(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdFlash, + }) + } + if value, ok := mpu.mutation.AddedUdFlash(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdFlash, + }) + } + if mpu.mutation.UdFlashCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldUdFlash, + }) + } + if value, ok := mpu.mutation.UdDecoy(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdDecoy, + }) + } + if value, ok := mpu.mutation.AddedUdDecoy(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdDecoy, + }) + } + if mpu.mutation.UdDecoyCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldUdDecoy, + }) + } + if value, ok := mpu.mutation.UdSmoke(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdSmoke, + }) + } + if value, ok := mpu.mutation.AddedUdSmoke(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdSmoke, + }) + } + if mpu.mutation.UdSmokeCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldUdSmoke, + }) + } + if value, ok := mpu.mutation.Crosshair(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: matchplayer.FieldCrosshair, + }) + } + if mpu.mutation.CrosshairCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: matchplayer.FieldCrosshair, + }) + } + if value, ok := mpu.mutation.Color(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeEnum, + Value: value, + Column: matchplayer.FieldColor, + }) + } + if mpu.mutation.ColorCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeEnum, + Column: matchplayer.FieldColor, + }) + } + if value, ok := mpu.mutation.Kast(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldKast, + }) + } + if value, ok := mpu.mutation.AddedKast(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldKast, + }) + } + if mpu.mutation.KastCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldKast, + }) + } + if value, ok := mpu.mutation.FlashDurationSelf(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: matchplayer.FieldFlashDurationSelf, + }) + } + if value, ok := mpu.mutation.AddedFlashDurationSelf(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: matchplayer.FieldFlashDurationSelf, + }) + } + if mpu.mutation.FlashDurationSelfCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Column: matchplayer.FieldFlashDurationSelf, + }) + } + if value, ok := mpu.mutation.FlashDurationTeam(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: matchplayer.FieldFlashDurationTeam, + }) + } + if value, ok := mpu.mutation.AddedFlashDurationTeam(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: matchplayer.FieldFlashDurationTeam, + }) + } + if mpu.mutation.FlashDurationTeamCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Column: matchplayer.FieldFlashDurationTeam, + }) + } + if value, ok := mpu.mutation.FlashDurationEnemy(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: matchplayer.FieldFlashDurationEnemy, + }) + } + if value, ok := mpu.mutation.AddedFlashDurationEnemy(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: matchplayer.FieldFlashDurationEnemy, + }) + } + if mpu.mutation.FlashDurationEnemyCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Column: matchplayer.FieldFlashDurationEnemy, + }) + } + if value, ok := mpu.mutation.FlashTotalSelf(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldFlashTotalSelf, + }) + } + if value, ok := mpu.mutation.AddedFlashTotalSelf(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldFlashTotalSelf, + }) + } + if mpu.mutation.FlashTotalSelfCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldFlashTotalSelf, + }) + } + if value, ok := mpu.mutation.FlashTotalTeam(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldFlashTotalTeam, + }) + } + if value, ok := mpu.mutation.AddedFlashTotalTeam(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldFlashTotalTeam, + }) + } + if mpu.mutation.FlashTotalTeamCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldFlashTotalTeam, + }) + } + if value, ok := mpu.mutation.FlashTotalEnemy(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldFlashTotalEnemy, + }) + } + if value, ok := mpu.mutation.AddedFlashTotalEnemy(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldFlashTotalEnemy, + }) + } + if mpu.mutation.FlashTotalEnemyCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldFlashTotalEnemy, + }) + } + if value, ok := mpu.mutation.FlashAssists(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldFlashAssists, + }) + } + if value, ok := mpu.mutation.AddedFlashAssists(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldFlashAssists, + }) + } + if mpu.mutation.FlashAssistsCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldFlashAssists, + }) + } + if mpu.mutation.MatchesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: matchplayer.MatchesTable, + Columns: []string{matchplayer.MatchesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Column: match.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mpu.mutation.MatchesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: matchplayer.MatchesTable, + Columns: []string{matchplayer.MatchesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Column: match.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if mpu.mutation.PlayersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: matchplayer.PlayersTable, + Columns: []string{matchplayer.PlayersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Column: player.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mpu.mutation.PlayersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: matchplayer.PlayersTable, + Columns: []string{matchplayer.PlayersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Column: player.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if mpu.mutation.WeaponStatsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.WeaponStatsTable, + Columns: []string{matchplayer.WeaponStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weapon.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mpu.mutation.RemovedWeaponStatsIDs(); len(nodes) > 0 && !mpu.mutation.WeaponStatsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.WeaponStatsTable, + Columns: []string{matchplayer.WeaponStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weapon.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mpu.mutation.WeaponStatsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.WeaponStatsTable, + Columns: []string{matchplayer.WeaponStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weapon.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if mpu.mutation.RoundStatsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.RoundStatsTable, + Columns: []string{matchplayer.RoundStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: roundstats.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mpu.mutation.RemovedRoundStatsIDs(); len(nodes) > 0 && !mpu.mutation.RoundStatsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.RoundStatsTable, + Columns: []string{matchplayer.RoundStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: roundstats.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mpu.mutation.RoundStatsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.RoundStatsTable, + Columns: []string{matchplayer.RoundStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: roundstats.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if mpu.mutation.SprayCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.SprayTable, + Columns: []string{matchplayer.SprayColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: spray.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mpu.mutation.RemovedSprayIDs(); len(nodes) > 0 && !mpu.mutation.SprayCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.SprayTable, + Columns: []string{matchplayer.SprayColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: spray.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mpu.mutation.SprayIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.SprayTable, + Columns: []string{matchplayer.SprayColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: spray.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, mpu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{matchplayer.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} + } + return 0, err + } + return n, nil +} + +// MatchPlayerUpdateOne is the builder for updating a single MatchPlayer entity. +type MatchPlayerUpdateOne struct { + config + fields []string + hooks []Hook + mutation *MatchPlayerMutation +} + +// SetTeamID sets the "team_id" field. +func (mpuo *MatchPlayerUpdateOne) SetTeamID(i int) *MatchPlayerUpdateOne { + mpuo.mutation.ResetTeamID() + mpuo.mutation.SetTeamID(i) + return mpuo +} + +// AddTeamID adds i to the "team_id" field. +func (mpuo *MatchPlayerUpdateOne) AddTeamID(i int) *MatchPlayerUpdateOne { + mpuo.mutation.AddTeamID(i) + return mpuo +} + +// SetKills sets the "kills" field. +func (mpuo *MatchPlayerUpdateOne) SetKills(i int) *MatchPlayerUpdateOne { + mpuo.mutation.ResetKills() + mpuo.mutation.SetKills(i) + return mpuo +} + +// AddKills adds i to the "kills" field. +func (mpuo *MatchPlayerUpdateOne) AddKills(i int) *MatchPlayerUpdateOne { + mpuo.mutation.AddKills(i) + return mpuo +} + +// SetDeaths sets the "deaths" field. +func (mpuo *MatchPlayerUpdateOne) SetDeaths(i int) *MatchPlayerUpdateOne { + mpuo.mutation.ResetDeaths() + mpuo.mutation.SetDeaths(i) + return mpuo +} + +// AddDeaths adds i to the "deaths" field. +func (mpuo *MatchPlayerUpdateOne) AddDeaths(i int) *MatchPlayerUpdateOne { + mpuo.mutation.AddDeaths(i) + return mpuo +} + +// SetAssists sets the "assists" field. +func (mpuo *MatchPlayerUpdateOne) SetAssists(i int) *MatchPlayerUpdateOne { + mpuo.mutation.ResetAssists() + mpuo.mutation.SetAssists(i) + return mpuo +} + +// AddAssists adds i to the "assists" field. +func (mpuo *MatchPlayerUpdateOne) AddAssists(i int) *MatchPlayerUpdateOne { + mpuo.mutation.AddAssists(i) + return mpuo +} + +// SetHeadshot sets the "headshot" field. +func (mpuo *MatchPlayerUpdateOne) SetHeadshot(i int) *MatchPlayerUpdateOne { + mpuo.mutation.ResetHeadshot() + mpuo.mutation.SetHeadshot(i) + return mpuo +} + +// AddHeadshot adds i to the "headshot" field. +func (mpuo *MatchPlayerUpdateOne) AddHeadshot(i int) *MatchPlayerUpdateOne { + mpuo.mutation.AddHeadshot(i) + return mpuo +} + +// SetMvp sets the "mvp" field. +func (mpuo *MatchPlayerUpdateOne) SetMvp(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.ResetMvp() + mpuo.mutation.SetMvp(u) + return mpuo +} + +// AddMvp adds u to the "mvp" field. +func (mpuo *MatchPlayerUpdateOne) AddMvp(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.AddMvp(u) + return mpuo +} + +// SetScore sets the "score" field. +func (mpuo *MatchPlayerUpdateOne) SetScore(i int) *MatchPlayerUpdateOne { + mpuo.mutation.ResetScore() + mpuo.mutation.SetScore(i) + return mpuo +} + +// AddScore adds i to the "score" field. +func (mpuo *MatchPlayerUpdateOne) AddScore(i int) *MatchPlayerUpdateOne { + mpuo.mutation.AddScore(i) + return mpuo +} + +// SetRankNew sets the "rank_new" field. +func (mpuo *MatchPlayerUpdateOne) SetRankNew(i int) *MatchPlayerUpdateOne { + mpuo.mutation.ResetRankNew() + mpuo.mutation.SetRankNew(i) + return mpuo +} + +// SetNillableRankNew sets the "rank_new" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableRankNew(i *int) *MatchPlayerUpdateOne { + if i != nil { + mpuo.SetRankNew(*i) + } + return mpuo +} + +// AddRankNew adds i to the "rank_new" field. +func (mpuo *MatchPlayerUpdateOne) AddRankNew(i int) *MatchPlayerUpdateOne { + mpuo.mutation.AddRankNew(i) + return mpuo +} + +// ClearRankNew clears the value of the "rank_new" field. +func (mpuo *MatchPlayerUpdateOne) ClearRankNew() *MatchPlayerUpdateOne { + mpuo.mutation.ClearRankNew() + return mpuo +} + +// SetRankOld sets the "rank_old" field. +func (mpuo *MatchPlayerUpdateOne) SetRankOld(i int) *MatchPlayerUpdateOne { + mpuo.mutation.ResetRankOld() + mpuo.mutation.SetRankOld(i) + return mpuo +} + +// SetNillableRankOld sets the "rank_old" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableRankOld(i *int) *MatchPlayerUpdateOne { + if i != nil { + mpuo.SetRankOld(*i) + } + return mpuo +} + +// AddRankOld adds i to the "rank_old" field. +func (mpuo *MatchPlayerUpdateOne) AddRankOld(i int) *MatchPlayerUpdateOne { + mpuo.mutation.AddRankOld(i) + return mpuo +} + +// ClearRankOld clears the value of the "rank_old" field. +func (mpuo *MatchPlayerUpdateOne) ClearRankOld() *MatchPlayerUpdateOne { + mpuo.mutation.ClearRankOld() + return mpuo +} + +// SetMk2 sets the "mk_2" field. +func (mpuo *MatchPlayerUpdateOne) SetMk2(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.ResetMk2() + mpuo.mutation.SetMk2(u) + return mpuo +} + +// SetNillableMk2 sets the "mk_2" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableMk2(u *uint) *MatchPlayerUpdateOne { + if u != nil { + mpuo.SetMk2(*u) + } + return mpuo +} + +// AddMk2 adds u to the "mk_2" field. +func (mpuo *MatchPlayerUpdateOne) AddMk2(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.AddMk2(u) + return mpuo +} + +// ClearMk2 clears the value of the "mk_2" field. +func (mpuo *MatchPlayerUpdateOne) ClearMk2() *MatchPlayerUpdateOne { + mpuo.mutation.ClearMk2() + return mpuo +} + +// SetMk3 sets the "mk_3" field. +func (mpuo *MatchPlayerUpdateOne) SetMk3(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.ResetMk3() + mpuo.mutation.SetMk3(u) + return mpuo +} + +// SetNillableMk3 sets the "mk_3" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableMk3(u *uint) *MatchPlayerUpdateOne { + if u != nil { + mpuo.SetMk3(*u) + } + return mpuo +} + +// AddMk3 adds u to the "mk_3" field. +func (mpuo *MatchPlayerUpdateOne) AddMk3(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.AddMk3(u) + return mpuo +} + +// ClearMk3 clears the value of the "mk_3" field. +func (mpuo *MatchPlayerUpdateOne) ClearMk3() *MatchPlayerUpdateOne { + mpuo.mutation.ClearMk3() + return mpuo +} + +// SetMk4 sets the "mk_4" field. +func (mpuo *MatchPlayerUpdateOne) SetMk4(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.ResetMk4() + mpuo.mutation.SetMk4(u) + return mpuo +} + +// SetNillableMk4 sets the "mk_4" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableMk4(u *uint) *MatchPlayerUpdateOne { + if u != nil { + mpuo.SetMk4(*u) + } + return mpuo +} + +// AddMk4 adds u to the "mk_4" field. +func (mpuo *MatchPlayerUpdateOne) AddMk4(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.AddMk4(u) + return mpuo +} + +// ClearMk4 clears the value of the "mk_4" field. +func (mpuo *MatchPlayerUpdateOne) ClearMk4() *MatchPlayerUpdateOne { + mpuo.mutation.ClearMk4() + return mpuo +} + +// SetMk5 sets the "mk_5" field. +func (mpuo *MatchPlayerUpdateOne) SetMk5(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.ResetMk5() + mpuo.mutation.SetMk5(u) + return mpuo +} + +// SetNillableMk5 sets the "mk_5" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableMk5(u *uint) *MatchPlayerUpdateOne { + if u != nil { + mpuo.SetMk5(*u) + } + return mpuo +} + +// AddMk5 adds u to the "mk_5" field. +func (mpuo *MatchPlayerUpdateOne) AddMk5(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.AddMk5(u) + return mpuo +} + +// ClearMk5 clears the value of the "mk_5" field. +func (mpuo *MatchPlayerUpdateOne) ClearMk5() *MatchPlayerUpdateOne { + mpuo.mutation.ClearMk5() + return mpuo +} + +// SetDmgEnemy sets the "dmg_enemy" field. +func (mpuo *MatchPlayerUpdateOne) SetDmgEnemy(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.ResetDmgEnemy() + mpuo.mutation.SetDmgEnemy(u) + return mpuo +} + +// SetNillableDmgEnemy sets the "dmg_enemy" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableDmgEnemy(u *uint) *MatchPlayerUpdateOne { + if u != nil { + mpuo.SetDmgEnemy(*u) + } + return mpuo +} + +// AddDmgEnemy adds u to the "dmg_enemy" field. +func (mpuo *MatchPlayerUpdateOne) AddDmgEnemy(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.AddDmgEnemy(u) + return mpuo +} + +// ClearDmgEnemy clears the value of the "dmg_enemy" field. +func (mpuo *MatchPlayerUpdateOne) ClearDmgEnemy() *MatchPlayerUpdateOne { + mpuo.mutation.ClearDmgEnemy() + return mpuo +} + +// SetDmgTeam sets the "dmg_team" field. +func (mpuo *MatchPlayerUpdateOne) SetDmgTeam(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.ResetDmgTeam() + mpuo.mutation.SetDmgTeam(u) + return mpuo +} + +// SetNillableDmgTeam sets the "dmg_team" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableDmgTeam(u *uint) *MatchPlayerUpdateOne { + if u != nil { + mpuo.SetDmgTeam(*u) + } + return mpuo +} + +// AddDmgTeam adds u to the "dmg_team" field. +func (mpuo *MatchPlayerUpdateOne) AddDmgTeam(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.AddDmgTeam(u) + return mpuo +} + +// ClearDmgTeam clears the value of the "dmg_team" field. +func (mpuo *MatchPlayerUpdateOne) ClearDmgTeam() *MatchPlayerUpdateOne { + mpuo.mutation.ClearDmgTeam() + return mpuo +} + +// SetUdHe sets the "ud_he" field. +func (mpuo *MatchPlayerUpdateOne) SetUdHe(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.ResetUdHe() + mpuo.mutation.SetUdHe(u) + return mpuo +} + +// SetNillableUdHe sets the "ud_he" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableUdHe(u *uint) *MatchPlayerUpdateOne { + if u != nil { + mpuo.SetUdHe(*u) + } + return mpuo +} + +// AddUdHe adds u to the "ud_he" field. +func (mpuo *MatchPlayerUpdateOne) AddUdHe(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.AddUdHe(u) + return mpuo +} + +// ClearUdHe clears the value of the "ud_he" field. +func (mpuo *MatchPlayerUpdateOne) ClearUdHe() *MatchPlayerUpdateOne { + mpuo.mutation.ClearUdHe() + return mpuo +} + +// SetUdFlames sets the "ud_flames" field. +func (mpuo *MatchPlayerUpdateOne) SetUdFlames(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.ResetUdFlames() + mpuo.mutation.SetUdFlames(u) + return mpuo +} + +// SetNillableUdFlames sets the "ud_flames" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableUdFlames(u *uint) *MatchPlayerUpdateOne { + if u != nil { + mpuo.SetUdFlames(*u) + } + return mpuo +} + +// AddUdFlames adds u to the "ud_flames" field. +func (mpuo *MatchPlayerUpdateOne) AddUdFlames(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.AddUdFlames(u) + return mpuo +} + +// ClearUdFlames clears the value of the "ud_flames" field. +func (mpuo *MatchPlayerUpdateOne) ClearUdFlames() *MatchPlayerUpdateOne { + mpuo.mutation.ClearUdFlames() + return mpuo +} + +// SetUdFlash sets the "ud_flash" field. +func (mpuo *MatchPlayerUpdateOne) SetUdFlash(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.ResetUdFlash() + mpuo.mutation.SetUdFlash(u) + return mpuo +} + +// SetNillableUdFlash sets the "ud_flash" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableUdFlash(u *uint) *MatchPlayerUpdateOne { + if u != nil { + mpuo.SetUdFlash(*u) + } + return mpuo +} + +// AddUdFlash adds u to the "ud_flash" field. +func (mpuo *MatchPlayerUpdateOne) AddUdFlash(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.AddUdFlash(u) + return mpuo +} + +// ClearUdFlash clears the value of the "ud_flash" field. +func (mpuo *MatchPlayerUpdateOne) ClearUdFlash() *MatchPlayerUpdateOne { + mpuo.mutation.ClearUdFlash() + return mpuo +} + +// SetUdDecoy sets the "ud_decoy" field. +func (mpuo *MatchPlayerUpdateOne) SetUdDecoy(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.ResetUdDecoy() + mpuo.mutation.SetUdDecoy(u) + return mpuo +} + +// SetNillableUdDecoy sets the "ud_decoy" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableUdDecoy(u *uint) *MatchPlayerUpdateOne { + if u != nil { + mpuo.SetUdDecoy(*u) + } + return mpuo +} + +// AddUdDecoy adds u to the "ud_decoy" field. +func (mpuo *MatchPlayerUpdateOne) AddUdDecoy(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.AddUdDecoy(u) + return mpuo +} + +// ClearUdDecoy clears the value of the "ud_decoy" field. +func (mpuo *MatchPlayerUpdateOne) ClearUdDecoy() *MatchPlayerUpdateOne { + mpuo.mutation.ClearUdDecoy() + return mpuo +} + +// SetUdSmoke sets the "ud_smoke" field. +func (mpuo *MatchPlayerUpdateOne) SetUdSmoke(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.ResetUdSmoke() + mpuo.mutation.SetUdSmoke(u) + return mpuo +} + +// SetNillableUdSmoke sets the "ud_smoke" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableUdSmoke(u *uint) *MatchPlayerUpdateOne { + if u != nil { + mpuo.SetUdSmoke(*u) + } + return mpuo +} + +// AddUdSmoke adds u to the "ud_smoke" field. +func (mpuo *MatchPlayerUpdateOne) AddUdSmoke(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.AddUdSmoke(u) + return mpuo +} + +// ClearUdSmoke clears the value of the "ud_smoke" field. +func (mpuo *MatchPlayerUpdateOne) ClearUdSmoke() *MatchPlayerUpdateOne { + mpuo.mutation.ClearUdSmoke() + return mpuo +} + +// SetCrosshair sets the "crosshair" field. +func (mpuo *MatchPlayerUpdateOne) SetCrosshair(s string) *MatchPlayerUpdateOne { + mpuo.mutation.SetCrosshair(s) + return mpuo +} + +// SetNillableCrosshair sets the "crosshair" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableCrosshair(s *string) *MatchPlayerUpdateOne { + if s != nil { + mpuo.SetCrosshair(*s) + } + return mpuo +} + +// ClearCrosshair clears the value of the "crosshair" field. +func (mpuo *MatchPlayerUpdateOne) ClearCrosshair() *MatchPlayerUpdateOne { + mpuo.mutation.ClearCrosshair() + return mpuo +} + +// SetColor sets the "color" field. +func (mpuo *MatchPlayerUpdateOne) SetColor(m matchplayer.Color) *MatchPlayerUpdateOne { + mpuo.mutation.SetColor(m) + return mpuo +} + +// SetNillableColor sets the "color" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableColor(m *matchplayer.Color) *MatchPlayerUpdateOne { + if m != nil { + mpuo.SetColor(*m) + } + return mpuo +} + +// ClearColor clears the value of the "color" field. +func (mpuo *MatchPlayerUpdateOne) ClearColor() *MatchPlayerUpdateOne { + mpuo.mutation.ClearColor() + return mpuo +} + +// SetKast sets the "kast" field. +func (mpuo *MatchPlayerUpdateOne) SetKast(i int) *MatchPlayerUpdateOne { + mpuo.mutation.ResetKast() + mpuo.mutation.SetKast(i) + return mpuo +} + +// SetNillableKast sets the "kast" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableKast(i *int) *MatchPlayerUpdateOne { + if i != nil { + mpuo.SetKast(*i) + } + return mpuo +} + +// AddKast adds i to the "kast" field. +func (mpuo *MatchPlayerUpdateOne) AddKast(i int) *MatchPlayerUpdateOne { + mpuo.mutation.AddKast(i) + return mpuo +} + +// ClearKast clears the value of the "kast" field. +func (mpuo *MatchPlayerUpdateOne) ClearKast() *MatchPlayerUpdateOne { + mpuo.mutation.ClearKast() + return mpuo +} + +// SetFlashDurationSelf sets the "flash_duration_self" field. +func (mpuo *MatchPlayerUpdateOne) SetFlashDurationSelf(f float32) *MatchPlayerUpdateOne { + mpuo.mutation.ResetFlashDurationSelf() + mpuo.mutation.SetFlashDurationSelf(f) + return mpuo +} + +// SetNillableFlashDurationSelf sets the "flash_duration_self" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableFlashDurationSelf(f *float32) *MatchPlayerUpdateOne { + if f != nil { + mpuo.SetFlashDurationSelf(*f) + } + return mpuo +} + +// AddFlashDurationSelf adds f to the "flash_duration_self" field. +func (mpuo *MatchPlayerUpdateOne) AddFlashDurationSelf(f float32) *MatchPlayerUpdateOne { + mpuo.mutation.AddFlashDurationSelf(f) + return mpuo +} + +// ClearFlashDurationSelf clears the value of the "flash_duration_self" field. +func (mpuo *MatchPlayerUpdateOne) ClearFlashDurationSelf() *MatchPlayerUpdateOne { + mpuo.mutation.ClearFlashDurationSelf() + return mpuo +} + +// SetFlashDurationTeam sets the "flash_duration_team" field. +func (mpuo *MatchPlayerUpdateOne) SetFlashDurationTeam(f float32) *MatchPlayerUpdateOne { + mpuo.mutation.ResetFlashDurationTeam() + mpuo.mutation.SetFlashDurationTeam(f) + return mpuo +} + +// SetNillableFlashDurationTeam sets the "flash_duration_team" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableFlashDurationTeam(f *float32) *MatchPlayerUpdateOne { + if f != nil { + mpuo.SetFlashDurationTeam(*f) + } + return mpuo +} + +// AddFlashDurationTeam adds f to the "flash_duration_team" field. +func (mpuo *MatchPlayerUpdateOne) AddFlashDurationTeam(f float32) *MatchPlayerUpdateOne { + mpuo.mutation.AddFlashDurationTeam(f) + return mpuo +} + +// ClearFlashDurationTeam clears the value of the "flash_duration_team" field. +func (mpuo *MatchPlayerUpdateOne) ClearFlashDurationTeam() *MatchPlayerUpdateOne { + mpuo.mutation.ClearFlashDurationTeam() + return mpuo +} + +// SetFlashDurationEnemy sets the "flash_duration_enemy" field. +func (mpuo *MatchPlayerUpdateOne) SetFlashDurationEnemy(f float32) *MatchPlayerUpdateOne { + mpuo.mutation.ResetFlashDurationEnemy() + mpuo.mutation.SetFlashDurationEnemy(f) + return mpuo +} + +// SetNillableFlashDurationEnemy sets the "flash_duration_enemy" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableFlashDurationEnemy(f *float32) *MatchPlayerUpdateOne { + if f != nil { + mpuo.SetFlashDurationEnemy(*f) + } + return mpuo +} + +// AddFlashDurationEnemy adds f to the "flash_duration_enemy" field. +func (mpuo *MatchPlayerUpdateOne) AddFlashDurationEnemy(f float32) *MatchPlayerUpdateOne { + mpuo.mutation.AddFlashDurationEnemy(f) + return mpuo +} + +// ClearFlashDurationEnemy clears the value of the "flash_duration_enemy" field. +func (mpuo *MatchPlayerUpdateOne) ClearFlashDurationEnemy() *MatchPlayerUpdateOne { + mpuo.mutation.ClearFlashDurationEnemy() + return mpuo +} + +// SetFlashTotalSelf sets the "flash_total_self" field. +func (mpuo *MatchPlayerUpdateOne) SetFlashTotalSelf(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.ResetFlashTotalSelf() + mpuo.mutation.SetFlashTotalSelf(u) + return mpuo +} + +// SetNillableFlashTotalSelf sets the "flash_total_self" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableFlashTotalSelf(u *uint) *MatchPlayerUpdateOne { + if u != nil { + mpuo.SetFlashTotalSelf(*u) + } + return mpuo +} + +// AddFlashTotalSelf adds u to the "flash_total_self" field. +func (mpuo *MatchPlayerUpdateOne) AddFlashTotalSelf(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.AddFlashTotalSelf(u) + return mpuo +} + +// ClearFlashTotalSelf clears the value of the "flash_total_self" field. +func (mpuo *MatchPlayerUpdateOne) ClearFlashTotalSelf() *MatchPlayerUpdateOne { + mpuo.mutation.ClearFlashTotalSelf() + return mpuo +} + +// SetFlashTotalTeam sets the "flash_total_team" field. +func (mpuo *MatchPlayerUpdateOne) SetFlashTotalTeam(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.ResetFlashTotalTeam() + mpuo.mutation.SetFlashTotalTeam(u) + return mpuo +} + +// SetNillableFlashTotalTeam sets the "flash_total_team" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableFlashTotalTeam(u *uint) *MatchPlayerUpdateOne { + if u != nil { + mpuo.SetFlashTotalTeam(*u) + } + return mpuo +} + +// AddFlashTotalTeam adds u to the "flash_total_team" field. +func (mpuo *MatchPlayerUpdateOne) AddFlashTotalTeam(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.AddFlashTotalTeam(u) + return mpuo +} + +// ClearFlashTotalTeam clears the value of the "flash_total_team" field. +func (mpuo *MatchPlayerUpdateOne) ClearFlashTotalTeam() *MatchPlayerUpdateOne { + mpuo.mutation.ClearFlashTotalTeam() + return mpuo +} + +// SetFlashTotalEnemy sets the "flash_total_enemy" field. +func (mpuo *MatchPlayerUpdateOne) SetFlashTotalEnemy(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.ResetFlashTotalEnemy() + mpuo.mutation.SetFlashTotalEnemy(u) + return mpuo +} + +// SetNillableFlashTotalEnemy sets the "flash_total_enemy" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableFlashTotalEnemy(u *uint) *MatchPlayerUpdateOne { + if u != nil { + mpuo.SetFlashTotalEnemy(*u) + } + return mpuo +} + +// AddFlashTotalEnemy adds u to the "flash_total_enemy" field. +func (mpuo *MatchPlayerUpdateOne) AddFlashTotalEnemy(u uint) *MatchPlayerUpdateOne { + mpuo.mutation.AddFlashTotalEnemy(u) + return mpuo +} + +// ClearFlashTotalEnemy clears the value of the "flash_total_enemy" field. +func (mpuo *MatchPlayerUpdateOne) ClearFlashTotalEnemy() *MatchPlayerUpdateOne { + mpuo.mutation.ClearFlashTotalEnemy() + return mpuo +} + +// SetMatchStats sets the "match_stats" field. +func (mpuo *MatchPlayerUpdateOne) SetMatchStats(u uint64) *MatchPlayerUpdateOne { + mpuo.mutation.SetMatchStats(u) + return mpuo +} + +// SetNillableMatchStats sets the "match_stats" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableMatchStats(u *uint64) *MatchPlayerUpdateOne { + if u != nil { + mpuo.SetMatchStats(*u) + } + return mpuo +} + +// ClearMatchStats clears the value of the "match_stats" field. +func (mpuo *MatchPlayerUpdateOne) ClearMatchStats() *MatchPlayerUpdateOne { + mpuo.mutation.ClearMatchStats() + return mpuo +} + +// SetPlayerStats sets the "player_stats" field. +func (mpuo *MatchPlayerUpdateOne) SetPlayerStats(u uint64) *MatchPlayerUpdateOne { + mpuo.mutation.SetPlayerStats(u) + return mpuo +} + +// SetNillablePlayerStats sets the "player_stats" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillablePlayerStats(u *uint64) *MatchPlayerUpdateOne { + if u != nil { + mpuo.SetPlayerStats(*u) + } + return mpuo +} + +// ClearPlayerStats clears the value of the "player_stats" field. +func (mpuo *MatchPlayerUpdateOne) ClearPlayerStats() *MatchPlayerUpdateOne { + mpuo.mutation.ClearPlayerStats() + return mpuo +} + +// SetFlashAssists sets the "flash_assists" field. +func (mpuo *MatchPlayerUpdateOne) SetFlashAssists(i int) *MatchPlayerUpdateOne { + mpuo.mutation.ResetFlashAssists() + mpuo.mutation.SetFlashAssists(i) + return mpuo +} + +// SetNillableFlashAssists sets the "flash_assists" field if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableFlashAssists(i *int) *MatchPlayerUpdateOne { + if i != nil { + mpuo.SetFlashAssists(*i) + } + return mpuo +} + +// AddFlashAssists adds i to the "flash_assists" field. +func (mpuo *MatchPlayerUpdateOne) AddFlashAssists(i int) *MatchPlayerUpdateOne { + mpuo.mutation.AddFlashAssists(i) + return mpuo +} + +// ClearFlashAssists clears the value of the "flash_assists" field. +func (mpuo *MatchPlayerUpdateOne) ClearFlashAssists() *MatchPlayerUpdateOne { + mpuo.mutation.ClearFlashAssists() + return mpuo +} + +// SetMatchesID sets the "matches" edge to the Match entity by ID. +func (mpuo *MatchPlayerUpdateOne) SetMatchesID(id uint64) *MatchPlayerUpdateOne { + mpuo.mutation.SetMatchesID(id) + return mpuo +} + +// SetNillableMatchesID sets the "matches" edge to the Match entity by ID if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillableMatchesID(id *uint64) *MatchPlayerUpdateOne { + if id != nil { + mpuo = mpuo.SetMatchesID(*id) + } + return mpuo +} + +// SetMatches sets the "matches" edge to the Match entity. +func (mpuo *MatchPlayerUpdateOne) SetMatches(m *Match) *MatchPlayerUpdateOne { + return mpuo.SetMatchesID(m.ID) +} + +// SetPlayersID sets the "players" edge to the Player entity by ID. +func (mpuo *MatchPlayerUpdateOne) SetPlayersID(id uint64) *MatchPlayerUpdateOne { + mpuo.mutation.SetPlayersID(id) + return mpuo +} + +// SetNillablePlayersID sets the "players" edge to the Player entity by ID if the given value is not nil. +func (mpuo *MatchPlayerUpdateOne) SetNillablePlayersID(id *uint64) *MatchPlayerUpdateOne { + if id != nil { + mpuo = mpuo.SetPlayersID(*id) + } + return mpuo +} + +// SetPlayers sets the "players" edge to the Player entity. +func (mpuo *MatchPlayerUpdateOne) SetPlayers(p *Player) *MatchPlayerUpdateOne { + return mpuo.SetPlayersID(p.ID) +} + +// AddWeaponStatIDs adds the "weapon_stats" edge to the Weapon entity by IDs. +func (mpuo *MatchPlayerUpdateOne) AddWeaponStatIDs(ids ...int) *MatchPlayerUpdateOne { + mpuo.mutation.AddWeaponStatIDs(ids...) + return mpuo +} + +// AddWeaponStats adds the "weapon_stats" edges to the Weapon entity. +func (mpuo *MatchPlayerUpdateOne) AddWeaponStats(w ...*Weapon) *MatchPlayerUpdateOne { + ids := make([]int, len(w)) + for i := range w { + ids[i] = w[i].ID + } + return mpuo.AddWeaponStatIDs(ids...) +} + +// AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by IDs. +func (mpuo *MatchPlayerUpdateOne) AddRoundStatIDs(ids ...int) *MatchPlayerUpdateOne { + mpuo.mutation.AddRoundStatIDs(ids...) + return mpuo +} + +// AddRoundStats adds the "round_stats" edges to the RoundStats entity. +func (mpuo *MatchPlayerUpdateOne) AddRoundStats(r ...*RoundStats) *MatchPlayerUpdateOne { + ids := make([]int, len(r)) + for i := range r { + ids[i] = r[i].ID + } + return mpuo.AddRoundStatIDs(ids...) +} + +// AddSprayIDs adds the "spray" edge to the Spray entity by IDs. +func (mpuo *MatchPlayerUpdateOne) AddSprayIDs(ids ...int) *MatchPlayerUpdateOne { + mpuo.mutation.AddSprayIDs(ids...) + return mpuo +} + +// AddSpray adds the "spray" edges to the Spray entity. +func (mpuo *MatchPlayerUpdateOne) AddSpray(s ...*Spray) *MatchPlayerUpdateOne { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return mpuo.AddSprayIDs(ids...) +} + +// Mutation returns the MatchPlayerMutation object of the builder. +func (mpuo *MatchPlayerUpdateOne) Mutation() *MatchPlayerMutation { + return mpuo.mutation +} + +// ClearMatches clears the "matches" edge to the Match entity. +func (mpuo *MatchPlayerUpdateOne) ClearMatches() *MatchPlayerUpdateOne { + mpuo.mutation.ClearMatches() + return mpuo +} + +// ClearPlayers clears the "players" edge to the Player entity. +func (mpuo *MatchPlayerUpdateOne) ClearPlayers() *MatchPlayerUpdateOne { + mpuo.mutation.ClearPlayers() + return mpuo +} + +// ClearWeaponStats clears all "weapon_stats" edges to the Weapon entity. +func (mpuo *MatchPlayerUpdateOne) ClearWeaponStats() *MatchPlayerUpdateOne { + mpuo.mutation.ClearWeaponStats() + return mpuo +} + +// RemoveWeaponStatIDs removes the "weapon_stats" edge to Weapon entities by IDs. +func (mpuo *MatchPlayerUpdateOne) RemoveWeaponStatIDs(ids ...int) *MatchPlayerUpdateOne { + mpuo.mutation.RemoveWeaponStatIDs(ids...) + return mpuo +} + +// RemoveWeaponStats removes "weapon_stats" edges to Weapon entities. +func (mpuo *MatchPlayerUpdateOne) RemoveWeaponStats(w ...*Weapon) *MatchPlayerUpdateOne { + ids := make([]int, len(w)) + for i := range w { + ids[i] = w[i].ID + } + return mpuo.RemoveWeaponStatIDs(ids...) +} + +// ClearRoundStats clears all "round_stats" edges to the RoundStats entity. +func (mpuo *MatchPlayerUpdateOne) ClearRoundStats() *MatchPlayerUpdateOne { + mpuo.mutation.ClearRoundStats() + return mpuo +} + +// RemoveRoundStatIDs removes the "round_stats" edge to RoundStats entities by IDs. +func (mpuo *MatchPlayerUpdateOne) RemoveRoundStatIDs(ids ...int) *MatchPlayerUpdateOne { + mpuo.mutation.RemoveRoundStatIDs(ids...) + return mpuo +} + +// RemoveRoundStats removes "round_stats" edges to RoundStats entities. +func (mpuo *MatchPlayerUpdateOne) RemoveRoundStats(r ...*RoundStats) *MatchPlayerUpdateOne { + ids := make([]int, len(r)) + for i := range r { + ids[i] = r[i].ID + } + return mpuo.RemoveRoundStatIDs(ids...) +} + +// ClearSpray clears all "spray" edges to the Spray entity. +func (mpuo *MatchPlayerUpdateOne) ClearSpray() *MatchPlayerUpdateOne { + mpuo.mutation.ClearSpray() + return mpuo +} + +// RemoveSprayIDs removes the "spray" edge to Spray entities by IDs. +func (mpuo *MatchPlayerUpdateOne) RemoveSprayIDs(ids ...int) *MatchPlayerUpdateOne { + mpuo.mutation.RemoveSprayIDs(ids...) + return mpuo +} + +// RemoveSpray removes "spray" edges to Spray entities. +func (mpuo *MatchPlayerUpdateOne) RemoveSpray(s ...*Spray) *MatchPlayerUpdateOne { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return mpuo.RemoveSprayIDs(ids...) +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (mpuo *MatchPlayerUpdateOne) Select(field string, fields ...string) *MatchPlayerUpdateOne { + mpuo.fields = append([]string{field}, fields...) + return mpuo +} + +// Save executes the query and returns the updated MatchPlayer entity. +func (mpuo *MatchPlayerUpdateOne) Save(ctx context.Context) (*MatchPlayer, error) { + var ( + err error + node *MatchPlayer + ) + if len(mpuo.hooks) == 0 { + if err = mpuo.check(); err != nil { + return nil, err + } + node, err = mpuo.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*MatchPlayerMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err = mpuo.check(); err != nil { + return nil, err + } + mpuo.mutation = mutation + node, err = mpuo.sqlSave(ctx) + mutation.done = true + return node, err + }) + for i := len(mpuo.hooks) - 1; i >= 0; i-- { + if mpuo.hooks[i] == nil { + return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = mpuo.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, mpuo.mutation); err != nil { + return nil, err + } + } + return node, err +} + +// SaveX is like Save, but panics if an error occurs. +func (mpuo *MatchPlayerUpdateOne) SaveX(ctx context.Context) *MatchPlayer { + node, err := mpuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (mpuo *MatchPlayerUpdateOne) Exec(ctx context.Context) error { + _, err := mpuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mpuo *MatchPlayerUpdateOne) ExecX(ctx context.Context) { + if err := mpuo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mpuo *MatchPlayerUpdateOne) check() error { + if v, ok := mpuo.mutation.Color(); ok { + if err := matchplayer.ColorValidator(v); err != nil { + return &ValidationError{Name: "color", err: fmt.Errorf("ent: validator failed for field \"color\": %w", err)} + } + } + return nil +} + +func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlayer, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: matchplayer.Table, + Columns: matchplayer.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldID, + }, + }, + } + id, ok := mpuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing MatchPlayer.ID for update")} + } + _spec.Node.ID.Value = id + if fields := mpuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, matchplayer.FieldID) + for _, f := range fields { + if !matchplayer.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != matchplayer.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := mpuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := mpuo.mutation.TeamID(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldTeamID, + }) + } + if value, ok := mpuo.mutation.AddedTeamID(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldTeamID, + }) + } + if value, ok := mpuo.mutation.Kills(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldKills, + }) + } + if value, ok := mpuo.mutation.AddedKills(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldKills, + }) + } + if value, ok := mpuo.mutation.Deaths(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldDeaths, + }) + } + if value, ok := mpuo.mutation.AddedDeaths(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldDeaths, + }) + } + if value, ok := mpuo.mutation.Assists(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldAssists, + }) + } + if value, ok := mpuo.mutation.AddedAssists(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldAssists, + }) + } + if value, ok := mpuo.mutation.Headshot(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldHeadshot, + }) + } + if value, ok := mpuo.mutation.AddedHeadshot(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldHeadshot, + }) + } + if value, ok := mpuo.mutation.Mvp(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMvp, + }) + } + if value, ok := mpuo.mutation.AddedMvp(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMvp, + }) + } + if value, ok := mpuo.mutation.Score(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldScore, + }) + } + if value, ok := mpuo.mutation.AddedScore(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldScore, + }) + } + if value, ok := mpuo.mutation.RankNew(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldRankNew, + }) + } + if value, ok := mpuo.mutation.AddedRankNew(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldRankNew, + }) + } + if mpuo.mutation.RankNewCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldRankNew, + }) + } + if value, ok := mpuo.mutation.RankOld(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldRankOld, + }) + } + if value, ok := mpuo.mutation.AddedRankOld(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldRankOld, + }) + } + if mpuo.mutation.RankOldCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldRankOld, + }) + } + if value, ok := mpuo.mutation.Mk2(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk2, + }) + } + if value, ok := mpuo.mutation.AddedMk2(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk2, + }) + } + if mpuo.mutation.Mk2Cleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldMk2, + }) + } + if value, ok := mpuo.mutation.Mk3(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk3, + }) + } + if value, ok := mpuo.mutation.AddedMk3(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk3, + }) + } + if mpuo.mutation.Mk3Cleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldMk3, + }) + } + if value, ok := mpuo.mutation.Mk4(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk4, + }) + } + if value, ok := mpuo.mutation.AddedMk4(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk4, + }) + } + if mpuo.mutation.Mk4Cleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldMk4, + }) + } + if value, ok := mpuo.mutation.Mk5(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk5, + }) + } + if value, ok := mpuo.mutation.AddedMk5(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldMk5, + }) + } + if mpuo.mutation.Mk5Cleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldMk5, + }) + } + if value, ok := mpuo.mutation.DmgEnemy(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldDmgEnemy, + }) + } + if value, ok := mpuo.mutation.AddedDmgEnemy(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldDmgEnemy, + }) + } + if mpuo.mutation.DmgEnemyCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldDmgEnemy, + }) + } + if value, ok := mpuo.mutation.DmgTeam(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldDmgTeam, + }) + } + if value, ok := mpuo.mutation.AddedDmgTeam(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldDmgTeam, + }) + } + if mpuo.mutation.DmgTeamCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldDmgTeam, + }) + } + if value, ok := mpuo.mutation.UdHe(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdHe, + }) + } + if value, ok := mpuo.mutation.AddedUdHe(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdHe, + }) + } + if mpuo.mutation.UdHeCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldUdHe, + }) + } + if value, ok := mpuo.mutation.UdFlames(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdFlames, + }) + } + if value, ok := mpuo.mutation.AddedUdFlames(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdFlames, + }) + } + if mpuo.mutation.UdFlamesCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldUdFlames, + }) + } + if value, ok := mpuo.mutation.UdFlash(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdFlash, + }) + } + if value, ok := mpuo.mutation.AddedUdFlash(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdFlash, + }) + } + if mpuo.mutation.UdFlashCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldUdFlash, + }) + } + if value, ok := mpuo.mutation.UdDecoy(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdDecoy, + }) + } + if value, ok := mpuo.mutation.AddedUdDecoy(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdDecoy, + }) + } + if mpuo.mutation.UdDecoyCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldUdDecoy, + }) + } + if value, ok := mpuo.mutation.UdSmoke(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdSmoke, + }) + } + if value, ok := mpuo.mutation.AddedUdSmoke(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldUdSmoke, + }) + } + if mpuo.mutation.UdSmokeCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldUdSmoke, + }) + } + if value, ok := mpuo.mutation.Crosshair(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: matchplayer.FieldCrosshair, + }) + } + if mpuo.mutation.CrosshairCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: matchplayer.FieldCrosshair, + }) + } + if value, ok := mpuo.mutation.Color(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeEnum, + Value: value, + Column: matchplayer.FieldColor, + }) + } + if mpuo.mutation.ColorCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeEnum, + Column: matchplayer.FieldColor, + }) + } + if value, ok := mpuo.mutation.Kast(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldKast, + }) + } + if value, ok := mpuo.mutation.AddedKast(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldKast, + }) + } + if mpuo.mutation.KastCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldKast, + }) + } + if value, ok := mpuo.mutation.FlashDurationSelf(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: matchplayer.FieldFlashDurationSelf, + }) + } + if value, ok := mpuo.mutation.AddedFlashDurationSelf(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: matchplayer.FieldFlashDurationSelf, + }) + } + if mpuo.mutation.FlashDurationSelfCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Column: matchplayer.FieldFlashDurationSelf, + }) + } + if value, ok := mpuo.mutation.FlashDurationTeam(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: matchplayer.FieldFlashDurationTeam, + }) + } + if value, ok := mpuo.mutation.AddedFlashDurationTeam(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: matchplayer.FieldFlashDurationTeam, + }) + } + if mpuo.mutation.FlashDurationTeamCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Column: matchplayer.FieldFlashDurationTeam, + }) + } + if value, ok := mpuo.mutation.FlashDurationEnemy(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: matchplayer.FieldFlashDurationEnemy, + }) + } + if value, ok := mpuo.mutation.AddedFlashDurationEnemy(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: matchplayer.FieldFlashDurationEnemy, + }) + } + if mpuo.mutation.FlashDurationEnemyCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Column: matchplayer.FieldFlashDurationEnemy, + }) + } + if value, ok := mpuo.mutation.FlashTotalSelf(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldFlashTotalSelf, + }) + } + if value, ok := mpuo.mutation.AddedFlashTotalSelf(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldFlashTotalSelf, + }) + } + if mpuo.mutation.FlashTotalSelfCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldFlashTotalSelf, + }) + } + if value, ok := mpuo.mutation.FlashTotalTeam(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldFlashTotalTeam, + }) + } + if value, ok := mpuo.mutation.AddedFlashTotalTeam(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldFlashTotalTeam, + }) + } + if mpuo.mutation.FlashTotalTeamCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldFlashTotalTeam, + }) + } + if value, ok := mpuo.mutation.FlashTotalEnemy(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldFlashTotalEnemy, + }) + } + if value, ok := mpuo.mutation.AddedFlashTotalEnemy(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: matchplayer.FieldFlashTotalEnemy, + }) + } + if mpuo.mutation.FlashTotalEnemyCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: matchplayer.FieldFlashTotalEnemy, + }) + } + if value, ok := mpuo.mutation.FlashAssists(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldFlashAssists, + }) + } + if value, ok := mpuo.mutation.AddedFlashAssists(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: matchplayer.FieldFlashAssists, + }) + } + if mpuo.mutation.FlashAssistsCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldFlashAssists, + }) + } + if mpuo.mutation.MatchesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: matchplayer.MatchesTable, + Columns: []string{matchplayer.MatchesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Column: match.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mpuo.mutation.MatchesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: matchplayer.MatchesTable, + Columns: []string{matchplayer.MatchesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Column: match.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if mpuo.mutation.PlayersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: matchplayer.PlayersTable, + Columns: []string{matchplayer.PlayersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Column: player.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mpuo.mutation.PlayersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: matchplayer.PlayersTable, + Columns: []string{matchplayer.PlayersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Column: player.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if mpuo.mutation.WeaponStatsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.WeaponStatsTable, + Columns: []string{matchplayer.WeaponStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weapon.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mpuo.mutation.RemovedWeaponStatsIDs(); len(nodes) > 0 && !mpuo.mutation.WeaponStatsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.WeaponStatsTable, + Columns: []string{matchplayer.WeaponStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weapon.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mpuo.mutation.WeaponStatsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.WeaponStatsTable, + Columns: []string{matchplayer.WeaponStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weapon.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if mpuo.mutation.RoundStatsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.RoundStatsTable, + Columns: []string{matchplayer.RoundStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: roundstats.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mpuo.mutation.RemovedRoundStatsIDs(); len(nodes) > 0 && !mpuo.mutation.RoundStatsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.RoundStatsTable, + Columns: []string{matchplayer.RoundStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: roundstats.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mpuo.mutation.RoundStatsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.RoundStatsTable, + Columns: []string{matchplayer.RoundStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: roundstats.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if mpuo.mutation.SprayCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.SprayTable, + Columns: []string{matchplayer.SprayColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: spray.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mpuo.mutation.RemovedSprayIDs(); len(nodes) > 0 && !mpuo.mutation.SprayCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.SprayTable, + Columns: []string{matchplayer.SprayColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: spray.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mpuo.mutation.SprayIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: matchplayer.SprayTable, + Columns: []string{matchplayer.SprayColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: spray.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &MatchPlayer{config: mpuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, mpuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{matchplayer.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} + } + return nil, err + } + return _node, nil +} diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index 7fbecee..6d9287e 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -30,54 +30,8 @@ var ( Columns: MatchesColumns, PrimaryKey: []*schema.Column{MatchesColumns[0]}, } - // PlayersColumns holds the columns for the "players" table. - PlayersColumns = []*schema.Column{ - {Name: "id", Type: field.TypeUint64, Increment: true}, - {Name: "name", Type: field.TypeString, Nullable: true}, - {Name: "avatar", Type: field.TypeString, Nullable: true}, - {Name: "vanity_url", Type: field.TypeString, Nullable: true}, - {Name: "vanity_url_real", Type: field.TypeString, Nullable: true}, - {Name: "vac_date", Type: field.TypeTime, Nullable: true}, - {Name: "vac_count", Type: field.TypeInt, Nullable: true}, - {Name: "game_ban_date", Type: field.TypeTime, Nullable: true}, - {Name: "game_ban_count", Type: field.TypeInt, Nullable: true}, - {Name: "steam_updated", Type: field.TypeTime}, - {Name: "sharecode_updated", Type: field.TypeTime, Nullable: true}, - {Name: "auth_code", Type: field.TypeString, Nullable: true}, - {Name: "profile_created", Type: field.TypeTime, Nullable: true}, - {Name: "oldest_sharecode_seen", Type: field.TypeString, Nullable: true}, - } - // PlayersTable holds the schema information for the "players" table. - PlayersTable = &schema.Table{ - Name: "players", - Columns: PlayersColumns, - PrimaryKey: []*schema.Column{PlayersColumns[0]}, - } - // RoundStatsColumns holds the columns for the "round_stats" table. - RoundStatsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, - {Name: "round", Type: field.TypeUint}, - {Name: "bank", Type: field.TypeUint}, - {Name: "equipment", Type: field.TypeUint}, - {Name: "spent", Type: field.TypeUint}, - {Name: "stats_round_stats", Type: field.TypeInt, Nullable: true}, - } - // RoundStatsTable holds the schema information for the "round_stats" table. - RoundStatsTable = &schema.Table{ - Name: "round_stats", - Columns: RoundStatsColumns, - PrimaryKey: []*schema.Column{RoundStatsColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "round_stats_stats_round_stats", - Columns: []*schema.Column{RoundStatsColumns[5]}, - RefColumns: []*schema.Column{StatsColumns[0]}, - OnDelete: schema.SetNull, - }, - }, - } - // StatsColumns holds the columns for the "stats" table. - StatsColumns = []*schema.Column{ + // MatchPlayersColumns holds the columns for the "match_players" table. + MatchPlayersColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "team_id", Type: field.TypeInt}, {Name: "kills", Type: field.TypeInt}, @@ -108,48 +62,119 @@ var ( {Name: "flash_total_self", Type: field.TypeUint, Nullable: true}, {Name: "flash_total_team", Type: field.TypeUint, Nullable: true}, {Name: "flash_total_enemy", Type: field.TypeUint, Nullable: true}, + {Name: "flash_assists", Type: field.TypeInt, Nullable: true}, {Name: "match_stats", Type: field.TypeUint64, Nullable: true}, {Name: "player_stats", Type: field.TypeUint64, Nullable: true}, } - // StatsTable holds the schema information for the "stats" table. - StatsTable = &schema.Table{ - Name: "stats", - Columns: StatsColumns, - PrimaryKey: []*schema.Column{StatsColumns[0]}, + // MatchPlayersTable holds the schema information for the "match_players" table. + MatchPlayersTable = &schema.Table{ + Name: "match_players", + Columns: MatchPlayersColumns, + PrimaryKey: []*schema.Column{MatchPlayersColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { - Symbol: "stats_matches_stats", - Columns: []*schema.Column{StatsColumns[30]}, + Symbol: "match_players_matches_stats", + Columns: []*schema.Column{MatchPlayersColumns[31]}, RefColumns: []*schema.Column{MatchesColumns[0]}, OnDelete: schema.SetNull, }, { - Symbol: "stats_players_stats", - Columns: []*schema.Column{StatsColumns[31]}, + Symbol: "match_players_players_stats", + Columns: []*schema.Column{MatchPlayersColumns[32]}, RefColumns: []*schema.Column{PlayersColumns[0]}, OnDelete: schema.SetNull, }, }, } - // WeaponStatsColumns holds the columns for the "weapon_stats" table. - WeaponStatsColumns = []*schema.Column{ + // PlayersColumns holds the columns for the "players" table. + PlayersColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUint64, Increment: true}, + {Name: "name", Type: field.TypeString, Nullable: true}, + {Name: "avatar", Type: field.TypeString, Nullable: true}, + {Name: "vanity_url", Type: field.TypeString, Nullable: true}, + {Name: "vanity_url_real", Type: field.TypeString, Nullable: true}, + {Name: "vac_date", Type: field.TypeTime, Nullable: true}, + {Name: "vac_count", Type: field.TypeInt, Nullable: true}, + {Name: "game_ban_date", Type: field.TypeTime, Nullable: true}, + {Name: "game_ban_count", Type: field.TypeInt, Nullable: true}, + {Name: "steam_updated", Type: field.TypeTime}, + {Name: "sharecode_updated", Type: field.TypeTime, Nullable: true}, + {Name: "auth_code", Type: field.TypeString, Nullable: true}, + {Name: "profile_created", Type: field.TypeTime, Nullable: true}, + {Name: "oldest_sharecode_seen", Type: field.TypeString, Nullable: true}, + {Name: "wins", Type: field.TypeInt, Nullable: true}, + {Name: "looses", Type: field.TypeInt, Nullable: true}, + {Name: "ties", Type: field.TypeInt, Nullable: true}, + } + // PlayersTable holds the schema information for the "players" table. + PlayersTable = &schema.Table{ + Name: "players", + Columns: PlayersColumns, + PrimaryKey: []*schema.Column{PlayersColumns[0]}, + } + // RoundStatsColumns holds the columns for the "round_stats" table. + RoundStatsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "round", Type: field.TypeUint}, + {Name: "bank", Type: field.TypeUint}, + {Name: "equipment", Type: field.TypeUint}, + {Name: "spent", Type: field.TypeUint}, + {Name: "match_player_round_stats", Type: field.TypeInt, Nullable: true}, + } + // RoundStatsTable holds the schema information for the "round_stats" table. + RoundStatsTable = &schema.Table{ + Name: "round_stats", + Columns: RoundStatsColumns, + PrimaryKey: []*schema.Column{RoundStatsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "round_stats_match_players_round_stats", + Columns: []*schema.Column{RoundStatsColumns[5]}, + RefColumns: []*schema.Column{MatchPlayersColumns[0]}, + OnDelete: schema.SetNull, + }, + }, + } + // SpraysColumns holds the columns for the "sprays" table. + SpraysColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "weapon", Type: field.TypeInt}, + {Name: "spray", Type: field.TypeBytes}, + {Name: "match_player_spray", Type: field.TypeInt, Nullable: true}, + } + // SpraysTable holds the schema information for the "sprays" table. + SpraysTable = &schema.Table{ + Name: "sprays", + Columns: SpraysColumns, + PrimaryKey: []*schema.Column{SpraysColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "sprays_match_players_spray", + Columns: []*schema.Column{SpraysColumns[3]}, + RefColumns: []*schema.Column{MatchPlayersColumns[0]}, + OnDelete: schema.SetNull, + }, + }, + } + // WeaponsColumns holds the columns for the "weapons" table. + WeaponsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "victim", Type: field.TypeUint64}, {Name: "dmg", Type: field.TypeUint}, {Name: "eq_type", Type: field.TypeInt}, {Name: "hit_group", Type: field.TypeInt}, - {Name: "stats_weapon_stats", Type: field.TypeInt, Nullable: true}, + {Name: "match_player_weapon_stats", Type: field.TypeInt, Nullable: true}, } - // WeaponStatsTable holds the schema information for the "weapon_stats" table. - WeaponStatsTable = &schema.Table{ - Name: "weapon_stats", - Columns: WeaponStatsColumns, - PrimaryKey: []*schema.Column{WeaponStatsColumns[0]}, + // WeaponsTable holds the schema information for the "weapons" table. + WeaponsTable = &schema.Table{ + Name: "weapons", + Columns: WeaponsColumns, + PrimaryKey: []*schema.Column{WeaponsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { - Symbol: "weapon_stats_stats_weapon_stats", - Columns: []*schema.Column{WeaponStatsColumns[5]}, - RefColumns: []*schema.Column{StatsColumns[0]}, + Symbol: "weapons_match_players_weapon_stats", + Columns: []*schema.Column{WeaponsColumns[5]}, + RefColumns: []*schema.Column{MatchPlayersColumns[0]}, OnDelete: schema.SetNull, }, }, @@ -182,19 +207,21 @@ var ( // Tables holds all the tables in the schema. Tables = []*schema.Table{ MatchesTable, + MatchPlayersTable, PlayersTable, RoundStatsTable, - StatsTable, - WeaponStatsTable, + SpraysTable, + WeaponsTable, PlayerMatchesTable, } ) func init() { - RoundStatsTable.ForeignKeys[0].RefTable = StatsTable - StatsTable.ForeignKeys[0].RefTable = MatchesTable - StatsTable.ForeignKeys[1].RefTable = PlayersTable - WeaponStatsTable.ForeignKeys[0].RefTable = StatsTable + MatchPlayersTable.ForeignKeys[0].RefTable = MatchesTable + MatchPlayersTable.ForeignKeys[1].RefTable = PlayersTable + RoundStatsTable.ForeignKeys[0].RefTable = MatchPlayersTable + SpraysTable.ForeignKeys[0].RefTable = MatchPlayersTable + WeaponsTable.ForeignKeys[0].RefTable = MatchPlayersTable PlayerMatchesTable.ForeignKeys[0].RefTable = PlayersTable PlayerMatchesTable.ForeignKeys[1].RefTable = MatchesTable } diff --git a/ent/mutation.go b/ent/mutation.go index fb314a3..c8b4e16 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -5,11 +5,12 @@ package ent import ( "context" "csgowtfd/ent/match" + "csgowtfd/ent/matchplayer" "csgowtfd/ent/player" "csgowtfd/ent/predicate" "csgowtfd/ent/roundstats" - "csgowtfd/ent/stats" - "csgowtfd/ent/weaponstats" + "csgowtfd/ent/spray" + "csgowtfd/ent/weapon" "fmt" "sync" "time" @@ -27,10 +28,11 @@ const ( // Node types. TypeMatch = "Match" + TypeMatchPlayer = "MatchPlayer" TypePlayer = "Player" TypeRoundStats = "RoundStats" - TypeStats = "Stats" - TypeWeaponStats = "WeaponStats" + TypeSpray = "Spray" + TypeWeapon = "Weapon" ) // MatchMutation represents an operation that mutates the Match nodes in the graph. @@ -711,7 +713,7 @@ func (m *MatchMutation) ResetGamebanPresent() { m.gameban_present = nil } -// AddStatIDs adds the "stats" edge to the Stats entity by ids. +// AddStatIDs adds the "stats" edge to the MatchPlayer entity by ids. func (m *MatchMutation) AddStatIDs(ids ...int) { if m.stats == nil { m.stats = make(map[int]struct{}) @@ -721,17 +723,17 @@ func (m *MatchMutation) AddStatIDs(ids ...int) { } } -// ClearStats clears the "stats" edge to the Stats entity. +// ClearStats clears the "stats" edge to the MatchPlayer entity. func (m *MatchMutation) ClearStats() { m.clearedstats = true } -// StatsCleared reports if the "stats" edge to the Stats entity was cleared. +// StatsCleared reports if the "stats" edge to the MatchPlayer entity was cleared. func (m *MatchMutation) StatsCleared() bool { return m.clearedstats } -// RemoveStatIDs removes the "stats" edge to the Stats entity by IDs. +// RemoveStatIDs removes the "stats" edge to the MatchPlayer entity by IDs. func (m *MatchMutation) RemoveStatIDs(ids ...int) { if m.removedstats == nil { m.removedstats = make(map[int]struct{}) @@ -742,7 +744,7 @@ func (m *MatchMutation) RemoveStatIDs(ids ...int) { } } -// RemovedStats returns the removed IDs of the "stats" edge to the Stats entity. +// RemovedStats returns the removed IDs of the "stats" edge to the MatchPlayer entity. func (m *MatchMutation) RemovedStatsIDs() (ids []int) { for id := range m.removedstats { ids = append(ids, id) @@ -1310,6 +1312,3773 @@ func (m *MatchMutation) ResetEdge(name string) error { return fmt.Errorf("unknown Match edge %s", name) } +// MatchPlayerMutation represents an operation that mutates the MatchPlayer nodes in the graph. +type MatchPlayerMutation struct { + config + op Op + typ string + id *int + team_id *int + addteam_id *int + kills *int + addkills *int + deaths *int + adddeaths *int + assists *int + addassists *int + headshot *int + addheadshot *int + mvp *uint + addmvp *uint + score *int + addscore *int + rank_new *int + addrank_new *int + rank_old *int + addrank_old *int + mk_2 *uint + addmk_2 *uint + mk_3 *uint + addmk_3 *uint + mk_4 *uint + addmk_4 *uint + mk_5 *uint + addmk_5 *uint + dmg_enemy *uint + adddmg_enemy *uint + dmg_team *uint + adddmg_team *uint + ud_he *uint + addud_he *uint + ud_flames *uint + addud_flames *uint + ud_flash *uint + addud_flash *uint + ud_decoy *uint + addud_decoy *uint + ud_smoke *uint + addud_smoke *uint + crosshair *string + color *matchplayer.Color + kast *int + addkast *int + flash_duration_self *float32 + addflash_duration_self *float32 + flash_duration_team *float32 + addflash_duration_team *float32 + flash_duration_enemy *float32 + addflash_duration_enemy *float32 + flash_total_self *uint + addflash_total_self *uint + flash_total_team *uint + addflash_total_team *uint + flash_total_enemy *uint + addflash_total_enemy *uint + flash_assists *int + addflash_assists *int + clearedFields map[string]struct{} + matches *uint64 + clearedmatches bool + players *uint64 + clearedplayers bool + weapon_stats map[int]struct{} + removedweapon_stats map[int]struct{} + clearedweapon_stats bool + round_stats map[int]struct{} + removedround_stats map[int]struct{} + clearedround_stats bool + spray map[int]struct{} + removedspray map[int]struct{} + clearedspray bool + done bool + oldValue func(context.Context) (*MatchPlayer, error) + predicates []predicate.MatchPlayer +} + +var _ ent.Mutation = (*MatchPlayerMutation)(nil) + +// matchplayerOption allows management of the mutation configuration using functional options. +type matchplayerOption func(*MatchPlayerMutation) + +// newMatchPlayerMutation creates new mutation for the MatchPlayer entity. +func newMatchPlayerMutation(c config, op Op, opts ...matchplayerOption) *MatchPlayerMutation { + m := &MatchPlayerMutation{ + config: c, + op: op, + typ: TypeMatchPlayer, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withMatchPlayerID sets the ID field of the mutation. +func withMatchPlayerID(id int) matchplayerOption { + return func(m *MatchPlayerMutation) { + var ( + err error + once sync.Once + value *MatchPlayer + ) + m.oldValue = func(ctx context.Context) (*MatchPlayer, error) { + once.Do(func() { + if m.done { + err = fmt.Errorf("querying old values post mutation is not allowed") + } else { + value, err = m.Client().MatchPlayer.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withMatchPlayer sets the old MatchPlayer of the mutation. +func withMatchPlayer(node *MatchPlayer) matchplayerOption { + return func(m *MatchPlayerMutation) { + m.oldValue = func(context.Context) (*MatchPlayer, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m MatchPlayerMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m MatchPlayerMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, fmt.Errorf("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *MatchPlayerMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// SetTeamID sets the "team_id" field. +func (m *MatchPlayerMutation) SetTeamID(i int) { + m.team_id = &i + m.addteam_id = nil +} + +// TeamID returns the value of the "team_id" field in the mutation. +func (m *MatchPlayerMutation) TeamID() (r int, exists bool) { + v := m.team_id + if v == nil { + return + } + return *v, true +} + +// OldTeamID returns the old "team_id" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldTeamID(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldTeamID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldTeamID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTeamID: %w", err) + } + return oldValue.TeamID, nil +} + +// AddTeamID adds i to the "team_id" field. +func (m *MatchPlayerMutation) AddTeamID(i int) { + if m.addteam_id != nil { + *m.addteam_id += i + } else { + m.addteam_id = &i + } +} + +// AddedTeamID returns the value that was added to the "team_id" field in this mutation. +func (m *MatchPlayerMutation) AddedTeamID() (r int, exists bool) { + v := m.addteam_id + if v == nil { + return + } + return *v, true +} + +// ResetTeamID resets all changes to the "team_id" field. +func (m *MatchPlayerMutation) ResetTeamID() { + m.team_id = nil + m.addteam_id = nil +} + +// SetKills sets the "kills" field. +func (m *MatchPlayerMutation) SetKills(i int) { + m.kills = &i + m.addkills = nil +} + +// Kills returns the value of the "kills" field in the mutation. +func (m *MatchPlayerMutation) Kills() (r int, exists bool) { + v := m.kills + if v == nil { + return + } + return *v, true +} + +// OldKills returns the old "kills" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldKills(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldKills is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldKills requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldKills: %w", err) + } + return oldValue.Kills, nil +} + +// AddKills adds i to the "kills" field. +func (m *MatchPlayerMutation) AddKills(i int) { + if m.addkills != nil { + *m.addkills += i + } else { + m.addkills = &i + } +} + +// AddedKills returns the value that was added to the "kills" field in this mutation. +func (m *MatchPlayerMutation) AddedKills() (r int, exists bool) { + v := m.addkills + if v == nil { + return + } + return *v, true +} + +// ResetKills resets all changes to the "kills" field. +func (m *MatchPlayerMutation) ResetKills() { + m.kills = nil + m.addkills = nil +} + +// SetDeaths sets the "deaths" field. +func (m *MatchPlayerMutation) SetDeaths(i int) { + m.deaths = &i + m.adddeaths = nil +} + +// Deaths returns the value of the "deaths" field in the mutation. +func (m *MatchPlayerMutation) Deaths() (r int, exists bool) { + v := m.deaths + if v == nil { + return + } + return *v, true +} + +// OldDeaths returns the old "deaths" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldDeaths(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldDeaths is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldDeaths requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeaths: %w", err) + } + return oldValue.Deaths, nil +} + +// AddDeaths adds i to the "deaths" field. +func (m *MatchPlayerMutation) AddDeaths(i int) { + if m.adddeaths != nil { + *m.adddeaths += i + } else { + m.adddeaths = &i + } +} + +// AddedDeaths returns the value that was added to the "deaths" field in this mutation. +func (m *MatchPlayerMutation) AddedDeaths() (r int, exists bool) { + v := m.adddeaths + if v == nil { + return + } + return *v, true +} + +// ResetDeaths resets all changes to the "deaths" field. +func (m *MatchPlayerMutation) ResetDeaths() { + m.deaths = nil + m.adddeaths = nil +} + +// SetAssists sets the "assists" field. +func (m *MatchPlayerMutation) SetAssists(i int) { + m.assists = &i + m.addassists = nil +} + +// Assists returns the value of the "assists" field in the mutation. +func (m *MatchPlayerMutation) Assists() (r int, exists bool) { + v := m.assists + if v == nil { + return + } + return *v, true +} + +// OldAssists returns the old "assists" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldAssists(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldAssists is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldAssists requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAssists: %w", err) + } + return oldValue.Assists, nil +} + +// AddAssists adds i to the "assists" field. +func (m *MatchPlayerMutation) AddAssists(i int) { + if m.addassists != nil { + *m.addassists += i + } else { + m.addassists = &i + } +} + +// AddedAssists returns the value that was added to the "assists" field in this mutation. +func (m *MatchPlayerMutation) AddedAssists() (r int, exists bool) { + v := m.addassists + if v == nil { + return + } + return *v, true +} + +// ResetAssists resets all changes to the "assists" field. +func (m *MatchPlayerMutation) ResetAssists() { + m.assists = nil + m.addassists = nil +} + +// SetHeadshot sets the "headshot" field. +func (m *MatchPlayerMutation) SetHeadshot(i int) { + m.headshot = &i + m.addheadshot = nil +} + +// Headshot returns the value of the "headshot" field in the mutation. +func (m *MatchPlayerMutation) Headshot() (r int, exists bool) { + v := m.headshot + if v == nil { + return + } + return *v, true +} + +// OldHeadshot returns the old "headshot" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldHeadshot(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldHeadshot is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldHeadshot requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHeadshot: %w", err) + } + return oldValue.Headshot, nil +} + +// AddHeadshot adds i to the "headshot" field. +func (m *MatchPlayerMutation) AddHeadshot(i int) { + if m.addheadshot != nil { + *m.addheadshot += i + } else { + m.addheadshot = &i + } +} + +// AddedHeadshot returns the value that was added to the "headshot" field in this mutation. +func (m *MatchPlayerMutation) AddedHeadshot() (r int, exists bool) { + v := m.addheadshot + if v == nil { + return + } + return *v, true +} + +// ResetHeadshot resets all changes to the "headshot" field. +func (m *MatchPlayerMutation) ResetHeadshot() { + m.headshot = nil + m.addheadshot = nil +} + +// SetMvp sets the "mvp" field. +func (m *MatchPlayerMutation) SetMvp(u uint) { + m.mvp = &u + m.addmvp = nil +} + +// Mvp returns the value of the "mvp" field in the mutation. +func (m *MatchPlayerMutation) Mvp() (r uint, exists bool) { + v := m.mvp + if v == nil { + return + } + return *v, true +} + +// OldMvp returns the old "mvp" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldMvp(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldMvp is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldMvp requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMvp: %w", err) + } + return oldValue.Mvp, nil +} + +// AddMvp adds u to the "mvp" field. +func (m *MatchPlayerMutation) AddMvp(u uint) { + if m.addmvp != nil { + *m.addmvp += u + } else { + m.addmvp = &u + } +} + +// AddedMvp returns the value that was added to the "mvp" field in this mutation. +func (m *MatchPlayerMutation) AddedMvp() (r uint, exists bool) { + v := m.addmvp + if v == nil { + return + } + return *v, true +} + +// ResetMvp resets all changes to the "mvp" field. +func (m *MatchPlayerMutation) ResetMvp() { + m.mvp = nil + m.addmvp = nil +} + +// SetScore sets the "score" field. +func (m *MatchPlayerMutation) SetScore(i int) { + m.score = &i + m.addscore = nil +} + +// Score returns the value of the "score" field in the mutation. +func (m *MatchPlayerMutation) Score() (r int, exists bool) { + v := m.score + if v == nil { + return + } + return *v, true +} + +// OldScore returns the old "score" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldScore(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldScore is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldScore requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldScore: %w", err) + } + return oldValue.Score, nil +} + +// AddScore adds i to the "score" field. +func (m *MatchPlayerMutation) AddScore(i int) { + if m.addscore != nil { + *m.addscore += i + } else { + m.addscore = &i + } +} + +// AddedScore returns the value that was added to the "score" field in this mutation. +func (m *MatchPlayerMutation) AddedScore() (r int, exists bool) { + v := m.addscore + if v == nil { + return + } + return *v, true +} + +// ResetScore resets all changes to the "score" field. +func (m *MatchPlayerMutation) ResetScore() { + m.score = nil + m.addscore = nil +} + +// SetRankNew sets the "rank_new" field. +func (m *MatchPlayerMutation) SetRankNew(i int) { + m.rank_new = &i + m.addrank_new = nil +} + +// RankNew returns the value of the "rank_new" field in the mutation. +func (m *MatchPlayerMutation) RankNew() (r int, exists bool) { + v := m.rank_new + if v == nil { + return + } + return *v, true +} + +// OldRankNew returns the old "rank_new" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldRankNew(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldRankNew is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldRankNew requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRankNew: %w", err) + } + return oldValue.RankNew, nil +} + +// AddRankNew adds i to the "rank_new" field. +func (m *MatchPlayerMutation) AddRankNew(i int) { + if m.addrank_new != nil { + *m.addrank_new += i + } else { + m.addrank_new = &i + } +} + +// AddedRankNew returns the value that was added to the "rank_new" field in this mutation. +func (m *MatchPlayerMutation) AddedRankNew() (r int, exists bool) { + v := m.addrank_new + if v == nil { + return + } + return *v, true +} + +// ClearRankNew clears the value of the "rank_new" field. +func (m *MatchPlayerMutation) ClearRankNew() { + m.rank_new = nil + m.addrank_new = nil + m.clearedFields[matchplayer.FieldRankNew] = struct{}{} +} + +// RankNewCleared returns if the "rank_new" field was cleared in this mutation. +func (m *MatchPlayerMutation) RankNewCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldRankNew] + return ok +} + +// ResetRankNew resets all changes to the "rank_new" field. +func (m *MatchPlayerMutation) ResetRankNew() { + m.rank_new = nil + m.addrank_new = nil + delete(m.clearedFields, matchplayer.FieldRankNew) +} + +// SetRankOld sets the "rank_old" field. +func (m *MatchPlayerMutation) SetRankOld(i int) { + m.rank_old = &i + m.addrank_old = nil +} + +// RankOld returns the value of the "rank_old" field in the mutation. +func (m *MatchPlayerMutation) RankOld() (r int, exists bool) { + v := m.rank_old + if v == nil { + return + } + return *v, true +} + +// OldRankOld returns the old "rank_old" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldRankOld(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldRankOld is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldRankOld requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRankOld: %w", err) + } + return oldValue.RankOld, nil +} + +// AddRankOld adds i to the "rank_old" field. +func (m *MatchPlayerMutation) AddRankOld(i int) { + if m.addrank_old != nil { + *m.addrank_old += i + } else { + m.addrank_old = &i + } +} + +// AddedRankOld returns the value that was added to the "rank_old" field in this mutation. +func (m *MatchPlayerMutation) AddedRankOld() (r int, exists bool) { + v := m.addrank_old + if v == nil { + return + } + return *v, true +} + +// ClearRankOld clears the value of the "rank_old" field. +func (m *MatchPlayerMutation) ClearRankOld() { + m.rank_old = nil + m.addrank_old = nil + m.clearedFields[matchplayer.FieldRankOld] = struct{}{} +} + +// RankOldCleared returns if the "rank_old" field was cleared in this mutation. +func (m *MatchPlayerMutation) RankOldCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldRankOld] + return ok +} + +// ResetRankOld resets all changes to the "rank_old" field. +func (m *MatchPlayerMutation) ResetRankOld() { + m.rank_old = nil + m.addrank_old = nil + delete(m.clearedFields, matchplayer.FieldRankOld) +} + +// SetMk2 sets the "mk_2" field. +func (m *MatchPlayerMutation) SetMk2(u uint) { + m.mk_2 = &u + m.addmk_2 = nil +} + +// Mk2 returns the value of the "mk_2" field in the mutation. +func (m *MatchPlayerMutation) Mk2() (r uint, exists bool) { + v := m.mk_2 + if v == nil { + return + } + return *v, true +} + +// OldMk2 returns the old "mk_2" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldMk2(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldMk2 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldMk2 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMk2: %w", err) + } + return oldValue.Mk2, nil +} + +// AddMk2 adds u to the "mk_2" field. +func (m *MatchPlayerMutation) AddMk2(u uint) { + if m.addmk_2 != nil { + *m.addmk_2 += u + } else { + m.addmk_2 = &u + } +} + +// AddedMk2 returns the value that was added to the "mk_2" field in this mutation. +func (m *MatchPlayerMutation) AddedMk2() (r uint, exists bool) { + v := m.addmk_2 + if v == nil { + return + } + return *v, true +} + +// ClearMk2 clears the value of the "mk_2" field. +func (m *MatchPlayerMutation) ClearMk2() { + m.mk_2 = nil + m.addmk_2 = nil + m.clearedFields[matchplayer.FieldMk2] = struct{}{} +} + +// Mk2Cleared returns if the "mk_2" field was cleared in this mutation. +func (m *MatchPlayerMutation) Mk2Cleared() bool { + _, ok := m.clearedFields[matchplayer.FieldMk2] + return ok +} + +// ResetMk2 resets all changes to the "mk_2" field. +func (m *MatchPlayerMutation) ResetMk2() { + m.mk_2 = nil + m.addmk_2 = nil + delete(m.clearedFields, matchplayer.FieldMk2) +} + +// SetMk3 sets the "mk_3" field. +func (m *MatchPlayerMutation) SetMk3(u uint) { + m.mk_3 = &u + m.addmk_3 = nil +} + +// Mk3 returns the value of the "mk_3" field in the mutation. +func (m *MatchPlayerMutation) Mk3() (r uint, exists bool) { + v := m.mk_3 + if v == nil { + return + } + return *v, true +} + +// OldMk3 returns the old "mk_3" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldMk3(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldMk3 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldMk3 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMk3: %w", err) + } + return oldValue.Mk3, nil +} + +// AddMk3 adds u to the "mk_3" field. +func (m *MatchPlayerMutation) AddMk3(u uint) { + if m.addmk_3 != nil { + *m.addmk_3 += u + } else { + m.addmk_3 = &u + } +} + +// AddedMk3 returns the value that was added to the "mk_3" field in this mutation. +func (m *MatchPlayerMutation) AddedMk3() (r uint, exists bool) { + v := m.addmk_3 + if v == nil { + return + } + return *v, true +} + +// ClearMk3 clears the value of the "mk_3" field. +func (m *MatchPlayerMutation) ClearMk3() { + m.mk_3 = nil + m.addmk_3 = nil + m.clearedFields[matchplayer.FieldMk3] = struct{}{} +} + +// Mk3Cleared returns if the "mk_3" field was cleared in this mutation. +func (m *MatchPlayerMutation) Mk3Cleared() bool { + _, ok := m.clearedFields[matchplayer.FieldMk3] + return ok +} + +// ResetMk3 resets all changes to the "mk_3" field. +func (m *MatchPlayerMutation) ResetMk3() { + m.mk_3 = nil + m.addmk_3 = nil + delete(m.clearedFields, matchplayer.FieldMk3) +} + +// SetMk4 sets the "mk_4" field. +func (m *MatchPlayerMutation) SetMk4(u uint) { + m.mk_4 = &u + m.addmk_4 = nil +} + +// Mk4 returns the value of the "mk_4" field in the mutation. +func (m *MatchPlayerMutation) Mk4() (r uint, exists bool) { + v := m.mk_4 + if v == nil { + return + } + return *v, true +} + +// OldMk4 returns the old "mk_4" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldMk4(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldMk4 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldMk4 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMk4: %w", err) + } + return oldValue.Mk4, nil +} + +// AddMk4 adds u to the "mk_4" field. +func (m *MatchPlayerMutation) AddMk4(u uint) { + if m.addmk_4 != nil { + *m.addmk_4 += u + } else { + m.addmk_4 = &u + } +} + +// AddedMk4 returns the value that was added to the "mk_4" field in this mutation. +func (m *MatchPlayerMutation) AddedMk4() (r uint, exists bool) { + v := m.addmk_4 + if v == nil { + return + } + return *v, true +} + +// ClearMk4 clears the value of the "mk_4" field. +func (m *MatchPlayerMutation) ClearMk4() { + m.mk_4 = nil + m.addmk_4 = nil + m.clearedFields[matchplayer.FieldMk4] = struct{}{} +} + +// Mk4Cleared returns if the "mk_4" field was cleared in this mutation. +func (m *MatchPlayerMutation) Mk4Cleared() bool { + _, ok := m.clearedFields[matchplayer.FieldMk4] + return ok +} + +// ResetMk4 resets all changes to the "mk_4" field. +func (m *MatchPlayerMutation) ResetMk4() { + m.mk_4 = nil + m.addmk_4 = nil + delete(m.clearedFields, matchplayer.FieldMk4) +} + +// SetMk5 sets the "mk_5" field. +func (m *MatchPlayerMutation) SetMk5(u uint) { + m.mk_5 = &u + m.addmk_5 = nil +} + +// Mk5 returns the value of the "mk_5" field in the mutation. +func (m *MatchPlayerMutation) Mk5() (r uint, exists bool) { + v := m.mk_5 + if v == nil { + return + } + return *v, true +} + +// OldMk5 returns the old "mk_5" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldMk5(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldMk5 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldMk5 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMk5: %w", err) + } + return oldValue.Mk5, nil +} + +// AddMk5 adds u to the "mk_5" field. +func (m *MatchPlayerMutation) AddMk5(u uint) { + if m.addmk_5 != nil { + *m.addmk_5 += u + } else { + m.addmk_5 = &u + } +} + +// AddedMk5 returns the value that was added to the "mk_5" field in this mutation. +func (m *MatchPlayerMutation) AddedMk5() (r uint, exists bool) { + v := m.addmk_5 + if v == nil { + return + } + return *v, true +} + +// ClearMk5 clears the value of the "mk_5" field. +func (m *MatchPlayerMutation) ClearMk5() { + m.mk_5 = nil + m.addmk_5 = nil + m.clearedFields[matchplayer.FieldMk5] = struct{}{} +} + +// Mk5Cleared returns if the "mk_5" field was cleared in this mutation. +func (m *MatchPlayerMutation) Mk5Cleared() bool { + _, ok := m.clearedFields[matchplayer.FieldMk5] + return ok +} + +// ResetMk5 resets all changes to the "mk_5" field. +func (m *MatchPlayerMutation) ResetMk5() { + m.mk_5 = nil + m.addmk_5 = nil + delete(m.clearedFields, matchplayer.FieldMk5) +} + +// SetDmgEnemy sets the "dmg_enemy" field. +func (m *MatchPlayerMutation) SetDmgEnemy(u uint) { + m.dmg_enemy = &u + m.adddmg_enemy = nil +} + +// DmgEnemy returns the value of the "dmg_enemy" field in the mutation. +func (m *MatchPlayerMutation) DmgEnemy() (r uint, exists bool) { + v := m.dmg_enemy + if v == nil { + return + } + return *v, true +} + +// OldDmgEnemy returns the old "dmg_enemy" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldDmgEnemy(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldDmgEnemy is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldDmgEnemy requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDmgEnemy: %w", err) + } + return oldValue.DmgEnemy, nil +} + +// AddDmgEnemy adds u to the "dmg_enemy" field. +func (m *MatchPlayerMutation) AddDmgEnemy(u uint) { + if m.adddmg_enemy != nil { + *m.adddmg_enemy += u + } else { + m.adddmg_enemy = &u + } +} + +// AddedDmgEnemy returns the value that was added to the "dmg_enemy" field in this mutation. +func (m *MatchPlayerMutation) AddedDmgEnemy() (r uint, exists bool) { + v := m.adddmg_enemy + if v == nil { + return + } + return *v, true +} + +// ClearDmgEnemy clears the value of the "dmg_enemy" field. +func (m *MatchPlayerMutation) ClearDmgEnemy() { + m.dmg_enemy = nil + m.adddmg_enemy = nil + m.clearedFields[matchplayer.FieldDmgEnemy] = struct{}{} +} + +// DmgEnemyCleared returns if the "dmg_enemy" field was cleared in this mutation. +func (m *MatchPlayerMutation) DmgEnemyCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldDmgEnemy] + return ok +} + +// ResetDmgEnemy resets all changes to the "dmg_enemy" field. +func (m *MatchPlayerMutation) ResetDmgEnemy() { + m.dmg_enemy = nil + m.adddmg_enemy = nil + delete(m.clearedFields, matchplayer.FieldDmgEnemy) +} + +// SetDmgTeam sets the "dmg_team" field. +func (m *MatchPlayerMutation) SetDmgTeam(u uint) { + m.dmg_team = &u + m.adddmg_team = nil +} + +// DmgTeam returns the value of the "dmg_team" field in the mutation. +func (m *MatchPlayerMutation) DmgTeam() (r uint, exists bool) { + v := m.dmg_team + if v == nil { + return + } + return *v, true +} + +// OldDmgTeam returns the old "dmg_team" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldDmgTeam(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldDmgTeam is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldDmgTeam requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDmgTeam: %w", err) + } + return oldValue.DmgTeam, nil +} + +// AddDmgTeam adds u to the "dmg_team" field. +func (m *MatchPlayerMutation) AddDmgTeam(u uint) { + if m.adddmg_team != nil { + *m.adddmg_team += u + } else { + m.adddmg_team = &u + } +} + +// AddedDmgTeam returns the value that was added to the "dmg_team" field in this mutation. +func (m *MatchPlayerMutation) AddedDmgTeam() (r uint, exists bool) { + v := m.adddmg_team + if v == nil { + return + } + return *v, true +} + +// ClearDmgTeam clears the value of the "dmg_team" field. +func (m *MatchPlayerMutation) ClearDmgTeam() { + m.dmg_team = nil + m.adddmg_team = nil + m.clearedFields[matchplayer.FieldDmgTeam] = struct{}{} +} + +// DmgTeamCleared returns if the "dmg_team" field was cleared in this mutation. +func (m *MatchPlayerMutation) DmgTeamCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldDmgTeam] + return ok +} + +// ResetDmgTeam resets all changes to the "dmg_team" field. +func (m *MatchPlayerMutation) ResetDmgTeam() { + m.dmg_team = nil + m.adddmg_team = nil + delete(m.clearedFields, matchplayer.FieldDmgTeam) +} + +// SetUdHe sets the "ud_he" field. +func (m *MatchPlayerMutation) SetUdHe(u uint) { + m.ud_he = &u + m.addud_he = nil +} + +// UdHe returns the value of the "ud_he" field in the mutation. +func (m *MatchPlayerMutation) UdHe() (r uint, exists bool) { + v := m.ud_he + if v == nil { + return + } + return *v, true +} + +// OldUdHe returns the old "ud_he" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldUdHe(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldUdHe is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldUdHe requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUdHe: %w", err) + } + return oldValue.UdHe, nil +} + +// AddUdHe adds u to the "ud_he" field. +func (m *MatchPlayerMutation) AddUdHe(u uint) { + if m.addud_he != nil { + *m.addud_he += u + } else { + m.addud_he = &u + } +} + +// AddedUdHe returns the value that was added to the "ud_he" field in this mutation. +func (m *MatchPlayerMutation) AddedUdHe() (r uint, exists bool) { + v := m.addud_he + if v == nil { + return + } + return *v, true +} + +// ClearUdHe clears the value of the "ud_he" field. +func (m *MatchPlayerMutation) ClearUdHe() { + m.ud_he = nil + m.addud_he = nil + m.clearedFields[matchplayer.FieldUdHe] = struct{}{} +} + +// UdHeCleared returns if the "ud_he" field was cleared in this mutation. +func (m *MatchPlayerMutation) UdHeCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldUdHe] + return ok +} + +// ResetUdHe resets all changes to the "ud_he" field. +func (m *MatchPlayerMutation) ResetUdHe() { + m.ud_he = nil + m.addud_he = nil + delete(m.clearedFields, matchplayer.FieldUdHe) +} + +// SetUdFlames sets the "ud_flames" field. +func (m *MatchPlayerMutation) SetUdFlames(u uint) { + m.ud_flames = &u + m.addud_flames = nil +} + +// UdFlames returns the value of the "ud_flames" field in the mutation. +func (m *MatchPlayerMutation) UdFlames() (r uint, exists bool) { + v := m.ud_flames + if v == nil { + return + } + return *v, true +} + +// OldUdFlames returns the old "ud_flames" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldUdFlames(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldUdFlames is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldUdFlames requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUdFlames: %w", err) + } + return oldValue.UdFlames, nil +} + +// AddUdFlames adds u to the "ud_flames" field. +func (m *MatchPlayerMutation) AddUdFlames(u uint) { + if m.addud_flames != nil { + *m.addud_flames += u + } else { + m.addud_flames = &u + } +} + +// AddedUdFlames returns the value that was added to the "ud_flames" field in this mutation. +func (m *MatchPlayerMutation) AddedUdFlames() (r uint, exists bool) { + v := m.addud_flames + if v == nil { + return + } + return *v, true +} + +// ClearUdFlames clears the value of the "ud_flames" field. +func (m *MatchPlayerMutation) ClearUdFlames() { + m.ud_flames = nil + m.addud_flames = nil + m.clearedFields[matchplayer.FieldUdFlames] = struct{}{} +} + +// UdFlamesCleared returns if the "ud_flames" field was cleared in this mutation. +func (m *MatchPlayerMutation) UdFlamesCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldUdFlames] + return ok +} + +// ResetUdFlames resets all changes to the "ud_flames" field. +func (m *MatchPlayerMutation) ResetUdFlames() { + m.ud_flames = nil + m.addud_flames = nil + delete(m.clearedFields, matchplayer.FieldUdFlames) +} + +// SetUdFlash sets the "ud_flash" field. +func (m *MatchPlayerMutation) SetUdFlash(u uint) { + m.ud_flash = &u + m.addud_flash = nil +} + +// UdFlash returns the value of the "ud_flash" field in the mutation. +func (m *MatchPlayerMutation) UdFlash() (r uint, exists bool) { + v := m.ud_flash + if v == nil { + return + } + return *v, true +} + +// OldUdFlash returns the old "ud_flash" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldUdFlash(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldUdFlash is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldUdFlash requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUdFlash: %w", err) + } + return oldValue.UdFlash, nil +} + +// AddUdFlash adds u to the "ud_flash" field. +func (m *MatchPlayerMutation) AddUdFlash(u uint) { + if m.addud_flash != nil { + *m.addud_flash += u + } else { + m.addud_flash = &u + } +} + +// AddedUdFlash returns the value that was added to the "ud_flash" field in this mutation. +func (m *MatchPlayerMutation) AddedUdFlash() (r uint, exists bool) { + v := m.addud_flash + if v == nil { + return + } + return *v, true +} + +// ClearUdFlash clears the value of the "ud_flash" field. +func (m *MatchPlayerMutation) ClearUdFlash() { + m.ud_flash = nil + m.addud_flash = nil + m.clearedFields[matchplayer.FieldUdFlash] = struct{}{} +} + +// UdFlashCleared returns if the "ud_flash" field was cleared in this mutation. +func (m *MatchPlayerMutation) UdFlashCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldUdFlash] + return ok +} + +// ResetUdFlash resets all changes to the "ud_flash" field. +func (m *MatchPlayerMutation) ResetUdFlash() { + m.ud_flash = nil + m.addud_flash = nil + delete(m.clearedFields, matchplayer.FieldUdFlash) +} + +// SetUdDecoy sets the "ud_decoy" field. +func (m *MatchPlayerMutation) SetUdDecoy(u uint) { + m.ud_decoy = &u + m.addud_decoy = nil +} + +// UdDecoy returns the value of the "ud_decoy" field in the mutation. +func (m *MatchPlayerMutation) UdDecoy() (r uint, exists bool) { + v := m.ud_decoy + if v == nil { + return + } + return *v, true +} + +// OldUdDecoy returns the old "ud_decoy" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldUdDecoy(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldUdDecoy is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldUdDecoy requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUdDecoy: %w", err) + } + return oldValue.UdDecoy, nil +} + +// AddUdDecoy adds u to the "ud_decoy" field. +func (m *MatchPlayerMutation) AddUdDecoy(u uint) { + if m.addud_decoy != nil { + *m.addud_decoy += u + } else { + m.addud_decoy = &u + } +} + +// AddedUdDecoy returns the value that was added to the "ud_decoy" field in this mutation. +func (m *MatchPlayerMutation) AddedUdDecoy() (r uint, exists bool) { + v := m.addud_decoy + if v == nil { + return + } + return *v, true +} + +// ClearUdDecoy clears the value of the "ud_decoy" field. +func (m *MatchPlayerMutation) ClearUdDecoy() { + m.ud_decoy = nil + m.addud_decoy = nil + m.clearedFields[matchplayer.FieldUdDecoy] = struct{}{} +} + +// UdDecoyCleared returns if the "ud_decoy" field was cleared in this mutation. +func (m *MatchPlayerMutation) UdDecoyCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldUdDecoy] + return ok +} + +// ResetUdDecoy resets all changes to the "ud_decoy" field. +func (m *MatchPlayerMutation) ResetUdDecoy() { + m.ud_decoy = nil + m.addud_decoy = nil + delete(m.clearedFields, matchplayer.FieldUdDecoy) +} + +// SetUdSmoke sets the "ud_smoke" field. +func (m *MatchPlayerMutation) SetUdSmoke(u uint) { + m.ud_smoke = &u + m.addud_smoke = nil +} + +// UdSmoke returns the value of the "ud_smoke" field in the mutation. +func (m *MatchPlayerMutation) UdSmoke() (r uint, exists bool) { + v := m.ud_smoke + if v == nil { + return + } + return *v, true +} + +// OldUdSmoke returns the old "ud_smoke" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldUdSmoke(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldUdSmoke is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldUdSmoke requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUdSmoke: %w", err) + } + return oldValue.UdSmoke, nil +} + +// AddUdSmoke adds u to the "ud_smoke" field. +func (m *MatchPlayerMutation) AddUdSmoke(u uint) { + if m.addud_smoke != nil { + *m.addud_smoke += u + } else { + m.addud_smoke = &u + } +} + +// AddedUdSmoke returns the value that was added to the "ud_smoke" field in this mutation. +func (m *MatchPlayerMutation) AddedUdSmoke() (r uint, exists bool) { + v := m.addud_smoke + if v == nil { + return + } + return *v, true +} + +// ClearUdSmoke clears the value of the "ud_smoke" field. +func (m *MatchPlayerMutation) ClearUdSmoke() { + m.ud_smoke = nil + m.addud_smoke = nil + m.clearedFields[matchplayer.FieldUdSmoke] = struct{}{} +} + +// UdSmokeCleared returns if the "ud_smoke" field was cleared in this mutation. +func (m *MatchPlayerMutation) UdSmokeCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldUdSmoke] + return ok +} + +// ResetUdSmoke resets all changes to the "ud_smoke" field. +func (m *MatchPlayerMutation) ResetUdSmoke() { + m.ud_smoke = nil + m.addud_smoke = nil + delete(m.clearedFields, matchplayer.FieldUdSmoke) +} + +// SetCrosshair sets the "crosshair" field. +func (m *MatchPlayerMutation) SetCrosshair(s string) { + m.crosshair = &s +} + +// Crosshair returns the value of the "crosshair" field in the mutation. +func (m *MatchPlayerMutation) Crosshair() (r string, exists bool) { + v := m.crosshair + if v == nil { + return + } + return *v, true +} + +// OldCrosshair returns the old "crosshair" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldCrosshair(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldCrosshair is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldCrosshair requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCrosshair: %w", err) + } + return oldValue.Crosshair, nil +} + +// ClearCrosshair clears the value of the "crosshair" field. +func (m *MatchPlayerMutation) ClearCrosshair() { + m.crosshair = nil + m.clearedFields[matchplayer.FieldCrosshair] = struct{}{} +} + +// CrosshairCleared returns if the "crosshair" field was cleared in this mutation. +func (m *MatchPlayerMutation) CrosshairCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldCrosshair] + return ok +} + +// ResetCrosshair resets all changes to the "crosshair" field. +func (m *MatchPlayerMutation) ResetCrosshair() { + m.crosshair = nil + delete(m.clearedFields, matchplayer.FieldCrosshair) +} + +// SetColor sets the "color" field. +func (m *MatchPlayerMutation) SetColor(value matchplayer.Color) { + m.color = &value +} + +// Color returns the value of the "color" field in the mutation. +func (m *MatchPlayerMutation) Color() (r matchplayer.Color, exists bool) { + v := m.color + if v == nil { + return + } + return *v, true +} + +// OldColor returns the old "color" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldColor(ctx context.Context) (v matchplayer.Color, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldColor is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldColor requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldColor: %w", err) + } + return oldValue.Color, nil +} + +// ClearColor clears the value of the "color" field. +func (m *MatchPlayerMutation) ClearColor() { + m.color = nil + m.clearedFields[matchplayer.FieldColor] = struct{}{} +} + +// ColorCleared returns if the "color" field was cleared in this mutation. +func (m *MatchPlayerMutation) ColorCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldColor] + return ok +} + +// ResetColor resets all changes to the "color" field. +func (m *MatchPlayerMutation) ResetColor() { + m.color = nil + delete(m.clearedFields, matchplayer.FieldColor) +} + +// SetKast sets the "kast" field. +func (m *MatchPlayerMutation) SetKast(i int) { + m.kast = &i + m.addkast = nil +} + +// Kast returns the value of the "kast" field in the mutation. +func (m *MatchPlayerMutation) Kast() (r int, exists bool) { + v := m.kast + if v == nil { + return + } + return *v, true +} + +// OldKast returns the old "kast" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldKast(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldKast is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldKast requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldKast: %w", err) + } + return oldValue.Kast, nil +} + +// AddKast adds i to the "kast" field. +func (m *MatchPlayerMutation) AddKast(i int) { + if m.addkast != nil { + *m.addkast += i + } else { + m.addkast = &i + } +} + +// AddedKast returns the value that was added to the "kast" field in this mutation. +func (m *MatchPlayerMutation) AddedKast() (r int, exists bool) { + v := m.addkast + if v == nil { + return + } + return *v, true +} + +// ClearKast clears the value of the "kast" field. +func (m *MatchPlayerMutation) ClearKast() { + m.kast = nil + m.addkast = nil + m.clearedFields[matchplayer.FieldKast] = struct{}{} +} + +// KastCleared returns if the "kast" field was cleared in this mutation. +func (m *MatchPlayerMutation) KastCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldKast] + return ok +} + +// ResetKast resets all changes to the "kast" field. +func (m *MatchPlayerMutation) ResetKast() { + m.kast = nil + m.addkast = nil + delete(m.clearedFields, matchplayer.FieldKast) +} + +// SetFlashDurationSelf sets the "flash_duration_self" field. +func (m *MatchPlayerMutation) SetFlashDurationSelf(f float32) { + m.flash_duration_self = &f + m.addflash_duration_self = nil +} + +// FlashDurationSelf returns the value of the "flash_duration_self" field in the mutation. +func (m *MatchPlayerMutation) FlashDurationSelf() (r float32, exists bool) { + v := m.flash_duration_self + if v == nil { + return + } + return *v, true +} + +// OldFlashDurationSelf returns the old "flash_duration_self" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldFlashDurationSelf(ctx context.Context) (v float32, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldFlashDurationSelf is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldFlashDurationSelf requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFlashDurationSelf: %w", err) + } + return oldValue.FlashDurationSelf, nil +} + +// AddFlashDurationSelf adds f to the "flash_duration_self" field. +func (m *MatchPlayerMutation) AddFlashDurationSelf(f float32) { + if m.addflash_duration_self != nil { + *m.addflash_duration_self += f + } else { + m.addflash_duration_self = &f + } +} + +// AddedFlashDurationSelf returns the value that was added to the "flash_duration_self" field in this mutation. +func (m *MatchPlayerMutation) AddedFlashDurationSelf() (r float32, exists bool) { + v := m.addflash_duration_self + if v == nil { + return + } + return *v, true +} + +// ClearFlashDurationSelf clears the value of the "flash_duration_self" field. +func (m *MatchPlayerMutation) ClearFlashDurationSelf() { + m.flash_duration_self = nil + m.addflash_duration_self = nil + m.clearedFields[matchplayer.FieldFlashDurationSelf] = struct{}{} +} + +// FlashDurationSelfCleared returns if the "flash_duration_self" field was cleared in this mutation. +func (m *MatchPlayerMutation) FlashDurationSelfCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldFlashDurationSelf] + return ok +} + +// ResetFlashDurationSelf resets all changes to the "flash_duration_self" field. +func (m *MatchPlayerMutation) ResetFlashDurationSelf() { + m.flash_duration_self = nil + m.addflash_duration_self = nil + delete(m.clearedFields, matchplayer.FieldFlashDurationSelf) +} + +// SetFlashDurationTeam sets the "flash_duration_team" field. +func (m *MatchPlayerMutation) SetFlashDurationTeam(f float32) { + m.flash_duration_team = &f + m.addflash_duration_team = nil +} + +// FlashDurationTeam returns the value of the "flash_duration_team" field in the mutation. +func (m *MatchPlayerMutation) FlashDurationTeam() (r float32, exists bool) { + v := m.flash_duration_team + if v == nil { + return + } + return *v, true +} + +// OldFlashDurationTeam returns the old "flash_duration_team" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldFlashDurationTeam(ctx context.Context) (v float32, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldFlashDurationTeam is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldFlashDurationTeam requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFlashDurationTeam: %w", err) + } + return oldValue.FlashDurationTeam, nil +} + +// AddFlashDurationTeam adds f to the "flash_duration_team" field. +func (m *MatchPlayerMutation) AddFlashDurationTeam(f float32) { + if m.addflash_duration_team != nil { + *m.addflash_duration_team += f + } else { + m.addflash_duration_team = &f + } +} + +// AddedFlashDurationTeam returns the value that was added to the "flash_duration_team" field in this mutation. +func (m *MatchPlayerMutation) AddedFlashDurationTeam() (r float32, exists bool) { + v := m.addflash_duration_team + if v == nil { + return + } + return *v, true +} + +// ClearFlashDurationTeam clears the value of the "flash_duration_team" field. +func (m *MatchPlayerMutation) ClearFlashDurationTeam() { + m.flash_duration_team = nil + m.addflash_duration_team = nil + m.clearedFields[matchplayer.FieldFlashDurationTeam] = struct{}{} +} + +// FlashDurationTeamCleared returns if the "flash_duration_team" field was cleared in this mutation. +func (m *MatchPlayerMutation) FlashDurationTeamCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldFlashDurationTeam] + return ok +} + +// ResetFlashDurationTeam resets all changes to the "flash_duration_team" field. +func (m *MatchPlayerMutation) ResetFlashDurationTeam() { + m.flash_duration_team = nil + m.addflash_duration_team = nil + delete(m.clearedFields, matchplayer.FieldFlashDurationTeam) +} + +// SetFlashDurationEnemy sets the "flash_duration_enemy" field. +func (m *MatchPlayerMutation) SetFlashDurationEnemy(f float32) { + m.flash_duration_enemy = &f + m.addflash_duration_enemy = nil +} + +// FlashDurationEnemy returns the value of the "flash_duration_enemy" field in the mutation. +func (m *MatchPlayerMutation) FlashDurationEnemy() (r float32, exists bool) { + v := m.flash_duration_enemy + if v == nil { + return + } + return *v, true +} + +// OldFlashDurationEnemy returns the old "flash_duration_enemy" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldFlashDurationEnemy(ctx context.Context) (v float32, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldFlashDurationEnemy is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldFlashDurationEnemy requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFlashDurationEnemy: %w", err) + } + return oldValue.FlashDurationEnemy, nil +} + +// AddFlashDurationEnemy adds f to the "flash_duration_enemy" field. +func (m *MatchPlayerMutation) AddFlashDurationEnemy(f float32) { + if m.addflash_duration_enemy != nil { + *m.addflash_duration_enemy += f + } else { + m.addflash_duration_enemy = &f + } +} + +// AddedFlashDurationEnemy returns the value that was added to the "flash_duration_enemy" field in this mutation. +func (m *MatchPlayerMutation) AddedFlashDurationEnemy() (r float32, exists bool) { + v := m.addflash_duration_enemy + if v == nil { + return + } + return *v, true +} + +// ClearFlashDurationEnemy clears the value of the "flash_duration_enemy" field. +func (m *MatchPlayerMutation) ClearFlashDurationEnemy() { + m.flash_duration_enemy = nil + m.addflash_duration_enemy = nil + m.clearedFields[matchplayer.FieldFlashDurationEnemy] = struct{}{} +} + +// FlashDurationEnemyCleared returns if the "flash_duration_enemy" field was cleared in this mutation. +func (m *MatchPlayerMutation) FlashDurationEnemyCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldFlashDurationEnemy] + return ok +} + +// ResetFlashDurationEnemy resets all changes to the "flash_duration_enemy" field. +func (m *MatchPlayerMutation) ResetFlashDurationEnemy() { + m.flash_duration_enemy = nil + m.addflash_duration_enemy = nil + delete(m.clearedFields, matchplayer.FieldFlashDurationEnemy) +} + +// SetFlashTotalSelf sets the "flash_total_self" field. +func (m *MatchPlayerMutation) SetFlashTotalSelf(u uint) { + m.flash_total_self = &u + m.addflash_total_self = nil +} + +// FlashTotalSelf returns the value of the "flash_total_self" field in the mutation. +func (m *MatchPlayerMutation) FlashTotalSelf() (r uint, exists bool) { + v := m.flash_total_self + if v == nil { + return + } + return *v, true +} + +// OldFlashTotalSelf returns the old "flash_total_self" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldFlashTotalSelf(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldFlashTotalSelf is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldFlashTotalSelf requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFlashTotalSelf: %w", err) + } + return oldValue.FlashTotalSelf, nil +} + +// AddFlashTotalSelf adds u to the "flash_total_self" field. +func (m *MatchPlayerMutation) AddFlashTotalSelf(u uint) { + if m.addflash_total_self != nil { + *m.addflash_total_self += u + } else { + m.addflash_total_self = &u + } +} + +// AddedFlashTotalSelf returns the value that was added to the "flash_total_self" field in this mutation. +func (m *MatchPlayerMutation) AddedFlashTotalSelf() (r uint, exists bool) { + v := m.addflash_total_self + if v == nil { + return + } + return *v, true +} + +// ClearFlashTotalSelf clears the value of the "flash_total_self" field. +func (m *MatchPlayerMutation) ClearFlashTotalSelf() { + m.flash_total_self = nil + m.addflash_total_self = nil + m.clearedFields[matchplayer.FieldFlashTotalSelf] = struct{}{} +} + +// FlashTotalSelfCleared returns if the "flash_total_self" field was cleared in this mutation. +func (m *MatchPlayerMutation) FlashTotalSelfCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldFlashTotalSelf] + return ok +} + +// ResetFlashTotalSelf resets all changes to the "flash_total_self" field. +func (m *MatchPlayerMutation) ResetFlashTotalSelf() { + m.flash_total_self = nil + m.addflash_total_self = nil + delete(m.clearedFields, matchplayer.FieldFlashTotalSelf) +} + +// SetFlashTotalTeam sets the "flash_total_team" field. +func (m *MatchPlayerMutation) SetFlashTotalTeam(u uint) { + m.flash_total_team = &u + m.addflash_total_team = nil +} + +// FlashTotalTeam returns the value of the "flash_total_team" field in the mutation. +func (m *MatchPlayerMutation) FlashTotalTeam() (r uint, exists bool) { + v := m.flash_total_team + if v == nil { + return + } + return *v, true +} + +// OldFlashTotalTeam returns the old "flash_total_team" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldFlashTotalTeam(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldFlashTotalTeam is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldFlashTotalTeam requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFlashTotalTeam: %w", err) + } + return oldValue.FlashTotalTeam, nil +} + +// AddFlashTotalTeam adds u to the "flash_total_team" field. +func (m *MatchPlayerMutation) AddFlashTotalTeam(u uint) { + if m.addflash_total_team != nil { + *m.addflash_total_team += u + } else { + m.addflash_total_team = &u + } +} + +// AddedFlashTotalTeam returns the value that was added to the "flash_total_team" field in this mutation. +func (m *MatchPlayerMutation) AddedFlashTotalTeam() (r uint, exists bool) { + v := m.addflash_total_team + if v == nil { + return + } + return *v, true +} + +// ClearFlashTotalTeam clears the value of the "flash_total_team" field. +func (m *MatchPlayerMutation) ClearFlashTotalTeam() { + m.flash_total_team = nil + m.addflash_total_team = nil + m.clearedFields[matchplayer.FieldFlashTotalTeam] = struct{}{} +} + +// FlashTotalTeamCleared returns if the "flash_total_team" field was cleared in this mutation. +func (m *MatchPlayerMutation) FlashTotalTeamCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldFlashTotalTeam] + return ok +} + +// ResetFlashTotalTeam resets all changes to the "flash_total_team" field. +func (m *MatchPlayerMutation) ResetFlashTotalTeam() { + m.flash_total_team = nil + m.addflash_total_team = nil + delete(m.clearedFields, matchplayer.FieldFlashTotalTeam) +} + +// SetFlashTotalEnemy sets the "flash_total_enemy" field. +func (m *MatchPlayerMutation) SetFlashTotalEnemy(u uint) { + m.flash_total_enemy = &u + m.addflash_total_enemy = nil +} + +// FlashTotalEnemy returns the value of the "flash_total_enemy" field in the mutation. +func (m *MatchPlayerMutation) FlashTotalEnemy() (r uint, exists bool) { + v := m.flash_total_enemy + if v == nil { + return + } + return *v, true +} + +// OldFlashTotalEnemy returns the old "flash_total_enemy" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldFlashTotalEnemy(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldFlashTotalEnemy is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldFlashTotalEnemy requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFlashTotalEnemy: %w", err) + } + return oldValue.FlashTotalEnemy, nil +} + +// AddFlashTotalEnemy adds u to the "flash_total_enemy" field. +func (m *MatchPlayerMutation) AddFlashTotalEnemy(u uint) { + if m.addflash_total_enemy != nil { + *m.addflash_total_enemy += u + } else { + m.addflash_total_enemy = &u + } +} + +// AddedFlashTotalEnemy returns the value that was added to the "flash_total_enemy" field in this mutation. +func (m *MatchPlayerMutation) AddedFlashTotalEnemy() (r uint, exists bool) { + v := m.addflash_total_enemy + if v == nil { + return + } + return *v, true +} + +// ClearFlashTotalEnemy clears the value of the "flash_total_enemy" field. +func (m *MatchPlayerMutation) ClearFlashTotalEnemy() { + m.flash_total_enemy = nil + m.addflash_total_enemy = nil + m.clearedFields[matchplayer.FieldFlashTotalEnemy] = struct{}{} +} + +// FlashTotalEnemyCleared returns if the "flash_total_enemy" field was cleared in this mutation. +func (m *MatchPlayerMutation) FlashTotalEnemyCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldFlashTotalEnemy] + return ok +} + +// ResetFlashTotalEnemy resets all changes to the "flash_total_enemy" field. +func (m *MatchPlayerMutation) ResetFlashTotalEnemy() { + m.flash_total_enemy = nil + m.addflash_total_enemy = nil + delete(m.clearedFields, matchplayer.FieldFlashTotalEnemy) +} + +// SetMatchStats sets the "match_stats" field. +func (m *MatchPlayerMutation) SetMatchStats(u uint64) { + m.matches = &u +} + +// MatchStats returns the value of the "match_stats" field in the mutation. +func (m *MatchPlayerMutation) MatchStats() (r uint64, exists bool) { + v := m.matches + if v == nil { + return + } + return *v, true +} + +// OldMatchStats returns the old "match_stats" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldMatchStats(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldMatchStats is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldMatchStats requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMatchStats: %w", err) + } + return oldValue.MatchStats, nil +} + +// ClearMatchStats clears the value of the "match_stats" field. +func (m *MatchPlayerMutation) ClearMatchStats() { + m.matches = nil + m.clearedFields[matchplayer.FieldMatchStats] = struct{}{} +} + +// MatchStatsCleared returns if the "match_stats" field was cleared in this mutation. +func (m *MatchPlayerMutation) MatchStatsCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldMatchStats] + return ok +} + +// ResetMatchStats resets all changes to the "match_stats" field. +func (m *MatchPlayerMutation) ResetMatchStats() { + m.matches = nil + delete(m.clearedFields, matchplayer.FieldMatchStats) +} + +// SetPlayerStats sets the "player_stats" field. +func (m *MatchPlayerMutation) SetPlayerStats(u uint64) { + m.players = &u +} + +// PlayerStats returns the value of the "player_stats" field in the mutation. +func (m *MatchPlayerMutation) PlayerStats() (r uint64, exists bool) { + v := m.players + if v == nil { + return + } + return *v, true +} + +// OldPlayerStats returns the old "player_stats" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldPlayerStats(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldPlayerStats is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldPlayerStats requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPlayerStats: %w", err) + } + return oldValue.PlayerStats, nil +} + +// ClearPlayerStats clears the value of the "player_stats" field. +func (m *MatchPlayerMutation) ClearPlayerStats() { + m.players = nil + m.clearedFields[matchplayer.FieldPlayerStats] = struct{}{} +} + +// PlayerStatsCleared returns if the "player_stats" field was cleared in this mutation. +func (m *MatchPlayerMutation) PlayerStatsCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldPlayerStats] + return ok +} + +// ResetPlayerStats resets all changes to the "player_stats" field. +func (m *MatchPlayerMutation) ResetPlayerStats() { + m.players = nil + delete(m.clearedFields, matchplayer.FieldPlayerStats) +} + +// SetFlashAssists sets the "flash_assists" field. +func (m *MatchPlayerMutation) SetFlashAssists(i int) { + m.flash_assists = &i + m.addflash_assists = nil +} + +// FlashAssists returns the value of the "flash_assists" field in the mutation. +func (m *MatchPlayerMutation) FlashAssists() (r int, exists bool) { + v := m.flash_assists + if v == nil { + return + } + return *v, true +} + +// OldFlashAssists returns the old "flash_assists" field's value of the MatchPlayer entity. +// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MatchPlayerMutation) OldFlashAssists(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldFlashAssists is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldFlashAssists requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFlashAssists: %w", err) + } + return oldValue.FlashAssists, nil +} + +// AddFlashAssists adds i to the "flash_assists" field. +func (m *MatchPlayerMutation) AddFlashAssists(i int) { + if m.addflash_assists != nil { + *m.addflash_assists += i + } else { + m.addflash_assists = &i + } +} + +// AddedFlashAssists returns the value that was added to the "flash_assists" field in this mutation. +func (m *MatchPlayerMutation) AddedFlashAssists() (r int, exists bool) { + v := m.addflash_assists + if v == nil { + return + } + return *v, true +} + +// ClearFlashAssists clears the value of the "flash_assists" field. +func (m *MatchPlayerMutation) ClearFlashAssists() { + m.flash_assists = nil + m.addflash_assists = nil + m.clearedFields[matchplayer.FieldFlashAssists] = struct{}{} +} + +// FlashAssistsCleared returns if the "flash_assists" field was cleared in this mutation. +func (m *MatchPlayerMutation) FlashAssistsCleared() bool { + _, ok := m.clearedFields[matchplayer.FieldFlashAssists] + return ok +} + +// ResetFlashAssists resets all changes to the "flash_assists" field. +func (m *MatchPlayerMutation) ResetFlashAssists() { + m.flash_assists = nil + m.addflash_assists = nil + delete(m.clearedFields, matchplayer.FieldFlashAssists) +} + +// SetMatchesID sets the "matches" edge to the Match entity by id. +func (m *MatchPlayerMutation) SetMatchesID(id uint64) { + m.matches = &id +} + +// ClearMatches clears the "matches" edge to the Match entity. +func (m *MatchPlayerMutation) ClearMatches() { + m.clearedmatches = true +} + +// MatchesCleared reports if the "matches" edge to the Match entity was cleared. +func (m *MatchPlayerMutation) MatchesCleared() bool { + return m.MatchStatsCleared() || m.clearedmatches +} + +// MatchesID returns the "matches" edge ID in the mutation. +func (m *MatchPlayerMutation) MatchesID() (id uint64, exists bool) { + if m.matches != nil { + return *m.matches, true + } + return +} + +// MatchesIDs returns the "matches" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// MatchesID instead. It exists only for internal usage by the builders. +func (m *MatchPlayerMutation) MatchesIDs() (ids []uint64) { + if id := m.matches; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetMatches resets all changes to the "matches" edge. +func (m *MatchPlayerMutation) ResetMatches() { + m.matches = nil + m.clearedmatches = false +} + +// SetPlayersID sets the "players" edge to the Player entity by id. +func (m *MatchPlayerMutation) SetPlayersID(id uint64) { + m.players = &id +} + +// ClearPlayers clears the "players" edge to the Player entity. +func (m *MatchPlayerMutation) ClearPlayers() { + m.clearedplayers = true +} + +// PlayersCleared reports if the "players" edge to the Player entity was cleared. +func (m *MatchPlayerMutation) PlayersCleared() bool { + return m.PlayerStatsCleared() || m.clearedplayers +} + +// PlayersID returns the "players" edge ID in the mutation. +func (m *MatchPlayerMutation) PlayersID() (id uint64, exists bool) { + if m.players != nil { + return *m.players, true + } + return +} + +// PlayersIDs returns the "players" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// PlayersID instead. It exists only for internal usage by the builders. +func (m *MatchPlayerMutation) PlayersIDs() (ids []uint64) { + if id := m.players; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetPlayers resets all changes to the "players" edge. +func (m *MatchPlayerMutation) ResetPlayers() { + m.players = nil + m.clearedplayers = false +} + +// AddWeaponStatIDs adds the "weapon_stats" edge to the Weapon entity by ids. +func (m *MatchPlayerMutation) AddWeaponStatIDs(ids ...int) { + if m.weapon_stats == nil { + m.weapon_stats = make(map[int]struct{}) + } + for i := range ids { + m.weapon_stats[ids[i]] = struct{}{} + } +} + +// ClearWeaponStats clears the "weapon_stats" edge to the Weapon entity. +func (m *MatchPlayerMutation) ClearWeaponStats() { + m.clearedweapon_stats = true +} + +// WeaponStatsCleared reports if the "weapon_stats" edge to the Weapon entity was cleared. +func (m *MatchPlayerMutation) WeaponStatsCleared() bool { + return m.clearedweapon_stats +} + +// RemoveWeaponStatIDs removes the "weapon_stats" edge to the Weapon entity by IDs. +func (m *MatchPlayerMutation) RemoveWeaponStatIDs(ids ...int) { + if m.removedweapon_stats == nil { + m.removedweapon_stats = make(map[int]struct{}) + } + for i := range ids { + delete(m.weapon_stats, ids[i]) + m.removedweapon_stats[ids[i]] = struct{}{} + } +} + +// RemovedWeaponStats returns the removed IDs of the "weapon_stats" edge to the Weapon entity. +func (m *MatchPlayerMutation) RemovedWeaponStatsIDs() (ids []int) { + for id := range m.removedweapon_stats { + ids = append(ids, id) + } + return +} + +// WeaponStatsIDs returns the "weapon_stats" edge IDs in the mutation. +func (m *MatchPlayerMutation) WeaponStatsIDs() (ids []int) { + for id := range m.weapon_stats { + ids = append(ids, id) + } + return +} + +// ResetWeaponStats resets all changes to the "weapon_stats" edge. +func (m *MatchPlayerMutation) ResetWeaponStats() { + m.weapon_stats = nil + m.clearedweapon_stats = false + m.removedweapon_stats = nil +} + +// AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by ids. +func (m *MatchPlayerMutation) AddRoundStatIDs(ids ...int) { + if m.round_stats == nil { + m.round_stats = make(map[int]struct{}) + } + for i := range ids { + m.round_stats[ids[i]] = struct{}{} + } +} + +// ClearRoundStats clears the "round_stats" edge to the RoundStats entity. +func (m *MatchPlayerMutation) ClearRoundStats() { + m.clearedround_stats = true +} + +// RoundStatsCleared reports if the "round_stats" edge to the RoundStats entity was cleared. +func (m *MatchPlayerMutation) RoundStatsCleared() bool { + return m.clearedround_stats +} + +// RemoveRoundStatIDs removes the "round_stats" edge to the RoundStats entity by IDs. +func (m *MatchPlayerMutation) RemoveRoundStatIDs(ids ...int) { + if m.removedround_stats == nil { + m.removedround_stats = make(map[int]struct{}) + } + for i := range ids { + delete(m.round_stats, ids[i]) + m.removedround_stats[ids[i]] = struct{}{} + } +} + +// RemovedRoundStats returns the removed IDs of the "round_stats" edge to the RoundStats entity. +func (m *MatchPlayerMutation) RemovedRoundStatsIDs() (ids []int) { + for id := range m.removedround_stats { + ids = append(ids, id) + } + return +} + +// RoundStatsIDs returns the "round_stats" edge IDs in the mutation. +func (m *MatchPlayerMutation) RoundStatsIDs() (ids []int) { + for id := range m.round_stats { + ids = append(ids, id) + } + return +} + +// ResetRoundStats resets all changes to the "round_stats" edge. +func (m *MatchPlayerMutation) ResetRoundStats() { + m.round_stats = nil + m.clearedround_stats = false + m.removedround_stats = nil +} + +// AddSprayIDs adds the "spray" edge to the Spray entity by ids. +func (m *MatchPlayerMutation) AddSprayIDs(ids ...int) { + if m.spray == nil { + m.spray = make(map[int]struct{}) + } + for i := range ids { + m.spray[ids[i]] = struct{}{} + } +} + +// ClearSpray clears the "spray" edge to the Spray entity. +func (m *MatchPlayerMutation) ClearSpray() { + m.clearedspray = true +} + +// SprayCleared reports if the "spray" edge to the Spray entity was cleared. +func (m *MatchPlayerMutation) SprayCleared() bool { + return m.clearedspray +} + +// RemoveSprayIDs removes the "spray" edge to the Spray entity by IDs. +func (m *MatchPlayerMutation) RemoveSprayIDs(ids ...int) { + if m.removedspray == nil { + m.removedspray = make(map[int]struct{}) + } + for i := range ids { + delete(m.spray, ids[i]) + m.removedspray[ids[i]] = struct{}{} + } +} + +// RemovedSpray returns the removed IDs of the "spray" edge to the Spray entity. +func (m *MatchPlayerMutation) RemovedSprayIDs() (ids []int) { + for id := range m.removedspray { + ids = append(ids, id) + } + return +} + +// SprayIDs returns the "spray" edge IDs in the mutation. +func (m *MatchPlayerMutation) SprayIDs() (ids []int) { + for id := range m.spray { + ids = append(ids, id) + } + return +} + +// ResetSpray resets all changes to the "spray" edge. +func (m *MatchPlayerMutation) ResetSpray() { + m.spray = nil + m.clearedspray = false + m.removedspray = nil +} + +// Where appends a list predicates to the MatchPlayerMutation builder. +func (m *MatchPlayerMutation) Where(ps ...predicate.MatchPlayer) { + m.predicates = append(m.predicates, ps...) +} + +// Op returns the operation name. +func (m *MatchPlayerMutation) Op() Op { + return m.op +} + +// Type returns the node type of this mutation (MatchPlayer). +func (m *MatchPlayerMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *MatchPlayerMutation) Fields() []string { + fields := make([]string, 0, 32) + if m.team_id != nil { + fields = append(fields, matchplayer.FieldTeamID) + } + if m.kills != nil { + fields = append(fields, matchplayer.FieldKills) + } + if m.deaths != nil { + fields = append(fields, matchplayer.FieldDeaths) + } + if m.assists != nil { + fields = append(fields, matchplayer.FieldAssists) + } + if m.headshot != nil { + fields = append(fields, matchplayer.FieldHeadshot) + } + if m.mvp != nil { + fields = append(fields, matchplayer.FieldMvp) + } + if m.score != nil { + fields = append(fields, matchplayer.FieldScore) + } + if m.rank_new != nil { + fields = append(fields, matchplayer.FieldRankNew) + } + if m.rank_old != nil { + fields = append(fields, matchplayer.FieldRankOld) + } + if m.mk_2 != nil { + fields = append(fields, matchplayer.FieldMk2) + } + if m.mk_3 != nil { + fields = append(fields, matchplayer.FieldMk3) + } + if m.mk_4 != nil { + fields = append(fields, matchplayer.FieldMk4) + } + if m.mk_5 != nil { + fields = append(fields, matchplayer.FieldMk5) + } + if m.dmg_enemy != nil { + fields = append(fields, matchplayer.FieldDmgEnemy) + } + if m.dmg_team != nil { + fields = append(fields, matchplayer.FieldDmgTeam) + } + if m.ud_he != nil { + fields = append(fields, matchplayer.FieldUdHe) + } + if m.ud_flames != nil { + fields = append(fields, matchplayer.FieldUdFlames) + } + if m.ud_flash != nil { + fields = append(fields, matchplayer.FieldUdFlash) + } + if m.ud_decoy != nil { + fields = append(fields, matchplayer.FieldUdDecoy) + } + if m.ud_smoke != nil { + fields = append(fields, matchplayer.FieldUdSmoke) + } + if m.crosshair != nil { + fields = append(fields, matchplayer.FieldCrosshair) + } + if m.color != nil { + fields = append(fields, matchplayer.FieldColor) + } + if m.kast != nil { + fields = append(fields, matchplayer.FieldKast) + } + if m.flash_duration_self != nil { + fields = append(fields, matchplayer.FieldFlashDurationSelf) + } + if m.flash_duration_team != nil { + fields = append(fields, matchplayer.FieldFlashDurationTeam) + } + if m.flash_duration_enemy != nil { + fields = append(fields, matchplayer.FieldFlashDurationEnemy) + } + if m.flash_total_self != nil { + fields = append(fields, matchplayer.FieldFlashTotalSelf) + } + if m.flash_total_team != nil { + fields = append(fields, matchplayer.FieldFlashTotalTeam) + } + if m.flash_total_enemy != nil { + fields = append(fields, matchplayer.FieldFlashTotalEnemy) + } + if m.matches != nil { + fields = append(fields, matchplayer.FieldMatchStats) + } + if m.players != nil { + fields = append(fields, matchplayer.FieldPlayerStats) + } + if m.flash_assists != nil { + fields = append(fields, matchplayer.FieldFlashAssists) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *MatchPlayerMutation) Field(name string) (ent.Value, bool) { + switch name { + case matchplayer.FieldTeamID: + return m.TeamID() + case matchplayer.FieldKills: + return m.Kills() + case matchplayer.FieldDeaths: + return m.Deaths() + case matchplayer.FieldAssists: + return m.Assists() + case matchplayer.FieldHeadshot: + return m.Headshot() + case matchplayer.FieldMvp: + return m.Mvp() + case matchplayer.FieldScore: + return m.Score() + case matchplayer.FieldRankNew: + return m.RankNew() + case matchplayer.FieldRankOld: + return m.RankOld() + case matchplayer.FieldMk2: + return m.Mk2() + case matchplayer.FieldMk3: + return m.Mk3() + case matchplayer.FieldMk4: + return m.Mk4() + case matchplayer.FieldMk5: + return m.Mk5() + case matchplayer.FieldDmgEnemy: + return m.DmgEnemy() + case matchplayer.FieldDmgTeam: + return m.DmgTeam() + case matchplayer.FieldUdHe: + return m.UdHe() + case matchplayer.FieldUdFlames: + return m.UdFlames() + case matchplayer.FieldUdFlash: + return m.UdFlash() + case matchplayer.FieldUdDecoy: + return m.UdDecoy() + case matchplayer.FieldUdSmoke: + return m.UdSmoke() + case matchplayer.FieldCrosshair: + return m.Crosshair() + case matchplayer.FieldColor: + return m.Color() + case matchplayer.FieldKast: + return m.Kast() + case matchplayer.FieldFlashDurationSelf: + return m.FlashDurationSelf() + case matchplayer.FieldFlashDurationTeam: + return m.FlashDurationTeam() + case matchplayer.FieldFlashDurationEnemy: + return m.FlashDurationEnemy() + case matchplayer.FieldFlashTotalSelf: + return m.FlashTotalSelf() + case matchplayer.FieldFlashTotalTeam: + return m.FlashTotalTeam() + case matchplayer.FieldFlashTotalEnemy: + return m.FlashTotalEnemy() + case matchplayer.FieldMatchStats: + return m.MatchStats() + case matchplayer.FieldPlayerStats: + return m.PlayerStats() + case matchplayer.FieldFlashAssists: + return m.FlashAssists() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *MatchPlayerMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case matchplayer.FieldTeamID: + return m.OldTeamID(ctx) + case matchplayer.FieldKills: + return m.OldKills(ctx) + case matchplayer.FieldDeaths: + return m.OldDeaths(ctx) + case matchplayer.FieldAssists: + return m.OldAssists(ctx) + case matchplayer.FieldHeadshot: + return m.OldHeadshot(ctx) + case matchplayer.FieldMvp: + return m.OldMvp(ctx) + case matchplayer.FieldScore: + return m.OldScore(ctx) + case matchplayer.FieldRankNew: + return m.OldRankNew(ctx) + case matchplayer.FieldRankOld: + return m.OldRankOld(ctx) + case matchplayer.FieldMk2: + return m.OldMk2(ctx) + case matchplayer.FieldMk3: + return m.OldMk3(ctx) + case matchplayer.FieldMk4: + return m.OldMk4(ctx) + case matchplayer.FieldMk5: + return m.OldMk5(ctx) + case matchplayer.FieldDmgEnemy: + return m.OldDmgEnemy(ctx) + case matchplayer.FieldDmgTeam: + return m.OldDmgTeam(ctx) + case matchplayer.FieldUdHe: + return m.OldUdHe(ctx) + case matchplayer.FieldUdFlames: + return m.OldUdFlames(ctx) + case matchplayer.FieldUdFlash: + return m.OldUdFlash(ctx) + case matchplayer.FieldUdDecoy: + return m.OldUdDecoy(ctx) + case matchplayer.FieldUdSmoke: + return m.OldUdSmoke(ctx) + case matchplayer.FieldCrosshair: + return m.OldCrosshair(ctx) + case matchplayer.FieldColor: + return m.OldColor(ctx) + case matchplayer.FieldKast: + return m.OldKast(ctx) + case matchplayer.FieldFlashDurationSelf: + return m.OldFlashDurationSelf(ctx) + case matchplayer.FieldFlashDurationTeam: + return m.OldFlashDurationTeam(ctx) + case matchplayer.FieldFlashDurationEnemy: + return m.OldFlashDurationEnemy(ctx) + case matchplayer.FieldFlashTotalSelf: + return m.OldFlashTotalSelf(ctx) + case matchplayer.FieldFlashTotalTeam: + return m.OldFlashTotalTeam(ctx) + case matchplayer.FieldFlashTotalEnemy: + return m.OldFlashTotalEnemy(ctx) + case matchplayer.FieldMatchStats: + return m.OldMatchStats(ctx) + case matchplayer.FieldPlayerStats: + return m.OldPlayerStats(ctx) + case matchplayer.FieldFlashAssists: + return m.OldFlashAssists(ctx) + } + return nil, fmt.Errorf("unknown MatchPlayer field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *MatchPlayerMutation) SetField(name string, value ent.Value) error { + switch name { + case matchplayer.FieldTeamID: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTeamID(v) + return nil + case matchplayer.FieldKills: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetKills(v) + return nil + case matchplayer.FieldDeaths: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeaths(v) + return nil + case matchplayer.FieldAssists: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAssists(v) + return nil + case matchplayer.FieldHeadshot: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHeadshot(v) + return nil + case matchplayer.FieldMvp: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMvp(v) + return nil + case matchplayer.FieldScore: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetScore(v) + return nil + case matchplayer.FieldRankNew: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRankNew(v) + return nil + case matchplayer.FieldRankOld: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRankOld(v) + return nil + case matchplayer.FieldMk2: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMk2(v) + return nil + case matchplayer.FieldMk3: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMk3(v) + return nil + case matchplayer.FieldMk4: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMk4(v) + return nil + case matchplayer.FieldMk5: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMk5(v) + return nil + case matchplayer.FieldDmgEnemy: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDmgEnemy(v) + return nil + case matchplayer.FieldDmgTeam: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDmgTeam(v) + return nil + case matchplayer.FieldUdHe: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUdHe(v) + return nil + case matchplayer.FieldUdFlames: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUdFlames(v) + return nil + case matchplayer.FieldUdFlash: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUdFlash(v) + return nil + case matchplayer.FieldUdDecoy: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUdDecoy(v) + return nil + case matchplayer.FieldUdSmoke: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUdSmoke(v) + return nil + case matchplayer.FieldCrosshair: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCrosshair(v) + return nil + case matchplayer.FieldColor: + v, ok := value.(matchplayer.Color) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetColor(v) + return nil + case matchplayer.FieldKast: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetKast(v) + return nil + case matchplayer.FieldFlashDurationSelf: + v, ok := value.(float32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFlashDurationSelf(v) + return nil + case matchplayer.FieldFlashDurationTeam: + v, ok := value.(float32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFlashDurationTeam(v) + return nil + case matchplayer.FieldFlashDurationEnemy: + v, ok := value.(float32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFlashDurationEnemy(v) + return nil + case matchplayer.FieldFlashTotalSelf: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFlashTotalSelf(v) + return nil + case matchplayer.FieldFlashTotalTeam: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFlashTotalTeam(v) + return nil + case matchplayer.FieldFlashTotalEnemy: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFlashTotalEnemy(v) + return nil + case matchplayer.FieldMatchStats: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMatchStats(v) + return nil + case matchplayer.FieldPlayerStats: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPlayerStats(v) + return nil + case matchplayer.FieldFlashAssists: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFlashAssists(v) + return nil + } + return fmt.Errorf("unknown MatchPlayer field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *MatchPlayerMutation) AddedFields() []string { + var fields []string + if m.addteam_id != nil { + fields = append(fields, matchplayer.FieldTeamID) + } + if m.addkills != nil { + fields = append(fields, matchplayer.FieldKills) + } + if m.adddeaths != nil { + fields = append(fields, matchplayer.FieldDeaths) + } + if m.addassists != nil { + fields = append(fields, matchplayer.FieldAssists) + } + if m.addheadshot != nil { + fields = append(fields, matchplayer.FieldHeadshot) + } + if m.addmvp != nil { + fields = append(fields, matchplayer.FieldMvp) + } + if m.addscore != nil { + fields = append(fields, matchplayer.FieldScore) + } + if m.addrank_new != nil { + fields = append(fields, matchplayer.FieldRankNew) + } + if m.addrank_old != nil { + fields = append(fields, matchplayer.FieldRankOld) + } + if m.addmk_2 != nil { + fields = append(fields, matchplayer.FieldMk2) + } + if m.addmk_3 != nil { + fields = append(fields, matchplayer.FieldMk3) + } + if m.addmk_4 != nil { + fields = append(fields, matchplayer.FieldMk4) + } + if m.addmk_5 != nil { + fields = append(fields, matchplayer.FieldMk5) + } + if m.adddmg_enemy != nil { + fields = append(fields, matchplayer.FieldDmgEnemy) + } + if m.adddmg_team != nil { + fields = append(fields, matchplayer.FieldDmgTeam) + } + if m.addud_he != nil { + fields = append(fields, matchplayer.FieldUdHe) + } + if m.addud_flames != nil { + fields = append(fields, matchplayer.FieldUdFlames) + } + if m.addud_flash != nil { + fields = append(fields, matchplayer.FieldUdFlash) + } + if m.addud_decoy != nil { + fields = append(fields, matchplayer.FieldUdDecoy) + } + if m.addud_smoke != nil { + fields = append(fields, matchplayer.FieldUdSmoke) + } + if m.addkast != nil { + fields = append(fields, matchplayer.FieldKast) + } + if m.addflash_duration_self != nil { + fields = append(fields, matchplayer.FieldFlashDurationSelf) + } + if m.addflash_duration_team != nil { + fields = append(fields, matchplayer.FieldFlashDurationTeam) + } + if m.addflash_duration_enemy != nil { + fields = append(fields, matchplayer.FieldFlashDurationEnemy) + } + if m.addflash_total_self != nil { + fields = append(fields, matchplayer.FieldFlashTotalSelf) + } + if m.addflash_total_team != nil { + fields = append(fields, matchplayer.FieldFlashTotalTeam) + } + if m.addflash_total_enemy != nil { + fields = append(fields, matchplayer.FieldFlashTotalEnemy) + } + if m.addflash_assists != nil { + fields = append(fields, matchplayer.FieldFlashAssists) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *MatchPlayerMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case matchplayer.FieldTeamID: + return m.AddedTeamID() + case matchplayer.FieldKills: + return m.AddedKills() + case matchplayer.FieldDeaths: + return m.AddedDeaths() + case matchplayer.FieldAssists: + return m.AddedAssists() + case matchplayer.FieldHeadshot: + return m.AddedHeadshot() + case matchplayer.FieldMvp: + return m.AddedMvp() + case matchplayer.FieldScore: + return m.AddedScore() + case matchplayer.FieldRankNew: + return m.AddedRankNew() + case matchplayer.FieldRankOld: + return m.AddedRankOld() + case matchplayer.FieldMk2: + return m.AddedMk2() + case matchplayer.FieldMk3: + return m.AddedMk3() + case matchplayer.FieldMk4: + return m.AddedMk4() + case matchplayer.FieldMk5: + return m.AddedMk5() + case matchplayer.FieldDmgEnemy: + return m.AddedDmgEnemy() + case matchplayer.FieldDmgTeam: + return m.AddedDmgTeam() + case matchplayer.FieldUdHe: + return m.AddedUdHe() + case matchplayer.FieldUdFlames: + return m.AddedUdFlames() + case matchplayer.FieldUdFlash: + return m.AddedUdFlash() + case matchplayer.FieldUdDecoy: + return m.AddedUdDecoy() + case matchplayer.FieldUdSmoke: + return m.AddedUdSmoke() + case matchplayer.FieldKast: + return m.AddedKast() + case matchplayer.FieldFlashDurationSelf: + return m.AddedFlashDurationSelf() + case matchplayer.FieldFlashDurationTeam: + return m.AddedFlashDurationTeam() + case matchplayer.FieldFlashDurationEnemy: + return m.AddedFlashDurationEnemy() + case matchplayer.FieldFlashTotalSelf: + return m.AddedFlashTotalSelf() + case matchplayer.FieldFlashTotalTeam: + return m.AddedFlashTotalTeam() + case matchplayer.FieldFlashTotalEnemy: + return m.AddedFlashTotalEnemy() + case matchplayer.FieldFlashAssists: + return m.AddedFlashAssists() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *MatchPlayerMutation) AddField(name string, value ent.Value) error { + switch name { + case matchplayer.FieldTeamID: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTeamID(v) + return nil + case matchplayer.FieldKills: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddKills(v) + return nil + case matchplayer.FieldDeaths: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDeaths(v) + return nil + case matchplayer.FieldAssists: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddAssists(v) + return nil + case matchplayer.FieldHeadshot: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddHeadshot(v) + return nil + case matchplayer.FieldMvp: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddMvp(v) + return nil + case matchplayer.FieldScore: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddScore(v) + return nil + case matchplayer.FieldRankNew: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddRankNew(v) + return nil + case matchplayer.FieldRankOld: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddRankOld(v) + return nil + case matchplayer.FieldMk2: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddMk2(v) + return nil + case matchplayer.FieldMk3: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddMk3(v) + return nil + case matchplayer.FieldMk4: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddMk4(v) + return nil + case matchplayer.FieldMk5: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddMk5(v) + return nil + case matchplayer.FieldDmgEnemy: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDmgEnemy(v) + return nil + case matchplayer.FieldDmgTeam: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDmgTeam(v) + return nil + case matchplayer.FieldUdHe: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUdHe(v) + return nil + case matchplayer.FieldUdFlames: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUdFlames(v) + return nil + case matchplayer.FieldUdFlash: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUdFlash(v) + return nil + case matchplayer.FieldUdDecoy: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUdDecoy(v) + return nil + case matchplayer.FieldUdSmoke: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUdSmoke(v) + return nil + case matchplayer.FieldKast: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddKast(v) + return nil + case matchplayer.FieldFlashDurationSelf: + v, ok := value.(float32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddFlashDurationSelf(v) + return nil + case matchplayer.FieldFlashDurationTeam: + v, ok := value.(float32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddFlashDurationTeam(v) + return nil + case matchplayer.FieldFlashDurationEnemy: + v, ok := value.(float32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddFlashDurationEnemy(v) + return nil + case matchplayer.FieldFlashTotalSelf: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddFlashTotalSelf(v) + return nil + case matchplayer.FieldFlashTotalTeam: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddFlashTotalTeam(v) + return nil + case matchplayer.FieldFlashTotalEnemy: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddFlashTotalEnemy(v) + return nil + case matchplayer.FieldFlashAssists: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddFlashAssists(v) + return nil + } + return fmt.Errorf("unknown MatchPlayer numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *MatchPlayerMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(matchplayer.FieldRankNew) { + fields = append(fields, matchplayer.FieldRankNew) + } + if m.FieldCleared(matchplayer.FieldRankOld) { + fields = append(fields, matchplayer.FieldRankOld) + } + if m.FieldCleared(matchplayer.FieldMk2) { + fields = append(fields, matchplayer.FieldMk2) + } + if m.FieldCleared(matchplayer.FieldMk3) { + fields = append(fields, matchplayer.FieldMk3) + } + if m.FieldCleared(matchplayer.FieldMk4) { + fields = append(fields, matchplayer.FieldMk4) + } + if m.FieldCleared(matchplayer.FieldMk5) { + fields = append(fields, matchplayer.FieldMk5) + } + if m.FieldCleared(matchplayer.FieldDmgEnemy) { + fields = append(fields, matchplayer.FieldDmgEnemy) + } + if m.FieldCleared(matchplayer.FieldDmgTeam) { + fields = append(fields, matchplayer.FieldDmgTeam) + } + if m.FieldCleared(matchplayer.FieldUdHe) { + fields = append(fields, matchplayer.FieldUdHe) + } + if m.FieldCleared(matchplayer.FieldUdFlames) { + fields = append(fields, matchplayer.FieldUdFlames) + } + if m.FieldCleared(matchplayer.FieldUdFlash) { + fields = append(fields, matchplayer.FieldUdFlash) + } + if m.FieldCleared(matchplayer.FieldUdDecoy) { + fields = append(fields, matchplayer.FieldUdDecoy) + } + if m.FieldCleared(matchplayer.FieldUdSmoke) { + fields = append(fields, matchplayer.FieldUdSmoke) + } + if m.FieldCleared(matchplayer.FieldCrosshair) { + fields = append(fields, matchplayer.FieldCrosshair) + } + if m.FieldCleared(matchplayer.FieldColor) { + fields = append(fields, matchplayer.FieldColor) + } + if m.FieldCleared(matchplayer.FieldKast) { + fields = append(fields, matchplayer.FieldKast) + } + if m.FieldCleared(matchplayer.FieldFlashDurationSelf) { + fields = append(fields, matchplayer.FieldFlashDurationSelf) + } + if m.FieldCleared(matchplayer.FieldFlashDurationTeam) { + fields = append(fields, matchplayer.FieldFlashDurationTeam) + } + if m.FieldCleared(matchplayer.FieldFlashDurationEnemy) { + fields = append(fields, matchplayer.FieldFlashDurationEnemy) + } + if m.FieldCleared(matchplayer.FieldFlashTotalSelf) { + fields = append(fields, matchplayer.FieldFlashTotalSelf) + } + if m.FieldCleared(matchplayer.FieldFlashTotalTeam) { + fields = append(fields, matchplayer.FieldFlashTotalTeam) + } + if m.FieldCleared(matchplayer.FieldFlashTotalEnemy) { + fields = append(fields, matchplayer.FieldFlashTotalEnemy) + } + if m.FieldCleared(matchplayer.FieldMatchStats) { + fields = append(fields, matchplayer.FieldMatchStats) + } + if m.FieldCleared(matchplayer.FieldPlayerStats) { + fields = append(fields, matchplayer.FieldPlayerStats) + } + if m.FieldCleared(matchplayer.FieldFlashAssists) { + fields = append(fields, matchplayer.FieldFlashAssists) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *MatchPlayerMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *MatchPlayerMutation) ClearField(name string) error { + switch name { + case matchplayer.FieldRankNew: + m.ClearRankNew() + return nil + case matchplayer.FieldRankOld: + m.ClearRankOld() + return nil + case matchplayer.FieldMk2: + m.ClearMk2() + return nil + case matchplayer.FieldMk3: + m.ClearMk3() + return nil + case matchplayer.FieldMk4: + m.ClearMk4() + return nil + case matchplayer.FieldMk5: + m.ClearMk5() + return nil + case matchplayer.FieldDmgEnemy: + m.ClearDmgEnemy() + return nil + case matchplayer.FieldDmgTeam: + m.ClearDmgTeam() + return nil + case matchplayer.FieldUdHe: + m.ClearUdHe() + return nil + case matchplayer.FieldUdFlames: + m.ClearUdFlames() + return nil + case matchplayer.FieldUdFlash: + m.ClearUdFlash() + return nil + case matchplayer.FieldUdDecoy: + m.ClearUdDecoy() + return nil + case matchplayer.FieldUdSmoke: + m.ClearUdSmoke() + return nil + case matchplayer.FieldCrosshair: + m.ClearCrosshair() + return nil + case matchplayer.FieldColor: + m.ClearColor() + return nil + case matchplayer.FieldKast: + m.ClearKast() + return nil + case matchplayer.FieldFlashDurationSelf: + m.ClearFlashDurationSelf() + return nil + case matchplayer.FieldFlashDurationTeam: + m.ClearFlashDurationTeam() + return nil + case matchplayer.FieldFlashDurationEnemy: + m.ClearFlashDurationEnemy() + return nil + case matchplayer.FieldFlashTotalSelf: + m.ClearFlashTotalSelf() + return nil + case matchplayer.FieldFlashTotalTeam: + m.ClearFlashTotalTeam() + return nil + case matchplayer.FieldFlashTotalEnemy: + m.ClearFlashTotalEnemy() + return nil + case matchplayer.FieldMatchStats: + m.ClearMatchStats() + return nil + case matchplayer.FieldPlayerStats: + m.ClearPlayerStats() + return nil + case matchplayer.FieldFlashAssists: + m.ClearFlashAssists() + return nil + } + return fmt.Errorf("unknown MatchPlayer nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *MatchPlayerMutation) ResetField(name string) error { + switch name { + case matchplayer.FieldTeamID: + m.ResetTeamID() + return nil + case matchplayer.FieldKills: + m.ResetKills() + return nil + case matchplayer.FieldDeaths: + m.ResetDeaths() + return nil + case matchplayer.FieldAssists: + m.ResetAssists() + return nil + case matchplayer.FieldHeadshot: + m.ResetHeadshot() + return nil + case matchplayer.FieldMvp: + m.ResetMvp() + return nil + case matchplayer.FieldScore: + m.ResetScore() + return nil + case matchplayer.FieldRankNew: + m.ResetRankNew() + return nil + case matchplayer.FieldRankOld: + m.ResetRankOld() + return nil + case matchplayer.FieldMk2: + m.ResetMk2() + return nil + case matchplayer.FieldMk3: + m.ResetMk3() + return nil + case matchplayer.FieldMk4: + m.ResetMk4() + return nil + case matchplayer.FieldMk5: + m.ResetMk5() + return nil + case matchplayer.FieldDmgEnemy: + m.ResetDmgEnemy() + return nil + case matchplayer.FieldDmgTeam: + m.ResetDmgTeam() + return nil + case matchplayer.FieldUdHe: + m.ResetUdHe() + return nil + case matchplayer.FieldUdFlames: + m.ResetUdFlames() + return nil + case matchplayer.FieldUdFlash: + m.ResetUdFlash() + return nil + case matchplayer.FieldUdDecoy: + m.ResetUdDecoy() + return nil + case matchplayer.FieldUdSmoke: + m.ResetUdSmoke() + return nil + case matchplayer.FieldCrosshair: + m.ResetCrosshair() + return nil + case matchplayer.FieldColor: + m.ResetColor() + return nil + case matchplayer.FieldKast: + m.ResetKast() + return nil + case matchplayer.FieldFlashDurationSelf: + m.ResetFlashDurationSelf() + return nil + case matchplayer.FieldFlashDurationTeam: + m.ResetFlashDurationTeam() + return nil + case matchplayer.FieldFlashDurationEnemy: + m.ResetFlashDurationEnemy() + return nil + case matchplayer.FieldFlashTotalSelf: + m.ResetFlashTotalSelf() + return nil + case matchplayer.FieldFlashTotalTeam: + m.ResetFlashTotalTeam() + return nil + case matchplayer.FieldFlashTotalEnemy: + m.ResetFlashTotalEnemy() + return nil + case matchplayer.FieldMatchStats: + m.ResetMatchStats() + return nil + case matchplayer.FieldPlayerStats: + m.ResetPlayerStats() + return nil + case matchplayer.FieldFlashAssists: + m.ResetFlashAssists() + return nil + } + return fmt.Errorf("unknown MatchPlayer field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *MatchPlayerMutation) AddedEdges() []string { + edges := make([]string, 0, 5) + if m.matches != nil { + edges = append(edges, matchplayer.EdgeMatches) + } + if m.players != nil { + edges = append(edges, matchplayer.EdgePlayers) + } + if m.weapon_stats != nil { + edges = append(edges, matchplayer.EdgeWeaponStats) + } + if m.round_stats != nil { + edges = append(edges, matchplayer.EdgeRoundStats) + } + if m.spray != nil { + edges = append(edges, matchplayer.EdgeSpray) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *MatchPlayerMutation) AddedIDs(name string) []ent.Value { + switch name { + case matchplayer.EdgeMatches: + if id := m.matches; id != nil { + return []ent.Value{*id} + } + case matchplayer.EdgePlayers: + if id := m.players; id != nil { + return []ent.Value{*id} + } + case matchplayer.EdgeWeaponStats: + ids := make([]ent.Value, 0, len(m.weapon_stats)) + for id := range m.weapon_stats { + ids = append(ids, id) + } + return ids + case matchplayer.EdgeRoundStats: + ids := make([]ent.Value, 0, len(m.round_stats)) + for id := range m.round_stats { + ids = append(ids, id) + } + return ids + case matchplayer.EdgeSpray: + ids := make([]ent.Value, 0, len(m.spray)) + for id := range m.spray { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *MatchPlayerMutation) RemovedEdges() []string { + edges := make([]string, 0, 5) + if m.removedweapon_stats != nil { + edges = append(edges, matchplayer.EdgeWeaponStats) + } + if m.removedround_stats != nil { + edges = append(edges, matchplayer.EdgeRoundStats) + } + if m.removedspray != nil { + edges = append(edges, matchplayer.EdgeSpray) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *MatchPlayerMutation) RemovedIDs(name string) []ent.Value { + switch name { + case matchplayer.EdgeWeaponStats: + ids := make([]ent.Value, 0, len(m.removedweapon_stats)) + for id := range m.removedweapon_stats { + ids = append(ids, id) + } + return ids + case matchplayer.EdgeRoundStats: + ids := make([]ent.Value, 0, len(m.removedround_stats)) + for id := range m.removedround_stats { + ids = append(ids, id) + } + return ids + case matchplayer.EdgeSpray: + ids := make([]ent.Value, 0, len(m.removedspray)) + for id := range m.removedspray { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *MatchPlayerMutation) ClearedEdges() []string { + edges := make([]string, 0, 5) + if m.clearedmatches { + edges = append(edges, matchplayer.EdgeMatches) + } + if m.clearedplayers { + edges = append(edges, matchplayer.EdgePlayers) + } + if m.clearedweapon_stats { + edges = append(edges, matchplayer.EdgeWeaponStats) + } + if m.clearedround_stats { + edges = append(edges, matchplayer.EdgeRoundStats) + } + if m.clearedspray { + edges = append(edges, matchplayer.EdgeSpray) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *MatchPlayerMutation) EdgeCleared(name string) bool { + switch name { + case matchplayer.EdgeMatches: + return m.clearedmatches + case matchplayer.EdgePlayers: + return m.clearedplayers + case matchplayer.EdgeWeaponStats: + return m.clearedweapon_stats + case matchplayer.EdgeRoundStats: + return m.clearedround_stats + case matchplayer.EdgeSpray: + return m.clearedspray + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *MatchPlayerMutation) ClearEdge(name string) error { + switch name { + case matchplayer.EdgeMatches: + m.ClearMatches() + return nil + case matchplayer.EdgePlayers: + m.ClearPlayers() + return nil + } + return fmt.Errorf("unknown MatchPlayer unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *MatchPlayerMutation) ResetEdge(name string) error { + switch name { + case matchplayer.EdgeMatches: + m.ResetMatches() + return nil + case matchplayer.EdgePlayers: + m.ResetPlayers() + return nil + case matchplayer.EdgeWeaponStats: + m.ResetWeaponStats() + return nil + case matchplayer.EdgeRoundStats: + m.ResetRoundStats() + return nil + case matchplayer.EdgeSpray: + m.ResetSpray() + return nil + } + return fmt.Errorf("unknown MatchPlayer edge %s", name) +} + // PlayerMutation represents an operation that mutates the Player nodes in the graph. type PlayerMutation struct { config @@ -1331,6 +5100,12 @@ type PlayerMutation struct { auth_code *string profile_created *time.Time oldest_sharecode_seen *string + wins *int + addwins *int + looses *int + addlooses *int + ties *int + addties *int clearedFields map[string]struct{} stats map[int]struct{} removedstats map[int]struct{} @@ -2094,7 +5869,217 @@ func (m *PlayerMutation) ResetOldestSharecodeSeen() { delete(m.clearedFields, player.FieldOldestSharecodeSeen) } -// AddStatIDs adds the "stats" edge to the Stats entity by ids. +// SetWins sets the "wins" field. +func (m *PlayerMutation) SetWins(i int) { + m.wins = &i + m.addwins = nil +} + +// Wins returns the value of the "wins" field in the mutation. +func (m *PlayerMutation) Wins() (r int, exists bool) { + v := m.wins + if v == nil { + return + } + return *v, true +} + +// OldWins returns the old "wins" field's value of the Player entity. +// If the Player object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlayerMutation) OldWins(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldWins is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldWins requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldWins: %w", err) + } + return oldValue.Wins, nil +} + +// AddWins adds i to the "wins" field. +func (m *PlayerMutation) AddWins(i int) { + if m.addwins != nil { + *m.addwins += i + } else { + m.addwins = &i + } +} + +// AddedWins returns the value that was added to the "wins" field in this mutation. +func (m *PlayerMutation) AddedWins() (r int, exists bool) { + v := m.addwins + if v == nil { + return + } + return *v, true +} + +// ClearWins clears the value of the "wins" field. +func (m *PlayerMutation) ClearWins() { + m.wins = nil + m.addwins = nil + m.clearedFields[player.FieldWins] = struct{}{} +} + +// WinsCleared returns if the "wins" field was cleared in this mutation. +func (m *PlayerMutation) WinsCleared() bool { + _, ok := m.clearedFields[player.FieldWins] + return ok +} + +// ResetWins resets all changes to the "wins" field. +func (m *PlayerMutation) ResetWins() { + m.wins = nil + m.addwins = nil + delete(m.clearedFields, player.FieldWins) +} + +// SetLooses sets the "looses" field. +func (m *PlayerMutation) SetLooses(i int) { + m.looses = &i + m.addlooses = nil +} + +// Looses returns the value of the "looses" field in the mutation. +func (m *PlayerMutation) Looses() (r int, exists bool) { + v := m.looses + if v == nil { + return + } + return *v, true +} + +// OldLooses returns the old "looses" field's value of the Player entity. +// If the Player object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlayerMutation) OldLooses(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldLooses is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldLooses requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLooses: %w", err) + } + return oldValue.Looses, nil +} + +// AddLooses adds i to the "looses" field. +func (m *PlayerMutation) AddLooses(i int) { + if m.addlooses != nil { + *m.addlooses += i + } else { + m.addlooses = &i + } +} + +// AddedLooses returns the value that was added to the "looses" field in this mutation. +func (m *PlayerMutation) AddedLooses() (r int, exists bool) { + v := m.addlooses + if v == nil { + return + } + return *v, true +} + +// ClearLooses clears the value of the "looses" field. +func (m *PlayerMutation) ClearLooses() { + m.looses = nil + m.addlooses = nil + m.clearedFields[player.FieldLooses] = struct{}{} +} + +// LoosesCleared returns if the "looses" field was cleared in this mutation. +func (m *PlayerMutation) LoosesCleared() bool { + _, ok := m.clearedFields[player.FieldLooses] + return ok +} + +// ResetLooses resets all changes to the "looses" field. +func (m *PlayerMutation) ResetLooses() { + m.looses = nil + m.addlooses = nil + delete(m.clearedFields, player.FieldLooses) +} + +// SetTies sets the "ties" field. +func (m *PlayerMutation) SetTies(i int) { + m.ties = &i + m.addties = nil +} + +// Ties returns the value of the "ties" field in the mutation. +func (m *PlayerMutation) Ties() (r int, exists bool) { + v := m.ties + if v == nil { + return + } + return *v, true +} + +// OldTies returns the old "ties" field's value of the Player entity. +// If the Player object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlayerMutation) OldTies(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldTies is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldTies requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTies: %w", err) + } + return oldValue.Ties, nil +} + +// AddTies adds i to the "ties" field. +func (m *PlayerMutation) AddTies(i int) { + if m.addties != nil { + *m.addties += i + } else { + m.addties = &i + } +} + +// AddedTies returns the value that was added to the "ties" field in this mutation. +func (m *PlayerMutation) AddedTies() (r int, exists bool) { + v := m.addties + if v == nil { + return + } + return *v, true +} + +// ClearTies clears the value of the "ties" field. +func (m *PlayerMutation) ClearTies() { + m.ties = nil + m.addties = nil + m.clearedFields[player.FieldTies] = struct{}{} +} + +// TiesCleared returns if the "ties" field was cleared in this mutation. +func (m *PlayerMutation) TiesCleared() bool { + _, ok := m.clearedFields[player.FieldTies] + return ok +} + +// ResetTies resets all changes to the "ties" field. +func (m *PlayerMutation) ResetTies() { + m.ties = nil + m.addties = nil + delete(m.clearedFields, player.FieldTies) +} + +// AddStatIDs adds the "stats" edge to the MatchPlayer entity by ids. func (m *PlayerMutation) AddStatIDs(ids ...int) { if m.stats == nil { m.stats = make(map[int]struct{}) @@ -2104,17 +6089,17 @@ func (m *PlayerMutation) AddStatIDs(ids ...int) { } } -// ClearStats clears the "stats" edge to the Stats entity. +// ClearStats clears the "stats" edge to the MatchPlayer entity. func (m *PlayerMutation) ClearStats() { m.clearedstats = true } -// StatsCleared reports if the "stats" edge to the Stats entity was cleared. +// StatsCleared reports if the "stats" edge to the MatchPlayer entity was cleared. func (m *PlayerMutation) StatsCleared() bool { return m.clearedstats } -// RemoveStatIDs removes the "stats" edge to the Stats entity by IDs. +// RemoveStatIDs removes the "stats" edge to the MatchPlayer entity by IDs. func (m *PlayerMutation) RemoveStatIDs(ids ...int) { if m.removedstats == nil { m.removedstats = make(map[int]struct{}) @@ -2125,7 +6110,7 @@ func (m *PlayerMutation) RemoveStatIDs(ids ...int) { } } -// RemovedStats returns the removed IDs of the "stats" edge to the Stats entity. +// RemovedStats returns the removed IDs of the "stats" edge to the MatchPlayer entity. func (m *PlayerMutation) RemovedStatsIDs() (ids []int) { for id := range m.removedstats { ids = append(ids, id) @@ -2221,7 +6206,7 @@ func (m *PlayerMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *PlayerMutation) Fields() []string { - fields := make([]string, 0, 13) + fields := make([]string, 0, 16) if m.name != nil { fields = append(fields, player.FieldName) } @@ -2261,6 +6246,15 @@ func (m *PlayerMutation) Fields() []string { if m.oldest_sharecode_seen != nil { fields = append(fields, player.FieldOldestSharecodeSeen) } + if m.wins != nil { + fields = append(fields, player.FieldWins) + } + if m.looses != nil { + fields = append(fields, player.FieldLooses) + } + if m.ties != nil { + fields = append(fields, player.FieldTies) + } return fields } @@ -2295,6 +6289,12 @@ func (m *PlayerMutation) Field(name string) (ent.Value, bool) { return m.ProfileCreated() case player.FieldOldestSharecodeSeen: return m.OldestSharecodeSeen() + case player.FieldWins: + return m.Wins() + case player.FieldLooses: + return m.Looses() + case player.FieldTies: + return m.Ties() } return nil, false } @@ -2330,6 +6330,12 @@ func (m *PlayerMutation) OldField(ctx context.Context, name string) (ent.Value, return m.OldProfileCreated(ctx) case player.FieldOldestSharecodeSeen: return m.OldOldestSharecodeSeen(ctx) + case player.FieldWins: + return m.OldWins(ctx) + case player.FieldLooses: + return m.OldLooses(ctx) + case player.FieldTies: + return m.OldTies(ctx) } return nil, fmt.Errorf("unknown Player field %s", name) } @@ -2430,6 +6436,27 @@ func (m *PlayerMutation) SetField(name string, value ent.Value) error { } m.SetOldestSharecodeSeen(v) return nil + case player.FieldWins: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetWins(v) + return nil + case player.FieldLooses: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLooses(v) + return nil + case player.FieldTies: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTies(v) + return nil } return fmt.Errorf("unknown Player field %s", name) } @@ -2444,6 +6471,15 @@ func (m *PlayerMutation) AddedFields() []string { if m.addgame_ban_count != nil { fields = append(fields, player.FieldGameBanCount) } + if m.addwins != nil { + fields = append(fields, player.FieldWins) + } + if m.addlooses != nil { + fields = append(fields, player.FieldLooses) + } + if m.addties != nil { + fields = append(fields, player.FieldTies) + } return fields } @@ -2456,6 +6492,12 @@ func (m *PlayerMutation) AddedField(name string) (ent.Value, bool) { return m.AddedVacCount() case player.FieldGameBanCount: return m.AddedGameBanCount() + case player.FieldWins: + return m.AddedWins() + case player.FieldLooses: + return m.AddedLooses() + case player.FieldTies: + return m.AddedTies() } return nil, false } @@ -2479,6 +6521,27 @@ func (m *PlayerMutation) AddField(name string, value ent.Value) error { } m.AddGameBanCount(v) return nil + case player.FieldWins: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddWins(v) + return nil + case player.FieldLooses: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddLooses(v) + return nil + case player.FieldTies: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTies(v) + return nil } return fmt.Errorf("unknown Player numeric field %s", name) } @@ -2523,6 +6586,15 @@ func (m *PlayerMutation) ClearedFields() []string { if m.FieldCleared(player.FieldOldestSharecodeSeen) { fields = append(fields, player.FieldOldestSharecodeSeen) } + if m.FieldCleared(player.FieldWins) { + fields = append(fields, player.FieldWins) + } + if m.FieldCleared(player.FieldLooses) { + fields = append(fields, player.FieldLooses) + } + if m.FieldCleared(player.FieldTies) { + fields = append(fields, player.FieldTies) + } return fields } @@ -2573,6 +6645,15 @@ func (m *PlayerMutation) ClearField(name string) error { case player.FieldOldestSharecodeSeen: m.ClearOldestSharecodeSeen() return nil + case player.FieldWins: + m.ClearWins() + return nil + case player.FieldLooses: + m.ClearLooses() + return nil + case player.FieldTies: + m.ClearTies() + return nil } return fmt.Errorf("unknown Player nullable field %s", name) } @@ -2620,6 +6701,15 @@ func (m *PlayerMutation) ResetField(name string) error { case player.FieldOldestSharecodeSeen: m.ResetOldestSharecodeSeen() return nil + case player.FieldWins: + m.ResetWins() + return nil + case player.FieldLooses: + m.ResetLooses() + return nil + case player.FieldTies: + m.ResetTies() + return nil } return fmt.Errorf("unknown Player field %s", name) } @@ -2737,23 +6827,23 @@ func (m *PlayerMutation) ResetEdge(name string) error { // RoundStatsMutation represents an operation that mutates the RoundStats nodes in the graph. type RoundStatsMutation struct { config - op Op - typ string - id *int - round *uint - addround *uint - bank *uint - addbank *uint - equipment *uint - addequipment *uint - spent *uint - addspent *uint - clearedFields map[string]struct{} - stat *int - clearedstat bool - done bool - oldValue func(context.Context) (*RoundStats, error) - predicates []predicate.RoundStats + op Op + typ string + id *int + round *uint + addround *uint + bank *uint + addbank *uint + equipment *uint + addequipment *uint + spent *uint + addspent *uint + clearedFields map[string]struct{} + match_player *int + clearedmatch_player bool + done bool + oldValue func(context.Context) (*RoundStats, error) + predicates []predicate.RoundStats } var _ ent.Mutation = (*RoundStatsMutation)(nil) @@ -3059,43 +7149,43 @@ func (m *RoundStatsMutation) ResetSpent() { m.addspent = nil } -// SetStatID sets the "stat" edge to the Stats entity by id. -func (m *RoundStatsMutation) SetStatID(id int) { - m.stat = &id +// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by id. +func (m *RoundStatsMutation) SetMatchPlayerID(id int) { + m.match_player = &id } -// ClearStat clears the "stat" edge to the Stats entity. -func (m *RoundStatsMutation) ClearStat() { - m.clearedstat = true +// ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity. +func (m *RoundStatsMutation) ClearMatchPlayer() { + m.clearedmatch_player = true } -// StatCleared reports if the "stat" edge to the Stats entity was cleared. -func (m *RoundStatsMutation) StatCleared() bool { - return m.clearedstat +// MatchPlayerCleared reports if the "match_player" edge to the MatchPlayer entity was cleared. +func (m *RoundStatsMutation) MatchPlayerCleared() bool { + return m.clearedmatch_player } -// StatID returns the "stat" edge ID in the mutation. -func (m *RoundStatsMutation) StatID() (id int, exists bool) { - if m.stat != nil { - return *m.stat, true +// MatchPlayerID returns the "match_player" edge ID in the mutation. +func (m *RoundStatsMutation) MatchPlayerID() (id int, exists bool) { + if m.match_player != nil { + return *m.match_player, true } return } -// StatIDs returns the "stat" edge IDs in the mutation. +// MatchPlayerIDs returns the "match_player" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// StatID instead. It exists only for internal usage by the builders. -func (m *RoundStatsMutation) StatIDs() (ids []int) { - if id := m.stat; id != nil { +// MatchPlayerID instead. It exists only for internal usage by the builders. +func (m *RoundStatsMutation) MatchPlayerIDs() (ids []int) { + if id := m.match_player; id != nil { ids = append(ids, *id) } return } -// ResetStat resets all changes to the "stat" edge. -func (m *RoundStatsMutation) ResetStat() { - m.stat = nil - m.clearedstat = false +// ResetMatchPlayer resets all changes to the "match_player" edge. +func (m *RoundStatsMutation) ResetMatchPlayer() { + m.match_player = nil + m.clearedmatch_player = false } // Where appends a list predicates to the RoundStatsMutation builder. @@ -3319,8 +7409,8 @@ func (m *RoundStatsMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *RoundStatsMutation) AddedEdges() []string { edges := make([]string, 0, 1) - if m.stat != nil { - edges = append(edges, roundstats.EdgeStat) + if m.match_player != nil { + edges = append(edges, roundstats.EdgeMatchPlayer) } return edges } @@ -3329,8 +7419,8 @@ func (m *RoundStatsMutation) AddedEdges() []string { // name in this mutation. func (m *RoundStatsMutation) AddedIDs(name string) []ent.Value { switch name { - case roundstats.EdgeStat: - if id := m.stat; id != nil { + case roundstats.EdgeMatchPlayer: + if id := m.match_player; id != nil { return []ent.Value{*id} } } @@ -3354,8 +7444,8 @@ func (m *RoundStatsMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *RoundStatsMutation) ClearedEdges() []string { edges := make([]string, 0, 1) - if m.clearedstat { - edges = append(edges, roundstats.EdgeStat) + if m.clearedmatch_player { + edges = append(edges, roundstats.EdgeMatchPlayer) } return edges } @@ -3364,8 +7454,8 @@ func (m *RoundStatsMutation) ClearedEdges() []string { // was cleared in this mutation. func (m *RoundStatsMutation) EdgeCleared(name string) bool { switch name { - case roundstats.EdgeStat: - return m.clearedstat + case roundstats.EdgeMatchPlayer: + return m.clearedmatch_player } return false } @@ -3374,8 +7464,8 @@ func (m *RoundStatsMutation) EdgeCleared(name string) bool { // if that edge is not defined in the schema. func (m *RoundStatsMutation) ClearEdge(name string) error { switch name { - case roundstats.EdgeStat: - m.ClearStat() + case roundstats.EdgeMatchPlayer: + m.ClearMatchPlayer() return nil } return fmt.Errorf("unknown RoundStats unique edge %s", name) @@ -3385,102 +7475,41 @@ func (m *RoundStatsMutation) ClearEdge(name string) error { // It returns an error if the edge is not defined in the schema. func (m *RoundStatsMutation) ResetEdge(name string) error { switch name { - case roundstats.EdgeStat: - m.ResetStat() + case roundstats.EdgeMatchPlayer: + m.ResetMatchPlayer() return nil } return fmt.Errorf("unknown RoundStats edge %s", name) } -// StatsMutation represents an operation that mutates the Stats nodes in the graph. -type StatsMutation struct { +// SprayMutation represents an operation that mutates the Spray nodes in the graph. +type SprayMutation struct { config - op Op - typ string - id *int - team_id *int - addteam_id *int - kills *int - addkills *int - deaths *int - adddeaths *int - assists *int - addassists *int - headshot *int - addheadshot *int - mvp *uint - addmvp *uint - score *int - addscore *int - rank_new *int - addrank_new *int - rank_old *int - addrank_old *int - mk_2 *uint - addmk_2 *uint - mk_3 *uint - addmk_3 *uint - mk_4 *uint - addmk_4 *uint - mk_5 *uint - addmk_5 *uint - dmg_enemy *uint - adddmg_enemy *uint - dmg_team *uint - adddmg_team *uint - ud_he *uint - addud_he *uint - ud_flames *uint - addud_flames *uint - ud_flash *uint - addud_flash *uint - ud_decoy *uint - addud_decoy *uint - ud_smoke *uint - addud_smoke *uint - crosshair *string - color *stats.Color - kast *int - addkast *int - flash_duration_self *float32 - addflash_duration_self *float32 - flash_duration_team *float32 - addflash_duration_team *float32 - flash_duration_enemy *float32 - addflash_duration_enemy *float32 - flash_total_self *uint - addflash_total_self *uint - flash_total_team *uint - addflash_total_team *uint - flash_total_enemy *uint - addflash_total_enemy *uint - clearedFields map[string]struct{} - matches *uint64 - clearedmatches bool - players *uint64 - clearedplayers bool - weapon_stats map[int]struct{} - removedweapon_stats map[int]struct{} - clearedweapon_stats bool - round_stats map[int]struct{} - removedround_stats map[int]struct{} - clearedround_stats bool - done bool - oldValue func(context.Context) (*Stats, error) - predicates []predicate.Stats + op Op + typ string + id *int + weapon *int + addweapon *int + spray *[]byte + clearedFields map[string]struct{} + match_players *int + clearedmatch_players bool + done bool + oldValue func(context.Context) (*Spray, error) + predicates []predicate.Spray } -var _ ent.Mutation = (*StatsMutation)(nil) +var _ ent.Mutation = (*SprayMutation)(nil) -// statsOption allows management of the mutation configuration using functional options. -type statsOption func(*StatsMutation) +// sprayOption allows management of the mutation configuration using functional options. +type sprayOption func(*SprayMutation) -// newStatsMutation creates new mutation for the Stats entity. -func newStatsMutation(c config, op Op, opts ...statsOption) *StatsMutation { - m := &StatsMutation{ +// newSprayMutation creates new mutation for the Spray entity. +func newSprayMutation(c config, op Op, opts ...sprayOption) *SprayMutation { + m := &SprayMutation{ config: c, op: op, - typ: TypeStats, + typ: TypeSpray, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -3489,20 +7518,20 @@ func newStatsMutation(c config, op Op, opts ...statsOption) *StatsMutation { return m } -// withStatsID sets the ID field of the mutation. -func withStatsID(id int) statsOption { - return func(m *StatsMutation) { +// withSprayID sets the ID field of the mutation. +func withSprayID(id int) sprayOption { + return func(m *SprayMutation) { var ( err error once sync.Once - value *Stats + value *Spray ) - m.oldValue = func(ctx context.Context) (*Stats, error) { + m.oldValue = func(ctx context.Context) (*Spray, error) { once.Do(func() { if m.done { err = fmt.Errorf("querying old values post mutation is not allowed") } else { - value, err = m.Client().Stats.Get(ctx, id) + value, err = m.Client().Spray.Get(ctx, id) } }) return value, err @@ -3511,10 +7540,10 @@ func withStatsID(id int) statsOption { } } -// withStats sets the old Stats of the mutation. -func withStats(node *Stats) statsOption { - return func(m *StatsMutation) { - m.oldValue = func(context.Context) (*Stats, error) { +// withSpray sets the old Spray of the mutation. +func withSpray(node *Spray) sprayOption { + return func(m *SprayMutation) { + m.oldValue = func(context.Context) (*Spray, error) { return node, nil } m.id = &node.ID @@ -3523,7 +7552,7 @@ func withStats(node *Stats) statsOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m StatsMutation) Client() *Client { +func (m SprayMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -3531,7 +7560,7 @@ func (m StatsMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m StatsMutation) Tx() (*Tx, error) { +func (m SprayMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, fmt.Errorf("ent: mutation is not running in a transaction") } @@ -3542,2299 +7571,169 @@ func (m StatsMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *StatsMutation) ID() (id int, exists bool) { +func (m *SprayMutation) ID() (id int, exists bool) { if m.id == nil { return } return *m.id, true } -// SetTeamID sets the "team_id" field. -func (m *StatsMutation) SetTeamID(i int) { - m.team_id = &i - m.addteam_id = nil +// SetWeapon sets the "weapon" field. +func (m *SprayMutation) SetWeapon(i int) { + m.weapon = &i + m.addweapon = nil } -// TeamID returns the value of the "team_id" field in the mutation. -func (m *StatsMutation) TeamID() (r int, exists bool) { - v := m.team_id +// Weapon returns the value of the "weapon" field in the mutation. +func (m *SprayMutation) Weapon() (r int, exists bool) { + v := m.weapon if v == nil { return } return *v, true } -// OldTeamID returns the old "team_id" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. +// OldWeapon returns the old "weapon" field's value of the Spray entity. +// If the Spray object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldTeamID(ctx context.Context) (v int, err error) { +func (m *SprayMutation) OldWeapon(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldTeamID is only allowed on UpdateOne operations") + return v, fmt.Errorf("OldWeapon is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldTeamID requires an ID field in the mutation") + return v, fmt.Errorf("OldWeapon requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTeamID: %w", err) + return v, fmt.Errorf("querying old value for OldWeapon: %w", err) } - return oldValue.TeamID, nil + return oldValue.Weapon, nil } -// AddTeamID adds i to the "team_id" field. -func (m *StatsMutation) AddTeamID(i int) { - if m.addteam_id != nil { - *m.addteam_id += i +// AddWeapon adds i to the "weapon" field. +func (m *SprayMutation) AddWeapon(i int) { + if m.addweapon != nil { + *m.addweapon += i } else { - m.addteam_id = &i + m.addweapon = &i } } -// AddedTeamID returns the value that was added to the "team_id" field in this mutation. -func (m *StatsMutation) AddedTeamID() (r int, exists bool) { - v := m.addteam_id +// AddedWeapon returns the value that was added to the "weapon" field in this mutation. +func (m *SprayMutation) AddedWeapon() (r int, exists bool) { + v := m.addweapon if v == nil { return } return *v, true } -// ResetTeamID resets all changes to the "team_id" field. -func (m *StatsMutation) ResetTeamID() { - m.team_id = nil - m.addteam_id = nil +// ResetWeapon resets all changes to the "weapon" field. +func (m *SprayMutation) ResetWeapon() { + m.weapon = nil + m.addweapon = nil } -// SetKills sets the "kills" field. -func (m *StatsMutation) SetKills(i int) { - m.kills = &i - m.addkills = nil +// SetSpray sets the "spray" field. +func (m *SprayMutation) SetSpray(b []byte) { + m.spray = &b } -// Kills returns the value of the "kills" field in the mutation. -func (m *StatsMutation) Kills() (r int, exists bool) { - v := m.kills +// Spray returns the value of the "spray" field in the mutation. +func (m *SprayMutation) Spray() (r []byte, exists bool) { + v := m.spray if v == nil { return } return *v, true } -// OldKills returns the old "kills" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. +// OldSpray returns the old "spray" field's value of the Spray entity. +// If the Spray object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldKills(ctx context.Context) (v int, err error) { +func (m *SprayMutation) OldSpray(ctx context.Context) (v []byte, err error) { if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldKills is only allowed on UpdateOne operations") + return v, fmt.Errorf("OldSpray is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldKills requires an ID field in the mutation") + return v, fmt.Errorf("OldSpray requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldKills: %w", err) + return v, fmt.Errorf("querying old value for OldSpray: %w", err) } - return oldValue.Kills, nil + return oldValue.Spray, nil } -// AddKills adds i to the "kills" field. -func (m *StatsMutation) AddKills(i int) { - if m.addkills != nil { - *m.addkills += i - } else { - m.addkills = &i - } -} - -// AddedKills returns the value that was added to the "kills" field in this mutation. -func (m *StatsMutation) AddedKills() (r int, exists bool) { - v := m.addkills - if v == nil { - return - } - return *v, true -} - -// ResetKills resets all changes to the "kills" field. -func (m *StatsMutation) ResetKills() { - m.kills = nil - m.addkills = nil -} - -// SetDeaths sets the "deaths" field. -func (m *StatsMutation) SetDeaths(i int) { - m.deaths = &i - m.adddeaths = nil -} - -// Deaths returns the value of the "deaths" field in the mutation. -func (m *StatsMutation) Deaths() (r int, exists bool) { - v := m.deaths - if v == nil { - return - } - return *v, true -} - -// OldDeaths returns the old "deaths" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldDeaths(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldDeaths is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldDeaths requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDeaths: %w", err) - } - return oldValue.Deaths, nil -} - -// AddDeaths adds i to the "deaths" field. -func (m *StatsMutation) AddDeaths(i int) { - if m.adddeaths != nil { - *m.adddeaths += i - } else { - m.adddeaths = &i - } -} - -// AddedDeaths returns the value that was added to the "deaths" field in this mutation. -func (m *StatsMutation) AddedDeaths() (r int, exists bool) { - v := m.adddeaths - if v == nil { - return - } - return *v, true -} - -// ResetDeaths resets all changes to the "deaths" field. -func (m *StatsMutation) ResetDeaths() { - m.deaths = nil - m.adddeaths = nil -} - -// SetAssists sets the "assists" field. -func (m *StatsMutation) SetAssists(i int) { - m.assists = &i - m.addassists = nil -} - -// Assists returns the value of the "assists" field in the mutation. -func (m *StatsMutation) Assists() (r int, exists bool) { - v := m.assists - if v == nil { - return - } - return *v, true -} - -// OldAssists returns the old "assists" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldAssists(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldAssists is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldAssists requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldAssists: %w", err) - } - return oldValue.Assists, nil -} - -// AddAssists adds i to the "assists" field. -func (m *StatsMutation) AddAssists(i int) { - if m.addassists != nil { - *m.addassists += i - } else { - m.addassists = &i - } -} - -// AddedAssists returns the value that was added to the "assists" field in this mutation. -func (m *StatsMutation) AddedAssists() (r int, exists bool) { - v := m.addassists - if v == nil { - return - } - return *v, true -} - -// ResetAssists resets all changes to the "assists" field. -func (m *StatsMutation) ResetAssists() { - m.assists = nil - m.addassists = nil -} - -// SetHeadshot sets the "headshot" field. -func (m *StatsMutation) SetHeadshot(i int) { - m.headshot = &i - m.addheadshot = nil -} - -// Headshot returns the value of the "headshot" field in the mutation. -func (m *StatsMutation) Headshot() (r int, exists bool) { - v := m.headshot - if v == nil { - return - } - return *v, true -} - -// OldHeadshot returns the old "headshot" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldHeadshot(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldHeadshot is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldHeadshot requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldHeadshot: %w", err) - } - return oldValue.Headshot, nil -} - -// AddHeadshot adds i to the "headshot" field. -func (m *StatsMutation) AddHeadshot(i int) { - if m.addheadshot != nil { - *m.addheadshot += i - } else { - m.addheadshot = &i - } -} - -// AddedHeadshot returns the value that was added to the "headshot" field in this mutation. -func (m *StatsMutation) AddedHeadshot() (r int, exists bool) { - v := m.addheadshot - if v == nil { - return - } - return *v, true -} - -// ResetHeadshot resets all changes to the "headshot" field. -func (m *StatsMutation) ResetHeadshot() { - m.headshot = nil - m.addheadshot = nil -} - -// SetMvp sets the "mvp" field. -func (m *StatsMutation) SetMvp(u uint) { - m.mvp = &u - m.addmvp = nil -} - -// Mvp returns the value of the "mvp" field in the mutation. -func (m *StatsMutation) Mvp() (r uint, exists bool) { - v := m.mvp - if v == nil { - return - } - return *v, true -} - -// OldMvp returns the old "mvp" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldMvp(ctx context.Context) (v uint, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldMvp is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldMvp requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldMvp: %w", err) - } - return oldValue.Mvp, nil -} - -// AddMvp adds u to the "mvp" field. -func (m *StatsMutation) AddMvp(u uint) { - if m.addmvp != nil { - *m.addmvp += u - } else { - m.addmvp = &u - } -} - -// AddedMvp returns the value that was added to the "mvp" field in this mutation. -func (m *StatsMutation) AddedMvp() (r uint, exists bool) { - v := m.addmvp - if v == nil { - return - } - return *v, true -} - -// ResetMvp resets all changes to the "mvp" field. -func (m *StatsMutation) ResetMvp() { - m.mvp = nil - m.addmvp = nil -} - -// SetScore sets the "score" field. -func (m *StatsMutation) SetScore(i int) { - m.score = &i - m.addscore = nil -} - -// Score returns the value of the "score" field in the mutation. -func (m *StatsMutation) Score() (r int, exists bool) { - v := m.score - if v == nil { - return - } - return *v, true -} - -// OldScore returns the old "score" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldScore(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldScore is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldScore requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldScore: %w", err) - } - return oldValue.Score, nil -} - -// AddScore adds i to the "score" field. -func (m *StatsMutation) AddScore(i int) { - if m.addscore != nil { - *m.addscore += i - } else { - m.addscore = &i - } -} - -// AddedScore returns the value that was added to the "score" field in this mutation. -func (m *StatsMutation) AddedScore() (r int, exists bool) { - v := m.addscore - if v == nil { - return - } - return *v, true -} - -// ResetScore resets all changes to the "score" field. -func (m *StatsMutation) ResetScore() { - m.score = nil - m.addscore = nil -} - -// SetRankNew sets the "rank_new" field. -func (m *StatsMutation) SetRankNew(i int) { - m.rank_new = &i - m.addrank_new = nil -} - -// RankNew returns the value of the "rank_new" field in the mutation. -func (m *StatsMutation) RankNew() (r int, exists bool) { - v := m.rank_new - if v == nil { - return - } - return *v, true -} - -// OldRankNew returns the old "rank_new" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldRankNew(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldRankNew is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldRankNew requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRankNew: %w", err) - } - return oldValue.RankNew, nil -} - -// AddRankNew adds i to the "rank_new" field. -func (m *StatsMutation) AddRankNew(i int) { - if m.addrank_new != nil { - *m.addrank_new += i - } else { - m.addrank_new = &i - } -} - -// AddedRankNew returns the value that was added to the "rank_new" field in this mutation. -func (m *StatsMutation) AddedRankNew() (r int, exists bool) { - v := m.addrank_new - if v == nil { - return - } - return *v, true -} - -// ClearRankNew clears the value of the "rank_new" field. -func (m *StatsMutation) ClearRankNew() { - m.rank_new = nil - m.addrank_new = nil - m.clearedFields[stats.FieldRankNew] = struct{}{} -} - -// RankNewCleared returns if the "rank_new" field was cleared in this mutation. -func (m *StatsMutation) RankNewCleared() bool { - _, ok := m.clearedFields[stats.FieldRankNew] - return ok -} - -// ResetRankNew resets all changes to the "rank_new" field. -func (m *StatsMutation) ResetRankNew() { - m.rank_new = nil - m.addrank_new = nil - delete(m.clearedFields, stats.FieldRankNew) -} - -// SetRankOld sets the "rank_old" field. -func (m *StatsMutation) SetRankOld(i int) { - m.rank_old = &i - m.addrank_old = nil -} - -// RankOld returns the value of the "rank_old" field in the mutation. -func (m *StatsMutation) RankOld() (r int, exists bool) { - v := m.rank_old - if v == nil { - return - } - return *v, true -} - -// OldRankOld returns the old "rank_old" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldRankOld(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldRankOld is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldRankOld requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRankOld: %w", err) - } - return oldValue.RankOld, nil -} - -// AddRankOld adds i to the "rank_old" field. -func (m *StatsMutation) AddRankOld(i int) { - if m.addrank_old != nil { - *m.addrank_old += i - } else { - m.addrank_old = &i - } -} - -// AddedRankOld returns the value that was added to the "rank_old" field in this mutation. -func (m *StatsMutation) AddedRankOld() (r int, exists bool) { - v := m.addrank_old - if v == nil { - return - } - return *v, true -} - -// ClearRankOld clears the value of the "rank_old" field. -func (m *StatsMutation) ClearRankOld() { - m.rank_old = nil - m.addrank_old = nil - m.clearedFields[stats.FieldRankOld] = struct{}{} -} - -// RankOldCleared returns if the "rank_old" field was cleared in this mutation. -func (m *StatsMutation) RankOldCleared() bool { - _, ok := m.clearedFields[stats.FieldRankOld] - return ok -} - -// ResetRankOld resets all changes to the "rank_old" field. -func (m *StatsMutation) ResetRankOld() { - m.rank_old = nil - m.addrank_old = nil - delete(m.clearedFields, stats.FieldRankOld) -} - -// SetMk2 sets the "mk_2" field. -func (m *StatsMutation) SetMk2(u uint) { - m.mk_2 = &u - m.addmk_2 = nil -} - -// Mk2 returns the value of the "mk_2" field in the mutation. -func (m *StatsMutation) Mk2() (r uint, exists bool) { - v := m.mk_2 - if v == nil { - return - } - return *v, true -} - -// OldMk2 returns the old "mk_2" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldMk2(ctx context.Context) (v uint, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldMk2 is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldMk2 requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldMk2: %w", err) - } - return oldValue.Mk2, nil -} - -// AddMk2 adds u to the "mk_2" field. -func (m *StatsMutation) AddMk2(u uint) { - if m.addmk_2 != nil { - *m.addmk_2 += u - } else { - m.addmk_2 = &u - } -} - -// AddedMk2 returns the value that was added to the "mk_2" field in this mutation. -func (m *StatsMutation) AddedMk2() (r uint, exists bool) { - v := m.addmk_2 - if v == nil { - return - } - return *v, true -} - -// ClearMk2 clears the value of the "mk_2" field. -func (m *StatsMutation) ClearMk2() { - m.mk_2 = nil - m.addmk_2 = nil - m.clearedFields[stats.FieldMk2] = struct{}{} -} - -// Mk2Cleared returns if the "mk_2" field was cleared in this mutation. -func (m *StatsMutation) Mk2Cleared() bool { - _, ok := m.clearedFields[stats.FieldMk2] - return ok -} - -// ResetMk2 resets all changes to the "mk_2" field. -func (m *StatsMutation) ResetMk2() { - m.mk_2 = nil - m.addmk_2 = nil - delete(m.clearedFields, stats.FieldMk2) -} - -// SetMk3 sets the "mk_3" field. -func (m *StatsMutation) SetMk3(u uint) { - m.mk_3 = &u - m.addmk_3 = nil -} - -// Mk3 returns the value of the "mk_3" field in the mutation. -func (m *StatsMutation) Mk3() (r uint, exists bool) { - v := m.mk_3 - if v == nil { - return - } - return *v, true -} - -// OldMk3 returns the old "mk_3" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldMk3(ctx context.Context) (v uint, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldMk3 is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldMk3 requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldMk3: %w", err) - } - return oldValue.Mk3, nil -} - -// AddMk3 adds u to the "mk_3" field. -func (m *StatsMutation) AddMk3(u uint) { - if m.addmk_3 != nil { - *m.addmk_3 += u - } else { - m.addmk_3 = &u - } -} - -// AddedMk3 returns the value that was added to the "mk_3" field in this mutation. -func (m *StatsMutation) AddedMk3() (r uint, exists bool) { - v := m.addmk_3 - if v == nil { - return - } - return *v, true -} - -// ClearMk3 clears the value of the "mk_3" field. -func (m *StatsMutation) ClearMk3() { - m.mk_3 = nil - m.addmk_3 = nil - m.clearedFields[stats.FieldMk3] = struct{}{} -} - -// Mk3Cleared returns if the "mk_3" field was cleared in this mutation. -func (m *StatsMutation) Mk3Cleared() bool { - _, ok := m.clearedFields[stats.FieldMk3] - return ok -} - -// ResetMk3 resets all changes to the "mk_3" field. -func (m *StatsMutation) ResetMk3() { - m.mk_3 = nil - m.addmk_3 = nil - delete(m.clearedFields, stats.FieldMk3) -} - -// SetMk4 sets the "mk_4" field. -func (m *StatsMutation) SetMk4(u uint) { - m.mk_4 = &u - m.addmk_4 = nil -} - -// Mk4 returns the value of the "mk_4" field in the mutation. -func (m *StatsMutation) Mk4() (r uint, exists bool) { - v := m.mk_4 - if v == nil { - return - } - return *v, true -} - -// OldMk4 returns the old "mk_4" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldMk4(ctx context.Context) (v uint, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldMk4 is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldMk4 requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldMk4: %w", err) - } - return oldValue.Mk4, nil -} - -// AddMk4 adds u to the "mk_4" field. -func (m *StatsMutation) AddMk4(u uint) { - if m.addmk_4 != nil { - *m.addmk_4 += u - } else { - m.addmk_4 = &u - } -} - -// AddedMk4 returns the value that was added to the "mk_4" field in this mutation. -func (m *StatsMutation) AddedMk4() (r uint, exists bool) { - v := m.addmk_4 - if v == nil { - return - } - return *v, true -} - -// ClearMk4 clears the value of the "mk_4" field. -func (m *StatsMutation) ClearMk4() { - m.mk_4 = nil - m.addmk_4 = nil - m.clearedFields[stats.FieldMk4] = struct{}{} -} - -// Mk4Cleared returns if the "mk_4" field was cleared in this mutation. -func (m *StatsMutation) Mk4Cleared() bool { - _, ok := m.clearedFields[stats.FieldMk4] - return ok -} - -// ResetMk4 resets all changes to the "mk_4" field. -func (m *StatsMutation) ResetMk4() { - m.mk_4 = nil - m.addmk_4 = nil - delete(m.clearedFields, stats.FieldMk4) -} - -// SetMk5 sets the "mk_5" field. -func (m *StatsMutation) SetMk5(u uint) { - m.mk_5 = &u - m.addmk_5 = nil -} - -// Mk5 returns the value of the "mk_5" field in the mutation. -func (m *StatsMutation) Mk5() (r uint, exists bool) { - v := m.mk_5 - if v == nil { - return - } - return *v, true -} - -// OldMk5 returns the old "mk_5" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldMk5(ctx context.Context) (v uint, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldMk5 is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldMk5 requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldMk5: %w", err) - } - return oldValue.Mk5, nil -} - -// AddMk5 adds u to the "mk_5" field. -func (m *StatsMutation) AddMk5(u uint) { - if m.addmk_5 != nil { - *m.addmk_5 += u - } else { - m.addmk_5 = &u - } -} - -// AddedMk5 returns the value that was added to the "mk_5" field in this mutation. -func (m *StatsMutation) AddedMk5() (r uint, exists bool) { - v := m.addmk_5 - if v == nil { - return - } - return *v, true -} - -// ClearMk5 clears the value of the "mk_5" field. -func (m *StatsMutation) ClearMk5() { - m.mk_5 = nil - m.addmk_5 = nil - m.clearedFields[stats.FieldMk5] = struct{}{} -} - -// Mk5Cleared returns if the "mk_5" field was cleared in this mutation. -func (m *StatsMutation) Mk5Cleared() bool { - _, ok := m.clearedFields[stats.FieldMk5] - return ok -} - -// ResetMk5 resets all changes to the "mk_5" field. -func (m *StatsMutation) ResetMk5() { - m.mk_5 = nil - m.addmk_5 = nil - delete(m.clearedFields, stats.FieldMk5) -} - -// SetDmgEnemy sets the "dmg_enemy" field. -func (m *StatsMutation) SetDmgEnemy(u uint) { - m.dmg_enemy = &u - m.adddmg_enemy = nil -} - -// DmgEnemy returns the value of the "dmg_enemy" field in the mutation. -func (m *StatsMutation) DmgEnemy() (r uint, exists bool) { - v := m.dmg_enemy - if v == nil { - return - } - return *v, true -} - -// OldDmgEnemy returns the old "dmg_enemy" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldDmgEnemy(ctx context.Context) (v uint, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldDmgEnemy is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldDmgEnemy requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDmgEnemy: %w", err) - } - return oldValue.DmgEnemy, nil -} - -// AddDmgEnemy adds u to the "dmg_enemy" field. -func (m *StatsMutation) AddDmgEnemy(u uint) { - if m.adddmg_enemy != nil { - *m.adddmg_enemy += u - } else { - m.adddmg_enemy = &u - } -} - -// AddedDmgEnemy returns the value that was added to the "dmg_enemy" field in this mutation. -func (m *StatsMutation) AddedDmgEnemy() (r uint, exists bool) { - v := m.adddmg_enemy - if v == nil { - return - } - return *v, true -} - -// ClearDmgEnemy clears the value of the "dmg_enemy" field. -func (m *StatsMutation) ClearDmgEnemy() { - m.dmg_enemy = nil - m.adddmg_enemy = nil - m.clearedFields[stats.FieldDmgEnemy] = struct{}{} -} - -// DmgEnemyCleared returns if the "dmg_enemy" field was cleared in this mutation. -func (m *StatsMutation) DmgEnemyCleared() bool { - _, ok := m.clearedFields[stats.FieldDmgEnemy] - return ok -} - -// ResetDmgEnemy resets all changes to the "dmg_enemy" field. -func (m *StatsMutation) ResetDmgEnemy() { - m.dmg_enemy = nil - m.adddmg_enemy = nil - delete(m.clearedFields, stats.FieldDmgEnemy) -} - -// SetDmgTeam sets the "dmg_team" field. -func (m *StatsMutation) SetDmgTeam(u uint) { - m.dmg_team = &u - m.adddmg_team = nil -} - -// DmgTeam returns the value of the "dmg_team" field in the mutation. -func (m *StatsMutation) DmgTeam() (r uint, exists bool) { - v := m.dmg_team - if v == nil { - return - } - return *v, true -} - -// OldDmgTeam returns the old "dmg_team" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldDmgTeam(ctx context.Context) (v uint, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldDmgTeam is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldDmgTeam requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDmgTeam: %w", err) - } - return oldValue.DmgTeam, nil -} - -// AddDmgTeam adds u to the "dmg_team" field. -func (m *StatsMutation) AddDmgTeam(u uint) { - if m.adddmg_team != nil { - *m.adddmg_team += u - } else { - m.adddmg_team = &u - } -} - -// AddedDmgTeam returns the value that was added to the "dmg_team" field in this mutation. -func (m *StatsMutation) AddedDmgTeam() (r uint, exists bool) { - v := m.adddmg_team - if v == nil { - return - } - return *v, true -} - -// ClearDmgTeam clears the value of the "dmg_team" field. -func (m *StatsMutation) ClearDmgTeam() { - m.dmg_team = nil - m.adddmg_team = nil - m.clearedFields[stats.FieldDmgTeam] = struct{}{} -} - -// DmgTeamCleared returns if the "dmg_team" field was cleared in this mutation. -func (m *StatsMutation) DmgTeamCleared() bool { - _, ok := m.clearedFields[stats.FieldDmgTeam] - return ok -} - -// ResetDmgTeam resets all changes to the "dmg_team" field. -func (m *StatsMutation) ResetDmgTeam() { - m.dmg_team = nil - m.adddmg_team = nil - delete(m.clearedFields, stats.FieldDmgTeam) -} - -// SetUdHe sets the "ud_he" field. -func (m *StatsMutation) SetUdHe(u uint) { - m.ud_he = &u - m.addud_he = nil -} - -// UdHe returns the value of the "ud_he" field in the mutation. -func (m *StatsMutation) UdHe() (r uint, exists bool) { - v := m.ud_he - if v == nil { - return - } - return *v, true -} - -// OldUdHe returns the old "ud_he" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldUdHe(ctx context.Context) (v uint, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldUdHe is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldUdHe requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUdHe: %w", err) - } - return oldValue.UdHe, nil -} - -// AddUdHe adds u to the "ud_he" field. -func (m *StatsMutation) AddUdHe(u uint) { - if m.addud_he != nil { - *m.addud_he += u - } else { - m.addud_he = &u - } -} - -// AddedUdHe returns the value that was added to the "ud_he" field in this mutation. -func (m *StatsMutation) AddedUdHe() (r uint, exists bool) { - v := m.addud_he - if v == nil { - return - } - return *v, true -} - -// ClearUdHe clears the value of the "ud_he" field. -func (m *StatsMutation) ClearUdHe() { - m.ud_he = nil - m.addud_he = nil - m.clearedFields[stats.FieldUdHe] = struct{}{} -} - -// UdHeCleared returns if the "ud_he" field was cleared in this mutation. -func (m *StatsMutation) UdHeCleared() bool { - _, ok := m.clearedFields[stats.FieldUdHe] - return ok -} - -// ResetUdHe resets all changes to the "ud_he" field. -func (m *StatsMutation) ResetUdHe() { - m.ud_he = nil - m.addud_he = nil - delete(m.clearedFields, stats.FieldUdHe) -} - -// SetUdFlames sets the "ud_flames" field. -func (m *StatsMutation) SetUdFlames(u uint) { - m.ud_flames = &u - m.addud_flames = nil -} - -// UdFlames returns the value of the "ud_flames" field in the mutation. -func (m *StatsMutation) UdFlames() (r uint, exists bool) { - v := m.ud_flames - if v == nil { - return - } - return *v, true -} - -// OldUdFlames returns the old "ud_flames" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldUdFlames(ctx context.Context) (v uint, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldUdFlames is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldUdFlames requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUdFlames: %w", err) - } - return oldValue.UdFlames, nil -} - -// AddUdFlames adds u to the "ud_flames" field. -func (m *StatsMutation) AddUdFlames(u uint) { - if m.addud_flames != nil { - *m.addud_flames += u - } else { - m.addud_flames = &u - } -} - -// AddedUdFlames returns the value that was added to the "ud_flames" field in this mutation. -func (m *StatsMutation) AddedUdFlames() (r uint, exists bool) { - v := m.addud_flames - if v == nil { - return - } - return *v, true -} - -// ClearUdFlames clears the value of the "ud_flames" field. -func (m *StatsMutation) ClearUdFlames() { - m.ud_flames = nil - m.addud_flames = nil - m.clearedFields[stats.FieldUdFlames] = struct{}{} -} - -// UdFlamesCleared returns if the "ud_flames" field was cleared in this mutation. -func (m *StatsMutation) UdFlamesCleared() bool { - _, ok := m.clearedFields[stats.FieldUdFlames] - return ok -} - -// ResetUdFlames resets all changes to the "ud_flames" field. -func (m *StatsMutation) ResetUdFlames() { - m.ud_flames = nil - m.addud_flames = nil - delete(m.clearedFields, stats.FieldUdFlames) -} - -// SetUdFlash sets the "ud_flash" field. -func (m *StatsMutation) SetUdFlash(u uint) { - m.ud_flash = &u - m.addud_flash = nil -} - -// UdFlash returns the value of the "ud_flash" field in the mutation. -func (m *StatsMutation) UdFlash() (r uint, exists bool) { - v := m.ud_flash - if v == nil { - return - } - return *v, true -} - -// OldUdFlash returns the old "ud_flash" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldUdFlash(ctx context.Context) (v uint, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldUdFlash is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldUdFlash requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUdFlash: %w", err) - } - return oldValue.UdFlash, nil -} - -// AddUdFlash adds u to the "ud_flash" field. -func (m *StatsMutation) AddUdFlash(u uint) { - if m.addud_flash != nil { - *m.addud_flash += u - } else { - m.addud_flash = &u - } -} - -// AddedUdFlash returns the value that was added to the "ud_flash" field in this mutation. -func (m *StatsMutation) AddedUdFlash() (r uint, exists bool) { - v := m.addud_flash - if v == nil { - return - } - return *v, true -} - -// ClearUdFlash clears the value of the "ud_flash" field. -func (m *StatsMutation) ClearUdFlash() { - m.ud_flash = nil - m.addud_flash = nil - m.clearedFields[stats.FieldUdFlash] = struct{}{} -} - -// UdFlashCleared returns if the "ud_flash" field was cleared in this mutation. -func (m *StatsMutation) UdFlashCleared() bool { - _, ok := m.clearedFields[stats.FieldUdFlash] - return ok -} - -// ResetUdFlash resets all changes to the "ud_flash" field. -func (m *StatsMutation) ResetUdFlash() { - m.ud_flash = nil - m.addud_flash = nil - delete(m.clearedFields, stats.FieldUdFlash) -} - -// SetUdDecoy sets the "ud_decoy" field. -func (m *StatsMutation) SetUdDecoy(u uint) { - m.ud_decoy = &u - m.addud_decoy = nil -} - -// UdDecoy returns the value of the "ud_decoy" field in the mutation. -func (m *StatsMutation) UdDecoy() (r uint, exists bool) { - v := m.ud_decoy - if v == nil { - return - } - return *v, true -} - -// OldUdDecoy returns the old "ud_decoy" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldUdDecoy(ctx context.Context) (v uint, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldUdDecoy is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldUdDecoy requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUdDecoy: %w", err) - } - return oldValue.UdDecoy, nil -} - -// AddUdDecoy adds u to the "ud_decoy" field. -func (m *StatsMutation) AddUdDecoy(u uint) { - if m.addud_decoy != nil { - *m.addud_decoy += u - } else { - m.addud_decoy = &u - } -} - -// AddedUdDecoy returns the value that was added to the "ud_decoy" field in this mutation. -func (m *StatsMutation) AddedUdDecoy() (r uint, exists bool) { - v := m.addud_decoy - if v == nil { - return - } - return *v, true -} - -// ClearUdDecoy clears the value of the "ud_decoy" field. -func (m *StatsMutation) ClearUdDecoy() { - m.ud_decoy = nil - m.addud_decoy = nil - m.clearedFields[stats.FieldUdDecoy] = struct{}{} -} - -// UdDecoyCleared returns if the "ud_decoy" field was cleared in this mutation. -func (m *StatsMutation) UdDecoyCleared() bool { - _, ok := m.clearedFields[stats.FieldUdDecoy] - return ok -} - -// ResetUdDecoy resets all changes to the "ud_decoy" field. -func (m *StatsMutation) ResetUdDecoy() { - m.ud_decoy = nil - m.addud_decoy = nil - delete(m.clearedFields, stats.FieldUdDecoy) -} - -// SetUdSmoke sets the "ud_smoke" field. -func (m *StatsMutation) SetUdSmoke(u uint) { - m.ud_smoke = &u - m.addud_smoke = nil -} - -// UdSmoke returns the value of the "ud_smoke" field in the mutation. -func (m *StatsMutation) UdSmoke() (r uint, exists bool) { - v := m.ud_smoke - if v == nil { - return - } - return *v, true -} - -// OldUdSmoke returns the old "ud_smoke" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldUdSmoke(ctx context.Context) (v uint, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldUdSmoke is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldUdSmoke requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUdSmoke: %w", err) - } - return oldValue.UdSmoke, nil -} - -// AddUdSmoke adds u to the "ud_smoke" field. -func (m *StatsMutation) AddUdSmoke(u uint) { - if m.addud_smoke != nil { - *m.addud_smoke += u - } else { - m.addud_smoke = &u - } -} - -// AddedUdSmoke returns the value that was added to the "ud_smoke" field in this mutation. -func (m *StatsMutation) AddedUdSmoke() (r uint, exists bool) { - v := m.addud_smoke - if v == nil { - return - } - return *v, true -} - -// ClearUdSmoke clears the value of the "ud_smoke" field. -func (m *StatsMutation) ClearUdSmoke() { - m.ud_smoke = nil - m.addud_smoke = nil - m.clearedFields[stats.FieldUdSmoke] = struct{}{} -} - -// UdSmokeCleared returns if the "ud_smoke" field was cleared in this mutation. -func (m *StatsMutation) UdSmokeCleared() bool { - _, ok := m.clearedFields[stats.FieldUdSmoke] - return ok -} - -// ResetUdSmoke resets all changes to the "ud_smoke" field. -func (m *StatsMutation) ResetUdSmoke() { - m.ud_smoke = nil - m.addud_smoke = nil - delete(m.clearedFields, stats.FieldUdSmoke) -} - -// SetCrosshair sets the "crosshair" field. -func (m *StatsMutation) SetCrosshair(s string) { - m.crosshair = &s -} - -// Crosshair returns the value of the "crosshair" field in the mutation. -func (m *StatsMutation) Crosshair() (r string, exists bool) { - v := m.crosshair - if v == nil { - return - } - return *v, true -} - -// OldCrosshair returns the old "crosshair" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldCrosshair(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldCrosshair is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldCrosshair requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCrosshair: %w", err) - } - return oldValue.Crosshair, nil -} - -// ClearCrosshair clears the value of the "crosshair" field. -func (m *StatsMutation) ClearCrosshair() { - m.crosshair = nil - m.clearedFields[stats.FieldCrosshair] = struct{}{} -} - -// CrosshairCleared returns if the "crosshair" field was cleared in this mutation. -func (m *StatsMutation) CrosshairCleared() bool { - _, ok := m.clearedFields[stats.FieldCrosshair] - return ok -} - -// ResetCrosshair resets all changes to the "crosshair" field. -func (m *StatsMutation) ResetCrosshair() { - m.crosshair = nil - delete(m.clearedFields, stats.FieldCrosshair) -} - -// SetColor sets the "color" field. -func (m *StatsMutation) SetColor(s stats.Color) { - m.color = &s -} - -// Color returns the value of the "color" field in the mutation. -func (m *StatsMutation) Color() (r stats.Color, exists bool) { - v := m.color - if v == nil { - return - } - return *v, true -} - -// OldColor returns the old "color" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldColor(ctx context.Context) (v stats.Color, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldColor is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldColor requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldColor: %w", err) - } - return oldValue.Color, nil -} - -// ClearColor clears the value of the "color" field. -func (m *StatsMutation) ClearColor() { - m.color = nil - m.clearedFields[stats.FieldColor] = struct{}{} -} - -// ColorCleared returns if the "color" field was cleared in this mutation. -func (m *StatsMutation) ColorCleared() bool { - _, ok := m.clearedFields[stats.FieldColor] - return ok -} - -// ResetColor resets all changes to the "color" field. -func (m *StatsMutation) ResetColor() { - m.color = nil - delete(m.clearedFields, stats.FieldColor) -} - -// SetKast sets the "kast" field. -func (m *StatsMutation) SetKast(i int) { - m.kast = &i - m.addkast = nil -} - -// Kast returns the value of the "kast" field in the mutation. -func (m *StatsMutation) Kast() (r int, exists bool) { - v := m.kast - if v == nil { - return - } - return *v, true -} - -// OldKast returns the old "kast" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldKast(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldKast is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldKast requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldKast: %w", err) - } - return oldValue.Kast, nil -} - -// AddKast adds i to the "kast" field. -func (m *StatsMutation) AddKast(i int) { - if m.addkast != nil { - *m.addkast += i - } else { - m.addkast = &i - } -} - -// AddedKast returns the value that was added to the "kast" field in this mutation. -func (m *StatsMutation) AddedKast() (r int, exists bool) { - v := m.addkast - if v == nil { - return - } - return *v, true -} - -// ClearKast clears the value of the "kast" field. -func (m *StatsMutation) ClearKast() { - m.kast = nil - m.addkast = nil - m.clearedFields[stats.FieldKast] = struct{}{} -} - -// KastCleared returns if the "kast" field was cleared in this mutation. -func (m *StatsMutation) KastCleared() bool { - _, ok := m.clearedFields[stats.FieldKast] - return ok -} - -// ResetKast resets all changes to the "kast" field. -func (m *StatsMutation) ResetKast() { - m.kast = nil - m.addkast = nil - delete(m.clearedFields, stats.FieldKast) -} - -// SetFlashDurationSelf sets the "flash_duration_self" field. -func (m *StatsMutation) SetFlashDurationSelf(f float32) { - m.flash_duration_self = &f - m.addflash_duration_self = nil -} - -// FlashDurationSelf returns the value of the "flash_duration_self" field in the mutation. -func (m *StatsMutation) FlashDurationSelf() (r float32, exists bool) { - v := m.flash_duration_self - if v == nil { - return - } - return *v, true -} - -// OldFlashDurationSelf returns the old "flash_duration_self" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldFlashDurationSelf(ctx context.Context) (v float32, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldFlashDurationSelf is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldFlashDurationSelf requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldFlashDurationSelf: %w", err) - } - return oldValue.FlashDurationSelf, nil -} - -// AddFlashDurationSelf adds f to the "flash_duration_self" field. -func (m *StatsMutation) AddFlashDurationSelf(f float32) { - if m.addflash_duration_self != nil { - *m.addflash_duration_self += f - } else { - m.addflash_duration_self = &f - } -} - -// AddedFlashDurationSelf returns the value that was added to the "flash_duration_self" field in this mutation. -func (m *StatsMutation) AddedFlashDurationSelf() (r float32, exists bool) { - v := m.addflash_duration_self - if v == nil { - return - } - return *v, true -} - -// ClearFlashDurationSelf clears the value of the "flash_duration_self" field. -func (m *StatsMutation) ClearFlashDurationSelf() { - m.flash_duration_self = nil - m.addflash_duration_self = nil - m.clearedFields[stats.FieldFlashDurationSelf] = struct{}{} -} - -// FlashDurationSelfCleared returns if the "flash_duration_self" field was cleared in this mutation. -func (m *StatsMutation) FlashDurationSelfCleared() bool { - _, ok := m.clearedFields[stats.FieldFlashDurationSelf] - return ok -} - -// ResetFlashDurationSelf resets all changes to the "flash_duration_self" field. -func (m *StatsMutation) ResetFlashDurationSelf() { - m.flash_duration_self = nil - m.addflash_duration_self = nil - delete(m.clearedFields, stats.FieldFlashDurationSelf) -} - -// SetFlashDurationTeam sets the "flash_duration_team" field. -func (m *StatsMutation) SetFlashDurationTeam(f float32) { - m.flash_duration_team = &f - m.addflash_duration_team = nil -} - -// FlashDurationTeam returns the value of the "flash_duration_team" field in the mutation. -func (m *StatsMutation) FlashDurationTeam() (r float32, exists bool) { - v := m.flash_duration_team - if v == nil { - return - } - return *v, true -} - -// OldFlashDurationTeam returns the old "flash_duration_team" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldFlashDurationTeam(ctx context.Context) (v float32, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldFlashDurationTeam is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldFlashDurationTeam requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldFlashDurationTeam: %w", err) - } - return oldValue.FlashDurationTeam, nil -} - -// AddFlashDurationTeam adds f to the "flash_duration_team" field. -func (m *StatsMutation) AddFlashDurationTeam(f float32) { - if m.addflash_duration_team != nil { - *m.addflash_duration_team += f - } else { - m.addflash_duration_team = &f - } -} - -// AddedFlashDurationTeam returns the value that was added to the "flash_duration_team" field in this mutation. -func (m *StatsMutation) AddedFlashDurationTeam() (r float32, exists bool) { - v := m.addflash_duration_team - if v == nil { - return - } - return *v, true -} - -// ClearFlashDurationTeam clears the value of the "flash_duration_team" field. -func (m *StatsMutation) ClearFlashDurationTeam() { - m.flash_duration_team = nil - m.addflash_duration_team = nil - m.clearedFields[stats.FieldFlashDurationTeam] = struct{}{} -} - -// FlashDurationTeamCleared returns if the "flash_duration_team" field was cleared in this mutation. -func (m *StatsMutation) FlashDurationTeamCleared() bool { - _, ok := m.clearedFields[stats.FieldFlashDurationTeam] - return ok -} - -// ResetFlashDurationTeam resets all changes to the "flash_duration_team" field. -func (m *StatsMutation) ResetFlashDurationTeam() { - m.flash_duration_team = nil - m.addflash_duration_team = nil - delete(m.clearedFields, stats.FieldFlashDurationTeam) -} - -// SetFlashDurationEnemy sets the "flash_duration_enemy" field. -func (m *StatsMutation) SetFlashDurationEnemy(f float32) { - m.flash_duration_enemy = &f - m.addflash_duration_enemy = nil -} - -// FlashDurationEnemy returns the value of the "flash_duration_enemy" field in the mutation. -func (m *StatsMutation) FlashDurationEnemy() (r float32, exists bool) { - v := m.flash_duration_enemy - if v == nil { - return - } - return *v, true -} - -// OldFlashDurationEnemy returns the old "flash_duration_enemy" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldFlashDurationEnemy(ctx context.Context) (v float32, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldFlashDurationEnemy is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldFlashDurationEnemy requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldFlashDurationEnemy: %w", err) - } - return oldValue.FlashDurationEnemy, nil -} - -// AddFlashDurationEnemy adds f to the "flash_duration_enemy" field. -func (m *StatsMutation) AddFlashDurationEnemy(f float32) { - if m.addflash_duration_enemy != nil { - *m.addflash_duration_enemy += f - } else { - m.addflash_duration_enemy = &f - } -} - -// AddedFlashDurationEnemy returns the value that was added to the "flash_duration_enemy" field in this mutation. -func (m *StatsMutation) AddedFlashDurationEnemy() (r float32, exists bool) { - v := m.addflash_duration_enemy - if v == nil { - return - } - return *v, true -} - -// ClearFlashDurationEnemy clears the value of the "flash_duration_enemy" field. -func (m *StatsMutation) ClearFlashDurationEnemy() { - m.flash_duration_enemy = nil - m.addflash_duration_enemy = nil - m.clearedFields[stats.FieldFlashDurationEnemy] = struct{}{} -} - -// FlashDurationEnemyCleared returns if the "flash_duration_enemy" field was cleared in this mutation. -func (m *StatsMutation) FlashDurationEnemyCleared() bool { - _, ok := m.clearedFields[stats.FieldFlashDurationEnemy] - return ok -} - -// ResetFlashDurationEnemy resets all changes to the "flash_duration_enemy" field. -func (m *StatsMutation) ResetFlashDurationEnemy() { - m.flash_duration_enemy = nil - m.addflash_duration_enemy = nil - delete(m.clearedFields, stats.FieldFlashDurationEnemy) -} - -// SetFlashTotalSelf sets the "flash_total_self" field. -func (m *StatsMutation) SetFlashTotalSelf(u uint) { - m.flash_total_self = &u - m.addflash_total_self = nil -} - -// FlashTotalSelf returns the value of the "flash_total_self" field in the mutation. -func (m *StatsMutation) FlashTotalSelf() (r uint, exists bool) { - v := m.flash_total_self - if v == nil { - return - } - return *v, true -} - -// OldFlashTotalSelf returns the old "flash_total_self" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldFlashTotalSelf(ctx context.Context) (v uint, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldFlashTotalSelf is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldFlashTotalSelf requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldFlashTotalSelf: %w", err) - } - return oldValue.FlashTotalSelf, nil -} - -// AddFlashTotalSelf adds u to the "flash_total_self" field. -func (m *StatsMutation) AddFlashTotalSelf(u uint) { - if m.addflash_total_self != nil { - *m.addflash_total_self += u - } else { - m.addflash_total_self = &u - } -} - -// AddedFlashTotalSelf returns the value that was added to the "flash_total_self" field in this mutation. -func (m *StatsMutation) AddedFlashTotalSelf() (r uint, exists bool) { - v := m.addflash_total_self - if v == nil { - return - } - return *v, true -} - -// ClearFlashTotalSelf clears the value of the "flash_total_self" field. -func (m *StatsMutation) ClearFlashTotalSelf() { - m.flash_total_self = nil - m.addflash_total_self = nil - m.clearedFields[stats.FieldFlashTotalSelf] = struct{}{} -} - -// FlashTotalSelfCleared returns if the "flash_total_self" field was cleared in this mutation. -func (m *StatsMutation) FlashTotalSelfCleared() bool { - _, ok := m.clearedFields[stats.FieldFlashTotalSelf] - return ok -} - -// ResetFlashTotalSelf resets all changes to the "flash_total_self" field. -func (m *StatsMutation) ResetFlashTotalSelf() { - m.flash_total_self = nil - m.addflash_total_self = nil - delete(m.clearedFields, stats.FieldFlashTotalSelf) -} - -// SetFlashTotalTeam sets the "flash_total_team" field. -func (m *StatsMutation) SetFlashTotalTeam(u uint) { - m.flash_total_team = &u - m.addflash_total_team = nil -} - -// FlashTotalTeam returns the value of the "flash_total_team" field in the mutation. -func (m *StatsMutation) FlashTotalTeam() (r uint, exists bool) { - v := m.flash_total_team - if v == nil { - return - } - return *v, true -} - -// OldFlashTotalTeam returns the old "flash_total_team" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldFlashTotalTeam(ctx context.Context) (v uint, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldFlashTotalTeam is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldFlashTotalTeam requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldFlashTotalTeam: %w", err) - } - return oldValue.FlashTotalTeam, nil -} - -// AddFlashTotalTeam adds u to the "flash_total_team" field. -func (m *StatsMutation) AddFlashTotalTeam(u uint) { - if m.addflash_total_team != nil { - *m.addflash_total_team += u - } else { - m.addflash_total_team = &u - } -} - -// AddedFlashTotalTeam returns the value that was added to the "flash_total_team" field in this mutation. -func (m *StatsMutation) AddedFlashTotalTeam() (r uint, exists bool) { - v := m.addflash_total_team - if v == nil { - return - } - return *v, true -} - -// ClearFlashTotalTeam clears the value of the "flash_total_team" field. -func (m *StatsMutation) ClearFlashTotalTeam() { - m.flash_total_team = nil - m.addflash_total_team = nil - m.clearedFields[stats.FieldFlashTotalTeam] = struct{}{} -} - -// FlashTotalTeamCleared returns if the "flash_total_team" field was cleared in this mutation. -func (m *StatsMutation) FlashTotalTeamCleared() bool { - _, ok := m.clearedFields[stats.FieldFlashTotalTeam] - return ok -} - -// ResetFlashTotalTeam resets all changes to the "flash_total_team" field. -func (m *StatsMutation) ResetFlashTotalTeam() { - m.flash_total_team = nil - m.addflash_total_team = nil - delete(m.clearedFields, stats.FieldFlashTotalTeam) -} - -// SetFlashTotalEnemy sets the "flash_total_enemy" field. -func (m *StatsMutation) SetFlashTotalEnemy(u uint) { - m.flash_total_enemy = &u - m.addflash_total_enemy = nil -} - -// FlashTotalEnemy returns the value of the "flash_total_enemy" field in the mutation. -func (m *StatsMutation) FlashTotalEnemy() (r uint, exists bool) { - v := m.flash_total_enemy - if v == nil { - return - } - return *v, true -} - -// OldFlashTotalEnemy returns the old "flash_total_enemy" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldFlashTotalEnemy(ctx context.Context) (v uint, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldFlashTotalEnemy is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldFlashTotalEnemy requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldFlashTotalEnemy: %w", err) - } - return oldValue.FlashTotalEnemy, nil -} - -// AddFlashTotalEnemy adds u to the "flash_total_enemy" field. -func (m *StatsMutation) AddFlashTotalEnemy(u uint) { - if m.addflash_total_enemy != nil { - *m.addflash_total_enemy += u - } else { - m.addflash_total_enemy = &u - } -} - -// AddedFlashTotalEnemy returns the value that was added to the "flash_total_enemy" field in this mutation. -func (m *StatsMutation) AddedFlashTotalEnemy() (r uint, exists bool) { - v := m.addflash_total_enemy - if v == nil { - return - } - return *v, true -} - -// ClearFlashTotalEnemy clears the value of the "flash_total_enemy" field. -func (m *StatsMutation) ClearFlashTotalEnemy() { - m.flash_total_enemy = nil - m.addflash_total_enemy = nil - m.clearedFields[stats.FieldFlashTotalEnemy] = struct{}{} -} - -// FlashTotalEnemyCleared returns if the "flash_total_enemy" field was cleared in this mutation. -func (m *StatsMutation) FlashTotalEnemyCleared() bool { - _, ok := m.clearedFields[stats.FieldFlashTotalEnemy] - return ok -} - -// ResetFlashTotalEnemy resets all changes to the "flash_total_enemy" field. -func (m *StatsMutation) ResetFlashTotalEnemy() { - m.flash_total_enemy = nil - m.addflash_total_enemy = nil - delete(m.clearedFields, stats.FieldFlashTotalEnemy) -} - -// SetMatchStats sets the "match_stats" field. -func (m *StatsMutation) SetMatchStats(u uint64) { - m.matches = &u -} - -// MatchStats returns the value of the "match_stats" field in the mutation. -func (m *StatsMutation) MatchStats() (r uint64, exists bool) { - v := m.matches - if v == nil { - return - } - return *v, true -} - -// OldMatchStats returns the old "match_stats" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldMatchStats(ctx context.Context) (v uint64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldMatchStats is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldMatchStats requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldMatchStats: %w", err) - } - return oldValue.MatchStats, nil -} - -// ClearMatchStats clears the value of the "match_stats" field. -func (m *StatsMutation) ClearMatchStats() { - m.matches = nil - m.clearedFields[stats.FieldMatchStats] = struct{}{} -} - -// MatchStatsCleared returns if the "match_stats" field was cleared in this mutation. -func (m *StatsMutation) MatchStatsCleared() bool { - _, ok := m.clearedFields[stats.FieldMatchStats] - return ok -} - -// ResetMatchStats resets all changes to the "match_stats" field. -func (m *StatsMutation) ResetMatchStats() { - m.matches = nil - delete(m.clearedFields, stats.FieldMatchStats) -} - -// SetPlayerStats sets the "player_stats" field. -func (m *StatsMutation) SetPlayerStats(u uint64) { - m.players = &u -} - -// PlayerStats returns the value of the "player_stats" field in the mutation. -func (m *StatsMutation) PlayerStats() (r uint64, exists bool) { - v := m.players - if v == nil { - return - } - return *v, true -} - -// OldPlayerStats returns the old "player_stats" field's value of the Stats entity. -// If the Stats object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *StatsMutation) OldPlayerStats(ctx context.Context) (v uint64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldPlayerStats is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldPlayerStats requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPlayerStats: %w", err) - } - return oldValue.PlayerStats, nil -} - -// ClearPlayerStats clears the value of the "player_stats" field. -func (m *StatsMutation) ClearPlayerStats() { - m.players = nil - m.clearedFields[stats.FieldPlayerStats] = struct{}{} -} - -// PlayerStatsCleared returns if the "player_stats" field was cleared in this mutation. -func (m *StatsMutation) PlayerStatsCleared() bool { - _, ok := m.clearedFields[stats.FieldPlayerStats] - return ok -} - -// ResetPlayerStats resets all changes to the "player_stats" field. -func (m *StatsMutation) ResetPlayerStats() { - m.players = nil - delete(m.clearedFields, stats.FieldPlayerStats) +// ResetSpray resets all changes to the "spray" field. +func (m *SprayMutation) ResetSpray() { + m.spray = nil } -// SetMatchesID sets the "matches" edge to the Match entity by id. -func (m *StatsMutation) SetMatchesID(id uint64) { - m.matches = &id +// SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by id. +func (m *SprayMutation) SetMatchPlayersID(id int) { + m.match_players = &id } -// ClearMatches clears the "matches" edge to the Match entity. -func (m *StatsMutation) ClearMatches() { - m.clearedmatches = true +// ClearMatchPlayers clears the "match_players" edge to the MatchPlayer entity. +func (m *SprayMutation) ClearMatchPlayers() { + m.clearedmatch_players = true } -// MatchesCleared reports if the "matches" edge to the Match entity was cleared. -func (m *StatsMutation) MatchesCleared() bool { - return m.MatchStatsCleared() || m.clearedmatches +// MatchPlayersCleared reports if the "match_players" edge to the MatchPlayer entity was cleared. +func (m *SprayMutation) MatchPlayersCleared() bool { + return m.clearedmatch_players } -// MatchesID returns the "matches" edge ID in the mutation. -func (m *StatsMutation) MatchesID() (id uint64, exists bool) { - if m.matches != nil { - return *m.matches, true +// MatchPlayersID returns the "match_players" edge ID in the mutation. +func (m *SprayMutation) MatchPlayersID() (id int, exists bool) { + if m.match_players != nil { + return *m.match_players, true } return } -// MatchesIDs returns the "matches" edge IDs in the mutation. +// MatchPlayersIDs returns the "match_players" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// MatchesID instead. It exists only for internal usage by the builders. -func (m *StatsMutation) MatchesIDs() (ids []uint64) { - if id := m.matches; id != nil { +// MatchPlayersID instead. It exists only for internal usage by the builders. +func (m *SprayMutation) MatchPlayersIDs() (ids []int) { + if id := m.match_players; id != nil { ids = append(ids, *id) } return } -// ResetMatches resets all changes to the "matches" edge. -func (m *StatsMutation) ResetMatches() { - m.matches = nil - m.clearedmatches = false +// ResetMatchPlayers resets all changes to the "match_players" edge. +func (m *SprayMutation) ResetMatchPlayers() { + m.match_players = nil + m.clearedmatch_players = false } -// SetPlayersID sets the "players" edge to the Player entity by id. -func (m *StatsMutation) SetPlayersID(id uint64) { - m.players = &id -} - -// ClearPlayers clears the "players" edge to the Player entity. -func (m *StatsMutation) ClearPlayers() { - m.clearedplayers = true -} - -// PlayersCleared reports if the "players" edge to the Player entity was cleared. -func (m *StatsMutation) PlayersCleared() bool { - return m.PlayerStatsCleared() || m.clearedplayers -} - -// PlayersID returns the "players" edge ID in the mutation. -func (m *StatsMutation) PlayersID() (id uint64, exists bool) { - if m.players != nil { - return *m.players, true - } - return -} - -// PlayersIDs returns the "players" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// PlayersID instead. It exists only for internal usage by the builders. -func (m *StatsMutation) PlayersIDs() (ids []uint64) { - if id := m.players; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetPlayers resets all changes to the "players" edge. -func (m *StatsMutation) ResetPlayers() { - m.players = nil - m.clearedplayers = false -} - -// AddWeaponStatIDs adds the "weapon_stats" edge to the WeaponStats entity by ids. -func (m *StatsMutation) AddWeaponStatIDs(ids ...int) { - if m.weapon_stats == nil { - m.weapon_stats = make(map[int]struct{}) - } - for i := range ids { - m.weapon_stats[ids[i]] = struct{}{} - } -} - -// ClearWeaponStats clears the "weapon_stats" edge to the WeaponStats entity. -func (m *StatsMutation) ClearWeaponStats() { - m.clearedweapon_stats = true -} - -// WeaponStatsCleared reports if the "weapon_stats" edge to the WeaponStats entity was cleared. -func (m *StatsMutation) WeaponStatsCleared() bool { - return m.clearedweapon_stats -} - -// RemoveWeaponStatIDs removes the "weapon_stats" edge to the WeaponStats entity by IDs. -func (m *StatsMutation) RemoveWeaponStatIDs(ids ...int) { - if m.removedweapon_stats == nil { - m.removedweapon_stats = make(map[int]struct{}) - } - for i := range ids { - delete(m.weapon_stats, ids[i]) - m.removedweapon_stats[ids[i]] = struct{}{} - } -} - -// RemovedWeaponStats returns the removed IDs of the "weapon_stats" edge to the WeaponStats entity. -func (m *StatsMutation) RemovedWeaponStatsIDs() (ids []int) { - for id := range m.removedweapon_stats { - ids = append(ids, id) - } - return -} - -// WeaponStatsIDs returns the "weapon_stats" edge IDs in the mutation. -func (m *StatsMutation) WeaponStatsIDs() (ids []int) { - for id := range m.weapon_stats { - ids = append(ids, id) - } - return -} - -// ResetWeaponStats resets all changes to the "weapon_stats" edge. -func (m *StatsMutation) ResetWeaponStats() { - m.weapon_stats = nil - m.clearedweapon_stats = false - m.removedweapon_stats = nil -} - -// AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by ids. -func (m *StatsMutation) AddRoundStatIDs(ids ...int) { - if m.round_stats == nil { - m.round_stats = make(map[int]struct{}) - } - for i := range ids { - m.round_stats[ids[i]] = struct{}{} - } -} - -// ClearRoundStats clears the "round_stats" edge to the RoundStats entity. -func (m *StatsMutation) ClearRoundStats() { - m.clearedround_stats = true -} - -// RoundStatsCleared reports if the "round_stats" edge to the RoundStats entity was cleared. -func (m *StatsMutation) RoundStatsCleared() bool { - return m.clearedround_stats -} - -// RemoveRoundStatIDs removes the "round_stats" edge to the RoundStats entity by IDs. -func (m *StatsMutation) RemoveRoundStatIDs(ids ...int) { - if m.removedround_stats == nil { - m.removedround_stats = make(map[int]struct{}) - } - for i := range ids { - delete(m.round_stats, ids[i]) - m.removedround_stats[ids[i]] = struct{}{} - } -} - -// RemovedRoundStats returns the removed IDs of the "round_stats" edge to the RoundStats entity. -func (m *StatsMutation) RemovedRoundStatsIDs() (ids []int) { - for id := range m.removedround_stats { - ids = append(ids, id) - } - return -} - -// RoundStatsIDs returns the "round_stats" edge IDs in the mutation. -func (m *StatsMutation) RoundStatsIDs() (ids []int) { - for id := range m.round_stats { - ids = append(ids, id) - } - return -} - -// ResetRoundStats resets all changes to the "round_stats" edge. -func (m *StatsMutation) ResetRoundStats() { - m.round_stats = nil - m.clearedround_stats = false - m.removedround_stats = nil -} - -// Where appends a list predicates to the StatsMutation builder. -func (m *StatsMutation) Where(ps ...predicate.Stats) { +// Where appends a list predicates to the SprayMutation builder. +func (m *SprayMutation) Where(ps ...predicate.Spray) { m.predicates = append(m.predicates, ps...) } // Op returns the operation name. -func (m *StatsMutation) Op() Op { +func (m *SprayMutation) Op() Op { return m.op } -// Type returns the node type of this mutation (Stats). -func (m *StatsMutation) Type() string { +// Type returns the node type of this mutation (Spray). +func (m *SprayMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *StatsMutation) Fields() []string { - fields := make([]string, 0, 31) - if m.team_id != nil { - fields = append(fields, stats.FieldTeamID) +func (m *SprayMutation) Fields() []string { + fields := make([]string, 0, 2) + if m.weapon != nil { + fields = append(fields, spray.FieldWeapon) } - if m.kills != nil { - fields = append(fields, stats.FieldKills) - } - if m.deaths != nil { - fields = append(fields, stats.FieldDeaths) - } - if m.assists != nil { - fields = append(fields, stats.FieldAssists) - } - if m.headshot != nil { - fields = append(fields, stats.FieldHeadshot) - } - if m.mvp != nil { - fields = append(fields, stats.FieldMvp) - } - if m.score != nil { - fields = append(fields, stats.FieldScore) - } - if m.rank_new != nil { - fields = append(fields, stats.FieldRankNew) - } - if m.rank_old != nil { - fields = append(fields, stats.FieldRankOld) - } - if m.mk_2 != nil { - fields = append(fields, stats.FieldMk2) - } - if m.mk_3 != nil { - fields = append(fields, stats.FieldMk3) - } - if m.mk_4 != nil { - fields = append(fields, stats.FieldMk4) - } - if m.mk_5 != nil { - fields = append(fields, stats.FieldMk5) - } - if m.dmg_enemy != nil { - fields = append(fields, stats.FieldDmgEnemy) - } - if m.dmg_team != nil { - fields = append(fields, stats.FieldDmgTeam) - } - if m.ud_he != nil { - fields = append(fields, stats.FieldUdHe) - } - if m.ud_flames != nil { - fields = append(fields, stats.FieldUdFlames) - } - if m.ud_flash != nil { - fields = append(fields, stats.FieldUdFlash) - } - if m.ud_decoy != nil { - fields = append(fields, stats.FieldUdDecoy) - } - if m.ud_smoke != nil { - fields = append(fields, stats.FieldUdSmoke) - } - if m.crosshair != nil { - fields = append(fields, stats.FieldCrosshair) - } - if m.color != nil { - fields = append(fields, stats.FieldColor) - } - if m.kast != nil { - fields = append(fields, stats.FieldKast) - } - if m.flash_duration_self != nil { - fields = append(fields, stats.FieldFlashDurationSelf) - } - if m.flash_duration_team != nil { - fields = append(fields, stats.FieldFlashDurationTeam) - } - if m.flash_duration_enemy != nil { - fields = append(fields, stats.FieldFlashDurationEnemy) - } - if m.flash_total_self != nil { - fields = append(fields, stats.FieldFlashTotalSelf) - } - if m.flash_total_team != nil { - fields = append(fields, stats.FieldFlashTotalTeam) - } - if m.flash_total_enemy != nil { - fields = append(fields, stats.FieldFlashTotalEnemy) - } - if m.matches != nil { - fields = append(fields, stats.FieldMatchStats) - } - if m.players != nil { - fields = append(fields, stats.FieldPlayerStats) + if m.spray != nil { + fields = append(fields, spray.FieldSpray) } return fields } @@ -5842,70 +7741,12 @@ func (m *StatsMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *StatsMutation) Field(name string) (ent.Value, bool) { +func (m *SprayMutation) Field(name string) (ent.Value, bool) { switch name { - case stats.FieldTeamID: - return m.TeamID() - case stats.FieldKills: - return m.Kills() - case stats.FieldDeaths: - return m.Deaths() - case stats.FieldAssists: - return m.Assists() - case stats.FieldHeadshot: - return m.Headshot() - case stats.FieldMvp: - return m.Mvp() - case stats.FieldScore: - return m.Score() - case stats.FieldRankNew: - return m.RankNew() - case stats.FieldRankOld: - return m.RankOld() - case stats.FieldMk2: - return m.Mk2() - case stats.FieldMk3: - return m.Mk3() - case stats.FieldMk4: - return m.Mk4() - case stats.FieldMk5: - return m.Mk5() - case stats.FieldDmgEnemy: - return m.DmgEnemy() - case stats.FieldDmgTeam: - return m.DmgTeam() - case stats.FieldUdHe: - return m.UdHe() - case stats.FieldUdFlames: - return m.UdFlames() - case stats.FieldUdFlash: - return m.UdFlash() - case stats.FieldUdDecoy: - return m.UdDecoy() - case stats.FieldUdSmoke: - return m.UdSmoke() - case stats.FieldCrosshair: - return m.Crosshair() - case stats.FieldColor: - return m.Color() - case stats.FieldKast: - return m.Kast() - case stats.FieldFlashDurationSelf: - return m.FlashDurationSelf() - case stats.FieldFlashDurationTeam: - return m.FlashDurationTeam() - case stats.FieldFlashDurationEnemy: - return m.FlashDurationEnemy() - case stats.FieldFlashTotalSelf: - return m.FlashTotalSelf() - case stats.FieldFlashTotalTeam: - return m.FlashTotalTeam() - case stats.FieldFlashTotalEnemy: - return m.FlashTotalEnemy() - case stats.FieldMatchStats: - return m.MatchStats() - case stats.FieldPlayerStats: - return m.PlayerStats() + case spray.FieldWeapon: + return m.Weapon() + case spray.FieldSpray: + return m.Spray() } return nil, false } @@ -5913,384 +7754,45 @@ func (m *StatsMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *StatsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *SprayMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case stats.FieldTeamID: - return m.OldTeamID(ctx) - case stats.FieldKills: - return m.OldKills(ctx) - case stats.FieldDeaths: - return m.OldDeaths(ctx) - case stats.FieldAssists: - return m.OldAssists(ctx) - case stats.FieldHeadshot: - return m.OldHeadshot(ctx) - case stats.FieldMvp: - return m.OldMvp(ctx) - case stats.FieldScore: - return m.OldScore(ctx) - case stats.FieldRankNew: - return m.OldRankNew(ctx) - case stats.FieldRankOld: - return m.OldRankOld(ctx) - case stats.FieldMk2: - return m.OldMk2(ctx) - case stats.FieldMk3: - return m.OldMk3(ctx) - case stats.FieldMk4: - return m.OldMk4(ctx) - case stats.FieldMk5: - return m.OldMk5(ctx) - case stats.FieldDmgEnemy: - return m.OldDmgEnemy(ctx) - case stats.FieldDmgTeam: - return m.OldDmgTeam(ctx) - case stats.FieldUdHe: - return m.OldUdHe(ctx) - case stats.FieldUdFlames: - return m.OldUdFlames(ctx) - case stats.FieldUdFlash: - return m.OldUdFlash(ctx) - case stats.FieldUdDecoy: - return m.OldUdDecoy(ctx) - case stats.FieldUdSmoke: - return m.OldUdSmoke(ctx) - case stats.FieldCrosshair: - return m.OldCrosshair(ctx) - case stats.FieldColor: - return m.OldColor(ctx) - case stats.FieldKast: - return m.OldKast(ctx) - case stats.FieldFlashDurationSelf: - return m.OldFlashDurationSelf(ctx) - case stats.FieldFlashDurationTeam: - return m.OldFlashDurationTeam(ctx) - case stats.FieldFlashDurationEnemy: - return m.OldFlashDurationEnemy(ctx) - case stats.FieldFlashTotalSelf: - return m.OldFlashTotalSelf(ctx) - case stats.FieldFlashTotalTeam: - return m.OldFlashTotalTeam(ctx) - case stats.FieldFlashTotalEnemy: - return m.OldFlashTotalEnemy(ctx) - case stats.FieldMatchStats: - return m.OldMatchStats(ctx) - case stats.FieldPlayerStats: - return m.OldPlayerStats(ctx) + case spray.FieldWeapon: + return m.OldWeapon(ctx) + case spray.FieldSpray: + return m.OldSpray(ctx) } - return nil, fmt.Errorf("unknown Stats field %s", name) + return nil, fmt.Errorf("unknown Spray field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *StatsMutation) SetField(name string, value ent.Value) error { +func (m *SprayMutation) SetField(name string, value ent.Value) error { switch name { - case stats.FieldTeamID: + case spray.FieldWeapon: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetTeamID(v) + m.SetWeapon(v) return nil - case stats.FieldKills: - v, ok := value.(int) + case spray.FieldSpray: + v, ok := value.([]byte) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetKills(v) - return nil - case stats.FieldDeaths: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDeaths(v) - return nil - case stats.FieldAssists: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAssists(v) - return nil - case stats.FieldHeadshot: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetHeadshot(v) - return nil - case stats.FieldMvp: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetMvp(v) - return nil - case stats.FieldScore: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetScore(v) - return nil - case stats.FieldRankNew: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRankNew(v) - return nil - case stats.FieldRankOld: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRankOld(v) - return nil - case stats.FieldMk2: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetMk2(v) - return nil - case stats.FieldMk3: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetMk3(v) - return nil - case stats.FieldMk4: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetMk4(v) - return nil - case stats.FieldMk5: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetMk5(v) - return nil - case stats.FieldDmgEnemy: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDmgEnemy(v) - return nil - case stats.FieldDmgTeam: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDmgTeam(v) - return nil - case stats.FieldUdHe: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUdHe(v) - return nil - case stats.FieldUdFlames: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUdFlames(v) - return nil - case stats.FieldUdFlash: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUdFlash(v) - return nil - case stats.FieldUdDecoy: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUdDecoy(v) - return nil - case stats.FieldUdSmoke: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUdSmoke(v) - return nil - case stats.FieldCrosshair: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCrosshair(v) - return nil - case stats.FieldColor: - v, ok := value.(stats.Color) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetColor(v) - return nil - case stats.FieldKast: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetKast(v) - return nil - case stats.FieldFlashDurationSelf: - v, ok := value.(float32) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetFlashDurationSelf(v) - return nil - case stats.FieldFlashDurationTeam: - v, ok := value.(float32) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetFlashDurationTeam(v) - return nil - case stats.FieldFlashDurationEnemy: - v, ok := value.(float32) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetFlashDurationEnemy(v) - return nil - case stats.FieldFlashTotalSelf: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetFlashTotalSelf(v) - return nil - case stats.FieldFlashTotalTeam: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetFlashTotalTeam(v) - return nil - case stats.FieldFlashTotalEnemy: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetFlashTotalEnemy(v) - return nil - case stats.FieldMatchStats: - v, ok := value.(uint64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetMatchStats(v) - return nil - case stats.FieldPlayerStats: - v, ok := value.(uint64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPlayerStats(v) + m.SetSpray(v) return nil } - return fmt.Errorf("unknown Stats field %s", name) + return fmt.Errorf("unknown Spray field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *StatsMutation) AddedFields() []string { +func (m *SprayMutation) AddedFields() []string { var fields []string - if m.addteam_id != nil { - fields = append(fields, stats.FieldTeamID) - } - if m.addkills != nil { - fields = append(fields, stats.FieldKills) - } - if m.adddeaths != nil { - fields = append(fields, stats.FieldDeaths) - } - if m.addassists != nil { - fields = append(fields, stats.FieldAssists) - } - if m.addheadshot != nil { - fields = append(fields, stats.FieldHeadshot) - } - if m.addmvp != nil { - fields = append(fields, stats.FieldMvp) - } - if m.addscore != nil { - fields = append(fields, stats.FieldScore) - } - if m.addrank_new != nil { - fields = append(fields, stats.FieldRankNew) - } - if m.addrank_old != nil { - fields = append(fields, stats.FieldRankOld) - } - if m.addmk_2 != nil { - fields = append(fields, stats.FieldMk2) - } - if m.addmk_3 != nil { - fields = append(fields, stats.FieldMk3) - } - if m.addmk_4 != nil { - fields = append(fields, stats.FieldMk4) - } - if m.addmk_5 != nil { - fields = append(fields, stats.FieldMk5) - } - if m.adddmg_enemy != nil { - fields = append(fields, stats.FieldDmgEnemy) - } - if m.adddmg_team != nil { - fields = append(fields, stats.FieldDmgTeam) - } - if m.addud_he != nil { - fields = append(fields, stats.FieldUdHe) - } - if m.addud_flames != nil { - fields = append(fields, stats.FieldUdFlames) - } - if m.addud_flash != nil { - fields = append(fields, stats.FieldUdFlash) - } - if m.addud_decoy != nil { - fields = append(fields, stats.FieldUdDecoy) - } - if m.addud_smoke != nil { - fields = append(fields, stats.FieldUdSmoke) - } - if m.addkast != nil { - fields = append(fields, stats.FieldKast) - } - if m.addflash_duration_self != nil { - fields = append(fields, stats.FieldFlashDurationSelf) - } - if m.addflash_duration_team != nil { - fields = append(fields, stats.FieldFlashDurationTeam) - } - if m.addflash_duration_enemy != nil { - fields = append(fields, stats.FieldFlashDurationEnemy) - } - if m.addflash_total_self != nil { - fields = append(fields, stats.FieldFlashTotalSelf) - } - if m.addflash_total_team != nil { - fields = append(fields, stats.FieldFlashTotalTeam) - } - if m.addflash_total_enemy != nil { - fields = append(fields, stats.FieldFlashTotalEnemy) + if m.addweapon != nil { + fields = append(fields, spray.FieldWeapon) } return fields } @@ -6298,62 +7800,10 @@ func (m *StatsMutation) AddedFields() []string { // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *StatsMutation) AddedField(name string) (ent.Value, bool) { +func (m *SprayMutation) AddedField(name string) (ent.Value, bool) { switch name { - case stats.FieldTeamID: - return m.AddedTeamID() - case stats.FieldKills: - return m.AddedKills() - case stats.FieldDeaths: - return m.AddedDeaths() - case stats.FieldAssists: - return m.AddedAssists() - case stats.FieldHeadshot: - return m.AddedHeadshot() - case stats.FieldMvp: - return m.AddedMvp() - case stats.FieldScore: - return m.AddedScore() - case stats.FieldRankNew: - return m.AddedRankNew() - case stats.FieldRankOld: - return m.AddedRankOld() - case stats.FieldMk2: - return m.AddedMk2() - case stats.FieldMk3: - return m.AddedMk3() - case stats.FieldMk4: - return m.AddedMk4() - case stats.FieldMk5: - return m.AddedMk5() - case stats.FieldDmgEnemy: - return m.AddedDmgEnemy() - case stats.FieldDmgTeam: - return m.AddedDmgTeam() - case stats.FieldUdHe: - return m.AddedUdHe() - case stats.FieldUdFlames: - return m.AddedUdFlames() - case stats.FieldUdFlash: - return m.AddedUdFlash() - case stats.FieldUdDecoy: - return m.AddedUdDecoy() - case stats.FieldUdSmoke: - return m.AddedUdSmoke() - case stats.FieldKast: - return m.AddedKast() - case stats.FieldFlashDurationSelf: - return m.AddedFlashDurationSelf() - case stats.FieldFlashDurationTeam: - return m.AddedFlashDurationTeam() - case stats.FieldFlashDurationEnemy: - return m.AddedFlashDurationEnemy() - case stats.FieldFlashTotalSelf: - return m.AddedFlashTotalSelf() - case stats.FieldFlashTotalTeam: - return m.AddedFlashTotalTeam() - case stats.FieldFlashTotalEnemy: - return m.AddedFlashTotalEnemy() + case spray.FieldWeapon: + return m.AddedWeapon() } return nil, false } @@ -6361,616 +7811,130 @@ func (m *StatsMutation) AddedField(name string) (ent.Value, bool) { // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *StatsMutation) AddField(name string, value ent.Value) error { +func (m *SprayMutation) AddField(name string, value ent.Value) error { switch name { - case stats.FieldTeamID: + case spray.FieldWeapon: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.AddTeamID(v) - return nil - case stats.FieldKills: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddKills(v) - return nil - case stats.FieldDeaths: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddDeaths(v) - return nil - case stats.FieldAssists: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddAssists(v) - return nil - case stats.FieldHeadshot: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddHeadshot(v) - return nil - case stats.FieldMvp: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddMvp(v) - return nil - case stats.FieldScore: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddScore(v) - return nil - case stats.FieldRankNew: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddRankNew(v) - return nil - case stats.FieldRankOld: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddRankOld(v) - return nil - case stats.FieldMk2: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddMk2(v) - return nil - case stats.FieldMk3: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddMk3(v) - return nil - case stats.FieldMk4: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddMk4(v) - return nil - case stats.FieldMk5: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddMk5(v) - return nil - case stats.FieldDmgEnemy: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddDmgEnemy(v) - return nil - case stats.FieldDmgTeam: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddDmgTeam(v) - return nil - case stats.FieldUdHe: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddUdHe(v) - return nil - case stats.FieldUdFlames: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddUdFlames(v) - return nil - case stats.FieldUdFlash: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddUdFlash(v) - return nil - case stats.FieldUdDecoy: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddUdDecoy(v) - return nil - case stats.FieldUdSmoke: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddUdSmoke(v) - return nil - case stats.FieldKast: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddKast(v) - return nil - case stats.FieldFlashDurationSelf: - v, ok := value.(float32) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddFlashDurationSelf(v) - return nil - case stats.FieldFlashDurationTeam: - v, ok := value.(float32) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddFlashDurationTeam(v) - return nil - case stats.FieldFlashDurationEnemy: - v, ok := value.(float32) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddFlashDurationEnemy(v) - return nil - case stats.FieldFlashTotalSelf: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddFlashTotalSelf(v) - return nil - case stats.FieldFlashTotalTeam: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddFlashTotalTeam(v) - return nil - case stats.FieldFlashTotalEnemy: - v, ok := value.(uint) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddFlashTotalEnemy(v) + m.AddWeapon(v) return nil } - return fmt.Errorf("unknown Stats numeric field %s", name) + return fmt.Errorf("unknown Spray numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *StatsMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(stats.FieldRankNew) { - fields = append(fields, stats.FieldRankNew) - } - if m.FieldCleared(stats.FieldRankOld) { - fields = append(fields, stats.FieldRankOld) - } - if m.FieldCleared(stats.FieldMk2) { - fields = append(fields, stats.FieldMk2) - } - if m.FieldCleared(stats.FieldMk3) { - fields = append(fields, stats.FieldMk3) - } - if m.FieldCleared(stats.FieldMk4) { - fields = append(fields, stats.FieldMk4) - } - if m.FieldCleared(stats.FieldMk5) { - fields = append(fields, stats.FieldMk5) - } - if m.FieldCleared(stats.FieldDmgEnemy) { - fields = append(fields, stats.FieldDmgEnemy) - } - if m.FieldCleared(stats.FieldDmgTeam) { - fields = append(fields, stats.FieldDmgTeam) - } - if m.FieldCleared(stats.FieldUdHe) { - fields = append(fields, stats.FieldUdHe) - } - if m.FieldCleared(stats.FieldUdFlames) { - fields = append(fields, stats.FieldUdFlames) - } - if m.FieldCleared(stats.FieldUdFlash) { - fields = append(fields, stats.FieldUdFlash) - } - if m.FieldCleared(stats.FieldUdDecoy) { - fields = append(fields, stats.FieldUdDecoy) - } - if m.FieldCleared(stats.FieldUdSmoke) { - fields = append(fields, stats.FieldUdSmoke) - } - if m.FieldCleared(stats.FieldCrosshair) { - fields = append(fields, stats.FieldCrosshair) - } - if m.FieldCleared(stats.FieldColor) { - fields = append(fields, stats.FieldColor) - } - if m.FieldCleared(stats.FieldKast) { - fields = append(fields, stats.FieldKast) - } - if m.FieldCleared(stats.FieldFlashDurationSelf) { - fields = append(fields, stats.FieldFlashDurationSelf) - } - if m.FieldCleared(stats.FieldFlashDurationTeam) { - fields = append(fields, stats.FieldFlashDurationTeam) - } - if m.FieldCleared(stats.FieldFlashDurationEnemy) { - fields = append(fields, stats.FieldFlashDurationEnemy) - } - if m.FieldCleared(stats.FieldFlashTotalSelf) { - fields = append(fields, stats.FieldFlashTotalSelf) - } - if m.FieldCleared(stats.FieldFlashTotalTeam) { - fields = append(fields, stats.FieldFlashTotalTeam) - } - if m.FieldCleared(stats.FieldFlashTotalEnemy) { - fields = append(fields, stats.FieldFlashTotalEnemy) - } - if m.FieldCleared(stats.FieldMatchStats) { - fields = append(fields, stats.FieldMatchStats) - } - if m.FieldCleared(stats.FieldPlayerStats) { - fields = append(fields, stats.FieldPlayerStats) - } - return fields +func (m *SprayMutation) ClearedFields() []string { + return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *StatsMutation) FieldCleared(name string) bool { +func (m *SprayMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *StatsMutation) ClearField(name string) error { - switch name { - case stats.FieldRankNew: - m.ClearRankNew() - return nil - case stats.FieldRankOld: - m.ClearRankOld() - return nil - case stats.FieldMk2: - m.ClearMk2() - return nil - case stats.FieldMk3: - m.ClearMk3() - return nil - case stats.FieldMk4: - m.ClearMk4() - return nil - case stats.FieldMk5: - m.ClearMk5() - return nil - case stats.FieldDmgEnemy: - m.ClearDmgEnemy() - return nil - case stats.FieldDmgTeam: - m.ClearDmgTeam() - return nil - case stats.FieldUdHe: - m.ClearUdHe() - return nil - case stats.FieldUdFlames: - m.ClearUdFlames() - return nil - case stats.FieldUdFlash: - m.ClearUdFlash() - return nil - case stats.FieldUdDecoy: - m.ClearUdDecoy() - return nil - case stats.FieldUdSmoke: - m.ClearUdSmoke() - return nil - case stats.FieldCrosshair: - m.ClearCrosshair() - return nil - case stats.FieldColor: - m.ClearColor() - return nil - case stats.FieldKast: - m.ClearKast() - return nil - case stats.FieldFlashDurationSelf: - m.ClearFlashDurationSelf() - return nil - case stats.FieldFlashDurationTeam: - m.ClearFlashDurationTeam() - return nil - case stats.FieldFlashDurationEnemy: - m.ClearFlashDurationEnemy() - return nil - case stats.FieldFlashTotalSelf: - m.ClearFlashTotalSelf() - return nil - case stats.FieldFlashTotalTeam: - m.ClearFlashTotalTeam() - return nil - case stats.FieldFlashTotalEnemy: - m.ClearFlashTotalEnemy() - return nil - case stats.FieldMatchStats: - m.ClearMatchStats() - return nil - case stats.FieldPlayerStats: - m.ClearPlayerStats() - return nil - } - return fmt.Errorf("unknown Stats nullable field %s", name) +func (m *SprayMutation) ClearField(name string) error { + return fmt.Errorf("unknown Spray nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *StatsMutation) ResetField(name string) error { +func (m *SprayMutation) ResetField(name string) error { switch name { - case stats.FieldTeamID: - m.ResetTeamID() + case spray.FieldWeapon: + m.ResetWeapon() return nil - case stats.FieldKills: - m.ResetKills() - return nil - case stats.FieldDeaths: - m.ResetDeaths() - return nil - case stats.FieldAssists: - m.ResetAssists() - return nil - case stats.FieldHeadshot: - m.ResetHeadshot() - return nil - case stats.FieldMvp: - m.ResetMvp() - return nil - case stats.FieldScore: - m.ResetScore() - return nil - case stats.FieldRankNew: - m.ResetRankNew() - return nil - case stats.FieldRankOld: - m.ResetRankOld() - return nil - case stats.FieldMk2: - m.ResetMk2() - return nil - case stats.FieldMk3: - m.ResetMk3() - return nil - case stats.FieldMk4: - m.ResetMk4() - return nil - case stats.FieldMk5: - m.ResetMk5() - return nil - case stats.FieldDmgEnemy: - m.ResetDmgEnemy() - return nil - case stats.FieldDmgTeam: - m.ResetDmgTeam() - return nil - case stats.FieldUdHe: - m.ResetUdHe() - return nil - case stats.FieldUdFlames: - m.ResetUdFlames() - return nil - case stats.FieldUdFlash: - m.ResetUdFlash() - return nil - case stats.FieldUdDecoy: - m.ResetUdDecoy() - return nil - case stats.FieldUdSmoke: - m.ResetUdSmoke() - return nil - case stats.FieldCrosshair: - m.ResetCrosshair() - return nil - case stats.FieldColor: - m.ResetColor() - return nil - case stats.FieldKast: - m.ResetKast() - return nil - case stats.FieldFlashDurationSelf: - m.ResetFlashDurationSelf() - return nil - case stats.FieldFlashDurationTeam: - m.ResetFlashDurationTeam() - return nil - case stats.FieldFlashDurationEnemy: - m.ResetFlashDurationEnemy() - return nil - case stats.FieldFlashTotalSelf: - m.ResetFlashTotalSelf() - return nil - case stats.FieldFlashTotalTeam: - m.ResetFlashTotalTeam() - return nil - case stats.FieldFlashTotalEnemy: - m.ResetFlashTotalEnemy() - return nil - case stats.FieldMatchStats: - m.ResetMatchStats() - return nil - case stats.FieldPlayerStats: - m.ResetPlayerStats() + case spray.FieldSpray: + m.ResetSpray() return nil } - return fmt.Errorf("unknown Stats field %s", name) + return fmt.Errorf("unknown Spray field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *StatsMutation) AddedEdges() []string { - edges := make([]string, 0, 4) - if m.matches != nil { - edges = append(edges, stats.EdgeMatches) - } - if m.players != nil { - edges = append(edges, stats.EdgePlayers) - } - if m.weapon_stats != nil { - edges = append(edges, stats.EdgeWeaponStats) - } - if m.round_stats != nil { - edges = append(edges, stats.EdgeRoundStats) +func (m *SprayMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.match_players != nil { + edges = append(edges, spray.EdgeMatchPlayers) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *StatsMutation) AddedIDs(name string) []ent.Value { +func (m *SprayMutation) AddedIDs(name string) []ent.Value { switch name { - case stats.EdgeMatches: - if id := m.matches; id != nil { + case spray.EdgeMatchPlayers: + if id := m.match_players; id != nil { return []ent.Value{*id} } - case stats.EdgePlayers: - if id := m.players; id != nil { - return []ent.Value{*id} - } - case stats.EdgeWeaponStats: - ids := make([]ent.Value, 0, len(m.weapon_stats)) - for id := range m.weapon_stats { - ids = append(ids, id) - } - return ids - case stats.EdgeRoundStats: - ids := make([]ent.Value, 0, len(m.round_stats)) - for id := range m.round_stats { - ids = append(ids, id) - } - return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *StatsMutation) RemovedEdges() []string { - edges := make([]string, 0, 4) - if m.removedweapon_stats != nil { - edges = append(edges, stats.EdgeWeaponStats) - } - if m.removedround_stats != nil { - edges = append(edges, stats.EdgeRoundStats) - } +func (m *SprayMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *StatsMutation) RemovedIDs(name string) []ent.Value { +func (m *SprayMutation) RemovedIDs(name string) []ent.Value { switch name { - case stats.EdgeWeaponStats: - ids := make([]ent.Value, 0, len(m.removedweapon_stats)) - for id := range m.removedweapon_stats { - ids = append(ids, id) - } - return ids - case stats.EdgeRoundStats: - ids := make([]ent.Value, 0, len(m.removedround_stats)) - for id := range m.removedround_stats { - ids = append(ids, id) - } - return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *StatsMutation) ClearedEdges() []string { - edges := make([]string, 0, 4) - if m.clearedmatches { - edges = append(edges, stats.EdgeMatches) - } - if m.clearedplayers { - edges = append(edges, stats.EdgePlayers) - } - if m.clearedweapon_stats { - edges = append(edges, stats.EdgeWeaponStats) - } - if m.clearedround_stats { - edges = append(edges, stats.EdgeRoundStats) +func (m *SprayMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedmatch_players { + edges = append(edges, spray.EdgeMatchPlayers) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *StatsMutation) EdgeCleared(name string) bool { +func (m *SprayMutation) EdgeCleared(name string) bool { switch name { - case stats.EdgeMatches: - return m.clearedmatches - case stats.EdgePlayers: - return m.clearedplayers - case stats.EdgeWeaponStats: - return m.clearedweapon_stats - case stats.EdgeRoundStats: - return m.clearedround_stats + case spray.EdgeMatchPlayers: + return m.clearedmatch_players } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *StatsMutation) ClearEdge(name string) error { +func (m *SprayMutation) ClearEdge(name string) error { switch name { - case stats.EdgeMatches: - m.ClearMatches() - return nil - case stats.EdgePlayers: - m.ClearPlayers() + case spray.EdgeMatchPlayers: + m.ClearMatchPlayers() return nil } - return fmt.Errorf("unknown Stats unique edge %s", name) + return fmt.Errorf("unknown Spray unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *StatsMutation) ResetEdge(name string) error { +func (m *SprayMutation) ResetEdge(name string) error { switch name { - case stats.EdgeMatches: - m.ResetMatches() - return nil - case stats.EdgePlayers: - m.ResetPlayers() - return nil - case stats.EdgeWeaponStats: - m.ResetWeaponStats() - return nil - case stats.EdgeRoundStats: - m.ResetRoundStats() + case spray.EdgeMatchPlayers: + m.ResetMatchPlayers() return nil } - return fmt.Errorf("unknown Stats edge %s", name) + return fmt.Errorf("unknown Spray edge %s", name) } -// WeaponStatsMutation represents an operation that mutates the WeaponStats nodes in the graph. -type WeaponStatsMutation struct { +// WeaponMutation represents an operation that mutates the Weapon nodes in the graph. +type WeaponMutation struct { config op Op typ string @@ -6987,21 +7951,21 @@ type WeaponStatsMutation struct { stat *int clearedstat bool done bool - oldValue func(context.Context) (*WeaponStats, error) - predicates []predicate.WeaponStats + oldValue func(context.Context) (*Weapon, error) + predicates []predicate.Weapon } -var _ ent.Mutation = (*WeaponStatsMutation)(nil) +var _ ent.Mutation = (*WeaponMutation)(nil) -// weaponstatsOption allows management of the mutation configuration using functional options. -type weaponstatsOption func(*WeaponStatsMutation) +// weaponOption allows management of the mutation configuration using functional options. +type weaponOption func(*WeaponMutation) -// newWeaponStatsMutation creates new mutation for the WeaponStats entity. -func newWeaponStatsMutation(c config, op Op, opts ...weaponstatsOption) *WeaponStatsMutation { - m := &WeaponStatsMutation{ +// newWeaponMutation creates new mutation for the Weapon entity. +func newWeaponMutation(c config, op Op, opts ...weaponOption) *WeaponMutation { + m := &WeaponMutation{ config: c, op: op, - typ: TypeWeaponStats, + typ: TypeWeapon, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -7010,20 +7974,20 @@ func newWeaponStatsMutation(c config, op Op, opts ...weaponstatsOption) *WeaponS return m } -// withWeaponStatsID sets the ID field of the mutation. -func withWeaponStatsID(id int) weaponstatsOption { - return func(m *WeaponStatsMutation) { +// withWeaponID sets the ID field of the mutation. +func withWeaponID(id int) weaponOption { + return func(m *WeaponMutation) { var ( err error once sync.Once - value *WeaponStats + value *Weapon ) - m.oldValue = func(ctx context.Context) (*WeaponStats, error) { + m.oldValue = func(ctx context.Context) (*Weapon, error) { once.Do(func() { if m.done { err = fmt.Errorf("querying old values post mutation is not allowed") } else { - value, err = m.Client().WeaponStats.Get(ctx, id) + value, err = m.Client().Weapon.Get(ctx, id) } }) return value, err @@ -7032,10 +7996,10 @@ func withWeaponStatsID(id int) weaponstatsOption { } } -// withWeaponStats sets the old WeaponStats of the mutation. -func withWeaponStats(node *WeaponStats) weaponstatsOption { - return func(m *WeaponStatsMutation) { - m.oldValue = func(context.Context) (*WeaponStats, error) { +// withWeapon sets the old Weapon of the mutation. +func withWeapon(node *Weapon) weaponOption { + return func(m *WeaponMutation) { + m.oldValue = func(context.Context) (*Weapon, error) { return node, nil } m.id = &node.ID @@ -7044,7 +8008,7 @@ func withWeaponStats(node *WeaponStats) weaponstatsOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m WeaponStatsMutation) Client() *Client { +func (m WeaponMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -7052,7 +8016,7 @@ func (m WeaponStatsMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m WeaponStatsMutation) Tx() (*Tx, error) { +func (m WeaponMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, fmt.Errorf("ent: mutation is not running in a transaction") } @@ -7063,7 +8027,7 @@ func (m WeaponStatsMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *WeaponStatsMutation) ID() (id int, exists bool) { +func (m *WeaponMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -7071,13 +8035,13 @@ func (m *WeaponStatsMutation) ID() (id int, exists bool) { } // SetVictim sets the "victim" field. -func (m *WeaponStatsMutation) SetVictim(u uint64) { +func (m *WeaponMutation) SetVictim(u uint64) { m.victim = &u m.addvictim = nil } // Victim returns the value of the "victim" field in the mutation. -func (m *WeaponStatsMutation) Victim() (r uint64, exists bool) { +func (m *WeaponMutation) Victim() (r uint64, exists bool) { v := m.victim if v == nil { return @@ -7085,10 +8049,10 @@ func (m *WeaponStatsMutation) Victim() (r uint64, exists bool) { return *v, true } -// OldVictim returns the old "victim" field's value of the WeaponStats entity. -// If the WeaponStats object wasn't provided to the builder, the object is fetched from the database. +// OldVictim returns the old "victim" field's value of the Weapon entity. +// If the Weapon object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *WeaponStatsMutation) OldVictim(ctx context.Context) (v uint64, err error) { +func (m *WeaponMutation) OldVictim(ctx context.Context) (v uint64, err error) { if !m.op.Is(OpUpdateOne) { return v, fmt.Errorf("OldVictim is only allowed on UpdateOne operations") } @@ -7103,7 +8067,7 @@ func (m *WeaponStatsMutation) OldVictim(ctx context.Context) (v uint64, err erro } // AddVictim adds u to the "victim" field. -func (m *WeaponStatsMutation) AddVictim(u uint64) { +func (m *WeaponMutation) AddVictim(u uint64) { if m.addvictim != nil { *m.addvictim += u } else { @@ -7112,7 +8076,7 @@ func (m *WeaponStatsMutation) AddVictim(u uint64) { } // AddedVictim returns the value that was added to the "victim" field in this mutation. -func (m *WeaponStatsMutation) AddedVictim() (r uint64, exists bool) { +func (m *WeaponMutation) AddedVictim() (r uint64, exists bool) { v := m.addvictim if v == nil { return @@ -7121,19 +8085,19 @@ func (m *WeaponStatsMutation) AddedVictim() (r uint64, exists bool) { } // ResetVictim resets all changes to the "victim" field. -func (m *WeaponStatsMutation) ResetVictim() { +func (m *WeaponMutation) ResetVictim() { m.victim = nil m.addvictim = nil } // SetDmg sets the "dmg" field. -func (m *WeaponStatsMutation) SetDmg(u uint) { +func (m *WeaponMutation) SetDmg(u uint) { m.dmg = &u m.adddmg = nil } // Dmg returns the value of the "dmg" field in the mutation. -func (m *WeaponStatsMutation) Dmg() (r uint, exists bool) { +func (m *WeaponMutation) Dmg() (r uint, exists bool) { v := m.dmg if v == nil { return @@ -7141,10 +8105,10 @@ func (m *WeaponStatsMutation) Dmg() (r uint, exists bool) { return *v, true } -// OldDmg returns the old "dmg" field's value of the WeaponStats entity. -// If the WeaponStats object wasn't provided to the builder, the object is fetched from the database. +// OldDmg returns the old "dmg" field's value of the Weapon entity. +// If the Weapon object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *WeaponStatsMutation) OldDmg(ctx context.Context) (v uint, err error) { +func (m *WeaponMutation) OldDmg(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, fmt.Errorf("OldDmg is only allowed on UpdateOne operations") } @@ -7159,7 +8123,7 @@ func (m *WeaponStatsMutation) OldDmg(ctx context.Context) (v uint, err error) { } // AddDmg adds u to the "dmg" field. -func (m *WeaponStatsMutation) AddDmg(u uint) { +func (m *WeaponMutation) AddDmg(u uint) { if m.adddmg != nil { *m.adddmg += u } else { @@ -7168,7 +8132,7 @@ func (m *WeaponStatsMutation) AddDmg(u uint) { } // AddedDmg returns the value that was added to the "dmg" field in this mutation. -func (m *WeaponStatsMutation) AddedDmg() (r uint, exists bool) { +func (m *WeaponMutation) AddedDmg() (r uint, exists bool) { v := m.adddmg if v == nil { return @@ -7177,19 +8141,19 @@ func (m *WeaponStatsMutation) AddedDmg() (r uint, exists bool) { } // ResetDmg resets all changes to the "dmg" field. -func (m *WeaponStatsMutation) ResetDmg() { +func (m *WeaponMutation) ResetDmg() { m.dmg = nil m.adddmg = nil } // SetEqType sets the "eq_type" field. -func (m *WeaponStatsMutation) SetEqType(i int) { +func (m *WeaponMutation) SetEqType(i int) { m.eq_type = &i m.addeq_type = nil } // EqType returns the value of the "eq_type" field in the mutation. -func (m *WeaponStatsMutation) EqType() (r int, exists bool) { +func (m *WeaponMutation) EqType() (r int, exists bool) { v := m.eq_type if v == nil { return @@ -7197,10 +8161,10 @@ func (m *WeaponStatsMutation) EqType() (r int, exists bool) { return *v, true } -// OldEqType returns the old "eq_type" field's value of the WeaponStats entity. -// If the WeaponStats object wasn't provided to the builder, the object is fetched from the database. +// OldEqType returns the old "eq_type" field's value of the Weapon entity. +// If the Weapon object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *WeaponStatsMutation) OldEqType(ctx context.Context) (v int, err error) { +func (m *WeaponMutation) OldEqType(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, fmt.Errorf("OldEqType is only allowed on UpdateOne operations") } @@ -7215,7 +8179,7 @@ func (m *WeaponStatsMutation) OldEqType(ctx context.Context) (v int, err error) } // AddEqType adds i to the "eq_type" field. -func (m *WeaponStatsMutation) AddEqType(i int) { +func (m *WeaponMutation) AddEqType(i int) { if m.addeq_type != nil { *m.addeq_type += i } else { @@ -7224,7 +8188,7 @@ func (m *WeaponStatsMutation) AddEqType(i int) { } // AddedEqType returns the value that was added to the "eq_type" field in this mutation. -func (m *WeaponStatsMutation) AddedEqType() (r int, exists bool) { +func (m *WeaponMutation) AddedEqType() (r int, exists bool) { v := m.addeq_type if v == nil { return @@ -7233,19 +8197,19 @@ func (m *WeaponStatsMutation) AddedEqType() (r int, exists bool) { } // ResetEqType resets all changes to the "eq_type" field. -func (m *WeaponStatsMutation) ResetEqType() { +func (m *WeaponMutation) ResetEqType() { m.eq_type = nil m.addeq_type = nil } // SetHitGroup sets the "hit_group" field. -func (m *WeaponStatsMutation) SetHitGroup(i int) { +func (m *WeaponMutation) SetHitGroup(i int) { m.hit_group = &i m.addhit_group = nil } // HitGroup returns the value of the "hit_group" field in the mutation. -func (m *WeaponStatsMutation) HitGroup() (r int, exists bool) { +func (m *WeaponMutation) HitGroup() (r int, exists bool) { v := m.hit_group if v == nil { return @@ -7253,10 +8217,10 @@ func (m *WeaponStatsMutation) HitGroup() (r int, exists bool) { return *v, true } -// OldHitGroup returns the old "hit_group" field's value of the WeaponStats entity. -// If the WeaponStats object wasn't provided to the builder, the object is fetched from the database. +// OldHitGroup returns the old "hit_group" field's value of the Weapon entity. +// If the Weapon object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *WeaponStatsMutation) OldHitGroup(ctx context.Context) (v int, err error) { +func (m *WeaponMutation) OldHitGroup(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, fmt.Errorf("OldHitGroup is only allowed on UpdateOne operations") } @@ -7271,7 +8235,7 @@ func (m *WeaponStatsMutation) OldHitGroup(ctx context.Context) (v int, err error } // AddHitGroup adds i to the "hit_group" field. -func (m *WeaponStatsMutation) AddHitGroup(i int) { +func (m *WeaponMutation) AddHitGroup(i int) { if m.addhit_group != nil { *m.addhit_group += i } else { @@ -7280,7 +8244,7 @@ func (m *WeaponStatsMutation) AddHitGroup(i int) { } // AddedHitGroup returns the value that was added to the "hit_group" field in this mutation. -func (m *WeaponStatsMutation) AddedHitGroup() (r int, exists bool) { +func (m *WeaponMutation) AddedHitGroup() (r int, exists bool) { v := m.addhit_group if v == nil { return @@ -7289,28 +8253,28 @@ func (m *WeaponStatsMutation) AddedHitGroup() (r int, exists bool) { } // ResetHitGroup resets all changes to the "hit_group" field. -func (m *WeaponStatsMutation) ResetHitGroup() { +func (m *WeaponMutation) ResetHitGroup() { m.hit_group = nil m.addhit_group = nil } -// SetStatID sets the "stat" edge to the Stats entity by id. -func (m *WeaponStatsMutation) SetStatID(id int) { +// SetStatID sets the "stat" edge to the MatchPlayer entity by id. +func (m *WeaponMutation) SetStatID(id int) { m.stat = &id } -// ClearStat clears the "stat" edge to the Stats entity. -func (m *WeaponStatsMutation) ClearStat() { +// ClearStat clears the "stat" edge to the MatchPlayer entity. +func (m *WeaponMutation) ClearStat() { m.clearedstat = true } -// StatCleared reports if the "stat" edge to the Stats entity was cleared. -func (m *WeaponStatsMutation) StatCleared() bool { +// StatCleared reports if the "stat" edge to the MatchPlayer entity was cleared. +func (m *WeaponMutation) StatCleared() bool { return m.clearedstat } // StatID returns the "stat" edge ID in the mutation. -func (m *WeaponStatsMutation) StatID() (id int, exists bool) { +func (m *WeaponMutation) StatID() (id int, exists bool) { if m.stat != nil { return *m.stat, true } @@ -7320,7 +8284,7 @@ func (m *WeaponStatsMutation) StatID() (id int, exists bool) { // StatIDs returns the "stat" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // StatID instead. It exists only for internal usage by the builders. -func (m *WeaponStatsMutation) StatIDs() (ids []int) { +func (m *WeaponMutation) StatIDs() (ids []int) { if id := m.stat; id != nil { ids = append(ids, *id) } @@ -7328,42 +8292,42 @@ func (m *WeaponStatsMutation) StatIDs() (ids []int) { } // ResetStat resets all changes to the "stat" edge. -func (m *WeaponStatsMutation) ResetStat() { +func (m *WeaponMutation) ResetStat() { m.stat = nil m.clearedstat = false } -// Where appends a list predicates to the WeaponStatsMutation builder. -func (m *WeaponStatsMutation) Where(ps ...predicate.WeaponStats) { +// Where appends a list predicates to the WeaponMutation builder. +func (m *WeaponMutation) Where(ps ...predicate.Weapon) { m.predicates = append(m.predicates, ps...) } // Op returns the operation name. -func (m *WeaponStatsMutation) Op() Op { +func (m *WeaponMutation) Op() Op { return m.op } -// Type returns the node type of this mutation (WeaponStats). -func (m *WeaponStatsMutation) Type() string { +// Type returns the node type of this mutation (Weapon). +func (m *WeaponMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *WeaponStatsMutation) Fields() []string { +func (m *WeaponMutation) Fields() []string { fields := make([]string, 0, 4) if m.victim != nil { - fields = append(fields, weaponstats.FieldVictim) + fields = append(fields, weapon.FieldVictim) } if m.dmg != nil { - fields = append(fields, weaponstats.FieldDmg) + fields = append(fields, weapon.FieldDmg) } if m.eq_type != nil { - fields = append(fields, weaponstats.FieldEqType) + fields = append(fields, weapon.FieldEqType) } if m.hit_group != nil { - fields = append(fields, weaponstats.FieldHitGroup) + fields = append(fields, weapon.FieldHitGroup) } return fields } @@ -7371,15 +8335,15 @@ func (m *WeaponStatsMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *WeaponStatsMutation) Field(name string) (ent.Value, bool) { +func (m *WeaponMutation) Field(name string) (ent.Value, bool) { switch name { - case weaponstats.FieldVictim: + case weapon.FieldVictim: return m.Victim() - case weaponstats.FieldDmg: + case weapon.FieldDmg: return m.Dmg() - case weaponstats.FieldEqType: + case weapon.FieldEqType: return m.EqType() - case weaponstats.FieldHitGroup: + case weapon.FieldHitGroup: return m.HitGroup() } return nil, false @@ -7388,47 +8352,47 @@ func (m *WeaponStatsMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *WeaponStatsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *WeaponMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case weaponstats.FieldVictim: + case weapon.FieldVictim: return m.OldVictim(ctx) - case weaponstats.FieldDmg: + case weapon.FieldDmg: return m.OldDmg(ctx) - case weaponstats.FieldEqType: + case weapon.FieldEqType: return m.OldEqType(ctx) - case weaponstats.FieldHitGroup: + case weapon.FieldHitGroup: return m.OldHitGroup(ctx) } - return nil, fmt.Errorf("unknown WeaponStats field %s", name) + return nil, fmt.Errorf("unknown Weapon field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *WeaponStatsMutation) SetField(name string, value ent.Value) error { +func (m *WeaponMutation) SetField(name string, value ent.Value) error { switch name { - case weaponstats.FieldVictim: + case weapon.FieldVictim: v, ok := value.(uint64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetVictim(v) return nil - case weaponstats.FieldDmg: + case weapon.FieldDmg: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDmg(v) return nil - case weaponstats.FieldEqType: + case weapon.FieldEqType: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetEqType(v) return nil - case weaponstats.FieldHitGroup: + case weapon.FieldHitGroup: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) @@ -7436,24 +8400,24 @@ func (m *WeaponStatsMutation) SetField(name string, value ent.Value) error { m.SetHitGroup(v) return nil } - return fmt.Errorf("unknown WeaponStats field %s", name) + return fmt.Errorf("unknown Weapon field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *WeaponStatsMutation) AddedFields() []string { +func (m *WeaponMutation) AddedFields() []string { var fields []string if m.addvictim != nil { - fields = append(fields, weaponstats.FieldVictim) + fields = append(fields, weapon.FieldVictim) } if m.adddmg != nil { - fields = append(fields, weaponstats.FieldDmg) + fields = append(fields, weapon.FieldDmg) } if m.addeq_type != nil { - fields = append(fields, weaponstats.FieldEqType) + fields = append(fields, weapon.FieldEqType) } if m.addhit_group != nil { - fields = append(fields, weaponstats.FieldHitGroup) + fields = append(fields, weapon.FieldHitGroup) } return fields } @@ -7461,15 +8425,15 @@ func (m *WeaponStatsMutation) AddedFields() []string { // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *WeaponStatsMutation) AddedField(name string) (ent.Value, bool) { +func (m *WeaponMutation) AddedField(name string) (ent.Value, bool) { switch name { - case weaponstats.FieldVictim: + case weapon.FieldVictim: return m.AddedVictim() - case weaponstats.FieldDmg: + case weapon.FieldDmg: return m.AddedDmg() - case weaponstats.FieldEqType: + case weapon.FieldEqType: return m.AddedEqType() - case weaponstats.FieldHitGroup: + case weapon.FieldHitGroup: return m.AddedHitGroup() } return nil, false @@ -7478,30 +8442,30 @@ func (m *WeaponStatsMutation) AddedField(name string) (ent.Value, bool) { // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *WeaponStatsMutation) AddField(name string, value ent.Value) error { +func (m *WeaponMutation) AddField(name string, value ent.Value) error { switch name { - case weaponstats.FieldVictim: + case weapon.FieldVictim: v, ok := value.(uint64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddVictim(v) return nil - case weaponstats.FieldDmg: + case weapon.FieldDmg: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddDmg(v) return nil - case weaponstats.FieldEqType: + case weapon.FieldEqType: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddEqType(v) return nil - case weaponstats.FieldHitGroup: + case weapon.FieldHitGroup: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) @@ -7509,62 +8473,62 @@ func (m *WeaponStatsMutation) AddField(name string, value ent.Value) error { m.AddHitGroup(v) return nil } - return fmt.Errorf("unknown WeaponStats numeric field %s", name) + return fmt.Errorf("unknown Weapon numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *WeaponStatsMutation) ClearedFields() []string { +func (m *WeaponMutation) ClearedFields() []string { return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *WeaponStatsMutation) FieldCleared(name string) bool { +func (m *WeaponMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *WeaponStatsMutation) ClearField(name string) error { - return fmt.Errorf("unknown WeaponStats nullable field %s", name) +func (m *WeaponMutation) ClearField(name string) error { + return fmt.Errorf("unknown Weapon nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *WeaponStatsMutation) ResetField(name string) error { +func (m *WeaponMutation) ResetField(name string) error { switch name { - case weaponstats.FieldVictim: + case weapon.FieldVictim: m.ResetVictim() return nil - case weaponstats.FieldDmg: + case weapon.FieldDmg: m.ResetDmg() return nil - case weaponstats.FieldEqType: + case weapon.FieldEqType: m.ResetEqType() return nil - case weaponstats.FieldHitGroup: + case weapon.FieldHitGroup: m.ResetHitGroup() return nil } - return fmt.Errorf("unknown WeaponStats field %s", name) + return fmt.Errorf("unknown Weapon field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *WeaponStatsMutation) AddedEdges() []string { +func (m *WeaponMutation) AddedEdges() []string { edges := make([]string, 0, 1) if m.stat != nil { - edges = append(edges, weaponstats.EdgeStat) + edges = append(edges, weapon.EdgeStat) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *WeaponStatsMutation) AddedIDs(name string) []ent.Value { +func (m *WeaponMutation) AddedIDs(name string) []ent.Value { switch name { - case weaponstats.EdgeStat: + case weapon.EdgeStat: if id := m.stat; id != nil { return []ent.Value{*id} } @@ -7573,33 +8537,33 @@ func (m *WeaponStatsMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *WeaponStatsMutation) RemovedEdges() []string { +func (m *WeaponMutation) RemovedEdges() []string { edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *WeaponStatsMutation) RemovedIDs(name string) []ent.Value { +func (m *WeaponMutation) RemovedIDs(name string) []ent.Value { switch name { } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *WeaponStatsMutation) ClearedEdges() []string { +func (m *WeaponMutation) ClearedEdges() []string { edges := make([]string, 0, 1) if m.clearedstat { - edges = append(edges, weaponstats.EdgeStat) + edges = append(edges, weapon.EdgeStat) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *WeaponStatsMutation) EdgeCleared(name string) bool { +func (m *WeaponMutation) EdgeCleared(name string) bool { switch name { - case weaponstats.EdgeStat: + case weapon.EdgeStat: return m.clearedstat } return false @@ -7607,22 +8571,22 @@ func (m *WeaponStatsMutation) EdgeCleared(name string) bool { // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *WeaponStatsMutation) ClearEdge(name string) error { +func (m *WeaponMutation) ClearEdge(name string) error { switch name { - case weaponstats.EdgeStat: + case weapon.EdgeStat: m.ClearStat() return nil } - return fmt.Errorf("unknown WeaponStats unique edge %s", name) + return fmt.Errorf("unknown Weapon unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *WeaponStatsMutation) ResetEdge(name string) error { +func (m *WeaponMutation) ResetEdge(name string) error { switch name { - case weaponstats.EdgeStat: + case weapon.EdgeStat: m.ResetStat() return nil } - return fmt.Errorf("unknown WeaponStats edge %s", name) + return fmt.Errorf("unknown Weapon edge %s", name) } diff --git a/ent/player.go b/ent/player.go index cdc8ab3..7d226b6 100644 --- a/ent/player.go +++ b/ent/player.go @@ -42,6 +42,12 @@ type Player struct { ProfileCreated time.Time `json:"profile_created,omitempty"` // OldestSharecodeSeen holds the value of the "oldest_sharecode_seen" field. OldestSharecodeSeen string `json:"oldest_sharecode_seen,omitempty"` + // Wins holds the value of the "wins" field. + Wins int `json:"wins,omitempty"` + // Looses holds the value of the "looses" field. + Looses int `json:"looses,omitempty"` + // Ties holds the value of the "ties" field. + Ties int `json:"ties,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the PlayerQuery when eager-loading is set. Edges PlayerEdges `json:"edges"` @@ -50,7 +56,7 @@ type Player struct { // PlayerEdges holds the relations/edges for other nodes in the graph. type PlayerEdges struct { // Stats holds the value of the stats edge. - Stats []*Stats `json:"stats,omitempty"` + Stats []*MatchPlayer `json:"stats,omitempty"` // Matches holds the value of the matches edge. Matches []*Match `json:"matches,omitempty"` // loadedTypes holds the information for reporting if a @@ -60,7 +66,7 @@ type PlayerEdges struct { // StatsOrErr returns the Stats value or an error if the edge // was not loaded in eager-loading. -func (e PlayerEdges) StatsOrErr() ([]*Stats, error) { +func (e PlayerEdges) StatsOrErr() ([]*MatchPlayer, error) { if e.loadedTypes[0] { return e.Stats, nil } @@ -81,7 +87,7 @@ func (*Player) scanValues(columns []string) ([]interface{}, error) { values := make([]interface{}, len(columns)) for i := range columns { switch columns[i] { - case player.FieldID, player.FieldVacCount, player.FieldGameBanCount: + case player.FieldID, player.FieldVacCount, player.FieldGameBanCount, player.FieldWins, player.FieldLooses, player.FieldTies: values[i] = new(sql.NullInt64) case player.FieldName, player.FieldAvatar, player.FieldVanityURL, player.FieldVanityURLReal, player.FieldAuthCode, player.FieldOldestSharecodeSeen: values[i] = new(sql.NullString) @@ -186,13 +192,31 @@ func (pl *Player) assignValues(columns []string, values []interface{}) error { } else if value.Valid { pl.OldestSharecodeSeen = value.String } + case player.FieldWins: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field wins", values[i]) + } else if value.Valid { + pl.Wins = int(value.Int64) + } + case player.FieldLooses: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field looses", values[i]) + } else if value.Valid { + pl.Looses = int(value.Int64) + } + case player.FieldTies: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field ties", values[i]) + } else if value.Valid { + pl.Ties = int(value.Int64) + } } } return nil } // QueryStats queries the "stats" edge of the Player entity. -func (pl *Player) QueryStats() *StatsQuery { +func (pl *Player) QueryStats() *MatchPlayerQuery { return (&PlayerClient{config: pl.config}).QueryStats(pl) } @@ -249,6 +273,12 @@ func (pl *Player) String() string { builder.WriteString(pl.ProfileCreated.Format(time.ANSIC)) builder.WriteString(", oldest_sharecode_seen=") builder.WriteString(pl.OldestSharecodeSeen) + builder.WriteString(", wins=") + builder.WriteString(fmt.Sprintf("%v", pl.Wins)) + builder.WriteString(", looses=") + builder.WriteString(fmt.Sprintf("%v", pl.Looses)) + builder.WriteString(", ties=") + builder.WriteString(fmt.Sprintf("%v", pl.Ties)) builder.WriteByte(')') return builder.String() } diff --git a/ent/player/player.go b/ent/player/player.go index e4f0bd8..624c149 100644 --- a/ent/player/player.go +++ b/ent/player/player.go @@ -37,6 +37,12 @@ const ( FieldProfileCreated = "profile_created" // FieldOldestSharecodeSeen holds the string denoting the oldest_sharecode_seen field in the database. FieldOldestSharecodeSeen = "oldest_sharecode_seen" + // FieldWins holds the string denoting the wins field in the database. + FieldWins = "wins" + // FieldLooses holds the string denoting the looses field in the database. + FieldLooses = "looses" + // FieldTies holds the string denoting the ties field in the database. + FieldTies = "ties" // EdgeStats holds the string denoting the stats edge name in mutations. EdgeStats = "stats" // EdgeMatches holds the string denoting the matches edge name in mutations. @@ -44,10 +50,10 @@ const ( // Table holds the table name of the player in the database. Table = "players" // StatsTable is the table that holds the stats relation/edge. - StatsTable = "stats" - // StatsInverseTable is the table name for the Stats entity. - // It exists in this package in order to avoid circular dependency with the "stats" package. - StatsInverseTable = "stats" + StatsTable = "match_players" + // StatsInverseTable is the table name for the MatchPlayer entity. + // It exists in this package in order to avoid circular dependency with the "matchplayer" package. + StatsInverseTable = "match_players" // StatsColumn is the table column denoting the stats relation/edge. StatsColumn = "player_stats" // MatchesTable is the table that holds the matches relation/edge. The primary key declared below. @@ -73,6 +79,9 @@ var Columns = []string{ FieldAuthCode, FieldProfileCreated, FieldOldestSharecodeSeen, + FieldWins, + FieldLooses, + FieldTies, } var ( diff --git a/ent/player/where.go b/ent/player/where.go index fa2a45c..6c784e6 100644 --- a/ent/player/where.go +++ b/ent/player/where.go @@ -184,6 +184,27 @@ func OldestSharecodeSeen(v string) predicate.Player { }) } +// Wins applies equality check predicate on the "wins" field. It's identical to WinsEQ. +func Wins(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldWins), v)) + }) +} + +// Looses applies equality check predicate on the "looses" field. It's identical to LoosesEQ. +func Looses(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldLooses), v)) + }) +} + +// Ties applies equality check predicate on the "ties" field. It's identical to TiesEQ. +func Ties(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldTies), v)) + }) +} + // NameEQ applies the EQ predicate on the "name" field. func NameEQ(v string) predicate.Player { return predicate.Player(func(s *sql.Selector) { @@ -1550,6 +1571,276 @@ func OldestSharecodeSeenContainsFold(v string) predicate.Player { }) } +// WinsEQ applies the EQ predicate on the "wins" field. +func WinsEQ(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldWins), v)) + }) +} + +// WinsNEQ applies the NEQ predicate on the "wins" field. +func WinsNEQ(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldWins), v)) + }) +} + +// WinsIn applies the In predicate on the "wins" field. +func WinsIn(vs ...int) predicate.Player { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Player(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldWins), v...)) + }) +} + +// WinsNotIn applies the NotIn predicate on the "wins" field. +func WinsNotIn(vs ...int) predicate.Player { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Player(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldWins), v...)) + }) +} + +// WinsGT applies the GT predicate on the "wins" field. +func WinsGT(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldWins), v)) + }) +} + +// WinsGTE applies the GTE predicate on the "wins" field. +func WinsGTE(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldWins), v)) + }) +} + +// WinsLT applies the LT predicate on the "wins" field. +func WinsLT(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldWins), v)) + }) +} + +// WinsLTE applies the LTE predicate on the "wins" field. +func WinsLTE(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldWins), v)) + }) +} + +// WinsIsNil applies the IsNil predicate on the "wins" field. +func WinsIsNil() predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldWins))) + }) +} + +// WinsNotNil applies the NotNil predicate on the "wins" field. +func WinsNotNil() predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldWins))) + }) +} + +// LoosesEQ applies the EQ predicate on the "looses" field. +func LoosesEQ(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldLooses), v)) + }) +} + +// LoosesNEQ applies the NEQ predicate on the "looses" field. +func LoosesNEQ(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldLooses), v)) + }) +} + +// LoosesIn applies the In predicate on the "looses" field. +func LoosesIn(vs ...int) predicate.Player { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Player(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldLooses), v...)) + }) +} + +// LoosesNotIn applies the NotIn predicate on the "looses" field. +func LoosesNotIn(vs ...int) predicate.Player { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Player(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldLooses), v...)) + }) +} + +// LoosesGT applies the GT predicate on the "looses" field. +func LoosesGT(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldLooses), v)) + }) +} + +// LoosesGTE applies the GTE predicate on the "looses" field. +func LoosesGTE(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldLooses), v)) + }) +} + +// LoosesLT applies the LT predicate on the "looses" field. +func LoosesLT(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldLooses), v)) + }) +} + +// LoosesLTE applies the LTE predicate on the "looses" field. +func LoosesLTE(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldLooses), v)) + }) +} + +// LoosesIsNil applies the IsNil predicate on the "looses" field. +func LoosesIsNil() predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldLooses))) + }) +} + +// LoosesNotNil applies the NotNil predicate on the "looses" field. +func LoosesNotNil() predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldLooses))) + }) +} + +// TiesEQ applies the EQ predicate on the "ties" field. +func TiesEQ(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldTies), v)) + }) +} + +// TiesNEQ applies the NEQ predicate on the "ties" field. +func TiesNEQ(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldTies), v)) + }) +} + +// TiesIn applies the In predicate on the "ties" field. +func TiesIn(vs ...int) predicate.Player { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Player(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldTies), v...)) + }) +} + +// TiesNotIn applies the NotIn predicate on the "ties" field. +func TiesNotIn(vs ...int) predicate.Player { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Player(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldTies), v...)) + }) +} + +// TiesGT applies the GT predicate on the "ties" field. +func TiesGT(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldTies), v)) + }) +} + +// TiesGTE applies the GTE predicate on the "ties" field. +func TiesGTE(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldTies), v)) + }) +} + +// TiesLT applies the LT predicate on the "ties" field. +func TiesLT(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldTies), v)) + }) +} + +// TiesLTE applies the LTE predicate on the "ties" field. +func TiesLTE(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldTies), v)) + }) +} + +// TiesIsNil applies the IsNil predicate on the "ties" field. +func TiesIsNil() predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldTies))) + }) +} + +// TiesNotNil applies the NotNil predicate on the "ties" field. +func TiesNotNil() predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldTies))) + }) +} + // HasStats applies the HasEdge predicate on the "stats" edge. func HasStats() predicate.Player { return predicate.Player(func(s *sql.Selector) { @@ -1563,7 +1854,7 @@ func HasStats() predicate.Player { } // HasStatsWith applies the HasEdge predicate on the "stats" edge with a given conditions (other predicates). -func HasStatsWith(preds ...predicate.Stats) predicate.Player { +func HasStatsWith(preds ...predicate.MatchPlayer) predicate.Player { return predicate.Player(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), diff --git a/ent/player_create.go b/ent/player_create.go index ea7d3b6..e7c5396 100644 --- a/ent/player_create.go +++ b/ent/player_create.go @@ -5,8 +5,8 @@ package ent import ( "context" "csgowtfd/ent/match" + "csgowtfd/ent/matchplayer" "csgowtfd/ent/player" - "csgowtfd/ent/stats" "errors" "fmt" "time" @@ -204,23 +204,65 @@ func (pc *PlayerCreate) SetNillableOldestSharecodeSeen(s *string) *PlayerCreate return pc } +// SetWins sets the "wins" field. +func (pc *PlayerCreate) SetWins(i int) *PlayerCreate { + pc.mutation.SetWins(i) + return pc +} + +// SetNillableWins sets the "wins" field if the given value is not nil. +func (pc *PlayerCreate) SetNillableWins(i *int) *PlayerCreate { + if i != nil { + pc.SetWins(*i) + } + return pc +} + +// SetLooses sets the "looses" field. +func (pc *PlayerCreate) SetLooses(i int) *PlayerCreate { + pc.mutation.SetLooses(i) + return pc +} + +// SetNillableLooses sets the "looses" field if the given value is not nil. +func (pc *PlayerCreate) SetNillableLooses(i *int) *PlayerCreate { + if i != nil { + pc.SetLooses(*i) + } + return pc +} + +// SetTies sets the "ties" field. +func (pc *PlayerCreate) SetTies(i int) *PlayerCreate { + pc.mutation.SetTies(i) + return pc +} + +// SetNillableTies sets the "ties" field if the given value is not nil. +func (pc *PlayerCreate) SetNillableTies(i *int) *PlayerCreate { + if i != nil { + pc.SetTies(*i) + } + return pc +} + // SetID sets the "id" field. func (pc *PlayerCreate) SetID(u uint64) *PlayerCreate { pc.mutation.SetID(u) return pc } -// AddStatIDs adds the "stats" edge to the Stats entity by IDs. +// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs. func (pc *PlayerCreate) AddStatIDs(ids ...int) *PlayerCreate { pc.mutation.AddStatIDs(ids...) return pc } -// AddStats adds the "stats" edges to the Stats entity. -func (pc *PlayerCreate) AddStats(s ...*Stats) *PlayerCreate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +// AddStats adds the "stats" edges to the MatchPlayer entity. +func (pc *PlayerCreate) AddStats(m ...*MatchPlayer) *PlayerCreate { + ids := make([]int, len(m)) + for i := range m { + ids[i] = m[i].ID } return pc.AddStatIDs(ids...) } @@ -459,6 +501,30 @@ func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) { }) _node.OldestSharecodeSeen = value } + if value, ok := pc.mutation.Wins(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldWins, + }) + _node.Wins = value + } + if value, ok := pc.mutation.Looses(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldLooses, + }) + _node.Looses = value + } + if value, ok := pc.mutation.Ties(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldTies, + }) + _node.Ties = value + } if nodes := pc.mutation.StatsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -469,7 +535,7 @@ func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) { Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } diff --git a/ent/player_query.go b/ent/player_query.go index 8a931ec..494845c 100644 --- a/ent/player_query.go +++ b/ent/player_query.go @@ -5,9 +5,9 @@ package ent import ( "context" "csgowtfd/ent/match" + "csgowtfd/ent/matchplayer" "csgowtfd/ent/player" "csgowtfd/ent/predicate" - "csgowtfd/ent/stats" "database/sql/driver" "errors" "fmt" @@ -28,7 +28,7 @@ type PlayerQuery struct { fields []string predicates []predicate.Player // eager-loading edges. - withStats *StatsQuery + withStats *MatchPlayerQuery withMatches *MatchQuery modifiers []func(s *sql.Selector) // intermediate query (i.e. traversal path). @@ -68,8 +68,8 @@ func (pq *PlayerQuery) Order(o ...OrderFunc) *PlayerQuery { } // QueryStats chains the current query on the "stats" edge. -func (pq *PlayerQuery) QueryStats() *StatsQuery { - query := &StatsQuery{config: pq.config} +func (pq *PlayerQuery) QueryStats() *MatchPlayerQuery { + query := &MatchPlayerQuery{config: pq.config} query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := pq.prepareQuery(ctx); err != nil { return nil, err @@ -80,7 +80,7 @@ func (pq *PlayerQuery) QueryStats() *StatsQuery { } step := sqlgraph.NewStep( sqlgraph.From(player.Table, player.FieldID, selector), - sqlgraph.To(stats.Table, stats.FieldID), + sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, player.StatsTable, player.StatsColumn), ) fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) @@ -302,8 +302,8 @@ func (pq *PlayerQuery) Clone() *PlayerQuery { // WithStats tells the query-builder to eager-load the nodes that are connected to // the "stats" edge. The optional arguments are used to configure the query builder of the edge. -func (pq *PlayerQuery) WithStats(opts ...func(*StatsQuery)) *PlayerQuery { - query := &StatsQuery{config: pq.config} +func (pq *PlayerQuery) WithStats(opts ...func(*MatchPlayerQuery)) *PlayerQuery { + query := &MatchPlayerQuery{config: pq.config} for _, opt := range opts { opt(query) } @@ -421,9 +421,9 @@ func (pq *PlayerQuery) sqlAll(ctx context.Context) ([]*Player, error) { for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] - nodes[i].Edges.Stats = []*Stats{} + nodes[i].Edges.Stats = []*MatchPlayer{} } - query.Where(predicate.Stats(func(s *sql.Selector) { + query.Where(predicate.MatchPlayer(func(s *sql.Selector) { s.Where(sql.InValues(player.StatsColumn, fks...)) })) neighbors, err := query.All(ctx) diff --git a/ent/player_update.go b/ent/player_update.go index d2057b5..fe42a5e 100644 --- a/ent/player_update.go +++ b/ent/player_update.go @@ -5,9 +5,9 @@ package ent import ( "context" "csgowtfd/ent/match" + "csgowtfd/ent/matchplayer" "csgowtfd/ent/player" "csgowtfd/ent/predicate" - "csgowtfd/ent/stats" "fmt" "time" @@ -297,17 +297,98 @@ func (pu *PlayerUpdate) ClearOldestSharecodeSeen() *PlayerUpdate { return pu } -// AddStatIDs adds the "stats" edge to the Stats entity by IDs. +// SetWins sets the "wins" field. +func (pu *PlayerUpdate) SetWins(i int) *PlayerUpdate { + pu.mutation.ResetWins() + pu.mutation.SetWins(i) + return pu +} + +// SetNillableWins sets the "wins" field if the given value is not nil. +func (pu *PlayerUpdate) SetNillableWins(i *int) *PlayerUpdate { + if i != nil { + pu.SetWins(*i) + } + return pu +} + +// AddWins adds i to the "wins" field. +func (pu *PlayerUpdate) AddWins(i int) *PlayerUpdate { + pu.mutation.AddWins(i) + return pu +} + +// ClearWins clears the value of the "wins" field. +func (pu *PlayerUpdate) ClearWins() *PlayerUpdate { + pu.mutation.ClearWins() + return pu +} + +// SetLooses sets the "looses" field. +func (pu *PlayerUpdate) SetLooses(i int) *PlayerUpdate { + pu.mutation.ResetLooses() + pu.mutation.SetLooses(i) + return pu +} + +// SetNillableLooses sets the "looses" field if the given value is not nil. +func (pu *PlayerUpdate) SetNillableLooses(i *int) *PlayerUpdate { + if i != nil { + pu.SetLooses(*i) + } + return pu +} + +// AddLooses adds i to the "looses" field. +func (pu *PlayerUpdate) AddLooses(i int) *PlayerUpdate { + pu.mutation.AddLooses(i) + return pu +} + +// ClearLooses clears the value of the "looses" field. +func (pu *PlayerUpdate) ClearLooses() *PlayerUpdate { + pu.mutation.ClearLooses() + return pu +} + +// SetTies sets the "ties" field. +func (pu *PlayerUpdate) SetTies(i int) *PlayerUpdate { + pu.mutation.ResetTies() + pu.mutation.SetTies(i) + return pu +} + +// SetNillableTies sets the "ties" field if the given value is not nil. +func (pu *PlayerUpdate) SetNillableTies(i *int) *PlayerUpdate { + if i != nil { + pu.SetTies(*i) + } + return pu +} + +// AddTies adds i to the "ties" field. +func (pu *PlayerUpdate) AddTies(i int) *PlayerUpdate { + pu.mutation.AddTies(i) + return pu +} + +// ClearTies clears the value of the "ties" field. +func (pu *PlayerUpdate) ClearTies() *PlayerUpdate { + pu.mutation.ClearTies() + return pu +} + +// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs. func (pu *PlayerUpdate) AddStatIDs(ids ...int) *PlayerUpdate { pu.mutation.AddStatIDs(ids...) return pu } -// AddStats adds the "stats" edges to the Stats entity. -func (pu *PlayerUpdate) AddStats(s ...*Stats) *PlayerUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +// AddStats adds the "stats" edges to the MatchPlayer entity. +func (pu *PlayerUpdate) AddStats(m ...*MatchPlayer) *PlayerUpdate { + ids := make([]int, len(m)) + for i := range m { + ids[i] = m[i].ID } return pu.AddStatIDs(ids...) } @@ -332,23 +413,23 @@ func (pu *PlayerUpdate) Mutation() *PlayerMutation { return pu.mutation } -// ClearStats clears all "stats" edges to the Stats entity. +// ClearStats clears all "stats" edges to the MatchPlayer entity. func (pu *PlayerUpdate) ClearStats() *PlayerUpdate { pu.mutation.ClearStats() return pu } -// RemoveStatIDs removes the "stats" edge to Stats entities by IDs. +// RemoveStatIDs removes the "stats" edge to MatchPlayer entities by IDs. func (pu *PlayerUpdate) RemoveStatIDs(ids ...int) *PlayerUpdate { pu.mutation.RemoveStatIDs(ids...) return pu } -// RemoveStats removes "stats" edges to Stats entities. -func (pu *PlayerUpdate) RemoveStats(s ...*Stats) *PlayerUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +// RemoveStats removes "stats" edges to MatchPlayer entities. +func (pu *PlayerUpdate) RemoveStats(m ...*MatchPlayer) *PlayerUpdate { + ids := make([]int, len(m)) + for i := range m { + ids[i] = m[i].ID } return pu.RemoveStatIDs(ids...) } @@ -623,6 +704,66 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { Column: player.FieldOldestSharecodeSeen, }) } + if value, ok := pu.mutation.Wins(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldWins, + }) + } + if value, ok := pu.mutation.AddedWins(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldWins, + }) + } + if pu.mutation.WinsCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: player.FieldWins, + }) + } + if value, ok := pu.mutation.Looses(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldLooses, + }) + } + if value, ok := pu.mutation.AddedLooses(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldLooses, + }) + } + if pu.mutation.LoosesCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: player.FieldLooses, + }) + } + if value, ok := pu.mutation.Ties(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldTies, + }) + } + if value, ok := pu.mutation.AddedTies(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldTies, + }) + } + if pu.mutation.TiesCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: player.FieldTies, + }) + } if pu.mutation.StatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -633,7 +774,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } @@ -649,7 +790,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } @@ -668,7 +809,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } @@ -1018,17 +1159,98 @@ func (puo *PlayerUpdateOne) ClearOldestSharecodeSeen() *PlayerUpdateOne { return puo } -// AddStatIDs adds the "stats" edge to the Stats entity by IDs. +// SetWins sets the "wins" field. +func (puo *PlayerUpdateOne) SetWins(i int) *PlayerUpdateOne { + puo.mutation.ResetWins() + puo.mutation.SetWins(i) + return puo +} + +// SetNillableWins sets the "wins" field if the given value is not nil. +func (puo *PlayerUpdateOne) SetNillableWins(i *int) *PlayerUpdateOne { + if i != nil { + puo.SetWins(*i) + } + return puo +} + +// AddWins adds i to the "wins" field. +func (puo *PlayerUpdateOne) AddWins(i int) *PlayerUpdateOne { + puo.mutation.AddWins(i) + return puo +} + +// ClearWins clears the value of the "wins" field. +func (puo *PlayerUpdateOne) ClearWins() *PlayerUpdateOne { + puo.mutation.ClearWins() + return puo +} + +// SetLooses sets the "looses" field. +func (puo *PlayerUpdateOne) SetLooses(i int) *PlayerUpdateOne { + puo.mutation.ResetLooses() + puo.mutation.SetLooses(i) + return puo +} + +// SetNillableLooses sets the "looses" field if the given value is not nil. +func (puo *PlayerUpdateOne) SetNillableLooses(i *int) *PlayerUpdateOne { + if i != nil { + puo.SetLooses(*i) + } + return puo +} + +// AddLooses adds i to the "looses" field. +func (puo *PlayerUpdateOne) AddLooses(i int) *PlayerUpdateOne { + puo.mutation.AddLooses(i) + return puo +} + +// ClearLooses clears the value of the "looses" field. +func (puo *PlayerUpdateOne) ClearLooses() *PlayerUpdateOne { + puo.mutation.ClearLooses() + return puo +} + +// SetTies sets the "ties" field. +func (puo *PlayerUpdateOne) SetTies(i int) *PlayerUpdateOne { + puo.mutation.ResetTies() + puo.mutation.SetTies(i) + return puo +} + +// SetNillableTies sets the "ties" field if the given value is not nil. +func (puo *PlayerUpdateOne) SetNillableTies(i *int) *PlayerUpdateOne { + if i != nil { + puo.SetTies(*i) + } + return puo +} + +// AddTies adds i to the "ties" field. +func (puo *PlayerUpdateOne) AddTies(i int) *PlayerUpdateOne { + puo.mutation.AddTies(i) + return puo +} + +// ClearTies clears the value of the "ties" field. +func (puo *PlayerUpdateOne) ClearTies() *PlayerUpdateOne { + puo.mutation.ClearTies() + return puo +} + +// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs. func (puo *PlayerUpdateOne) AddStatIDs(ids ...int) *PlayerUpdateOne { puo.mutation.AddStatIDs(ids...) return puo } -// AddStats adds the "stats" edges to the Stats entity. -func (puo *PlayerUpdateOne) AddStats(s ...*Stats) *PlayerUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +// AddStats adds the "stats" edges to the MatchPlayer entity. +func (puo *PlayerUpdateOne) AddStats(m ...*MatchPlayer) *PlayerUpdateOne { + ids := make([]int, len(m)) + for i := range m { + ids[i] = m[i].ID } return puo.AddStatIDs(ids...) } @@ -1053,23 +1275,23 @@ func (puo *PlayerUpdateOne) Mutation() *PlayerMutation { return puo.mutation } -// ClearStats clears all "stats" edges to the Stats entity. +// ClearStats clears all "stats" edges to the MatchPlayer entity. func (puo *PlayerUpdateOne) ClearStats() *PlayerUpdateOne { puo.mutation.ClearStats() return puo } -// RemoveStatIDs removes the "stats" edge to Stats entities by IDs. +// RemoveStatIDs removes the "stats" edge to MatchPlayer entities by IDs. func (puo *PlayerUpdateOne) RemoveStatIDs(ids ...int) *PlayerUpdateOne { puo.mutation.RemoveStatIDs(ids...) return puo } -// RemoveStats removes "stats" edges to Stats entities. -func (puo *PlayerUpdateOne) RemoveStats(s ...*Stats) *PlayerUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +// RemoveStats removes "stats" edges to MatchPlayer entities. +func (puo *PlayerUpdateOne) RemoveStats(m ...*MatchPlayer) *PlayerUpdateOne { + ids := make([]int, len(m)) + for i := range m { + ids[i] = m[i].ID } return puo.RemoveStatIDs(ids...) } @@ -1368,6 +1590,66 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err Column: player.FieldOldestSharecodeSeen, }) } + if value, ok := puo.mutation.Wins(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldWins, + }) + } + if value, ok := puo.mutation.AddedWins(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldWins, + }) + } + if puo.mutation.WinsCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: player.FieldWins, + }) + } + if value, ok := puo.mutation.Looses(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldLooses, + }) + } + if value, ok := puo.mutation.AddedLooses(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldLooses, + }) + } + if puo.mutation.LoosesCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: player.FieldLooses, + }) + } + if value, ok := puo.mutation.Ties(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldTies, + }) + } + if value, ok := puo.mutation.AddedTies(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldTies, + }) + } + if puo.mutation.TiesCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: player.FieldTies, + }) + } if puo.mutation.StatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -1378,7 +1660,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } @@ -1394,7 +1676,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } @@ -1413,7 +1695,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } diff --git a/ent/predicate/predicate.go b/ent/predicate/predicate.go index a7ce4ca..020f865 100644 --- a/ent/predicate/predicate.go +++ b/ent/predicate/predicate.go @@ -9,14 +9,17 @@ import ( // Match is the predicate function for match builders. type Match func(*sql.Selector) +// MatchPlayer is the predicate function for matchplayer builders. +type MatchPlayer func(*sql.Selector) + // Player is the predicate function for player builders. type Player func(*sql.Selector) // RoundStats is the predicate function for roundstats builders. type RoundStats func(*sql.Selector) -// Stats is the predicate function for stats builders. -type Stats func(*sql.Selector) +// Spray is the predicate function for spray builders. +type Spray func(*sql.Selector) -// WeaponStats is the predicate function for weaponstats builders. -type WeaponStats func(*sql.Selector) +// Weapon is the predicate function for weapon builders. +type Weapon func(*sql.Selector) diff --git a/ent/roundstats.go b/ent/roundstats.go index aa28687..79f5f2b 100644 --- a/ent/roundstats.go +++ b/ent/roundstats.go @@ -3,8 +3,8 @@ package ent import ( + "csgowtfd/ent/matchplayer" "csgowtfd/ent/roundstats" - "csgowtfd/ent/stats" "fmt" "strings" @@ -26,31 +26,31 @@ type RoundStats struct { Spent uint `json:"spent,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the RoundStatsQuery when eager-loading is set. - Edges RoundStatsEdges `json:"edges"` - stats_round_stats *int + Edges RoundStatsEdges `json:"edges"` + match_player_round_stats *int } // RoundStatsEdges holds the relations/edges for other nodes in the graph. type RoundStatsEdges struct { - // Stat holds the value of the stat edge. - Stat *Stats `json:"stat,omitempty"` + // MatchPlayer holds the value of the match_player edge. + MatchPlayer *MatchPlayer `json:"match_player,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [1]bool } -// StatOrErr returns the Stat value or an error if the edge +// MatchPlayerOrErr returns the MatchPlayer value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. -func (e RoundStatsEdges) StatOrErr() (*Stats, error) { +func (e RoundStatsEdges) MatchPlayerOrErr() (*MatchPlayer, error) { if e.loadedTypes[0] { - if e.Stat == nil { - // The edge stat was loaded in eager-loading, + if e.MatchPlayer == nil { + // The edge match_player was loaded in eager-loading, // but was not found. - return nil, &NotFoundError{label: stats.Label} + return nil, &NotFoundError{label: matchplayer.Label} } - return e.Stat, nil + return e.MatchPlayer, nil } - return nil, &NotLoadedError{edge: "stat"} + return nil, &NotLoadedError{edge: "match_player"} } // scanValues returns the types for scanning values from sql.Rows. @@ -60,7 +60,7 @@ func (*RoundStats) scanValues(columns []string) ([]interface{}, error) { switch columns[i] { case roundstats.FieldID, roundstats.FieldRound, roundstats.FieldBank, roundstats.FieldEquipment, roundstats.FieldSpent: values[i] = new(sql.NullInt64) - case roundstats.ForeignKeys[0]: // stats_round_stats + case roundstats.ForeignKeys[0]: // match_player_round_stats values[i] = new(sql.NullInt64) default: return nil, fmt.Errorf("unexpected column %q for type RoundStats", columns[i]) @@ -109,19 +109,19 @@ func (rs *RoundStats) assignValues(columns []string, values []interface{}) error } case roundstats.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field stats_round_stats", value) + return fmt.Errorf("unexpected type %T for edge-field match_player_round_stats", value) } else if value.Valid { - rs.stats_round_stats = new(int) - *rs.stats_round_stats = int(value.Int64) + rs.match_player_round_stats = new(int) + *rs.match_player_round_stats = int(value.Int64) } } } return nil } -// QueryStat queries the "stat" edge of the RoundStats entity. -func (rs *RoundStats) QueryStat() *StatsQuery { - return (&RoundStatsClient{config: rs.config}).QueryStat(rs) +// QueryMatchPlayer queries the "match_player" edge of the RoundStats entity. +func (rs *RoundStats) QueryMatchPlayer() *MatchPlayerQuery { + return (&RoundStatsClient{config: rs.config}).QueryMatchPlayer(rs) } // Update returns a builder for updating this RoundStats. diff --git a/ent/roundstats/roundstats.go b/ent/roundstats/roundstats.go index 966f6b5..ef71737 100644 --- a/ent/roundstats/roundstats.go +++ b/ent/roundstats/roundstats.go @@ -15,17 +15,17 @@ const ( FieldEquipment = "equipment" // FieldSpent holds the string denoting the spent field in the database. FieldSpent = "spent" - // EdgeStat holds the string denoting the stat edge name in mutations. - EdgeStat = "stat" + // EdgeMatchPlayer holds the string denoting the match_player edge name in mutations. + EdgeMatchPlayer = "match_player" // Table holds the table name of the roundstats in the database. Table = "round_stats" - // StatTable is the table that holds the stat relation/edge. - StatTable = "round_stats" - // StatInverseTable is the table name for the Stats entity. - // It exists in this package in order to avoid circular dependency with the "stats" package. - StatInverseTable = "stats" - // StatColumn is the table column denoting the stat relation/edge. - StatColumn = "stats_round_stats" + // MatchPlayerTable is the table that holds the match_player relation/edge. + MatchPlayerTable = "round_stats" + // MatchPlayerInverseTable is the table name for the MatchPlayer entity. + // It exists in this package in order to avoid circular dependency with the "matchplayer" package. + MatchPlayerInverseTable = "match_players" + // MatchPlayerColumn is the table column denoting the match_player relation/edge. + MatchPlayerColumn = "match_player_round_stats" ) // Columns holds all SQL columns for roundstats fields. @@ -40,7 +40,7 @@ var Columns = []string{ // ForeignKeys holds the SQL foreign-keys that are owned by the "round_stats" // table and are not defined as standalone fields in the schema. var ForeignKeys = []string{ - "stats_round_stats", + "match_player_round_stats", } // ValidColumn reports if the column name is valid (part of the table columns). diff --git a/ent/roundstats/where.go b/ent/roundstats/where.go index 9532f49..eb652d3 100644 --- a/ent/roundstats/where.go +++ b/ent/roundstats/where.go @@ -424,25 +424,25 @@ func SpentLTE(v uint) predicate.RoundStats { }) } -// HasStat applies the HasEdge predicate on the "stat" edge. -func HasStat() predicate.RoundStats { +// HasMatchPlayer applies the HasEdge predicate on the "match_player" edge. +func HasMatchPlayer() predicate.RoundStats { return predicate.RoundStats(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(StatTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, StatTable, StatColumn), + sqlgraph.To(MatchPlayerTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, MatchPlayerTable, MatchPlayerColumn), ) sqlgraph.HasNeighbors(s, step) }) } -// HasStatWith applies the HasEdge predicate on the "stat" edge with a given conditions (other predicates). -func HasStatWith(preds ...predicate.Stats) predicate.RoundStats { +// HasMatchPlayerWith applies the HasEdge predicate on the "match_player" edge with a given conditions (other predicates). +func HasMatchPlayerWith(preds ...predicate.MatchPlayer) predicate.RoundStats { return predicate.RoundStats(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(StatInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, StatTable, StatColumn), + sqlgraph.To(MatchPlayerInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, MatchPlayerTable, MatchPlayerColumn), ) sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { for _, p := range preds { diff --git a/ent/roundstats_create.go b/ent/roundstats_create.go index 068af89..34f3d20 100644 --- a/ent/roundstats_create.go +++ b/ent/roundstats_create.go @@ -4,8 +4,8 @@ package ent import ( "context" + "csgowtfd/ent/matchplayer" "csgowtfd/ent/roundstats" - "csgowtfd/ent/stats" "errors" "fmt" @@ -44,23 +44,23 @@ func (rsc *RoundStatsCreate) SetSpent(u uint) *RoundStatsCreate { return rsc } -// SetStatID sets the "stat" edge to the Stats entity by ID. -func (rsc *RoundStatsCreate) SetStatID(id int) *RoundStatsCreate { - rsc.mutation.SetStatID(id) +// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID. +func (rsc *RoundStatsCreate) SetMatchPlayerID(id int) *RoundStatsCreate { + rsc.mutation.SetMatchPlayerID(id) return rsc } -// SetNillableStatID sets the "stat" edge to the Stats entity by ID if the given value is not nil. -func (rsc *RoundStatsCreate) SetNillableStatID(id *int) *RoundStatsCreate { +// SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil. +func (rsc *RoundStatsCreate) SetNillableMatchPlayerID(id *int) *RoundStatsCreate { if id != nil { - rsc = rsc.SetStatID(*id) + rsc = rsc.SetMatchPlayerID(*id) } return rsc } -// SetStat sets the "stat" edge to the Stats entity. -func (rsc *RoundStatsCreate) SetStat(s *Stats) *RoundStatsCreate { - return rsc.SetStatID(s.ID) +// SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity. +func (rsc *RoundStatsCreate) SetMatchPlayer(m *MatchPlayer) *RoundStatsCreate { + return rsc.SetMatchPlayerID(m.ID) } // Mutation returns the RoundStatsMutation object of the builder. @@ -204,24 +204,24 @@ func (rsc *RoundStatsCreate) createSpec() (*RoundStats, *sqlgraph.CreateSpec) { }) _node.Spent = value } - if nodes := rsc.mutation.StatIDs(); len(nodes) > 0 { + if nodes := rsc.mutation.MatchPlayerIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: roundstats.StatTable, - Columns: []string{roundstats.StatColumn}, + Table: roundstats.MatchPlayerTable, + Columns: []string{roundstats.MatchPlayerColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } - _node.stats_round_stats = &nodes[0] + _node.match_player_round_stats = &nodes[0] _spec.Edges = append(_spec.Edges, edge) } return _node, _spec diff --git a/ent/roundstats_query.go b/ent/roundstats_query.go index 340bdc2..5fc9fda 100644 --- a/ent/roundstats_query.go +++ b/ent/roundstats_query.go @@ -4,9 +4,9 @@ package ent import ( "context" + "csgowtfd/ent/matchplayer" "csgowtfd/ent/predicate" "csgowtfd/ent/roundstats" - "csgowtfd/ent/stats" "errors" "fmt" "math" @@ -26,9 +26,9 @@ type RoundStatsQuery struct { fields []string predicates []predicate.RoundStats // eager-loading edges. - withStat *StatsQuery - withFKs bool - modifiers []func(s *sql.Selector) + withMatchPlayer *MatchPlayerQuery + withFKs bool + modifiers []func(s *sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -65,9 +65,9 @@ func (rsq *RoundStatsQuery) Order(o ...OrderFunc) *RoundStatsQuery { return rsq } -// QueryStat chains the current query on the "stat" edge. -func (rsq *RoundStatsQuery) QueryStat() *StatsQuery { - query := &StatsQuery{config: rsq.config} +// QueryMatchPlayer chains the current query on the "match_player" edge. +func (rsq *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery { + query := &MatchPlayerQuery{config: rsq.config} query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := rsq.prepareQuery(ctx); err != nil { return nil, err @@ -78,8 +78,8 @@ func (rsq *RoundStatsQuery) QueryStat() *StatsQuery { } step := sqlgraph.NewStep( sqlgraph.From(roundstats.Table, roundstats.FieldID, selector), - sqlgraph.To(stats.Table, stats.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, roundstats.StatTable, roundstats.StatColumn), + sqlgraph.To(matchplayer.Table, matchplayer.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, roundstats.MatchPlayerTable, roundstats.MatchPlayerColumn), ) fromU = sqlgraph.SetNeighbors(rsq.driver.Dialect(), step) return fromU, nil @@ -263,26 +263,26 @@ func (rsq *RoundStatsQuery) Clone() *RoundStatsQuery { return nil } return &RoundStatsQuery{ - config: rsq.config, - limit: rsq.limit, - offset: rsq.offset, - order: append([]OrderFunc{}, rsq.order...), - predicates: append([]predicate.RoundStats{}, rsq.predicates...), - withStat: rsq.withStat.Clone(), + config: rsq.config, + limit: rsq.limit, + offset: rsq.offset, + order: append([]OrderFunc{}, rsq.order...), + predicates: append([]predicate.RoundStats{}, rsq.predicates...), + withMatchPlayer: rsq.withMatchPlayer.Clone(), // clone intermediate query. sql: rsq.sql.Clone(), path: rsq.path, } } -// WithStat tells the query-builder to eager-load the nodes that are connected to -// the "stat" edge. The optional arguments are used to configure the query builder of the edge. -func (rsq *RoundStatsQuery) WithStat(opts ...func(*StatsQuery)) *RoundStatsQuery { - query := &StatsQuery{config: rsq.config} +// WithMatchPlayer tells the query-builder to eager-load the nodes that are connected to +// the "match_player" edge. The optional arguments are used to configure the query builder of the edge. +func (rsq *RoundStatsQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *RoundStatsQuery { + query := &MatchPlayerQuery{config: rsq.config} for _, opt := range opts { opt(query) } - rsq.withStat = query + rsq.withMatchPlayer = query return rsq } @@ -353,10 +353,10 @@ func (rsq *RoundStatsQuery) sqlAll(ctx context.Context) ([]*RoundStats, error) { withFKs = rsq.withFKs _spec = rsq.querySpec() loadedTypes = [1]bool{ - rsq.withStat != nil, + rsq.withMatchPlayer != nil, } ) - if rsq.withStat != nil { + if rsq.withMatchPlayer != nil { withFKs = true } if withFKs { @@ -385,20 +385,20 @@ func (rsq *RoundStatsQuery) sqlAll(ctx context.Context) ([]*RoundStats, error) { return nodes, nil } - if query := rsq.withStat; query != nil { + if query := rsq.withMatchPlayer; query != nil { ids := make([]int, 0, len(nodes)) nodeids := make(map[int][]*RoundStats) for i := range nodes { - if nodes[i].stats_round_stats == nil { + if nodes[i].match_player_round_stats == nil { continue } - fk := *nodes[i].stats_round_stats + fk := *nodes[i].match_player_round_stats if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } nodeids[fk] = append(nodeids[fk], nodes[i]) } - query.Where(stats.IDIn(ids...)) + query.Where(matchplayer.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { return nil, err @@ -406,10 +406,10 @@ func (rsq *RoundStatsQuery) sqlAll(ctx context.Context) ([]*RoundStats, error) { for _, n := range neighbors { nodes, ok := nodeids[n.ID] if !ok { - return nil, fmt.Errorf(`unexpected foreign-key "stats_round_stats" returned %v`, n.ID) + return nil, fmt.Errorf(`unexpected foreign-key "match_player_round_stats" returned %v`, n.ID) } for i := range nodes { - nodes[i].Edges.Stat = n + nodes[i].Edges.MatchPlayer = n } } } diff --git a/ent/roundstats_update.go b/ent/roundstats_update.go index d22e863..b88dd0c 100644 --- a/ent/roundstats_update.go +++ b/ent/roundstats_update.go @@ -4,9 +4,9 @@ package ent import ( "context" + "csgowtfd/ent/matchplayer" "csgowtfd/ent/predicate" "csgowtfd/ent/roundstats" - "csgowtfd/ent/stats" "fmt" "entgo.io/ent/dialect/sql" @@ -79,23 +79,23 @@ func (rsu *RoundStatsUpdate) AddSpent(u uint) *RoundStatsUpdate { return rsu } -// SetStatID sets the "stat" edge to the Stats entity by ID. -func (rsu *RoundStatsUpdate) SetStatID(id int) *RoundStatsUpdate { - rsu.mutation.SetStatID(id) +// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID. +func (rsu *RoundStatsUpdate) SetMatchPlayerID(id int) *RoundStatsUpdate { + rsu.mutation.SetMatchPlayerID(id) return rsu } -// SetNillableStatID sets the "stat" edge to the Stats entity by ID if the given value is not nil. -func (rsu *RoundStatsUpdate) SetNillableStatID(id *int) *RoundStatsUpdate { +// SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil. +func (rsu *RoundStatsUpdate) SetNillableMatchPlayerID(id *int) *RoundStatsUpdate { if id != nil { - rsu = rsu.SetStatID(*id) + rsu = rsu.SetMatchPlayerID(*id) } return rsu } -// SetStat sets the "stat" edge to the Stats entity. -func (rsu *RoundStatsUpdate) SetStat(s *Stats) *RoundStatsUpdate { - return rsu.SetStatID(s.ID) +// SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity. +func (rsu *RoundStatsUpdate) SetMatchPlayer(m *MatchPlayer) *RoundStatsUpdate { + return rsu.SetMatchPlayerID(m.ID) } // Mutation returns the RoundStatsMutation object of the builder. @@ -103,9 +103,9 @@ func (rsu *RoundStatsUpdate) Mutation() *RoundStatsMutation { return rsu.mutation } -// ClearStat clears the "stat" edge to the Stats entity. -func (rsu *RoundStatsUpdate) ClearStat() *RoundStatsUpdate { - rsu.mutation.ClearStat() +// ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity. +func (rsu *RoundStatsUpdate) ClearMatchPlayer() *RoundStatsUpdate { + rsu.mutation.ClearMatchPlayer() return rsu } @@ -237,33 +237,33 @@ func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) { Column: roundstats.FieldSpent, }) } - if rsu.mutation.StatCleared() { + if rsu.mutation.MatchPlayerCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: roundstats.StatTable, - Columns: []string{roundstats.StatColumn}, + Table: roundstats.MatchPlayerTable, + Columns: []string{roundstats.MatchPlayerColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := rsu.mutation.StatIDs(); len(nodes) > 0 { + if nodes := rsu.mutation.MatchPlayerIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: roundstats.StatTable, - Columns: []string{roundstats.StatColumn}, + Table: roundstats.MatchPlayerTable, + Columns: []string{roundstats.MatchPlayerColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } @@ -343,23 +343,23 @@ func (rsuo *RoundStatsUpdateOne) AddSpent(u uint) *RoundStatsUpdateOne { return rsuo } -// SetStatID sets the "stat" edge to the Stats entity by ID. -func (rsuo *RoundStatsUpdateOne) SetStatID(id int) *RoundStatsUpdateOne { - rsuo.mutation.SetStatID(id) +// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID. +func (rsuo *RoundStatsUpdateOne) SetMatchPlayerID(id int) *RoundStatsUpdateOne { + rsuo.mutation.SetMatchPlayerID(id) return rsuo } -// SetNillableStatID sets the "stat" edge to the Stats entity by ID if the given value is not nil. -func (rsuo *RoundStatsUpdateOne) SetNillableStatID(id *int) *RoundStatsUpdateOne { +// SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil. +func (rsuo *RoundStatsUpdateOne) SetNillableMatchPlayerID(id *int) *RoundStatsUpdateOne { if id != nil { - rsuo = rsuo.SetStatID(*id) + rsuo = rsuo.SetMatchPlayerID(*id) } return rsuo } -// SetStat sets the "stat" edge to the Stats entity. -func (rsuo *RoundStatsUpdateOne) SetStat(s *Stats) *RoundStatsUpdateOne { - return rsuo.SetStatID(s.ID) +// SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity. +func (rsuo *RoundStatsUpdateOne) SetMatchPlayer(m *MatchPlayer) *RoundStatsUpdateOne { + return rsuo.SetMatchPlayerID(m.ID) } // Mutation returns the RoundStatsMutation object of the builder. @@ -367,9 +367,9 @@ func (rsuo *RoundStatsUpdateOne) Mutation() *RoundStatsMutation { return rsuo.mutation } -// ClearStat clears the "stat" edge to the Stats entity. -func (rsuo *RoundStatsUpdateOne) ClearStat() *RoundStatsUpdateOne { - rsuo.mutation.ClearStat() +// ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity. +func (rsuo *RoundStatsUpdateOne) ClearMatchPlayer() *RoundStatsUpdateOne { + rsuo.mutation.ClearMatchPlayer() return rsuo } @@ -525,33 +525,33 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats Column: roundstats.FieldSpent, }) } - if rsuo.mutation.StatCleared() { + if rsuo.mutation.MatchPlayerCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: roundstats.StatTable, - Columns: []string{roundstats.StatColumn}, + Table: roundstats.MatchPlayerTable, + Columns: []string{roundstats.MatchPlayerColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := rsuo.mutation.StatIDs(); len(nodes) > 0 { + if nodes := rsuo.mutation.MatchPlayerIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: roundstats.StatTable, - Columns: []string{roundstats.StatColumn}, + Table: roundstats.MatchPlayerTable, + Columns: []string{roundstats.MatchPlayerColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: matchplayer.FieldID, }, }, } diff --git a/ent/schema/match.go b/ent/schema/match.go index e0cbfd2..883b50c 100644 --- a/ent/schema/match.go +++ b/ent/schema/match.go @@ -33,7 +33,7 @@ func (Match) Fields() []ent.Field { // Edges of the Match. func (Match) Edges() []ent.Edge { return []ent.Edge{ - edge.To("stats", Stats.Type), + edge.To("stats", MatchPlayer.Type), edge.From("players", Player.Type).Ref("matches"), } } diff --git a/ent/schema/stats.go b/ent/schema/matchplayer.go similarity index 82% rename from ent/schema/stats.go rename to ent/schema/matchplayer.go index d70c67d..ff432dd 100644 --- a/ent/schema/stats.go +++ b/ent/schema/matchplayer.go @@ -6,13 +6,13 @@ import ( "entgo.io/ent/schema/field" ) -// Stats holds the schema definition for the Stats entity. -type Stats struct { +// MatchPlayer holds the schema definition for the MatchPlayer entity. +type MatchPlayer struct { ent.Schema } // Fields of the Stats. -func (Stats) Fields() []ent.Field { +func (MatchPlayer) Fields() []ent.Field { return []ent.Field{ field.Int("team_id"), field.Int("kills"), @@ -45,15 +45,17 @@ func (Stats) Fields() []ent.Field { field.Uint("flash_total_enemy").Optional(), field.Uint64("match_stats").Optional(), field.Uint64("player_stats").Optional(), + field.Int("flash_assists").Optional(), } } -// Edges of the Stats. -func (Stats) Edges() []ent.Edge { +// Edges of the MatchPlayer. +func (MatchPlayer) Edges() []ent.Edge { return []ent.Edge{ edge.From("matches", Match.Type).Ref("stats").Unique().Field("match_stats"), edge.From("players", Player.Type).Ref("stats").Unique().Field("player_stats"), - edge.To("weapon_stats", WeaponStats.Type), + edge.To("weapon_stats", Weapon.Type), edge.To("round_stats", RoundStats.Type), + edge.To("spray", Spray.Type), } } diff --git a/ent/schema/player.go b/ent/schema/player.go index fd99270..2c863b5 100644 --- a/ent/schema/player.go +++ b/ent/schema/player.go @@ -31,13 +31,16 @@ func (Player) Fields() []ent.Field { field.String("auth_code").Optional().Sensitive(), field.Time("profile_created").Optional(), field.String("oldest_sharecode_seen").Optional(), + field.Int("wins").Optional(), + field.Int("looses").Optional(), + field.Int("ties").Optional(), } } // Edges of the Player. func (Player) Edges() []ent.Edge { return []ent.Edge{ - edge.To("stats", Stats.Type), + edge.To("stats", MatchPlayer.Type), edge.To("matches", Match.Type), } } diff --git a/ent/schema/roundstats.go b/ent/schema/roundstats.go index a667984..7a98b22 100644 --- a/ent/schema/roundstats.go +++ b/ent/schema/roundstats.go @@ -24,6 +24,6 @@ func (RoundStats) Fields() []ent.Field { // Edges of the RoundStats. func (RoundStats) Edges() []ent.Edge { return []ent.Edge{ - edge.From("stat", Stats.Type).Ref("round_stats").Unique(), + edge.From("match_player", MatchPlayer.Type).Ref("round_stats").Unique(), } } diff --git a/ent/schema/spray.go b/ent/schema/spray.go new file mode 100644 index 0000000..7b5881b --- /dev/null +++ b/ent/schema/spray.go @@ -0,0 +1,27 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +// Spray holds the schema definition for the Spray entity. +type Spray struct { + ent.Schema +} + +// Fields of the Spray. +func (Spray) Fields() []ent.Field { + return []ent.Field{ + field.Int("weapon"), + field.Bytes("spray"), + } +} + +// Edges of the Spray. +func (Spray) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("match_players", MatchPlayer.Type).Ref("spray").Unique(), + } +} diff --git a/ent/schema/weapon.go b/ent/schema/weapon.go new file mode 100644 index 0000000..b191b3e --- /dev/null +++ b/ent/schema/weapon.go @@ -0,0 +1,29 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +// Weapon holds the schema definition for the Weapon entity. +type Weapon struct { + ent.Schema +} + +// Fields of the Weapon. +func (Weapon) Fields() []ent.Field { + return []ent.Field{ + field.Uint64("victim"), + field.Uint("dmg"), + field.Int("eq_type"), + field.Int("hit_group"), + } +} + +// Edges of the Weapon. +func (Weapon) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("stat", MatchPlayer.Type).Ref("weapon_stats").Unique(), + } +} diff --git a/ent/schema/weaponstats.go b/ent/schema/weaponstats.go deleted file mode 100644 index 25dac93..0000000 --- a/ent/schema/weaponstats.go +++ /dev/null @@ -1,29 +0,0 @@ -package schema - -import ( - "entgo.io/ent" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" -) - -// WeaponStats holds the schema definition for the WeaponStats entity. -type WeaponStats struct { - ent.Schema -} - -// Fields of the WeaponStats. -func (WeaponStats) Fields() []ent.Field { - return []ent.Field{ - field.Uint64("victim"), - field.Uint("dmg"), - field.Int("eq_type"), - field.Int("hit_group"), - } -} - -// Edges of the WeaponStats. -func (WeaponStats) Edges() []ent.Edge { - return []ent.Edge{ - edge.From("stat", Stats.Type).Ref("weapon_stats").Unique(), - } -} diff --git a/ent/spray.go b/ent/spray.go new file mode 100644 index 0000000..b5833e8 --- /dev/null +++ b/ent/spray.go @@ -0,0 +1,151 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "csgowtfd/ent/matchplayer" + "csgowtfd/ent/spray" + "fmt" + "strings" + + "entgo.io/ent/dialect/sql" +) + +// Spray is the model entity for the Spray schema. +type Spray struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Weapon holds the value of the "weapon" field. + Weapon int `json:"weapon,omitempty"` + // Spray holds the value of the "spray" field. + Spray []byte `json:"spray,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the SprayQuery when eager-loading is set. + Edges SprayEdges `json:"edges"` + match_player_spray *int +} + +// SprayEdges holds the relations/edges for other nodes in the graph. +type SprayEdges struct { + // MatchPlayers holds the value of the match_players edge. + MatchPlayers *MatchPlayer `json:"match_players,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// MatchPlayersOrErr returns the MatchPlayers value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e SprayEdges) MatchPlayersOrErr() (*MatchPlayer, error) { + if e.loadedTypes[0] { + if e.MatchPlayers == nil { + // The edge match_players was loaded in eager-loading, + // but was not found. + return nil, &NotFoundError{label: matchplayer.Label} + } + return e.MatchPlayers, nil + } + return nil, &NotLoadedError{edge: "match_players"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Spray) scanValues(columns []string) ([]interface{}, error) { + values := make([]interface{}, len(columns)) + for i := range columns { + switch columns[i] { + case spray.FieldSpray: + values[i] = new([]byte) + case spray.FieldID, spray.FieldWeapon: + values[i] = new(sql.NullInt64) + case spray.ForeignKeys[0]: // match_player_spray + values[i] = new(sql.NullInt64) + default: + return nil, fmt.Errorf("unexpected column %q for type Spray", columns[i]) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Spray fields. +func (s *Spray) assignValues(columns []string, values []interface{}) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case spray.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + s.ID = int(value.Int64) + case spray.FieldWeapon: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field weapon", values[i]) + } else if value.Valid { + s.Weapon = int(value.Int64) + } + case spray.FieldSpray: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field spray", values[i]) + } else if value != nil { + s.Spray = *value + } + case spray.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field match_player_spray", value) + } else if value.Valid { + s.match_player_spray = new(int) + *s.match_player_spray = int(value.Int64) + } + } + } + return nil +} + +// QueryMatchPlayers queries the "match_players" edge of the Spray entity. +func (s *Spray) QueryMatchPlayers() *MatchPlayerQuery { + return (&SprayClient{config: s.config}).QueryMatchPlayers(s) +} + +// Update returns a builder for updating this Spray. +// Note that you need to call Spray.Unwrap() before calling this method if this Spray +// was returned from a transaction, and the transaction was committed or rolled back. +func (s *Spray) Update() *SprayUpdateOne { + return (&SprayClient{config: s.config}).UpdateOne(s) +} + +// Unwrap unwraps the Spray entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (s *Spray) Unwrap() *Spray { + tx, ok := s.config.driver.(*txDriver) + if !ok { + panic("ent: Spray is not a transactional entity") + } + s.config.driver = tx.drv + return s +} + +// String implements the fmt.Stringer. +func (s *Spray) String() string { + var builder strings.Builder + builder.WriteString("Spray(") + builder.WriteString(fmt.Sprintf("id=%v", s.ID)) + builder.WriteString(", weapon=") + builder.WriteString(fmt.Sprintf("%v", s.Weapon)) + builder.WriteString(", spray=") + builder.WriteString(fmt.Sprintf("%v", s.Spray)) + builder.WriteByte(')') + return builder.String() +} + +// Sprays is a parsable slice of Spray. +type Sprays []*Spray + +func (s Sprays) config(cfg config) { + for _i := range s { + s[_i].config = cfg + } +} diff --git a/ent/spray/spray.go b/ent/spray/spray.go new file mode 100644 index 0000000..86c4a0f --- /dev/null +++ b/ent/spray/spray.go @@ -0,0 +1,53 @@ +// Code generated by entc, DO NOT EDIT. + +package spray + +const ( + // Label holds the string label denoting the spray type in the database. + Label = "spray" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldWeapon holds the string denoting the weapon field in the database. + FieldWeapon = "weapon" + // FieldSpray holds the string denoting the spray field in the database. + FieldSpray = "spray" + // EdgeMatchPlayers holds the string denoting the match_players edge name in mutations. + EdgeMatchPlayers = "match_players" + // Table holds the table name of the spray in the database. + Table = "sprays" + // MatchPlayersTable is the table that holds the match_players relation/edge. + MatchPlayersTable = "sprays" + // MatchPlayersInverseTable is the table name for the MatchPlayer entity. + // It exists in this package in order to avoid circular dependency with the "matchplayer" package. + MatchPlayersInverseTable = "match_players" + // MatchPlayersColumn is the table column denoting the match_players relation/edge. + MatchPlayersColumn = "match_player_spray" +) + +// Columns holds all SQL columns for spray fields. +var Columns = []string{ + FieldID, + FieldWeapon, + FieldSpray, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "sprays" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "match_player_spray", +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} diff --git a/ent/spray/where.go b/ent/spray/where.go new file mode 100644 index 0000000..a16d905 --- /dev/null +++ b/ent/spray/where.go @@ -0,0 +1,319 @@ +// Code generated by entc, DO NOT EDIT. + +package spray + +import ( + "csgowtfd/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldID), id)) + }) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldID), id)) + }) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldID), id)) + }) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(ids) == 0 { + s.Where(sql.False()) + return + } + v := make([]interface{}, len(ids)) + for i := range v { + v[i] = ids[i] + } + s.Where(sql.In(s.C(FieldID), v...)) + }) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(ids) == 0 { + s.Where(sql.False()) + return + } + v := make([]interface{}, len(ids)) + for i := range v { + v[i] = ids[i] + } + s.Where(sql.NotIn(s.C(FieldID), v...)) + }) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldID), id)) + }) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldID), id)) + }) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldID), id)) + }) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldID), id)) + }) +} + +// Weapon applies equality check predicate on the "weapon" field. It's identical to WeaponEQ. +func Weapon(v int) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldWeapon), v)) + }) +} + +// Spray applies equality check predicate on the "spray" field. It's identical to SprayEQ. +func Spray(v []byte) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldSpray), v)) + }) +} + +// WeaponEQ applies the EQ predicate on the "weapon" field. +func WeaponEQ(v int) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldWeapon), v)) + }) +} + +// WeaponNEQ applies the NEQ predicate on the "weapon" field. +func WeaponNEQ(v int) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldWeapon), v)) + }) +} + +// WeaponIn applies the In predicate on the "weapon" field. +func WeaponIn(vs ...int) predicate.Spray { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Spray(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldWeapon), v...)) + }) +} + +// WeaponNotIn applies the NotIn predicate on the "weapon" field. +func WeaponNotIn(vs ...int) predicate.Spray { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Spray(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldWeapon), v...)) + }) +} + +// WeaponGT applies the GT predicate on the "weapon" field. +func WeaponGT(v int) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldWeapon), v)) + }) +} + +// WeaponGTE applies the GTE predicate on the "weapon" field. +func WeaponGTE(v int) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldWeapon), v)) + }) +} + +// WeaponLT applies the LT predicate on the "weapon" field. +func WeaponLT(v int) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldWeapon), v)) + }) +} + +// WeaponLTE applies the LTE predicate on the "weapon" field. +func WeaponLTE(v int) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldWeapon), v)) + }) +} + +// SprayEQ applies the EQ predicate on the "spray" field. +func SprayEQ(v []byte) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldSpray), v)) + }) +} + +// SprayNEQ applies the NEQ predicate on the "spray" field. +func SprayNEQ(v []byte) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldSpray), v)) + }) +} + +// SprayIn applies the In predicate on the "spray" field. +func SprayIn(vs ...[]byte) predicate.Spray { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Spray(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldSpray), v...)) + }) +} + +// SprayNotIn applies the NotIn predicate on the "spray" field. +func SprayNotIn(vs ...[]byte) predicate.Spray { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Spray(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldSpray), v...)) + }) +} + +// SprayGT applies the GT predicate on the "spray" field. +func SprayGT(v []byte) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldSpray), v)) + }) +} + +// SprayGTE applies the GTE predicate on the "spray" field. +func SprayGTE(v []byte) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldSpray), v)) + }) +} + +// SprayLT applies the LT predicate on the "spray" field. +func SprayLT(v []byte) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldSpray), v)) + }) +} + +// SprayLTE applies the LTE predicate on the "spray" field. +func SprayLTE(v []byte) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldSpray), v)) + }) +} + +// HasMatchPlayers applies the HasEdge predicate on the "match_players" edge. +func HasMatchPlayers() predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(MatchPlayersTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, MatchPlayersTable, MatchPlayersColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasMatchPlayersWith applies the HasEdge predicate on the "match_players" edge with a given conditions (other predicates). +func HasMatchPlayersWith(preds ...predicate.MatchPlayer) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(MatchPlayersInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, MatchPlayersTable, MatchPlayersColumn), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Spray) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s1 := s.Clone().SetP(nil) + for _, p := range predicates { + p(s1) + } + s.Where(s1.P()) + }) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Spray) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + s1 := s.Clone().SetP(nil) + for i, p := range predicates { + if i > 0 { + s1.Or() + } + p(s1) + } + s.Where(s1.P()) + }) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Spray) predicate.Spray { + return predicate.Spray(func(s *sql.Selector) { + p(s.Not()) + }) +} diff --git a/ent/spray_create.go b/ent/spray_create.go new file mode 100644 index 0000000..025bfee --- /dev/null +++ b/ent/spray_create.go @@ -0,0 +1,277 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "csgowtfd/ent/matchplayer" + "csgowtfd/ent/spray" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// SprayCreate is the builder for creating a Spray entity. +type SprayCreate struct { + config + mutation *SprayMutation + hooks []Hook +} + +// SetWeapon sets the "weapon" field. +func (sc *SprayCreate) SetWeapon(i int) *SprayCreate { + sc.mutation.SetWeapon(i) + return sc +} + +// SetSpray sets the "spray" field. +func (sc *SprayCreate) SetSpray(b []byte) *SprayCreate { + sc.mutation.SetSpray(b) + return sc +} + +// SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID. +func (sc *SprayCreate) SetMatchPlayersID(id int) *SprayCreate { + sc.mutation.SetMatchPlayersID(id) + return sc +} + +// SetNillableMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID if the given value is not nil. +func (sc *SprayCreate) SetNillableMatchPlayersID(id *int) *SprayCreate { + if id != nil { + sc = sc.SetMatchPlayersID(*id) + } + return sc +} + +// SetMatchPlayers sets the "match_players" edge to the MatchPlayer entity. +func (sc *SprayCreate) SetMatchPlayers(m *MatchPlayer) *SprayCreate { + return sc.SetMatchPlayersID(m.ID) +} + +// Mutation returns the SprayMutation object of the builder. +func (sc *SprayCreate) Mutation() *SprayMutation { + return sc.mutation +} + +// Save creates the Spray in the database. +func (sc *SprayCreate) Save(ctx context.Context) (*Spray, error) { + var ( + err error + node *Spray + ) + if len(sc.hooks) == 0 { + if err = sc.check(); err != nil { + return nil, err + } + node, err = sc.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*SprayMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err = sc.check(); err != nil { + return nil, err + } + sc.mutation = mutation + if node, err = sc.sqlSave(ctx); err != nil { + return nil, err + } + mutation.id = &node.ID + mutation.done = true + return node, err + }) + for i := len(sc.hooks) - 1; i >= 0; i-- { + if sc.hooks[i] == nil { + return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = sc.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, sc.mutation); err != nil { + return nil, err + } + } + return node, err +} + +// SaveX calls Save and panics if Save returns an error. +func (sc *SprayCreate) SaveX(ctx context.Context) *Spray { + v, err := sc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (sc *SprayCreate) Exec(ctx context.Context) error { + _, err := sc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (sc *SprayCreate) ExecX(ctx context.Context) { + if err := sc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (sc *SprayCreate) check() error { + if _, ok := sc.mutation.Weapon(); !ok { + return &ValidationError{Name: "weapon", err: errors.New(`ent: missing required field "weapon"`)} + } + if _, ok := sc.mutation.Spray(); !ok { + return &ValidationError{Name: "spray", err: errors.New(`ent: missing required field "spray"`)} + } + return nil +} + +func (sc *SprayCreate) sqlSave(ctx context.Context) (*Spray, error) { + _node, _spec := sc.createSpec() + if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + return _node, nil +} + +func (sc *SprayCreate) createSpec() (*Spray, *sqlgraph.CreateSpec) { + var ( + _node = &Spray{config: sc.config} + _spec = &sqlgraph.CreateSpec{ + Table: spray.Table, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: spray.FieldID, + }, + } + ) + if value, ok := sc.mutation.Weapon(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: spray.FieldWeapon, + }) + _node.Weapon = value + } + if value, ok := sc.mutation.Spray(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeBytes, + Value: value, + Column: spray.FieldSpray, + }) + _node.Spray = value + } + if nodes := sc.mutation.MatchPlayersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: spray.MatchPlayersTable, + Columns: []string{spray.MatchPlayersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.match_player_spray = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// SprayCreateBulk is the builder for creating many Spray entities in bulk. +type SprayCreateBulk struct { + config + builders []*SprayCreate +} + +// Save creates the Spray entities in the database. +func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) { + specs := make([]*sqlgraph.CreateSpec, len(scb.builders)) + nodes := make([]*Spray, len(scb.builders)) + mutators := make([]Mutator, len(scb.builders)) + for i := range scb.builders { + func(i int, root context.Context) { + builder := scb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*SprayMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + nodes[i], specs[i] = builder.createSpec() + var err error + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, scb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, scb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, scb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (scb *SprayCreateBulk) SaveX(ctx context.Context) []*Spray { + v, err := scb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (scb *SprayCreateBulk) Exec(ctx context.Context) error { + _, err := scb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (scb *SprayCreateBulk) ExecX(ctx context.Context) { + if err := scb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/stats_delete.go b/ent/spray_delete.go similarity index 68% rename from ent/stats_delete.go rename to ent/spray_delete.go index 54fe570..d71ec28 100644 --- a/ent/stats_delete.go +++ b/ent/spray_delete.go @@ -5,7 +5,7 @@ package ent import ( "context" "csgowtfd/ent/predicate" - "csgowtfd/ent/stats" + "csgowtfd/ent/spray" "fmt" "entgo.io/ent/dialect/sql" @@ -13,21 +13,21 @@ import ( "entgo.io/ent/schema/field" ) -// StatsDelete is the builder for deleting a Stats entity. -type StatsDelete struct { +// SprayDelete is the builder for deleting a Spray entity. +type SprayDelete struct { config hooks []Hook - mutation *StatsMutation + mutation *SprayMutation } -// Where appends a list predicates to the StatsDelete builder. -func (sd *StatsDelete) Where(ps ...predicate.Stats) *StatsDelete { +// Where appends a list predicates to the SprayDelete builder. +func (sd *SprayDelete) Where(ps ...predicate.Spray) *SprayDelete { sd.mutation.Where(ps...) return sd } // Exec executes the deletion query and returns how many vertices were deleted. -func (sd *StatsDelete) Exec(ctx context.Context) (int, error) { +func (sd *SprayDelete) Exec(ctx context.Context) (int, error) { var ( err error affected int @@ -36,7 +36,7 @@ func (sd *StatsDelete) Exec(ctx context.Context) (int, error) { affected, err = sd.sqlExec(ctx) } else { var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*StatsMutation) + mutation, ok := m.(*SprayMutation) if !ok { return nil, fmt.Errorf("unexpected mutation type %T", m) } @@ -59,7 +59,7 @@ func (sd *StatsDelete) Exec(ctx context.Context) (int, error) { } // ExecX is like Exec, but panics if an error occurs. -func (sd *StatsDelete) ExecX(ctx context.Context) int { +func (sd *SprayDelete) ExecX(ctx context.Context) int { n, err := sd.Exec(ctx) if err != nil { panic(err) @@ -67,13 +67,13 @@ func (sd *StatsDelete) ExecX(ctx context.Context) int { return n } -func (sd *StatsDelete) sqlExec(ctx context.Context) (int, error) { +func (sd *SprayDelete) sqlExec(ctx context.Context) (int, error) { _spec := &sqlgraph.DeleteSpec{ Node: &sqlgraph.NodeSpec{ - Table: stats.Table, + Table: spray.Table, ID: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: spray.FieldID, }, }, } @@ -87,25 +87,25 @@ func (sd *StatsDelete) sqlExec(ctx context.Context) (int, error) { return sqlgraph.DeleteNodes(ctx, sd.driver, _spec) } -// StatsDeleteOne is the builder for deleting a single Stats entity. -type StatsDeleteOne struct { - sd *StatsDelete +// SprayDeleteOne is the builder for deleting a single Spray entity. +type SprayDeleteOne struct { + sd *SprayDelete } // Exec executes the deletion query. -func (sdo *StatsDeleteOne) Exec(ctx context.Context) error { +func (sdo *SprayDeleteOne) Exec(ctx context.Context) error { n, err := sdo.sd.Exec(ctx) switch { case err != nil: return err case n == 0: - return &NotFoundError{stats.Label} + return &NotFoundError{spray.Label} default: return nil } } // ExecX is like Exec, but panics if an error occurs. -func (sdo *StatsDeleteOne) ExecX(ctx context.Context) { +func (sdo *SprayDeleteOne) ExecX(ctx context.Context) { sdo.sd.ExecX(ctx) } diff --git a/ent/stats_query.go b/ent/spray_query.go similarity index 52% rename from ent/stats_query.go rename to ent/spray_query.go index bc72692..d703af5 100644 --- a/ent/stats_query.go +++ b/ent/spray_query.go @@ -4,13 +4,9 @@ package ent import ( "context" - "csgowtfd/ent/match" - "csgowtfd/ent/player" + "csgowtfd/ent/matchplayer" "csgowtfd/ent/predicate" - "csgowtfd/ent/roundstats" - "csgowtfd/ent/stats" - "csgowtfd/ent/weaponstats" - "database/sql/driver" + "csgowtfd/ent/spray" "errors" "fmt" "math" @@ -20,60 +16,58 @@ import ( "entgo.io/ent/schema/field" ) -// StatsQuery is the builder for querying Stats entities. -type StatsQuery struct { +// SprayQuery is the builder for querying Spray entities. +type SprayQuery struct { config limit *int offset *int unique *bool order []OrderFunc fields []string - predicates []predicate.Stats + predicates []predicate.Spray // eager-loading edges. - withMatches *MatchQuery - withPlayers *PlayerQuery - withWeaponStats *WeaponStatsQuery - withRoundStats *RoundStatsQuery - modifiers []func(s *sql.Selector) + withMatchPlayers *MatchPlayerQuery + withFKs bool + modifiers []func(s *sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) } -// Where adds a new predicate for the StatsQuery builder. -func (sq *StatsQuery) Where(ps ...predicate.Stats) *StatsQuery { +// Where adds a new predicate for the SprayQuery builder. +func (sq *SprayQuery) Where(ps ...predicate.Spray) *SprayQuery { sq.predicates = append(sq.predicates, ps...) return sq } // Limit adds a limit step to the query. -func (sq *StatsQuery) Limit(limit int) *StatsQuery { +func (sq *SprayQuery) Limit(limit int) *SprayQuery { sq.limit = &limit return sq } // Offset adds an offset step to the query. -func (sq *StatsQuery) Offset(offset int) *StatsQuery { +func (sq *SprayQuery) Offset(offset int) *SprayQuery { sq.offset = &offset return sq } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (sq *StatsQuery) Unique(unique bool) *StatsQuery { +func (sq *SprayQuery) Unique(unique bool) *SprayQuery { sq.unique = &unique return sq } // Order adds an order step to the query. -func (sq *StatsQuery) Order(o ...OrderFunc) *StatsQuery { +func (sq *SprayQuery) Order(o ...OrderFunc) *SprayQuery { sq.order = append(sq.order, o...) return sq } -// QueryMatches chains the current query on the "matches" edge. -func (sq *StatsQuery) QueryMatches() *MatchQuery { - query := &MatchQuery{config: sq.config} +// QueryMatchPlayers chains the current query on the "match_players" edge. +func (sq *SprayQuery) QueryMatchPlayers() *MatchPlayerQuery { + query := &MatchPlayerQuery{config: sq.config} query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := sq.prepareQuery(ctx); err != nil { return nil, err @@ -83,9 +77,9 @@ func (sq *StatsQuery) QueryMatches() *MatchQuery { return nil, err } step := sqlgraph.NewStep( - sqlgraph.From(stats.Table, stats.FieldID, selector), - sqlgraph.To(match.Table, match.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, stats.MatchesTable, stats.MatchesColumn), + sqlgraph.From(spray.Table, spray.FieldID, selector), + sqlgraph.To(matchplayer.Table, matchplayer.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, spray.MatchPlayersTable, spray.MatchPlayersColumn), ) fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) return fromU, nil @@ -93,87 +87,21 @@ func (sq *StatsQuery) QueryMatches() *MatchQuery { return query } -// QueryPlayers chains the current query on the "players" edge. -func (sq *StatsQuery) QueryPlayers() *PlayerQuery { - query := &PlayerQuery{config: sq.config} - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := sq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := sq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(stats.Table, stats.FieldID, selector), - sqlgraph.To(player.Table, player.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, stats.PlayersTable, stats.PlayersColumn), - ) - fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryWeaponStats chains the current query on the "weapon_stats" edge. -func (sq *StatsQuery) QueryWeaponStats() *WeaponStatsQuery { - query := &WeaponStatsQuery{config: sq.config} - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := sq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := sq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(stats.Table, stats.FieldID, selector), - sqlgraph.To(weaponstats.Table, weaponstats.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, stats.WeaponStatsTable, stats.WeaponStatsColumn), - ) - fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryRoundStats chains the current query on the "round_stats" edge. -func (sq *StatsQuery) QueryRoundStats() *RoundStatsQuery { - query := &RoundStatsQuery{config: sq.config} - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := sq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := sq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(stats.Table, stats.FieldID, selector), - sqlgraph.To(roundstats.Table, roundstats.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, stats.RoundStatsTable, stats.RoundStatsColumn), - ) - fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first Stats entity from the query. -// Returns a *NotFoundError when no Stats was found. -func (sq *StatsQuery) First(ctx context.Context) (*Stats, error) { +// First returns the first Spray entity from the query. +// Returns a *NotFoundError when no Spray was found. +func (sq *SprayQuery) First(ctx context.Context) (*Spray, error) { nodes, err := sq.Limit(1).All(ctx) if err != nil { return nil, err } if len(nodes) == 0 { - return nil, &NotFoundError{stats.Label} + return nil, &NotFoundError{spray.Label} } return nodes[0], nil } // FirstX is like First, but panics if an error occurs. -func (sq *StatsQuery) FirstX(ctx context.Context) *Stats { +func (sq *SprayQuery) FirstX(ctx context.Context) *Spray { node, err := sq.First(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -181,22 +109,22 @@ func (sq *StatsQuery) FirstX(ctx context.Context) *Stats { return node } -// FirstID returns the first Stats ID from the query. -// Returns a *NotFoundError when no Stats ID was found. -func (sq *StatsQuery) FirstID(ctx context.Context) (id int, err error) { +// FirstID returns the first Spray ID from the query. +// Returns a *NotFoundError when no Spray ID was found. +func (sq *SprayQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int if ids, err = sq.Limit(1).IDs(ctx); err != nil { return } if len(ids) == 0 { - err = &NotFoundError{stats.Label} + err = &NotFoundError{spray.Label} return } return ids[0], nil } // FirstIDX is like FirstID, but panics if an error occurs. -func (sq *StatsQuery) FirstIDX(ctx context.Context) int { +func (sq *SprayQuery) FirstIDX(ctx context.Context) int { id, err := sq.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -204,10 +132,10 @@ func (sq *StatsQuery) FirstIDX(ctx context.Context) int { return id } -// Only returns a single Stats entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when exactly one Stats entity is not found. -// Returns a *NotFoundError when no Stats entities are found. -func (sq *StatsQuery) Only(ctx context.Context) (*Stats, error) { +// Only returns a single Spray entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when exactly one Spray entity is not found. +// Returns a *NotFoundError when no Spray entities are found. +func (sq *SprayQuery) Only(ctx context.Context) (*Spray, error) { nodes, err := sq.Limit(2).All(ctx) if err != nil { return nil, err @@ -216,14 +144,14 @@ func (sq *StatsQuery) Only(ctx context.Context) (*Stats, error) { case 1: return nodes[0], nil case 0: - return nil, &NotFoundError{stats.Label} + return nil, &NotFoundError{spray.Label} default: - return nil, &NotSingularError{stats.Label} + return nil, &NotSingularError{spray.Label} } } // OnlyX is like Only, but panics if an error occurs. -func (sq *StatsQuery) OnlyX(ctx context.Context) *Stats { +func (sq *SprayQuery) OnlyX(ctx context.Context) *Spray { node, err := sq.Only(ctx) if err != nil { panic(err) @@ -231,10 +159,10 @@ func (sq *StatsQuery) OnlyX(ctx context.Context) *Stats { return node } -// OnlyID is like Only, but returns the only Stats ID in the query. -// Returns a *NotSingularError when exactly one Stats ID is not found. +// OnlyID is like Only, but returns the only Spray ID in the query. +// Returns a *NotSingularError when exactly one Spray ID is not found. // Returns a *NotFoundError when no entities are found. -func (sq *StatsQuery) OnlyID(ctx context.Context) (id int, err error) { +func (sq *SprayQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int if ids, err = sq.Limit(2).IDs(ctx); err != nil { return @@ -243,15 +171,15 @@ func (sq *StatsQuery) OnlyID(ctx context.Context) (id int, err error) { case 1: id = ids[0] case 0: - err = &NotFoundError{stats.Label} + err = &NotFoundError{spray.Label} default: - err = &NotSingularError{stats.Label} + err = &NotSingularError{spray.Label} } return } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (sq *StatsQuery) OnlyIDX(ctx context.Context) int { +func (sq *SprayQuery) OnlyIDX(ctx context.Context) int { id, err := sq.OnlyID(ctx) if err != nil { panic(err) @@ -259,8 +187,8 @@ func (sq *StatsQuery) OnlyIDX(ctx context.Context) int { return id } -// All executes the query and returns a list of StatsSlice. -func (sq *StatsQuery) All(ctx context.Context) ([]*Stats, error) { +// All executes the query and returns a list of Sprays. +func (sq *SprayQuery) All(ctx context.Context) ([]*Spray, error) { if err := sq.prepareQuery(ctx); err != nil { return nil, err } @@ -268,7 +196,7 @@ func (sq *StatsQuery) All(ctx context.Context) ([]*Stats, error) { } // AllX is like All, but panics if an error occurs. -func (sq *StatsQuery) AllX(ctx context.Context) []*Stats { +func (sq *SprayQuery) AllX(ctx context.Context) []*Spray { nodes, err := sq.All(ctx) if err != nil { panic(err) @@ -276,17 +204,17 @@ func (sq *StatsQuery) AllX(ctx context.Context) []*Stats { return nodes } -// IDs executes the query and returns a list of Stats IDs. -func (sq *StatsQuery) IDs(ctx context.Context) ([]int, error) { +// IDs executes the query and returns a list of Spray IDs. +func (sq *SprayQuery) IDs(ctx context.Context) ([]int, error) { var ids []int - if err := sq.Select(stats.FieldID).Scan(ctx, &ids); err != nil { + if err := sq.Select(spray.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (sq *StatsQuery) IDsX(ctx context.Context) []int { +func (sq *SprayQuery) IDsX(ctx context.Context) []int { ids, err := sq.IDs(ctx) if err != nil { panic(err) @@ -295,7 +223,7 @@ func (sq *StatsQuery) IDsX(ctx context.Context) []int { } // Count returns the count of the given query. -func (sq *StatsQuery) Count(ctx context.Context) (int, error) { +func (sq *SprayQuery) Count(ctx context.Context) (int, error) { if err := sq.prepareQuery(ctx); err != nil { return 0, err } @@ -303,7 +231,7 @@ func (sq *StatsQuery) Count(ctx context.Context) (int, error) { } // CountX is like Count, but panics if an error occurs. -func (sq *StatsQuery) CountX(ctx context.Context) int { +func (sq *SprayQuery) CountX(ctx context.Context) int { count, err := sq.Count(ctx) if err != nil { panic(err) @@ -312,7 +240,7 @@ func (sq *StatsQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (sq *StatsQuery) Exist(ctx context.Context) (bool, error) { +func (sq *SprayQuery) Exist(ctx context.Context) (bool, error) { if err := sq.prepareQuery(ctx); err != nil { return false, err } @@ -320,7 +248,7 @@ func (sq *StatsQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (sq *StatsQuery) ExistX(ctx context.Context) bool { +func (sq *SprayQuery) ExistX(ctx context.Context) bool { exist, err := sq.Exist(ctx) if err != nil { panic(err) @@ -328,69 +256,33 @@ func (sq *StatsQuery) ExistX(ctx context.Context) bool { return exist } -// Clone returns a duplicate of the StatsQuery builder, including all associated steps. It can be +// Clone returns a duplicate of the SprayQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (sq *StatsQuery) Clone() *StatsQuery { +func (sq *SprayQuery) Clone() *SprayQuery { if sq == nil { return nil } - return &StatsQuery{ - config: sq.config, - limit: sq.limit, - offset: sq.offset, - order: append([]OrderFunc{}, sq.order...), - predicates: append([]predicate.Stats{}, sq.predicates...), - withMatches: sq.withMatches.Clone(), - withPlayers: sq.withPlayers.Clone(), - withWeaponStats: sq.withWeaponStats.Clone(), - withRoundStats: sq.withRoundStats.Clone(), + return &SprayQuery{ + config: sq.config, + limit: sq.limit, + offset: sq.offset, + order: append([]OrderFunc{}, sq.order...), + predicates: append([]predicate.Spray{}, sq.predicates...), + withMatchPlayers: sq.withMatchPlayers.Clone(), // clone intermediate query. sql: sq.sql.Clone(), path: sq.path, } } -// WithMatches tells the query-builder to eager-load the nodes that are connected to -// the "matches" edge. The optional arguments are used to configure the query builder of the edge. -func (sq *StatsQuery) WithMatches(opts ...func(*MatchQuery)) *StatsQuery { - query := &MatchQuery{config: sq.config} +// WithMatchPlayers tells the query-builder to eager-load the nodes that are connected to +// the "match_players" edge. The optional arguments are used to configure the query builder of the edge. +func (sq *SprayQuery) WithMatchPlayers(opts ...func(*MatchPlayerQuery)) *SprayQuery { + query := &MatchPlayerQuery{config: sq.config} for _, opt := range opts { opt(query) } - sq.withMatches = query - return sq -} - -// WithPlayers tells the query-builder to eager-load the nodes that are connected to -// the "players" edge. The optional arguments are used to configure the query builder of the edge. -func (sq *StatsQuery) WithPlayers(opts ...func(*PlayerQuery)) *StatsQuery { - query := &PlayerQuery{config: sq.config} - for _, opt := range opts { - opt(query) - } - sq.withPlayers = query - return sq -} - -// WithWeaponStats tells the query-builder to eager-load the nodes that are connected to -// the "weapon_stats" edge. The optional arguments are used to configure the query builder of the edge. -func (sq *StatsQuery) WithWeaponStats(opts ...func(*WeaponStatsQuery)) *StatsQuery { - query := &WeaponStatsQuery{config: sq.config} - for _, opt := range opts { - opt(query) - } - sq.withWeaponStats = query - return sq -} - -// WithRoundStats tells the query-builder to eager-load the nodes that are connected to -// the "round_stats" edge. The optional arguments are used to configure the query builder of the edge. -func (sq *StatsQuery) WithRoundStats(opts ...func(*RoundStatsQuery)) *StatsQuery { - query := &RoundStatsQuery{config: sq.config} - for _, opt := range opts { - opt(query) - } - sq.withRoundStats = query + sq.withMatchPlayers = query return sq } @@ -400,17 +292,17 @@ func (sq *StatsQuery) WithRoundStats(opts ...func(*RoundStatsQuery)) *StatsQuery // Example: // // var v []struct { -// TeamID int `json:"team_id,omitempty"` +// Weapon int `json:"weapon,omitempty"` // Count int `json:"count,omitempty"` // } // -// client.Stats.Query(). -// GroupBy(stats.FieldTeamID). +// client.Spray.Query(). +// GroupBy(spray.FieldWeapon). // Aggregate(ent.Count()). // Scan(ctx, &v) // -func (sq *StatsQuery) GroupBy(field string, fields ...string) *StatsGroupBy { - group := &StatsGroupBy{config: sq.config} +func (sq *SprayQuery) GroupBy(field string, fields ...string) *SprayGroupBy { + group := &SprayGroupBy{config: sq.config} group.fields = append([]string{field}, fields...) group.path = func(ctx context.Context) (prev *sql.Selector, err error) { if err := sq.prepareQuery(ctx); err != nil { @@ -427,21 +319,21 @@ func (sq *StatsQuery) GroupBy(field string, fields ...string) *StatsGroupBy { // Example: // // var v []struct { -// TeamID int `json:"team_id,omitempty"` +// Weapon int `json:"weapon,omitempty"` // } // -// client.Stats.Query(). -// Select(stats.FieldTeamID). +// client.Spray.Query(). +// Select(spray.FieldWeapon). // Scan(ctx, &v) // -func (sq *StatsQuery) Select(fields ...string) *StatsSelect { +func (sq *SprayQuery) Select(fields ...string) *SpraySelect { sq.fields = append(sq.fields, fields...) - return &StatsSelect{StatsQuery: sq} + return &SpraySelect{SprayQuery: sq} } -func (sq *StatsQuery) prepareQuery(ctx context.Context) error { +func (sq *SprayQuery) prepareQuery(ctx context.Context) error { for _, f := range sq.fields { - if !stats.ValidColumn(f) { + if !spray.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } @@ -455,19 +347,23 @@ func (sq *StatsQuery) prepareQuery(ctx context.Context) error { return nil } -func (sq *StatsQuery) sqlAll(ctx context.Context) ([]*Stats, error) { +func (sq *SprayQuery) sqlAll(ctx context.Context) ([]*Spray, error) { var ( - nodes = []*Stats{} + nodes = []*Spray{} + withFKs = sq.withFKs _spec = sq.querySpec() - loadedTypes = [4]bool{ - sq.withMatches != nil, - sq.withPlayers != nil, - sq.withWeaponStats != nil, - sq.withRoundStats != nil, + loadedTypes = [1]bool{ + sq.withMatchPlayers != nil, } ) + if sq.withMatchPlayers != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, spray.ForeignKeys...) + } _spec.ScanValues = func(columns []string) ([]interface{}, error) { - node := &Stats{config: sq.config} + node := &Spray{config: sq.config} nodes = append(nodes, node) return node.scanValues(columns) } @@ -489,17 +385,20 @@ func (sq *StatsQuery) sqlAll(ctx context.Context) ([]*Stats, error) { return nodes, nil } - if query := sq.withMatches; query != nil { - ids := make([]uint64, 0, len(nodes)) - nodeids := make(map[uint64][]*Stats) + if query := sq.withMatchPlayers; query != nil { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*Spray) for i := range nodes { - fk := nodes[i].MatchStats + if nodes[i].match_player_spray == nil { + continue + } + fk := *nodes[i].match_player_spray if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } nodeids[fk] = append(nodeids[fk], nodes[i]) } - query.Where(match.IDIn(ids...)) + query.Where(matchplayer.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { return nil, err @@ -507,102 +406,18 @@ func (sq *StatsQuery) sqlAll(ctx context.Context) ([]*Stats, error) { for _, n := range neighbors { nodes, ok := nodeids[n.ID] if !ok { - return nil, fmt.Errorf(`unexpected foreign-key "match_stats" returned %v`, n.ID) + return nil, fmt.Errorf(`unexpected foreign-key "match_player_spray" returned %v`, n.ID) } for i := range nodes { - nodes[i].Edges.Matches = n + nodes[i].Edges.MatchPlayers = n } } } - if query := sq.withPlayers; query != nil { - ids := make([]uint64, 0, len(nodes)) - nodeids := make(map[uint64][]*Stats) - for i := range nodes { - fk := nodes[i].PlayerStats - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - query.Where(player.IDIn(ids...)) - neighbors, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, n := range neighbors { - nodes, ok := nodeids[n.ID] - if !ok { - return nil, fmt.Errorf(`unexpected foreign-key "player_stats" returned %v`, n.ID) - } - for i := range nodes { - nodes[i].Edges.Players = n - } - } - } - - if query := sq.withWeaponStats; query != nil { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int]*Stats) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - nodes[i].Edges.WeaponStats = []*WeaponStats{} - } - query.withFKs = true - query.Where(predicate.WeaponStats(func(s *sql.Selector) { - s.Where(sql.InValues(stats.WeaponStatsColumn, fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, n := range neighbors { - fk := n.stats_weapon_stats - if fk == nil { - return nil, fmt.Errorf(`foreign-key "stats_weapon_stats" is nil for node %v`, n.ID) - } - node, ok := nodeids[*fk] - if !ok { - return nil, fmt.Errorf(`unexpected foreign-key "stats_weapon_stats" returned %v for node %v`, *fk, n.ID) - } - node.Edges.WeaponStats = append(node.Edges.WeaponStats, n) - } - } - - if query := sq.withRoundStats; query != nil { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int]*Stats) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - nodes[i].Edges.RoundStats = []*RoundStats{} - } - query.withFKs = true - query.Where(predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.InValues(stats.RoundStatsColumn, fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, n := range neighbors { - fk := n.stats_round_stats - if fk == nil { - return nil, fmt.Errorf(`foreign-key "stats_round_stats" is nil for node %v`, n.ID) - } - node, ok := nodeids[*fk] - if !ok { - return nil, fmt.Errorf(`unexpected foreign-key "stats_round_stats" returned %v for node %v`, *fk, n.ID) - } - node.Edges.RoundStats = append(node.Edges.RoundStats, n) - } - } - return nodes, nil } -func (sq *StatsQuery) sqlCount(ctx context.Context) (int, error) { +func (sq *SprayQuery) sqlCount(ctx context.Context) (int, error) { _spec := sq.querySpec() if len(sq.modifiers) > 0 { _spec.Modifiers = sq.modifiers @@ -610,7 +425,7 @@ func (sq *StatsQuery) sqlCount(ctx context.Context) (int, error) { return sqlgraph.CountNodes(ctx, sq.driver, _spec) } -func (sq *StatsQuery) sqlExist(ctx context.Context) (bool, error) { +func (sq *SprayQuery) sqlExist(ctx context.Context) (bool, error) { n, err := sq.sqlCount(ctx) if err != nil { return false, fmt.Errorf("ent: check existence: %w", err) @@ -618,14 +433,14 @@ func (sq *StatsQuery) sqlExist(ctx context.Context) (bool, error) { return n > 0, nil } -func (sq *StatsQuery) querySpec() *sqlgraph.QuerySpec { +func (sq *SprayQuery) querySpec() *sqlgraph.QuerySpec { _spec := &sqlgraph.QuerySpec{ Node: &sqlgraph.NodeSpec{ - Table: stats.Table, - Columns: stats.Columns, + Table: spray.Table, + Columns: spray.Columns, ID: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: stats.FieldID, + Column: spray.FieldID, }, }, From: sq.sql, @@ -636,9 +451,9 @@ func (sq *StatsQuery) querySpec() *sqlgraph.QuerySpec { } if fields := sq.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, stats.FieldID) + _spec.Node.Columns = append(_spec.Node.Columns, spray.FieldID) for i := range fields { - if fields[i] != stats.FieldID { + if fields[i] != spray.FieldID { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } @@ -666,12 +481,12 @@ func (sq *StatsQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (sq *StatsQuery) sqlQuery(ctx context.Context) *sql.Selector { +func (sq *SprayQuery) sqlQuery(ctx context.Context) *sql.Selector { builder := sql.Dialect(sq.driver.Dialect()) - t1 := builder.Table(stats.Table) + t1 := builder.Table(spray.Table) columns := sq.fields if len(columns) == 0 { - columns = stats.Columns + columns = spray.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) if sq.sql != nil { @@ -699,13 +514,13 @@ func (sq *StatsQuery) sqlQuery(ctx context.Context) *sql.Selector { } // Modify adds a query modifier for attaching custom logic to queries. -func (sq *StatsQuery) Modify(modifiers ...func(s *sql.Selector)) *StatsSelect { +func (sq *SprayQuery) Modify(modifiers ...func(s *sql.Selector)) *SpraySelect { sq.modifiers = append(sq.modifiers, modifiers...) return sq.Select() } -// StatsGroupBy is the group-by builder for Stats entities. -type StatsGroupBy struct { +// SprayGroupBy is the group-by builder for Spray entities. +type SprayGroupBy struct { config fields []string fns []AggregateFunc @@ -715,13 +530,13 @@ type StatsGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (sgb *StatsGroupBy) Aggregate(fns ...AggregateFunc) *StatsGroupBy { +func (sgb *SprayGroupBy) Aggregate(fns ...AggregateFunc) *SprayGroupBy { sgb.fns = append(sgb.fns, fns...) return sgb } // Scan applies the group-by query and scans the result into the given value. -func (sgb *StatsGroupBy) Scan(ctx context.Context, v interface{}) error { +func (sgb *SprayGroupBy) Scan(ctx context.Context, v interface{}) error { query, err := sgb.path(ctx) if err != nil { return err @@ -731,7 +546,7 @@ func (sgb *StatsGroupBy) Scan(ctx context.Context, v interface{}) error { } // ScanX is like Scan, but panics if an error occurs. -func (sgb *StatsGroupBy) ScanX(ctx context.Context, v interface{}) { +func (sgb *SprayGroupBy) ScanX(ctx context.Context, v interface{}) { if err := sgb.Scan(ctx, v); err != nil { panic(err) } @@ -739,9 +554,9 @@ func (sgb *StatsGroupBy) ScanX(ctx context.Context, v interface{}) { // Strings returns list of strings from group-by. // It is only allowed when executing a group-by query with one field. -func (sgb *StatsGroupBy) Strings(ctx context.Context) ([]string, error) { +func (sgb *SprayGroupBy) Strings(ctx context.Context) ([]string, error) { if len(sgb.fields) > 1 { - return nil, errors.New("ent: StatsGroupBy.Strings is not achievable when grouping more than 1 field") + return nil, errors.New("ent: SprayGroupBy.Strings is not achievable when grouping more than 1 field") } var v []string if err := sgb.Scan(ctx, &v); err != nil { @@ -751,7 +566,7 @@ func (sgb *StatsGroupBy) Strings(ctx context.Context) ([]string, error) { } // StringsX is like Strings, but panics if an error occurs. -func (sgb *StatsGroupBy) StringsX(ctx context.Context) []string { +func (sgb *SprayGroupBy) StringsX(ctx context.Context) []string { v, err := sgb.Strings(ctx) if err != nil { panic(err) @@ -761,7 +576,7 @@ func (sgb *StatsGroupBy) StringsX(ctx context.Context) []string { // String returns a single string from a group-by query. // It is only allowed when executing a group-by query with one field. -func (sgb *StatsGroupBy) String(ctx context.Context) (_ string, err error) { +func (sgb *SprayGroupBy) String(ctx context.Context) (_ string, err error) { var v []string if v, err = sgb.Strings(ctx); err != nil { return @@ -770,15 +585,15 @@ func (sgb *StatsGroupBy) String(ctx context.Context) (_ string, err error) { case 1: return v[0], nil case 0: - err = &NotFoundError{stats.Label} + err = &NotFoundError{spray.Label} default: - err = fmt.Errorf("ent: StatsGroupBy.Strings returned %d results when one was expected", len(v)) + err = fmt.Errorf("ent: SprayGroupBy.Strings returned %d results when one was expected", len(v)) } return } // StringX is like String, but panics if an error occurs. -func (sgb *StatsGroupBy) StringX(ctx context.Context) string { +func (sgb *SprayGroupBy) StringX(ctx context.Context) string { v, err := sgb.String(ctx) if err != nil { panic(err) @@ -788,9 +603,9 @@ func (sgb *StatsGroupBy) StringX(ctx context.Context) string { // Ints returns list of ints from group-by. // It is only allowed when executing a group-by query with one field. -func (sgb *StatsGroupBy) Ints(ctx context.Context) ([]int, error) { +func (sgb *SprayGroupBy) Ints(ctx context.Context) ([]int, error) { if len(sgb.fields) > 1 { - return nil, errors.New("ent: StatsGroupBy.Ints is not achievable when grouping more than 1 field") + return nil, errors.New("ent: SprayGroupBy.Ints is not achievable when grouping more than 1 field") } var v []int if err := sgb.Scan(ctx, &v); err != nil { @@ -800,7 +615,7 @@ func (sgb *StatsGroupBy) Ints(ctx context.Context) ([]int, error) { } // IntsX is like Ints, but panics if an error occurs. -func (sgb *StatsGroupBy) IntsX(ctx context.Context) []int { +func (sgb *SprayGroupBy) IntsX(ctx context.Context) []int { v, err := sgb.Ints(ctx) if err != nil { panic(err) @@ -810,7 +625,7 @@ func (sgb *StatsGroupBy) IntsX(ctx context.Context) []int { // Int returns a single int from a group-by query. // It is only allowed when executing a group-by query with one field. -func (sgb *StatsGroupBy) Int(ctx context.Context) (_ int, err error) { +func (sgb *SprayGroupBy) Int(ctx context.Context) (_ int, err error) { var v []int if v, err = sgb.Ints(ctx); err != nil { return @@ -819,15 +634,15 @@ func (sgb *StatsGroupBy) Int(ctx context.Context) (_ int, err error) { case 1: return v[0], nil case 0: - err = &NotFoundError{stats.Label} + err = &NotFoundError{spray.Label} default: - err = fmt.Errorf("ent: StatsGroupBy.Ints returned %d results when one was expected", len(v)) + err = fmt.Errorf("ent: SprayGroupBy.Ints returned %d results when one was expected", len(v)) } return } // IntX is like Int, but panics if an error occurs. -func (sgb *StatsGroupBy) IntX(ctx context.Context) int { +func (sgb *SprayGroupBy) IntX(ctx context.Context) int { v, err := sgb.Int(ctx) if err != nil { panic(err) @@ -837,9 +652,9 @@ func (sgb *StatsGroupBy) IntX(ctx context.Context) int { // Float64s returns list of float64s from group-by. // It is only allowed when executing a group-by query with one field. -func (sgb *StatsGroupBy) Float64s(ctx context.Context) ([]float64, error) { +func (sgb *SprayGroupBy) Float64s(ctx context.Context) ([]float64, error) { if len(sgb.fields) > 1 { - return nil, errors.New("ent: StatsGroupBy.Float64s is not achievable when grouping more than 1 field") + return nil, errors.New("ent: SprayGroupBy.Float64s is not achievable when grouping more than 1 field") } var v []float64 if err := sgb.Scan(ctx, &v); err != nil { @@ -849,7 +664,7 @@ func (sgb *StatsGroupBy) Float64s(ctx context.Context) ([]float64, error) { } // Float64sX is like Float64s, but panics if an error occurs. -func (sgb *StatsGroupBy) Float64sX(ctx context.Context) []float64 { +func (sgb *SprayGroupBy) Float64sX(ctx context.Context) []float64 { v, err := sgb.Float64s(ctx) if err != nil { panic(err) @@ -859,7 +674,7 @@ func (sgb *StatsGroupBy) Float64sX(ctx context.Context) []float64 { // Float64 returns a single float64 from a group-by query. // It is only allowed when executing a group-by query with one field. -func (sgb *StatsGroupBy) Float64(ctx context.Context) (_ float64, err error) { +func (sgb *SprayGroupBy) Float64(ctx context.Context) (_ float64, err error) { var v []float64 if v, err = sgb.Float64s(ctx); err != nil { return @@ -868,15 +683,15 @@ func (sgb *StatsGroupBy) Float64(ctx context.Context) (_ float64, err error) { case 1: return v[0], nil case 0: - err = &NotFoundError{stats.Label} + err = &NotFoundError{spray.Label} default: - err = fmt.Errorf("ent: StatsGroupBy.Float64s returned %d results when one was expected", len(v)) + err = fmt.Errorf("ent: SprayGroupBy.Float64s returned %d results when one was expected", len(v)) } return } // Float64X is like Float64, but panics if an error occurs. -func (sgb *StatsGroupBy) Float64X(ctx context.Context) float64 { +func (sgb *SprayGroupBy) Float64X(ctx context.Context) float64 { v, err := sgb.Float64(ctx) if err != nil { panic(err) @@ -886,9 +701,9 @@ func (sgb *StatsGroupBy) Float64X(ctx context.Context) float64 { // Bools returns list of bools from group-by. // It is only allowed when executing a group-by query with one field. -func (sgb *StatsGroupBy) Bools(ctx context.Context) ([]bool, error) { +func (sgb *SprayGroupBy) Bools(ctx context.Context) ([]bool, error) { if len(sgb.fields) > 1 { - return nil, errors.New("ent: StatsGroupBy.Bools is not achievable when grouping more than 1 field") + return nil, errors.New("ent: SprayGroupBy.Bools is not achievable when grouping more than 1 field") } var v []bool if err := sgb.Scan(ctx, &v); err != nil { @@ -898,7 +713,7 @@ func (sgb *StatsGroupBy) Bools(ctx context.Context) ([]bool, error) { } // BoolsX is like Bools, but panics if an error occurs. -func (sgb *StatsGroupBy) BoolsX(ctx context.Context) []bool { +func (sgb *SprayGroupBy) BoolsX(ctx context.Context) []bool { v, err := sgb.Bools(ctx) if err != nil { panic(err) @@ -908,7 +723,7 @@ func (sgb *StatsGroupBy) BoolsX(ctx context.Context) []bool { // Bool returns a single bool from a group-by query. // It is only allowed when executing a group-by query with one field. -func (sgb *StatsGroupBy) Bool(ctx context.Context) (_ bool, err error) { +func (sgb *SprayGroupBy) Bool(ctx context.Context) (_ bool, err error) { var v []bool if v, err = sgb.Bools(ctx); err != nil { return @@ -917,15 +732,15 @@ func (sgb *StatsGroupBy) Bool(ctx context.Context) (_ bool, err error) { case 1: return v[0], nil case 0: - err = &NotFoundError{stats.Label} + err = &NotFoundError{spray.Label} default: - err = fmt.Errorf("ent: StatsGroupBy.Bools returned %d results when one was expected", len(v)) + err = fmt.Errorf("ent: SprayGroupBy.Bools returned %d results when one was expected", len(v)) } return } // BoolX is like Bool, but panics if an error occurs. -func (sgb *StatsGroupBy) BoolX(ctx context.Context) bool { +func (sgb *SprayGroupBy) BoolX(ctx context.Context) bool { v, err := sgb.Bool(ctx) if err != nil { panic(err) @@ -933,9 +748,9 @@ func (sgb *StatsGroupBy) BoolX(ctx context.Context) bool { return v } -func (sgb *StatsGroupBy) sqlScan(ctx context.Context, v interface{}) error { +func (sgb *SprayGroupBy) sqlScan(ctx context.Context, v interface{}) error { for _, f := range sgb.fields { - if !stats.ValidColumn(f) { + if !spray.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} } } @@ -952,7 +767,7 @@ func (sgb *StatsGroupBy) sqlScan(ctx context.Context, v interface{}) error { return sql.ScanSlice(rows, v) } -func (sgb *StatsGroupBy) sqlQuery() *sql.Selector { +func (sgb *SprayGroupBy) sqlQuery() *sql.Selector { selector := sgb.sql.Select() aggregation := make([]string, 0, len(sgb.fns)) for _, fn := range sgb.fns { @@ -973,33 +788,33 @@ func (sgb *StatsGroupBy) sqlQuery() *sql.Selector { return selector.GroupBy(selector.Columns(sgb.fields...)...) } -// StatsSelect is the builder for selecting fields of Stats entities. -type StatsSelect struct { - *StatsQuery +// SpraySelect is the builder for selecting fields of Spray entities. +type SpraySelect struct { + *SprayQuery // intermediate query (i.e. traversal path). sql *sql.Selector } // Scan applies the selector query and scans the result into the given value. -func (ss *StatsSelect) Scan(ctx context.Context, v interface{}) error { +func (ss *SpraySelect) Scan(ctx context.Context, v interface{}) error { if err := ss.prepareQuery(ctx); err != nil { return err } - ss.sql = ss.StatsQuery.sqlQuery(ctx) + ss.sql = ss.SprayQuery.sqlQuery(ctx) return ss.sqlScan(ctx, v) } // ScanX is like Scan, but panics if an error occurs. -func (ss *StatsSelect) ScanX(ctx context.Context, v interface{}) { +func (ss *SpraySelect) ScanX(ctx context.Context, v interface{}) { if err := ss.Scan(ctx, v); err != nil { panic(err) } } // Strings returns list of strings from a selector. It is only allowed when selecting one field. -func (ss *StatsSelect) Strings(ctx context.Context) ([]string, error) { +func (ss *SpraySelect) Strings(ctx context.Context) ([]string, error) { if len(ss.fields) > 1 { - return nil, errors.New("ent: StatsSelect.Strings is not achievable when selecting more than 1 field") + return nil, errors.New("ent: SpraySelect.Strings is not achievable when selecting more than 1 field") } var v []string if err := ss.Scan(ctx, &v); err != nil { @@ -1009,7 +824,7 @@ func (ss *StatsSelect) Strings(ctx context.Context) ([]string, error) { } // StringsX is like Strings, but panics if an error occurs. -func (ss *StatsSelect) StringsX(ctx context.Context) []string { +func (ss *SpraySelect) StringsX(ctx context.Context) []string { v, err := ss.Strings(ctx) if err != nil { panic(err) @@ -1018,7 +833,7 @@ func (ss *StatsSelect) StringsX(ctx context.Context) []string { } // String returns a single string from a selector. It is only allowed when selecting one field. -func (ss *StatsSelect) String(ctx context.Context) (_ string, err error) { +func (ss *SpraySelect) String(ctx context.Context) (_ string, err error) { var v []string if v, err = ss.Strings(ctx); err != nil { return @@ -1027,15 +842,15 @@ func (ss *StatsSelect) String(ctx context.Context) (_ string, err error) { case 1: return v[0], nil case 0: - err = &NotFoundError{stats.Label} + err = &NotFoundError{spray.Label} default: - err = fmt.Errorf("ent: StatsSelect.Strings returned %d results when one was expected", len(v)) + err = fmt.Errorf("ent: SpraySelect.Strings returned %d results when one was expected", len(v)) } return } // StringX is like String, but panics if an error occurs. -func (ss *StatsSelect) StringX(ctx context.Context) string { +func (ss *SpraySelect) StringX(ctx context.Context) string { v, err := ss.String(ctx) if err != nil { panic(err) @@ -1044,9 +859,9 @@ func (ss *StatsSelect) StringX(ctx context.Context) string { } // Ints returns list of ints from a selector. It is only allowed when selecting one field. -func (ss *StatsSelect) Ints(ctx context.Context) ([]int, error) { +func (ss *SpraySelect) Ints(ctx context.Context) ([]int, error) { if len(ss.fields) > 1 { - return nil, errors.New("ent: StatsSelect.Ints is not achievable when selecting more than 1 field") + return nil, errors.New("ent: SpraySelect.Ints is not achievable when selecting more than 1 field") } var v []int if err := ss.Scan(ctx, &v); err != nil { @@ -1056,7 +871,7 @@ func (ss *StatsSelect) Ints(ctx context.Context) ([]int, error) { } // IntsX is like Ints, but panics if an error occurs. -func (ss *StatsSelect) IntsX(ctx context.Context) []int { +func (ss *SpraySelect) IntsX(ctx context.Context) []int { v, err := ss.Ints(ctx) if err != nil { panic(err) @@ -1065,7 +880,7 @@ func (ss *StatsSelect) IntsX(ctx context.Context) []int { } // Int returns a single int from a selector. It is only allowed when selecting one field. -func (ss *StatsSelect) Int(ctx context.Context) (_ int, err error) { +func (ss *SpraySelect) Int(ctx context.Context) (_ int, err error) { var v []int if v, err = ss.Ints(ctx); err != nil { return @@ -1074,15 +889,15 @@ func (ss *StatsSelect) Int(ctx context.Context) (_ int, err error) { case 1: return v[0], nil case 0: - err = &NotFoundError{stats.Label} + err = &NotFoundError{spray.Label} default: - err = fmt.Errorf("ent: StatsSelect.Ints returned %d results when one was expected", len(v)) + err = fmt.Errorf("ent: SpraySelect.Ints returned %d results when one was expected", len(v)) } return } // IntX is like Int, but panics if an error occurs. -func (ss *StatsSelect) IntX(ctx context.Context) int { +func (ss *SpraySelect) IntX(ctx context.Context) int { v, err := ss.Int(ctx) if err != nil { panic(err) @@ -1091,9 +906,9 @@ func (ss *StatsSelect) IntX(ctx context.Context) int { } // Float64s returns list of float64s from a selector. It is only allowed when selecting one field. -func (ss *StatsSelect) Float64s(ctx context.Context) ([]float64, error) { +func (ss *SpraySelect) Float64s(ctx context.Context) ([]float64, error) { if len(ss.fields) > 1 { - return nil, errors.New("ent: StatsSelect.Float64s is not achievable when selecting more than 1 field") + return nil, errors.New("ent: SpraySelect.Float64s is not achievable when selecting more than 1 field") } var v []float64 if err := ss.Scan(ctx, &v); err != nil { @@ -1103,7 +918,7 @@ func (ss *StatsSelect) Float64s(ctx context.Context) ([]float64, error) { } // Float64sX is like Float64s, but panics if an error occurs. -func (ss *StatsSelect) Float64sX(ctx context.Context) []float64 { +func (ss *SpraySelect) Float64sX(ctx context.Context) []float64 { v, err := ss.Float64s(ctx) if err != nil { panic(err) @@ -1112,7 +927,7 @@ func (ss *StatsSelect) Float64sX(ctx context.Context) []float64 { } // Float64 returns a single float64 from a selector. It is only allowed when selecting one field. -func (ss *StatsSelect) Float64(ctx context.Context) (_ float64, err error) { +func (ss *SpraySelect) Float64(ctx context.Context) (_ float64, err error) { var v []float64 if v, err = ss.Float64s(ctx); err != nil { return @@ -1121,15 +936,15 @@ func (ss *StatsSelect) Float64(ctx context.Context) (_ float64, err error) { case 1: return v[0], nil case 0: - err = &NotFoundError{stats.Label} + err = &NotFoundError{spray.Label} default: - err = fmt.Errorf("ent: StatsSelect.Float64s returned %d results when one was expected", len(v)) + err = fmt.Errorf("ent: SpraySelect.Float64s returned %d results when one was expected", len(v)) } return } // Float64X is like Float64, but panics if an error occurs. -func (ss *StatsSelect) Float64X(ctx context.Context) float64 { +func (ss *SpraySelect) Float64X(ctx context.Context) float64 { v, err := ss.Float64(ctx) if err != nil { panic(err) @@ -1138,9 +953,9 @@ func (ss *StatsSelect) Float64X(ctx context.Context) float64 { } // Bools returns list of bools from a selector. It is only allowed when selecting one field. -func (ss *StatsSelect) Bools(ctx context.Context) ([]bool, error) { +func (ss *SpraySelect) Bools(ctx context.Context) ([]bool, error) { if len(ss.fields) > 1 { - return nil, errors.New("ent: StatsSelect.Bools is not achievable when selecting more than 1 field") + return nil, errors.New("ent: SpraySelect.Bools is not achievable when selecting more than 1 field") } var v []bool if err := ss.Scan(ctx, &v); err != nil { @@ -1150,7 +965,7 @@ func (ss *StatsSelect) Bools(ctx context.Context) ([]bool, error) { } // BoolsX is like Bools, but panics if an error occurs. -func (ss *StatsSelect) BoolsX(ctx context.Context) []bool { +func (ss *SpraySelect) BoolsX(ctx context.Context) []bool { v, err := ss.Bools(ctx) if err != nil { panic(err) @@ -1159,7 +974,7 @@ func (ss *StatsSelect) BoolsX(ctx context.Context) []bool { } // Bool returns a single bool from a selector. It is only allowed when selecting one field. -func (ss *StatsSelect) Bool(ctx context.Context) (_ bool, err error) { +func (ss *SpraySelect) Bool(ctx context.Context) (_ bool, err error) { var v []bool if v, err = ss.Bools(ctx); err != nil { return @@ -1168,15 +983,15 @@ func (ss *StatsSelect) Bool(ctx context.Context) (_ bool, err error) { case 1: return v[0], nil case 0: - err = &NotFoundError{stats.Label} + err = &NotFoundError{spray.Label} default: - err = fmt.Errorf("ent: StatsSelect.Bools returned %d results when one was expected", len(v)) + err = fmt.Errorf("ent: SpraySelect.Bools returned %d results when one was expected", len(v)) } return } // BoolX is like Bool, but panics if an error occurs. -func (ss *StatsSelect) BoolX(ctx context.Context) bool { +func (ss *SpraySelect) BoolX(ctx context.Context) bool { v, err := ss.Bool(ctx) if err != nil { panic(err) @@ -1184,7 +999,7 @@ func (ss *StatsSelect) BoolX(ctx context.Context) bool { return v } -func (ss *StatsSelect) sqlScan(ctx context.Context, v interface{}) error { +func (ss *SpraySelect) sqlScan(ctx context.Context, v interface{}) error { rows := &sql.Rows{} query, args := ss.sql.Query() if err := ss.driver.Query(ctx, query, args, rows); err != nil { @@ -1195,7 +1010,7 @@ func (ss *StatsSelect) sqlScan(ctx context.Context, v interface{}) error { } // Modify adds a query modifier for attaching custom logic to queries. -func (ss *StatsSelect) Modify(modifiers ...func(s *sql.Selector)) *StatsSelect { +func (ss *SpraySelect) Modify(modifiers ...func(s *sql.Selector)) *SpraySelect { ss.modifiers = append(ss.modifiers, modifiers...) return ss } diff --git a/ent/spray_update.go b/ent/spray_update.go new file mode 100644 index 0000000..1da037b --- /dev/null +++ b/ent/spray_update.go @@ -0,0 +1,439 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "csgowtfd/ent/matchplayer" + "csgowtfd/ent/predicate" + "csgowtfd/ent/spray" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// SprayUpdate is the builder for updating Spray entities. +type SprayUpdate struct { + config + hooks []Hook + mutation *SprayMutation +} + +// Where appends a list predicates to the SprayUpdate builder. +func (su *SprayUpdate) Where(ps ...predicate.Spray) *SprayUpdate { + su.mutation.Where(ps...) + return su +} + +// SetWeapon sets the "weapon" field. +func (su *SprayUpdate) SetWeapon(i int) *SprayUpdate { + su.mutation.ResetWeapon() + su.mutation.SetWeapon(i) + return su +} + +// AddWeapon adds i to the "weapon" field. +func (su *SprayUpdate) AddWeapon(i int) *SprayUpdate { + su.mutation.AddWeapon(i) + return su +} + +// SetSpray sets the "spray" field. +func (su *SprayUpdate) SetSpray(b []byte) *SprayUpdate { + su.mutation.SetSpray(b) + return su +} + +// SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID. +func (su *SprayUpdate) SetMatchPlayersID(id int) *SprayUpdate { + su.mutation.SetMatchPlayersID(id) + return su +} + +// SetNillableMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID if the given value is not nil. +func (su *SprayUpdate) SetNillableMatchPlayersID(id *int) *SprayUpdate { + if id != nil { + su = su.SetMatchPlayersID(*id) + } + return su +} + +// SetMatchPlayers sets the "match_players" edge to the MatchPlayer entity. +func (su *SprayUpdate) SetMatchPlayers(m *MatchPlayer) *SprayUpdate { + return su.SetMatchPlayersID(m.ID) +} + +// Mutation returns the SprayMutation object of the builder. +func (su *SprayUpdate) Mutation() *SprayMutation { + return su.mutation +} + +// ClearMatchPlayers clears the "match_players" edge to the MatchPlayer entity. +func (su *SprayUpdate) ClearMatchPlayers() *SprayUpdate { + su.mutation.ClearMatchPlayers() + return su +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (su *SprayUpdate) 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.(*SprayMutation) + 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 *SprayUpdate) SaveX(ctx context.Context) int { + affected, err := su.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (su *SprayUpdate) Exec(ctx context.Context) error { + _, err := su.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (su *SprayUpdate) ExecX(ctx context.Context) { + if err := su.Exec(ctx); err != nil { + panic(err) + } +} + +func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: spray.Table, + Columns: spray.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: spray.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.Weapon(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: spray.FieldWeapon, + }) + } + if value, ok := su.mutation.AddedWeapon(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: spray.FieldWeapon, + }) + } + if value, ok := su.mutation.Spray(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBytes, + Value: value, + Column: spray.FieldSpray, + }) + } + if su.mutation.MatchPlayersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: spray.MatchPlayersTable, + Columns: []string{spray.MatchPlayersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := su.mutation.MatchPlayersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: spray.MatchPlayersTable, + Columns: []string{spray.MatchPlayersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.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{spray.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} + } + return 0, err + } + return n, nil +} + +// SprayUpdateOne is the builder for updating a single Spray entity. +type SprayUpdateOne struct { + config + fields []string + hooks []Hook + mutation *SprayMutation +} + +// SetWeapon sets the "weapon" field. +func (suo *SprayUpdateOne) SetWeapon(i int) *SprayUpdateOne { + suo.mutation.ResetWeapon() + suo.mutation.SetWeapon(i) + return suo +} + +// AddWeapon adds i to the "weapon" field. +func (suo *SprayUpdateOne) AddWeapon(i int) *SprayUpdateOne { + suo.mutation.AddWeapon(i) + return suo +} + +// SetSpray sets the "spray" field. +func (suo *SprayUpdateOne) SetSpray(b []byte) *SprayUpdateOne { + suo.mutation.SetSpray(b) + return suo +} + +// SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID. +func (suo *SprayUpdateOne) SetMatchPlayersID(id int) *SprayUpdateOne { + suo.mutation.SetMatchPlayersID(id) + return suo +} + +// SetNillableMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID if the given value is not nil. +func (suo *SprayUpdateOne) SetNillableMatchPlayersID(id *int) *SprayUpdateOne { + if id != nil { + suo = suo.SetMatchPlayersID(*id) + } + return suo +} + +// SetMatchPlayers sets the "match_players" edge to the MatchPlayer entity. +func (suo *SprayUpdateOne) SetMatchPlayers(m *MatchPlayer) *SprayUpdateOne { + return suo.SetMatchPlayersID(m.ID) +} + +// Mutation returns the SprayMutation object of the builder. +func (suo *SprayUpdateOne) Mutation() *SprayMutation { + return suo.mutation +} + +// ClearMatchPlayers clears the "match_players" edge to the MatchPlayer entity. +func (suo *SprayUpdateOne) ClearMatchPlayers() *SprayUpdateOne { + suo.mutation.ClearMatchPlayers() + 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 *SprayUpdateOne) Select(field string, fields ...string) *SprayUpdateOne { + suo.fields = append([]string{field}, fields...) + return suo +} + +// Save executes the query and returns the updated Spray entity. +func (suo *SprayUpdateOne) Save(ctx context.Context) (*Spray, error) { + var ( + err error + node *Spray + ) + 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.(*SprayMutation) + 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 *SprayUpdateOne) SaveX(ctx context.Context) *Spray { + node, err := suo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (suo *SprayUpdateOne) Exec(ctx context.Context) error { + _, err := suo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (suo *SprayUpdateOne) ExecX(ctx context.Context) { + if err := suo.Exec(ctx); err != nil { + panic(err) + } +} + +func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: spray.Table, + Columns: spray.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: spray.FieldID, + }, + }, + } + id, ok := suo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Spray.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, spray.FieldID) + for _, f := range fields { + if !spray.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != spray.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.Weapon(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: spray.FieldWeapon, + }) + } + if value, ok := suo.mutation.AddedWeapon(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: spray.FieldWeapon, + }) + } + if value, ok := suo.mutation.Spray(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBytes, + Value: value, + Column: spray.FieldSpray, + }) + } + if suo.mutation.MatchPlayersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: spray.MatchPlayersTable, + Columns: []string{spray.MatchPlayersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := suo.mutation.MatchPlayersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: spray.MatchPlayersTable, + Columns: []string{spray.MatchPlayersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Spray{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{spray.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} + } + return nil, err + } + return _node, nil +} diff --git a/ent/stats_create.go b/ent/stats_create.go deleted file mode 100644 index de7371b..0000000 --- a/ent/stats_create.go +++ /dev/null @@ -1,989 +0,0 @@ -// Code generated by entc, DO NOT EDIT. - -package ent - -import ( - "context" - "csgowtfd/ent/match" - "csgowtfd/ent/player" - "csgowtfd/ent/roundstats" - "csgowtfd/ent/stats" - "csgowtfd/ent/weaponstats" - "errors" - "fmt" - - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// StatsCreate is the builder for creating a Stats entity. -type StatsCreate struct { - config - mutation *StatsMutation - hooks []Hook -} - -// SetTeamID sets the "team_id" field. -func (sc *StatsCreate) SetTeamID(i int) *StatsCreate { - sc.mutation.SetTeamID(i) - return sc -} - -// SetKills sets the "kills" field. -func (sc *StatsCreate) SetKills(i int) *StatsCreate { - sc.mutation.SetKills(i) - return sc -} - -// SetDeaths sets the "deaths" field. -func (sc *StatsCreate) SetDeaths(i int) *StatsCreate { - sc.mutation.SetDeaths(i) - return sc -} - -// SetAssists sets the "assists" field. -func (sc *StatsCreate) SetAssists(i int) *StatsCreate { - sc.mutation.SetAssists(i) - return sc -} - -// SetHeadshot sets the "headshot" field. -func (sc *StatsCreate) SetHeadshot(i int) *StatsCreate { - sc.mutation.SetHeadshot(i) - return sc -} - -// SetMvp sets the "mvp" field. -func (sc *StatsCreate) SetMvp(u uint) *StatsCreate { - sc.mutation.SetMvp(u) - return sc -} - -// SetScore sets the "score" field. -func (sc *StatsCreate) SetScore(i int) *StatsCreate { - sc.mutation.SetScore(i) - return sc -} - -// SetRankNew sets the "rank_new" field. -func (sc *StatsCreate) SetRankNew(i int) *StatsCreate { - sc.mutation.SetRankNew(i) - return sc -} - -// SetNillableRankNew sets the "rank_new" field if the given value is not nil. -func (sc *StatsCreate) SetNillableRankNew(i *int) *StatsCreate { - if i != nil { - sc.SetRankNew(*i) - } - return sc -} - -// SetRankOld sets the "rank_old" field. -func (sc *StatsCreate) SetRankOld(i int) *StatsCreate { - sc.mutation.SetRankOld(i) - return sc -} - -// SetNillableRankOld sets the "rank_old" field if the given value is not nil. -func (sc *StatsCreate) SetNillableRankOld(i *int) *StatsCreate { - if i != nil { - sc.SetRankOld(*i) - } - return sc -} - -// SetMk2 sets the "mk_2" field. -func (sc *StatsCreate) SetMk2(u uint) *StatsCreate { - sc.mutation.SetMk2(u) - return sc -} - -// SetNillableMk2 sets the "mk_2" field if the given value is not nil. -func (sc *StatsCreate) SetNillableMk2(u *uint) *StatsCreate { - if u != nil { - sc.SetMk2(*u) - } - return sc -} - -// SetMk3 sets the "mk_3" field. -func (sc *StatsCreate) SetMk3(u uint) *StatsCreate { - sc.mutation.SetMk3(u) - return sc -} - -// SetNillableMk3 sets the "mk_3" field if the given value is not nil. -func (sc *StatsCreate) SetNillableMk3(u *uint) *StatsCreate { - if u != nil { - sc.SetMk3(*u) - } - return sc -} - -// SetMk4 sets the "mk_4" field. -func (sc *StatsCreate) SetMk4(u uint) *StatsCreate { - sc.mutation.SetMk4(u) - return sc -} - -// SetNillableMk4 sets the "mk_4" field if the given value is not nil. -func (sc *StatsCreate) SetNillableMk4(u *uint) *StatsCreate { - if u != nil { - sc.SetMk4(*u) - } - return sc -} - -// SetMk5 sets the "mk_5" field. -func (sc *StatsCreate) SetMk5(u uint) *StatsCreate { - sc.mutation.SetMk5(u) - return sc -} - -// SetNillableMk5 sets the "mk_5" field if the given value is not nil. -func (sc *StatsCreate) SetNillableMk5(u *uint) *StatsCreate { - if u != nil { - sc.SetMk5(*u) - } - return sc -} - -// SetDmgEnemy sets the "dmg_enemy" field. -func (sc *StatsCreate) SetDmgEnemy(u uint) *StatsCreate { - sc.mutation.SetDmgEnemy(u) - return sc -} - -// SetNillableDmgEnemy sets the "dmg_enemy" field if the given value is not nil. -func (sc *StatsCreate) SetNillableDmgEnemy(u *uint) *StatsCreate { - if u != nil { - sc.SetDmgEnemy(*u) - } - return sc -} - -// SetDmgTeam sets the "dmg_team" field. -func (sc *StatsCreate) SetDmgTeam(u uint) *StatsCreate { - sc.mutation.SetDmgTeam(u) - return sc -} - -// SetNillableDmgTeam sets the "dmg_team" field if the given value is not nil. -func (sc *StatsCreate) SetNillableDmgTeam(u *uint) *StatsCreate { - if u != nil { - sc.SetDmgTeam(*u) - } - return sc -} - -// SetUdHe sets the "ud_he" field. -func (sc *StatsCreate) SetUdHe(u uint) *StatsCreate { - sc.mutation.SetUdHe(u) - return sc -} - -// SetNillableUdHe sets the "ud_he" field if the given value is not nil. -func (sc *StatsCreate) SetNillableUdHe(u *uint) *StatsCreate { - if u != nil { - sc.SetUdHe(*u) - } - return sc -} - -// SetUdFlames sets the "ud_flames" field. -func (sc *StatsCreate) SetUdFlames(u uint) *StatsCreate { - sc.mutation.SetUdFlames(u) - return sc -} - -// SetNillableUdFlames sets the "ud_flames" field if the given value is not nil. -func (sc *StatsCreate) SetNillableUdFlames(u *uint) *StatsCreate { - if u != nil { - sc.SetUdFlames(*u) - } - return sc -} - -// SetUdFlash sets the "ud_flash" field. -func (sc *StatsCreate) SetUdFlash(u uint) *StatsCreate { - sc.mutation.SetUdFlash(u) - return sc -} - -// SetNillableUdFlash sets the "ud_flash" field if the given value is not nil. -func (sc *StatsCreate) SetNillableUdFlash(u *uint) *StatsCreate { - if u != nil { - sc.SetUdFlash(*u) - } - return sc -} - -// SetUdDecoy sets the "ud_decoy" field. -func (sc *StatsCreate) SetUdDecoy(u uint) *StatsCreate { - sc.mutation.SetUdDecoy(u) - return sc -} - -// SetNillableUdDecoy sets the "ud_decoy" field if the given value is not nil. -func (sc *StatsCreate) SetNillableUdDecoy(u *uint) *StatsCreate { - if u != nil { - sc.SetUdDecoy(*u) - } - return sc -} - -// SetUdSmoke sets the "ud_smoke" field. -func (sc *StatsCreate) SetUdSmoke(u uint) *StatsCreate { - sc.mutation.SetUdSmoke(u) - return sc -} - -// SetNillableUdSmoke sets the "ud_smoke" field if the given value is not nil. -func (sc *StatsCreate) SetNillableUdSmoke(u *uint) *StatsCreate { - if u != nil { - sc.SetUdSmoke(*u) - } - return sc -} - -// SetCrosshair sets the "crosshair" field. -func (sc *StatsCreate) SetCrosshair(s string) *StatsCreate { - sc.mutation.SetCrosshair(s) - return sc -} - -// SetNillableCrosshair sets the "crosshair" field if the given value is not nil. -func (sc *StatsCreate) SetNillableCrosshair(s *string) *StatsCreate { - if s != nil { - sc.SetCrosshair(*s) - } - return sc -} - -// SetColor sets the "color" field. -func (sc *StatsCreate) SetColor(s stats.Color) *StatsCreate { - sc.mutation.SetColor(s) - return sc -} - -// SetNillableColor sets the "color" field if the given value is not nil. -func (sc *StatsCreate) SetNillableColor(s *stats.Color) *StatsCreate { - if s != nil { - sc.SetColor(*s) - } - return sc -} - -// SetKast sets the "kast" field. -func (sc *StatsCreate) SetKast(i int) *StatsCreate { - sc.mutation.SetKast(i) - return sc -} - -// SetNillableKast sets the "kast" field if the given value is not nil. -func (sc *StatsCreate) SetNillableKast(i *int) *StatsCreate { - if i != nil { - sc.SetKast(*i) - } - return sc -} - -// SetFlashDurationSelf sets the "flash_duration_self" field. -func (sc *StatsCreate) SetFlashDurationSelf(f float32) *StatsCreate { - sc.mutation.SetFlashDurationSelf(f) - return sc -} - -// SetNillableFlashDurationSelf sets the "flash_duration_self" field if the given value is not nil. -func (sc *StatsCreate) SetNillableFlashDurationSelf(f *float32) *StatsCreate { - if f != nil { - sc.SetFlashDurationSelf(*f) - } - return sc -} - -// SetFlashDurationTeam sets the "flash_duration_team" field. -func (sc *StatsCreate) SetFlashDurationTeam(f float32) *StatsCreate { - sc.mutation.SetFlashDurationTeam(f) - return sc -} - -// SetNillableFlashDurationTeam sets the "flash_duration_team" field if the given value is not nil. -func (sc *StatsCreate) SetNillableFlashDurationTeam(f *float32) *StatsCreate { - if f != nil { - sc.SetFlashDurationTeam(*f) - } - return sc -} - -// SetFlashDurationEnemy sets the "flash_duration_enemy" field. -func (sc *StatsCreate) SetFlashDurationEnemy(f float32) *StatsCreate { - sc.mutation.SetFlashDurationEnemy(f) - return sc -} - -// SetNillableFlashDurationEnemy sets the "flash_duration_enemy" field if the given value is not nil. -func (sc *StatsCreate) SetNillableFlashDurationEnemy(f *float32) *StatsCreate { - if f != nil { - sc.SetFlashDurationEnemy(*f) - } - return sc -} - -// SetFlashTotalSelf sets the "flash_total_self" field. -func (sc *StatsCreate) SetFlashTotalSelf(u uint) *StatsCreate { - sc.mutation.SetFlashTotalSelf(u) - return sc -} - -// SetNillableFlashTotalSelf sets the "flash_total_self" field if the given value is not nil. -func (sc *StatsCreate) SetNillableFlashTotalSelf(u *uint) *StatsCreate { - if u != nil { - sc.SetFlashTotalSelf(*u) - } - return sc -} - -// SetFlashTotalTeam sets the "flash_total_team" field. -func (sc *StatsCreate) SetFlashTotalTeam(u uint) *StatsCreate { - sc.mutation.SetFlashTotalTeam(u) - return sc -} - -// SetNillableFlashTotalTeam sets the "flash_total_team" field if the given value is not nil. -func (sc *StatsCreate) SetNillableFlashTotalTeam(u *uint) *StatsCreate { - if u != nil { - sc.SetFlashTotalTeam(*u) - } - return sc -} - -// SetFlashTotalEnemy sets the "flash_total_enemy" field. -func (sc *StatsCreate) SetFlashTotalEnemy(u uint) *StatsCreate { - sc.mutation.SetFlashTotalEnemy(u) - return sc -} - -// SetNillableFlashTotalEnemy sets the "flash_total_enemy" field if the given value is not nil. -func (sc *StatsCreate) SetNillableFlashTotalEnemy(u *uint) *StatsCreate { - if u != nil { - sc.SetFlashTotalEnemy(*u) - } - return sc -} - -// SetMatchStats sets the "match_stats" field. -func (sc *StatsCreate) SetMatchStats(u uint64) *StatsCreate { - sc.mutation.SetMatchStats(u) - return sc -} - -// SetNillableMatchStats sets the "match_stats" field if the given value is not nil. -func (sc *StatsCreate) SetNillableMatchStats(u *uint64) *StatsCreate { - if u != nil { - sc.SetMatchStats(*u) - } - return sc -} - -// SetPlayerStats sets the "player_stats" field. -func (sc *StatsCreate) SetPlayerStats(u uint64) *StatsCreate { - sc.mutation.SetPlayerStats(u) - return sc -} - -// SetNillablePlayerStats sets the "player_stats" field if the given value is not nil. -func (sc *StatsCreate) SetNillablePlayerStats(u *uint64) *StatsCreate { - if u != nil { - sc.SetPlayerStats(*u) - } - return sc -} - -// SetMatchesID sets the "matches" edge to the Match entity by ID. -func (sc *StatsCreate) SetMatchesID(id uint64) *StatsCreate { - sc.mutation.SetMatchesID(id) - return sc -} - -// SetNillableMatchesID sets the "matches" edge to the Match entity by ID if the given value is not nil. -func (sc *StatsCreate) SetNillableMatchesID(id *uint64) *StatsCreate { - if id != nil { - sc = sc.SetMatchesID(*id) - } - return sc -} - -// SetMatches sets the "matches" edge to the Match entity. -func (sc *StatsCreate) SetMatches(m *Match) *StatsCreate { - return sc.SetMatchesID(m.ID) -} - -// SetPlayersID sets the "players" edge to the Player entity by ID. -func (sc *StatsCreate) SetPlayersID(id uint64) *StatsCreate { - sc.mutation.SetPlayersID(id) - return sc -} - -// SetNillablePlayersID sets the "players" edge to the Player entity by ID if the given value is not nil. -func (sc *StatsCreate) SetNillablePlayersID(id *uint64) *StatsCreate { - if id != nil { - sc = sc.SetPlayersID(*id) - } - return sc -} - -// SetPlayers sets the "players" edge to the Player entity. -func (sc *StatsCreate) SetPlayers(p *Player) *StatsCreate { - return sc.SetPlayersID(p.ID) -} - -// AddWeaponStatIDs adds the "weapon_stats" edge to the WeaponStats entity by IDs. -func (sc *StatsCreate) AddWeaponStatIDs(ids ...int) *StatsCreate { - sc.mutation.AddWeaponStatIDs(ids...) - return sc -} - -// AddWeaponStats adds the "weapon_stats" edges to the WeaponStats entity. -func (sc *StatsCreate) AddWeaponStats(w ...*WeaponStats) *StatsCreate { - ids := make([]int, len(w)) - for i := range w { - ids[i] = w[i].ID - } - return sc.AddWeaponStatIDs(ids...) -} - -// AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by IDs. -func (sc *StatsCreate) AddRoundStatIDs(ids ...int) *StatsCreate { - sc.mutation.AddRoundStatIDs(ids...) - return sc -} - -// AddRoundStats adds the "round_stats" edges to the RoundStats entity. -func (sc *StatsCreate) AddRoundStats(r ...*RoundStats) *StatsCreate { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID - } - return sc.AddRoundStatIDs(ids...) -} - -// Mutation returns the StatsMutation object of the builder. -func (sc *StatsCreate) Mutation() *StatsMutation { - return sc.mutation -} - -// Save creates the Stats in the database. -func (sc *StatsCreate) Save(ctx context.Context) (*Stats, error) { - var ( - err error - node *Stats - ) - if len(sc.hooks) == 0 { - if err = sc.check(); err != nil { - return nil, err - } - node, err = sc.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) - } - if err = sc.check(); err != nil { - return nil, err - } - sc.mutation = mutation - if node, err = sc.sqlSave(ctx); err != nil { - return nil, err - } - mutation.id = &node.ID - mutation.done = true - return node, err - }) - for i := len(sc.hooks) - 1; i >= 0; i-- { - if sc.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = sc.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, sc.mutation); err != nil { - return nil, err - } - } - return node, err -} - -// SaveX calls Save and panics if Save returns an error. -func (sc *StatsCreate) SaveX(ctx context.Context) *Stats { - v, err := sc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (sc *StatsCreate) Exec(ctx context.Context) error { - _, err := sc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (sc *StatsCreate) ExecX(ctx context.Context) { - if err := sc.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (sc *StatsCreate) check() error { - if _, ok := sc.mutation.TeamID(); !ok { - return &ValidationError{Name: "team_id", err: errors.New(`ent: missing required field "team_id"`)} - } - if _, ok := sc.mutation.Kills(); !ok { - return &ValidationError{Name: "kills", err: errors.New(`ent: missing required field "kills"`)} - } - if _, ok := sc.mutation.Deaths(); !ok { - return &ValidationError{Name: "deaths", err: errors.New(`ent: missing required field "deaths"`)} - } - if _, ok := sc.mutation.Assists(); !ok { - return &ValidationError{Name: "assists", err: errors.New(`ent: missing required field "assists"`)} - } - if _, ok := sc.mutation.Headshot(); !ok { - return &ValidationError{Name: "headshot", err: errors.New(`ent: missing required field "headshot"`)} - } - if _, ok := sc.mutation.Mvp(); !ok { - return &ValidationError{Name: "mvp", err: errors.New(`ent: missing required field "mvp"`)} - } - if _, ok := sc.mutation.Score(); !ok { - return &ValidationError{Name: "score", err: errors.New(`ent: missing required field "score"`)} - } - if v, ok := sc.mutation.Color(); ok { - if err := stats.ColorValidator(v); err != nil { - return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "color": %w`, err)} - } - } - return nil -} - -func (sc *StatsCreate) sqlSave(ctx context.Context) (*Stats, error) { - _node, _spec := sc.createSpec() - if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{err.Error(), err} - } - return nil, err - } - id := _spec.ID.Value.(int64) - _node.ID = int(id) - return _node, nil -} - -func (sc *StatsCreate) createSpec() (*Stats, *sqlgraph.CreateSpec) { - var ( - _node = &Stats{config: sc.config} - _spec = &sqlgraph.CreateSpec{ - Table: stats.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: stats.FieldID, - }, - } - ) - if value, ok := sc.mutation.TeamID(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldTeamID, - }) - _node.TeamID = value - } - if value, ok := sc.mutation.Kills(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldKills, - }) - _node.Kills = value - } - if value, ok := sc.mutation.Deaths(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldDeaths, - }) - _node.Deaths = value - } - if value, ok := sc.mutation.Assists(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldAssists, - }) - _node.Assists = value - } - if value, ok := sc.mutation.Headshot(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldHeadshot, - }) - _node.Headshot = value - } - if value, ok := sc.mutation.Mvp(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMvp, - }) - _node.Mvp = value - } - if value, ok := sc.mutation.Score(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldScore, - }) - _node.Score = value - } - if value, ok := sc.mutation.RankNew(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldRankNew, - }) - _node.RankNew = value - } - if value, ok := sc.mutation.RankOld(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldRankOld, - }) - _node.RankOld = value - } - if value, ok := sc.mutation.Mk2(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk2, - }) - _node.Mk2 = value - } - if value, ok := sc.mutation.Mk3(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk3, - }) - _node.Mk3 = value - } - if value, ok := sc.mutation.Mk4(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk4, - }) - _node.Mk4 = value - } - if value, ok := sc.mutation.Mk5(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk5, - }) - _node.Mk5 = value - } - if value, ok := sc.mutation.DmgEnemy(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldDmgEnemy, - }) - _node.DmgEnemy = value - } - if value, ok := sc.mutation.DmgTeam(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldDmgTeam, - }) - _node.DmgTeam = value - } - if value, ok := sc.mutation.UdHe(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdHe, - }) - _node.UdHe = value - } - if value, ok := sc.mutation.UdFlames(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdFlames, - }) - _node.UdFlames = value - } - if value, ok := sc.mutation.UdFlash(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdFlash, - }) - _node.UdFlash = value - } - if value, ok := sc.mutation.UdDecoy(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdDecoy, - }) - _node.UdDecoy = value - } - if value, ok := sc.mutation.UdSmoke(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdSmoke, - }) - _node.UdSmoke = value - } - if value, ok := sc.mutation.Crosshair(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: stats.FieldCrosshair, - }) - _node.Crosshair = value - } - if value, ok := sc.mutation.Color(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeEnum, - Value: value, - Column: stats.FieldColor, - }) - _node.Color = value - } - if value, ok := sc.mutation.Kast(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldKast, - }) - _node.Kast = value - } - if value, ok := sc.mutation.FlashDurationSelf(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Value: value, - Column: stats.FieldFlashDurationSelf, - }) - _node.FlashDurationSelf = value - } - if value, ok := sc.mutation.FlashDurationTeam(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Value: value, - Column: stats.FieldFlashDurationTeam, - }) - _node.FlashDurationTeam = value - } - if value, ok := sc.mutation.FlashDurationEnemy(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Value: value, - Column: stats.FieldFlashDurationEnemy, - }) - _node.FlashDurationEnemy = value - } - if value, ok := sc.mutation.FlashTotalSelf(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldFlashTotalSelf, - }) - _node.FlashTotalSelf = value - } - if value, ok := sc.mutation.FlashTotalTeam(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldFlashTotalTeam, - }) - _node.FlashTotalTeam = value - } - if value, ok := sc.mutation.FlashTotalEnemy(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldFlashTotalEnemy, - }) - _node.FlashTotalEnemy = value - } - if nodes := sc.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.TypeUint64, - Column: match.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.MatchStats = nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := sc.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.TypeUint64, - Column: player.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.PlayerStats = nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := sc.mutation.WeaponStatsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: stats.WeaponStatsTable, - Columns: []string{stats.WeaponStatsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: weaponstats.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := sc.mutation.RoundStatsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: stats.RoundStatsTable, - Columns: []string{stats.RoundStatsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: roundstats.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// StatsCreateBulk is the builder for creating many Stats entities in bulk. -type StatsCreateBulk struct { - config - builders []*StatsCreate -} - -// Save creates the Stats entities in the database. -func (scb *StatsCreateBulk) Save(ctx context.Context) ([]*Stats, error) { - specs := make([]*sqlgraph.CreateSpec, len(scb.builders)) - nodes := make([]*Stats, len(scb.builders)) - mutators := make([]Mutator, len(scb.builders)) - for i := range scb.builders { - func(i int, root context.Context) { - builder := scb.builders[i] - 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) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - nodes[i], specs[i] = builder.createSpec() - var err error - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, scb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, scb.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{err.Error(), err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - mutation.done = true - if specs[i].ID.Value != nil { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int(id) - } - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, scb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (scb *StatsCreateBulk) SaveX(ctx context.Context) []*Stats { - v, err := scb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (scb *StatsCreateBulk) Exec(ctx context.Context) error { - _, err := scb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (scb *StatsCreateBulk) ExecX(ctx context.Context) { - if err := scb.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/ent/stats_update.go b/ent/stats_update.go deleted file mode 100644 index a7cff12..0000000 --- a/ent/stats_update.go +++ /dev/null @@ -1,3344 +0,0 @@ -// Code generated by entc, DO NOT EDIT. - -package ent - -import ( - "context" - "csgowtfd/ent/match" - "csgowtfd/ent/player" - "csgowtfd/ent/predicate" - "csgowtfd/ent/roundstats" - "csgowtfd/ent/stats" - "csgowtfd/ent/weaponstats" - "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(u uint) *StatsUpdate { - su.mutation.ResetMvp() - su.mutation.SetMvp(u) - return su -} - -// AddMvp adds u to the "mvp" field. -func (su *StatsUpdate) AddMvp(u uint) *StatsUpdate { - su.mutation.AddMvp(u) - 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 -} - -// SetRankNew sets the "rank_new" field. -func (su *StatsUpdate) SetRankNew(i int) *StatsUpdate { - su.mutation.ResetRankNew() - su.mutation.SetRankNew(i) - return su -} - -// SetNillableRankNew sets the "rank_new" field if the given value is not nil. -func (su *StatsUpdate) SetNillableRankNew(i *int) *StatsUpdate { - if i != nil { - su.SetRankNew(*i) - } - return su -} - -// AddRankNew adds i to the "rank_new" field. -func (su *StatsUpdate) AddRankNew(i int) *StatsUpdate { - su.mutation.AddRankNew(i) - return su -} - -// ClearRankNew clears the value of the "rank_new" field. -func (su *StatsUpdate) ClearRankNew() *StatsUpdate { - su.mutation.ClearRankNew() - return su -} - -// SetRankOld sets the "rank_old" field. -func (su *StatsUpdate) SetRankOld(i int) *StatsUpdate { - su.mutation.ResetRankOld() - su.mutation.SetRankOld(i) - return su -} - -// SetNillableRankOld sets the "rank_old" field if the given value is not nil. -func (su *StatsUpdate) SetNillableRankOld(i *int) *StatsUpdate { - if i != nil { - su.SetRankOld(*i) - } - return su -} - -// AddRankOld adds i to the "rank_old" field. -func (su *StatsUpdate) AddRankOld(i int) *StatsUpdate { - su.mutation.AddRankOld(i) - return su -} - -// ClearRankOld clears the value of the "rank_old" field. -func (su *StatsUpdate) ClearRankOld() *StatsUpdate { - su.mutation.ClearRankOld() - return su -} - -// SetMk2 sets the "mk_2" field. -func (su *StatsUpdate) SetMk2(u uint) *StatsUpdate { - su.mutation.ResetMk2() - su.mutation.SetMk2(u) - return su -} - -// SetNillableMk2 sets the "mk_2" field if the given value is not nil. -func (su *StatsUpdate) SetNillableMk2(u *uint) *StatsUpdate { - if u != nil { - su.SetMk2(*u) - } - return su -} - -// AddMk2 adds u to the "mk_2" field. -func (su *StatsUpdate) AddMk2(u uint) *StatsUpdate { - su.mutation.AddMk2(u) - return su -} - -// ClearMk2 clears the value of the "mk_2" field. -func (su *StatsUpdate) ClearMk2() *StatsUpdate { - su.mutation.ClearMk2() - return su -} - -// SetMk3 sets the "mk_3" field. -func (su *StatsUpdate) SetMk3(u uint) *StatsUpdate { - su.mutation.ResetMk3() - su.mutation.SetMk3(u) - return su -} - -// SetNillableMk3 sets the "mk_3" field if the given value is not nil. -func (su *StatsUpdate) SetNillableMk3(u *uint) *StatsUpdate { - if u != nil { - su.SetMk3(*u) - } - return su -} - -// AddMk3 adds u to the "mk_3" field. -func (su *StatsUpdate) AddMk3(u uint) *StatsUpdate { - su.mutation.AddMk3(u) - return su -} - -// ClearMk3 clears the value of the "mk_3" field. -func (su *StatsUpdate) ClearMk3() *StatsUpdate { - su.mutation.ClearMk3() - return su -} - -// SetMk4 sets the "mk_4" field. -func (su *StatsUpdate) SetMk4(u uint) *StatsUpdate { - su.mutation.ResetMk4() - su.mutation.SetMk4(u) - return su -} - -// SetNillableMk4 sets the "mk_4" field if the given value is not nil. -func (su *StatsUpdate) SetNillableMk4(u *uint) *StatsUpdate { - if u != nil { - su.SetMk4(*u) - } - return su -} - -// AddMk4 adds u to the "mk_4" field. -func (su *StatsUpdate) AddMk4(u uint) *StatsUpdate { - su.mutation.AddMk4(u) - return su -} - -// ClearMk4 clears the value of the "mk_4" field. -func (su *StatsUpdate) ClearMk4() *StatsUpdate { - su.mutation.ClearMk4() - return su -} - -// SetMk5 sets the "mk_5" field. -func (su *StatsUpdate) SetMk5(u uint) *StatsUpdate { - su.mutation.ResetMk5() - su.mutation.SetMk5(u) - return su -} - -// SetNillableMk5 sets the "mk_5" field if the given value is not nil. -func (su *StatsUpdate) SetNillableMk5(u *uint) *StatsUpdate { - if u != nil { - su.SetMk5(*u) - } - return su -} - -// AddMk5 adds u to the "mk_5" field. -func (su *StatsUpdate) AddMk5(u uint) *StatsUpdate { - su.mutation.AddMk5(u) - return su -} - -// ClearMk5 clears the value of the "mk_5" field. -func (su *StatsUpdate) ClearMk5() *StatsUpdate { - su.mutation.ClearMk5() - return su -} - -// SetDmgEnemy sets the "dmg_enemy" field. -func (su *StatsUpdate) SetDmgEnemy(u uint) *StatsUpdate { - su.mutation.ResetDmgEnemy() - su.mutation.SetDmgEnemy(u) - return su -} - -// SetNillableDmgEnemy sets the "dmg_enemy" field if the given value is not nil. -func (su *StatsUpdate) SetNillableDmgEnemy(u *uint) *StatsUpdate { - if u != nil { - su.SetDmgEnemy(*u) - } - return su -} - -// AddDmgEnemy adds u to the "dmg_enemy" field. -func (su *StatsUpdate) AddDmgEnemy(u uint) *StatsUpdate { - su.mutation.AddDmgEnemy(u) - return su -} - -// ClearDmgEnemy clears the value of the "dmg_enemy" field. -func (su *StatsUpdate) ClearDmgEnemy() *StatsUpdate { - su.mutation.ClearDmgEnemy() - return su -} - -// SetDmgTeam sets the "dmg_team" field. -func (su *StatsUpdate) SetDmgTeam(u uint) *StatsUpdate { - su.mutation.ResetDmgTeam() - su.mutation.SetDmgTeam(u) - return su -} - -// SetNillableDmgTeam sets the "dmg_team" field if the given value is not nil. -func (su *StatsUpdate) SetNillableDmgTeam(u *uint) *StatsUpdate { - if u != nil { - su.SetDmgTeam(*u) - } - return su -} - -// AddDmgTeam adds u to the "dmg_team" field. -func (su *StatsUpdate) AddDmgTeam(u uint) *StatsUpdate { - su.mutation.AddDmgTeam(u) - return su -} - -// ClearDmgTeam clears the value of the "dmg_team" field. -func (su *StatsUpdate) ClearDmgTeam() *StatsUpdate { - su.mutation.ClearDmgTeam() - return su -} - -// SetUdHe sets the "ud_he" field. -func (su *StatsUpdate) SetUdHe(u uint) *StatsUpdate { - su.mutation.ResetUdHe() - su.mutation.SetUdHe(u) - return su -} - -// SetNillableUdHe sets the "ud_he" field if the given value is not nil. -func (su *StatsUpdate) SetNillableUdHe(u *uint) *StatsUpdate { - if u != nil { - su.SetUdHe(*u) - } - return su -} - -// AddUdHe adds u to the "ud_he" field. -func (su *StatsUpdate) AddUdHe(u uint) *StatsUpdate { - su.mutation.AddUdHe(u) - return su -} - -// ClearUdHe clears the value of the "ud_he" field. -func (su *StatsUpdate) ClearUdHe() *StatsUpdate { - su.mutation.ClearUdHe() - return su -} - -// SetUdFlames sets the "ud_flames" field. -func (su *StatsUpdate) SetUdFlames(u uint) *StatsUpdate { - su.mutation.ResetUdFlames() - su.mutation.SetUdFlames(u) - return su -} - -// SetNillableUdFlames sets the "ud_flames" field if the given value is not nil. -func (su *StatsUpdate) SetNillableUdFlames(u *uint) *StatsUpdate { - if u != nil { - su.SetUdFlames(*u) - } - return su -} - -// AddUdFlames adds u to the "ud_flames" field. -func (su *StatsUpdate) AddUdFlames(u uint) *StatsUpdate { - su.mutation.AddUdFlames(u) - return su -} - -// ClearUdFlames clears the value of the "ud_flames" field. -func (su *StatsUpdate) ClearUdFlames() *StatsUpdate { - su.mutation.ClearUdFlames() - return su -} - -// SetUdFlash sets the "ud_flash" field. -func (su *StatsUpdate) SetUdFlash(u uint) *StatsUpdate { - su.mutation.ResetUdFlash() - su.mutation.SetUdFlash(u) - return su -} - -// SetNillableUdFlash sets the "ud_flash" field if the given value is not nil. -func (su *StatsUpdate) SetNillableUdFlash(u *uint) *StatsUpdate { - if u != nil { - su.SetUdFlash(*u) - } - return su -} - -// AddUdFlash adds u to the "ud_flash" field. -func (su *StatsUpdate) AddUdFlash(u uint) *StatsUpdate { - su.mutation.AddUdFlash(u) - return su -} - -// ClearUdFlash clears the value of the "ud_flash" field. -func (su *StatsUpdate) ClearUdFlash() *StatsUpdate { - su.mutation.ClearUdFlash() - return su -} - -// SetUdDecoy sets the "ud_decoy" field. -func (su *StatsUpdate) SetUdDecoy(u uint) *StatsUpdate { - su.mutation.ResetUdDecoy() - su.mutation.SetUdDecoy(u) - return su -} - -// SetNillableUdDecoy sets the "ud_decoy" field if the given value is not nil. -func (su *StatsUpdate) SetNillableUdDecoy(u *uint) *StatsUpdate { - if u != nil { - su.SetUdDecoy(*u) - } - return su -} - -// AddUdDecoy adds u to the "ud_decoy" field. -func (su *StatsUpdate) AddUdDecoy(u uint) *StatsUpdate { - su.mutation.AddUdDecoy(u) - return su -} - -// ClearUdDecoy clears the value of the "ud_decoy" field. -func (su *StatsUpdate) ClearUdDecoy() *StatsUpdate { - su.mutation.ClearUdDecoy() - return su -} - -// SetUdSmoke sets the "ud_smoke" field. -func (su *StatsUpdate) SetUdSmoke(u uint) *StatsUpdate { - su.mutation.ResetUdSmoke() - su.mutation.SetUdSmoke(u) - return su -} - -// SetNillableUdSmoke sets the "ud_smoke" field if the given value is not nil. -func (su *StatsUpdate) SetNillableUdSmoke(u *uint) *StatsUpdate { - if u != nil { - su.SetUdSmoke(*u) - } - return su -} - -// AddUdSmoke adds u to the "ud_smoke" field. -func (su *StatsUpdate) AddUdSmoke(u uint) *StatsUpdate { - su.mutation.AddUdSmoke(u) - return su -} - -// ClearUdSmoke clears the value of the "ud_smoke" field. -func (su *StatsUpdate) ClearUdSmoke() *StatsUpdate { - su.mutation.ClearUdSmoke() - return su -} - -// SetCrosshair sets the "crosshair" field. -func (su *StatsUpdate) SetCrosshair(s string) *StatsUpdate { - su.mutation.SetCrosshair(s) - return su -} - -// SetNillableCrosshair sets the "crosshair" field if the given value is not nil. -func (su *StatsUpdate) SetNillableCrosshair(s *string) *StatsUpdate { - if s != nil { - su.SetCrosshair(*s) - } - return su -} - -// ClearCrosshair clears the value of the "crosshair" field. -func (su *StatsUpdate) ClearCrosshair() *StatsUpdate { - su.mutation.ClearCrosshair() - return su -} - -// SetColor sets the "color" field. -func (su *StatsUpdate) SetColor(s stats.Color) *StatsUpdate { - su.mutation.SetColor(s) - return su -} - -// SetNillableColor sets the "color" field if the given value is not nil. -func (su *StatsUpdate) SetNillableColor(s *stats.Color) *StatsUpdate { - if s != nil { - su.SetColor(*s) - } - return su -} - -// ClearColor clears the value of the "color" field. -func (su *StatsUpdate) ClearColor() *StatsUpdate { - su.mutation.ClearColor() - return su -} - -// SetKast sets the "kast" field. -func (su *StatsUpdate) SetKast(i int) *StatsUpdate { - su.mutation.ResetKast() - su.mutation.SetKast(i) - return su -} - -// SetNillableKast sets the "kast" field if the given value is not nil. -func (su *StatsUpdate) SetNillableKast(i *int) *StatsUpdate { - if i != nil { - su.SetKast(*i) - } - return su -} - -// AddKast adds i to the "kast" field. -func (su *StatsUpdate) AddKast(i int) *StatsUpdate { - su.mutation.AddKast(i) - return su -} - -// ClearKast clears the value of the "kast" field. -func (su *StatsUpdate) ClearKast() *StatsUpdate { - su.mutation.ClearKast() - return su -} - -// SetFlashDurationSelf sets the "flash_duration_self" field. -func (su *StatsUpdate) SetFlashDurationSelf(f float32) *StatsUpdate { - su.mutation.ResetFlashDurationSelf() - su.mutation.SetFlashDurationSelf(f) - return su -} - -// SetNillableFlashDurationSelf sets the "flash_duration_self" field if the given value is not nil. -func (su *StatsUpdate) SetNillableFlashDurationSelf(f *float32) *StatsUpdate { - if f != nil { - su.SetFlashDurationSelf(*f) - } - return su -} - -// AddFlashDurationSelf adds f to the "flash_duration_self" field. -func (su *StatsUpdate) AddFlashDurationSelf(f float32) *StatsUpdate { - su.mutation.AddFlashDurationSelf(f) - return su -} - -// ClearFlashDurationSelf clears the value of the "flash_duration_self" field. -func (su *StatsUpdate) ClearFlashDurationSelf() *StatsUpdate { - su.mutation.ClearFlashDurationSelf() - return su -} - -// SetFlashDurationTeam sets the "flash_duration_team" field. -func (su *StatsUpdate) SetFlashDurationTeam(f float32) *StatsUpdate { - su.mutation.ResetFlashDurationTeam() - su.mutation.SetFlashDurationTeam(f) - return su -} - -// SetNillableFlashDurationTeam sets the "flash_duration_team" field if the given value is not nil. -func (su *StatsUpdate) SetNillableFlashDurationTeam(f *float32) *StatsUpdate { - if f != nil { - su.SetFlashDurationTeam(*f) - } - return su -} - -// AddFlashDurationTeam adds f to the "flash_duration_team" field. -func (su *StatsUpdate) AddFlashDurationTeam(f float32) *StatsUpdate { - su.mutation.AddFlashDurationTeam(f) - return su -} - -// ClearFlashDurationTeam clears the value of the "flash_duration_team" field. -func (su *StatsUpdate) ClearFlashDurationTeam() *StatsUpdate { - su.mutation.ClearFlashDurationTeam() - return su -} - -// SetFlashDurationEnemy sets the "flash_duration_enemy" field. -func (su *StatsUpdate) SetFlashDurationEnemy(f float32) *StatsUpdate { - su.mutation.ResetFlashDurationEnemy() - su.mutation.SetFlashDurationEnemy(f) - return su -} - -// SetNillableFlashDurationEnemy sets the "flash_duration_enemy" field if the given value is not nil. -func (su *StatsUpdate) SetNillableFlashDurationEnemy(f *float32) *StatsUpdate { - if f != nil { - su.SetFlashDurationEnemy(*f) - } - return su -} - -// AddFlashDurationEnemy adds f to the "flash_duration_enemy" field. -func (su *StatsUpdate) AddFlashDurationEnemy(f float32) *StatsUpdate { - su.mutation.AddFlashDurationEnemy(f) - return su -} - -// ClearFlashDurationEnemy clears the value of the "flash_duration_enemy" field. -func (su *StatsUpdate) ClearFlashDurationEnemy() *StatsUpdate { - su.mutation.ClearFlashDurationEnemy() - return su -} - -// SetFlashTotalSelf sets the "flash_total_self" field. -func (su *StatsUpdate) SetFlashTotalSelf(u uint) *StatsUpdate { - su.mutation.ResetFlashTotalSelf() - su.mutation.SetFlashTotalSelf(u) - return su -} - -// SetNillableFlashTotalSelf sets the "flash_total_self" field if the given value is not nil. -func (su *StatsUpdate) SetNillableFlashTotalSelf(u *uint) *StatsUpdate { - if u != nil { - su.SetFlashTotalSelf(*u) - } - return su -} - -// AddFlashTotalSelf adds u to the "flash_total_self" field. -func (su *StatsUpdate) AddFlashTotalSelf(u uint) *StatsUpdate { - su.mutation.AddFlashTotalSelf(u) - return su -} - -// ClearFlashTotalSelf clears the value of the "flash_total_self" field. -func (su *StatsUpdate) ClearFlashTotalSelf() *StatsUpdate { - su.mutation.ClearFlashTotalSelf() - return su -} - -// SetFlashTotalTeam sets the "flash_total_team" field. -func (su *StatsUpdate) SetFlashTotalTeam(u uint) *StatsUpdate { - su.mutation.ResetFlashTotalTeam() - su.mutation.SetFlashTotalTeam(u) - return su -} - -// SetNillableFlashTotalTeam sets the "flash_total_team" field if the given value is not nil. -func (su *StatsUpdate) SetNillableFlashTotalTeam(u *uint) *StatsUpdate { - if u != nil { - su.SetFlashTotalTeam(*u) - } - return su -} - -// AddFlashTotalTeam adds u to the "flash_total_team" field. -func (su *StatsUpdate) AddFlashTotalTeam(u uint) *StatsUpdate { - su.mutation.AddFlashTotalTeam(u) - return su -} - -// ClearFlashTotalTeam clears the value of the "flash_total_team" field. -func (su *StatsUpdate) ClearFlashTotalTeam() *StatsUpdate { - su.mutation.ClearFlashTotalTeam() - return su -} - -// SetFlashTotalEnemy sets the "flash_total_enemy" field. -func (su *StatsUpdate) SetFlashTotalEnemy(u uint) *StatsUpdate { - su.mutation.ResetFlashTotalEnemy() - su.mutation.SetFlashTotalEnemy(u) - return su -} - -// SetNillableFlashTotalEnemy sets the "flash_total_enemy" field if the given value is not nil. -func (su *StatsUpdate) SetNillableFlashTotalEnemy(u *uint) *StatsUpdate { - if u != nil { - su.SetFlashTotalEnemy(*u) - } - return su -} - -// AddFlashTotalEnemy adds u to the "flash_total_enemy" field. -func (su *StatsUpdate) AddFlashTotalEnemy(u uint) *StatsUpdate { - su.mutation.AddFlashTotalEnemy(u) - return su -} - -// ClearFlashTotalEnemy clears the value of the "flash_total_enemy" field. -func (su *StatsUpdate) ClearFlashTotalEnemy() *StatsUpdate { - su.mutation.ClearFlashTotalEnemy() - return su -} - -// SetMatchStats sets the "match_stats" field. -func (su *StatsUpdate) SetMatchStats(u uint64) *StatsUpdate { - su.mutation.SetMatchStats(u) - return su -} - -// SetNillableMatchStats sets the "match_stats" field if the given value is not nil. -func (su *StatsUpdate) SetNillableMatchStats(u *uint64) *StatsUpdate { - if u != nil { - su.SetMatchStats(*u) - } - return su -} - -// ClearMatchStats clears the value of the "match_stats" field. -func (su *StatsUpdate) ClearMatchStats() *StatsUpdate { - su.mutation.ClearMatchStats() - return su -} - -// SetPlayerStats sets the "player_stats" field. -func (su *StatsUpdate) SetPlayerStats(u uint64) *StatsUpdate { - su.mutation.SetPlayerStats(u) - return su -} - -// SetNillablePlayerStats sets the "player_stats" field if the given value is not nil. -func (su *StatsUpdate) SetNillablePlayerStats(u *uint64) *StatsUpdate { - if u != nil { - su.SetPlayerStats(*u) - } - return su -} - -// ClearPlayerStats clears the value of the "player_stats" field. -func (su *StatsUpdate) ClearPlayerStats() *StatsUpdate { - su.mutation.ClearPlayerStats() - return su -} - -// SetMatchesID sets the "matches" edge to the Match entity by ID. -func (su *StatsUpdate) SetMatchesID(id uint64) *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 *uint64) *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 uint64) *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 *uint64) *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) -} - -// AddWeaponStatIDs adds the "weapon_stats" edge to the WeaponStats entity by IDs. -func (su *StatsUpdate) AddWeaponStatIDs(ids ...int) *StatsUpdate { - su.mutation.AddWeaponStatIDs(ids...) - return su -} - -// AddWeaponStats adds the "weapon_stats" edges to the WeaponStats entity. -func (su *StatsUpdate) AddWeaponStats(w ...*WeaponStats) *StatsUpdate { - ids := make([]int, len(w)) - for i := range w { - ids[i] = w[i].ID - } - return su.AddWeaponStatIDs(ids...) -} - -// AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by IDs. -func (su *StatsUpdate) AddRoundStatIDs(ids ...int) *StatsUpdate { - su.mutation.AddRoundStatIDs(ids...) - return su -} - -// AddRoundStats adds the "round_stats" edges to the RoundStats entity. -func (su *StatsUpdate) AddRoundStats(r ...*RoundStats) *StatsUpdate { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID - } - return su.AddRoundStatIDs(ids...) -} - -// 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 -} - -// ClearWeaponStats clears all "weapon_stats" edges to the WeaponStats entity. -func (su *StatsUpdate) ClearWeaponStats() *StatsUpdate { - su.mutation.ClearWeaponStats() - return su -} - -// RemoveWeaponStatIDs removes the "weapon_stats" edge to WeaponStats entities by IDs. -func (su *StatsUpdate) RemoveWeaponStatIDs(ids ...int) *StatsUpdate { - su.mutation.RemoveWeaponStatIDs(ids...) - return su -} - -// RemoveWeaponStats removes "weapon_stats" edges to WeaponStats entities. -func (su *StatsUpdate) RemoveWeaponStats(w ...*WeaponStats) *StatsUpdate { - ids := make([]int, len(w)) - for i := range w { - ids[i] = w[i].ID - } - return su.RemoveWeaponStatIDs(ids...) -} - -// ClearRoundStats clears all "round_stats" edges to the RoundStats entity. -func (su *StatsUpdate) ClearRoundStats() *StatsUpdate { - su.mutation.ClearRoundStats() - return su -} - -// RemoveRoundStatIDs removes the "round_stats" edge to RoundStats entities by IDs. -func (su *StatsUpdate) RemoveRoundStatIDs(ids ...int) *StatsUpdate { - su.mutation.RemoveRoundStatIDs(ids...) - return su -} - -// RemoveRoundStats removes "round_stats" edges to RoundStats entities. -func (su *StatsUpdate) RemoveRoundStats(r ...*RoundStats) *StatsUpdate { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID - } - return su.RemoveRoundStatIDs(ids...) -} - -// 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 { - if err = su.check(); err != nil { - return 0, err - } - 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) - } - if err = su.check(); err != nil { - return 0, err - } - 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) - } -} - -// check runs all checks and user-defined validators on the builder. -func (su *StatsUpdate) check() error { - if v, ok := su.mutation.Color(); ok { - if err := stats.ColorValidator(v); err != nil { - return &ValidationError{Name: "color", err: fmt.Errorf("ent: validator failed for field \"color\": %w", err)} - } - } - return nil -} - -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.TypeUint, - Value: value, - Column: stats.FieldMvp, - }) - } - if value, ok := su.mutation.AddedMvp(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - 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.RankNew(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldRankNew, - }) - } - if value, ok := su.mutation.AddedRankNew(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldRankNew, - }) - } - if su.mutation.RankNewCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: stats.FieldRankNew, - }) - } - if value, ok := su.mutation.RankOld(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldRankOld, - }) - } - if value, ok := su.mutation.AddedRankOld(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldRankOld, - }) - } - if su.mutation.RankOldCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: stats.FieldRankOld, - }) - } - if value, ok := su.mutation.Mk2(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk2, - }) - } - if value, ok := su.mutation.AddedMk2(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk2, - }) - } - if su.mutation.Mk2Cleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldMk2, - }) - } - if value, ok := su.mutation.Mk3(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk3, - }) - } - if value, ok := su.mutation.AddedMk3(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk3, - }) - } - if su.mutation.Mk3Cleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldMk3, - }) - } - if value, ok := su.mutation.Mk4(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk4, - }) - } - if value, ok := su.mutation.AddedMk4(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk4, - }) - } - if su.mutation.Mk4Cleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldMk4, - }) - } - if value, ok := su.mutation.Mk5(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk5, - }) - } - if value, ok := su.mutation.AddedMk5(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk5, - }) - } - if su.mutation.Mk5Cleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldMk5, - }) - } - if value, ok := su.mutation.DmgEnemy(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldDmgEnemy, - }) - } - if value, ok := su.mutation.AddedDmgEnemy(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldDmgEnemy, - }) - } - if su.mutation.DmgEnemyCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldDmgEnemy, - }) - } - if value, ok := su.mutation.DmgTeam(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldDmgTeam, - }) - } - if value, ok := su.mutation.AddedDmgTeam(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldDmgTeam, - }) - } - if su.mutation.DmgTeamCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldDmgTeam, - }) - } - if value, ok := su.mutation.UdHe(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdHe, - }) - } - if value, ok := su.mutation.AddedUdHe(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdHe, - }) - } - if su.mutation.UdHeCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldUdHe, - }) - } - if value, ok := su.mutation.UdFlames(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdFlames, - }) - } - if value, ok := su.mutation.AddedUdFlames(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdFlames, - }) - } - if su.mutation.UdFlamesCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldUdFlames, - }) - } - if value, ok := su.mutation.UdFlash(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdFlash, - }) - } - if value, ok := su.mutation.AddedUdFlash(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdFlash, - }) - } - if su.mutation.UdFlashCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldUdFlash, - }) - } - if value, ok := su.mutation.UdDecoy(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdDecoy, - }) - } - if value, ok := su.mutation.AddedUdDecoy(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdDecoy, - }) - } - if su.mutation.UdDecoyCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldUdDecoy, - }) - } - if value, ok := su.mutation.UdSmoke(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdSmoke, - }) - } - if value, ok := su.mutation.AddedUdSmoke(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdSmoke, - }) - } - if su.mutation.UdSmokeCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldUdSmoke, - }) - } - if value, ok := su.mutation.Crosshair(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: stats.FieldCrosshair, - }) - } - if su.mutation.CrosshairCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: stats.FieldCrosshair, - }) - } - if value, ok := su.mutation.Color(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeEnum, - Value: value, - Column: stats.FieldColor, - }) - } - if su.mutation.ColorCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeEnum, - Column: stats.FieldColor, - }) - } - if value, ok := su.mutation.Kast(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldKast, - }) - } - if value, ok := su.mutation.AddedKast(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldKast, - }) - } - if su.mutation.KastCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: stats.FieldKast, - }) - } - if value, ok := su.mutation.FlashDurationSelf(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Value: value, - Column: stats.FieldFlashDurationSelf, - }) - } - if value, ok := su.mutation.AddedFlashDurationSelf(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Value: value, - Column: stats.FieldFlashDurationSelf, - }) - } - if su.mutation.FlashDurationSelfCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Column: stats.FieldFlashDurationSelf, - }) - } - if value, ok := su.mutation.FlashDurationTeam(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Value: value, - Column: stats.FieldFlashDurationTeam, - }) - } - if value, ok := su.mutation.AddedFlashDurationTeam(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Value: value, - Column: stats.FieldFlashDurationTeam, - }) - } - if su.mutation.FlashDurationTeamCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Column: stats.FieldFlashDurationTeam, - }) - } - if value, ok := su.mutation.FlashDurationEnemy(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Value: value, - Column: stats.FieldFlashDurationEnemy, - }) - } - if value, ok := su.mutation.AddedFlashDurationEnemy(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Value: value, - Column: stats.FieldFlashDurationEnemy, - }) - } - if su.mutation.FlashDurationEnemyCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Column: stats.FieldFlashDurationEnemy, - }) - } - if value, ok := su.mutation.FlashTotalSelf(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldFlashTotalSelf, - }) - } - if value, ok := su.mutation.AddedFlashTotalSelf(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldFlashTotalSelf, - }) - } - if su.mutation.FlashTotalSelfCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldFlashTotalSelf, - }) - } - if value, ok := su.mutation.FlashTotalTeam(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldFlashTotalTeam, - }) - } - if value, ok := su.mutation.AddedFlashTotalTeam(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldFlashTotalTeam, - }) - } - if su.mutation.FlashTotalTeamCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldFlashTotalTeam, - }) - } - if value, ok := su.mutation.FlashTotalEnemy(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldFlashTotalEnemy, - }) - } - if value, ok := su.mutation.AddedFlashTotalEnemy(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldFlashTotalEnemy, - }) - } - if su.mutation.FlashTotalEnemyCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldFlashTotalEnemy, - }) - } - 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.TypeUint64, - 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.TypeUint64, - 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.TypeUint64, - 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.TypeUint64, - Column: player.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if su.mutation.WeaponStatsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: stats.WeaponStatsTable, - Columns: []string{stats.WeaponStatsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: weaponstats.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := su.mutation.RemovedWeaponStatsIDs(); len(nodes) > 0 && !su.mutation.WeaponStatsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: stats.WeaponStatsTable, - Columns: []string{stats.WeaponStatsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: weaponstats.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := su.mutation.WeaponStatsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: stats.WeaponStatsTable, - Columns: []string{stats.WeaponStatsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: weaponstats.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if su.mutation.RoundStatsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: stats.RoundStatsTable, - Columns: []string{stats.RoundStatsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: roundstats.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := su.mutation.RemovedRoundStatsIDs(); len(nodes) > 0 && !su.mutation.RoundStatsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: stats.RoundStatsTable, - Columns: []string{stats.RoundStatsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: roundstats.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := su.mutation.RoundStatsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: stats.RoundStatsTable, - Columns: []string{stats.RoundStatsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: roundstats.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(u uint) *StatsUpdateOne { - suo.mutation.ResetMvp() - suo.mutation.SetMvp(u) - return suo -} - -// AddMvp adds u to the "mvp" field. -func (suo *StatsUpdateOne) AddMvp(u uint) *StatsUpdateOne { - suo.mutation.AddMvp(u) - 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 -} - -// SetRankNew sets the "rank_new" field. -func (suo *StatsUpdateOne) SetRankNew(i int) *StatsUpdateOne { - suo.mutation.ResetRankNew() - suo.mutation.SetRankNew(i) - return suo -} - -// SetNillableRankNew sets the "rank_new" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableRankNew(i *int) *StatsUpdateOne { - if i != nil { - suo.SetRankNew(*i) - } - return suo -} - -// AddRankNew adds i to the "rank_new" field. -func (suo *StatsUpdateOne) AddRankNew(i int) *StatsUpdateOne { - suo.mutation.AddRankNew(i) - return suo -} - -// ClearRankNew clears the value of the "rank_new" field. -func (suo *StatsUpdateOne) ClearRankNew() *StatsUpdateOne { - suo.mutation.ClearRankNew() - return suo -} - -// SetRankOld sets the "rank_old" field. -func (suo *StatsUpdateOne) SetRankOld(i int) *StatsUpdateOne { - suo.mutation.ResetRankOld() - suo.mutation.SetRankOld(i) - return suo -} - -// SetNillableRankOld sets the "rank_old" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableRankOld(i *int) *StatsUpdateOne { - if i != nil { - suo.SetRankOld(*i) - } - return suo -} - -// AddRankOld adds i to the "rank_old" field. -func (suo *StatsUpdateOne) AddRankOld(i int) *StatsUpdateOne { - suo.mutation.AddRankOld(i) - return suo -} - -// ClearRankOld clears the value of the "rank_old" field. -func (suo *StatsUpdateOne) ClearRankOld() *StatsUpdateOne { - suo.mutation.ClearRankOld() - return suo -} - -// SetMk2 sets the "mk_2" field. -func (suo *StatsUpdateOne) SetMk2(u uint) *StatsUpdateOne { - suo.mutation.ResetMk2() - suo.mutation.SetMk2(u) - return suo -} - -// SetNillableMk2 sets the "mk_2" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableMk2(u *uint) *StatsUpdateOne { - if u != nil { - suo.SetMk2(*u) - } - return suo -} - -// AddMk2 adds u to the "mk_2" field. -func (suo *StatsUpdateOne) AddMk2(u uint) *StatsUpdateOne { - suo.mutation.AddMk2(u) - return suo -} - -// ClearMk2 clears the value of the "mk_2" field. -func (suo *StatsUpdateOne) ClearMk2() *StatsUpdateOne { - suo.mutation.ClearMk2() - return suo -} - -// SetMk3 sets the "mk_3" field. -func (suo *StatsUpdateOne) SetMk3(u uint) *StatsUpdateOne { - suo.mutation.ResetMk3() - suo.mutation.SetMk3(u) - return suo -} - -// SetNillableMk3 sets the "mk_3" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableMk3(u *uint) *StatsUpdateOne { - if u != nil { - suo.SetMk3(*u) - } - return suo -} - -// AddMk3 adds u to the "mk_3" field. -func (suo *StatsUpdateOne) AddMk3(u uint) *StatsUpdateOne { - suo.mutation.AddMk3(u) - return suo -} - -// ClearMk3 clears the value of the "mk_3" field. -func (suo *StatsUpdateOne) ClearMk3() *StatsUpdateOne { - suo.mutation.ClearMk3() - return suo -} - -// SetMk4 sets the "mk_4" field. -func (suo *StatsUpdateOne) SetMk4(u uint) *StatsUpdateOne { - suo.mutation.ResetMk4() - suo.mutation.SetMk4(u) - return suo -} - -// SetNillableMk4 sets the "mk_4" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableMk4(u *uint) *StatsUpdateOne { - if u != nil { - suo.SetMk4(*u) - } - return suo -} - -// AddMk4 adds u to the "mk_4" field. -func (suo *StatsUpdateOne) AddMk4(u uint) *StatsUpdateOne { - suo.mutation.AddMk4(u) - return suo -} - -// ClearMk4 clears the value of the "mk_4" field. -func (suo *StatsUpdateOne) ClearMk4() *StatsUpdateOne { - suo.mutation.ClearMk4() - return suo -} - -// SetMk5 sets the "mk_5" field. -func (suo *StatsUpdateOne) SetMk5(u uint) *StatsUpdateOne { - suo.mutation.ResetMk5() - suo.mutation.SetMk5(u) - return suo -} - -// SetNillableMk5 sets the "mk_5" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableMk5(u *uint) *StatsUpdateOne { - if u != nil { - suo.SetMk5(*u) - } - return suo -} - -// AddMk5 adds u to the "mk_5" field. -func (suo *StatsUpdateOne) AddMk5(u uint) *StatsUpdateOne { - suo.mutation.AddMk5(u) - return suo -} - -// ClearMk5 clears the value of the "mk_5" field. -func (suo *StatsUpdateOne) ClearMk5() *StatsUpdateOne { - suo.mutation.ClearMk5() - return suo -} - -// SetDmgEnemy sets the "dmg_enemy" field. -func (suo *StatsUpdateOne) SetDmgEnemy(u uint) *StatsUpdateOne { - suo.mutation.ResetDmgEnemy() - suo.mutation.SetDmgEnemy(u) - return suo -} - -// SetNillableDmgEnemy sets the "dmg_enemy" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableDmgEnemy(u *uint) *StatsUpdateOne { - if u != nil { - suo.SetDmgEnemy(*u) - } - return suo -} - -// AddDmgEnemy adds u to the "dmg_enemy" field. -func (suo *StatsUpdateOne) AddDmgEnemy(u uint) *StatsUpdateOne { - suo.mutation.AddDmgEnemy(u) - return suo -} - -// ClearDmgEnemy clears the value of the "dmg_enemy" field. -func (suo *StatsUpdateOne) ClearDmgEnemy() *StatsUpdateOne { - suo.mutation.ClearDmgEnemy() - return suo -} - -// SetDmgTeam sets the "dmg_team" field. -func (suo *StatsUpdateOne) SetDmgTeam(u uint) *StatsUpdateOne { - suo.mutation.ResetDmgTeam() - suo.mutation.SetDmgTeam(u) - return suo -} - -// SetNillableDmgTeam sets the "dmg_team" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableDmgTeam(u *uint) *StatsUpdateOne { - if u != nil { - suo.SetDmgTeam(*u) - } - return suo -} - -// AddDmgTeam adds u to the "dmg_team" field. -func (suo *StatsUpdateOne) AddDmgTeam(u uint) *StatsUpdateOne { - suo.mutation.AddDmgTeam(u) - return suo -} - -// ClearDmgTeam clears the value of the "dmg_team" field. -func (suo *StatsUpdateOne) ClearDmgTeam() *StatsUpdateOne { - suo.mutation.ClearDmgTeam() - return suo -} - -// SetUdHe sets the "ud_he" field. -func (suo *StatsUpdateOne) SetUdHe(u uint) *StatsUpdateOne { - suo.mutation.ResetUdHe() - suo.mutation.SetUdHe(u) - return suo -} - -// SetNillableUdHe sets the "ud_he" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableUdHe(u *uint) *StatsUpdateOne { - if u != nil { - suo.SetUdHe(*u) - } - return suo -} - -// AddUdHe adds u to the "ud_he" field. -func (suo *StatsUpdateOne) AddUdHe(u uint) *StatsUpdateOne { - suo.mutation.AddUdHe(u) - return suo -} - -// ClearUdHe clears the value of the "ud_he" field. -func (suo *StatsUpdateOne) ClearUdHe() *StatsUpdateOne { - suo.mutation.ClearUdHe() - return suo -} - -// SetUdFlames sets the "ud_flames" field. -func (suo *StatsUpdateOne) SetUdFlames(u uint) *StatsUpdateOne { - suo.mutation.ResetUdFlames() - suo.mutation.SetUdFlames(u) - return suo -} - -// SetNillableUdFlames sets the "ud_flames" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableUdFlames(u *uint) *StatsUpdateOne { - if u != nil { - suo.SetUdFlames(*u) - } - return suo -} - -// AddUdFlames adds u to the "ud_flames" field. -func (suo *StatsUpdateOne) AddUdFlames(u uint) *StatsUpdateOne { - suo.mutation.AddUdFlames(u) - return suo -} - -// ClearUdFlames clears the value of the "ud_flames" field. -func (suo *StatsUpdateOne) ClearUdFlames() *StatsUpdateOne { - suo.mutation.ClearUdFlames() - return suo -} - -// SetUdFlash sets the "ud_flash" field. -func (suo *StatsUpdateOne) SetUdFlash(u uint) *StatsUpdateOne { - suo.mutation.ResetUdFlash() - suo.mutation.SetUdFlash(u) - return suo -} - -// SetNillableUdFlash sets the "ud_flash" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableUdFlash(u *uint) *StatsUpdateOne { - if u != nil { - suo.SetUdFlash(*u) - } - return suo -} - -// AddUdFlash adds u to the "ud_flash" field. -func (suo *StatsUpdateOne) AddUdFlash(u uint) *StatsUpdateOne { - suo.mutation.AddUdFlash(u) - return suo -} - -// ClearUdFlash clears the value of the "ud_flash" field. -func (suo *StatsUpdateOne) ClearUdFlash() *StatsUpdateOne { - suo.mutation.ClearUdFlash() - return suo -} - -// SetUdDecoy sets the "ud_decoy" field. -func (suo *StatsUpdateOne) SetUdDecoy(u uint) *StatsUpdateOne { - suo.mutation.ResetUdDecoy() - suo.mutation.SetUdDecoy(u) - return suo -} - -// SetNillableUdDecoy sets the "ud_decoy" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableUdDecoy(u *uint) *StatsUpdateOne { - if u != nil { - suo.SetUdDecoy(*u) - } - return suo -} - -// AddUdDecoy adds u to the "ud_decoy" field. -func (suo *StatsUpdateOne) AddUdDecoy(u uint) *StatsUpdateOne { - suo.mutation.AddUdDecoy(u) - return suo -} - -// ClearUdDecoy clears the value of the "ud_decoy" field. -func (suo *StatsUpdateOne) ClearUdDecoy() *StatsUpdateOne { - suo.mutation.ClearUdDecoy() - return suo -} - -// SetUdSmoke sets the "ud_smoke" field. -func (suo *StatsUpdateOne) SetUdSmoke(u uint) *StatsUpdateOne { - suo.mutation.ResetUdSmoke() - suo.mutation.SetUdSmoke(u) - return suo -} - -// SetNillableUdSmoke sets the "ud_smoke" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableUdSmoke(u *uint) *StatsUpdateOne { - if u != nil { - suo.SetUdSmoke(*u) - } - return suo -} - -// AddUdSmoke adds u to the "ud_smoke" field. -func (suo *StatsUpdateOne) AddUdSmoke(u uint) *StatsUpdateOne { - suo.mutation.AddUdSmoke(u) - return suo -} - -// ClearUdSmoke clears the value of the "ud_smoke" field. -func (suo *StatsUpdateOne) ClearUdSmoke() *StatsUpdateOne { - suo.mutation.ClearUdSmoke() - return suo -} - -// SetCrosshair sets the "crosshair" field. -func (suo *StatsUpdateOne) SetCrosshair(s string) *StatsUpdateOne { - suo.mutation.SetCrosshair(s) - return suo -} - -// SetNillableCrosshair sets the "crosshair" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableCrosshair(s *string) *StatsUpdateOne { - if s != nil { - suo.SetCrosshair(*s) - } - return suo -} - -// ClearCrosshair clears the value of the "crosshair" field. -func (suo *StatsUpdateOne) ClearCrosshair() *StatsUpdateOne { - suo.mutation.ClearCrosshair() - return suo -} - -// SetColor sets the "color" field. -func (suo *StatsUpdateOne) SetColor(s stats.Color) *StatsUpdateOne { - suo.mutation.SetColor(s) - return suo -} - -// SetNillableColor sets the "color" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableColor(s *stats.Color) *StatsUpdateOne { - if s != nil { - suo.SetColor(*s) - } - return suo -} - -// ClearColor clears the value of the "color" field. -func (suo *StatsUpdateOne) ClearColor() *StatsUpdateOne { - suo.mutation.ClearColor() - return suo -} - -// SetKast sets the "kast" field. -func (suo *StatsUpdateOne) SetKast(i int) *StatsUpdateOne { - suo.mutation.ResetKast() - suo.mutation.SetKast(i) - return suo -} - -// SetNillableKast sets the "kast" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableKast(i *int) *StatsUpdateOne { - if i != nil { - suo.SetKast(*i) - } - return suo -} - -// AddKast adds i to the "kast" field. -func (suo *StatsUpdateOne) AddKast(i int) *StatsUpdateOne { - suo.mutation.AddKast(i) - return suo -} - -// ClearKast clears the value of the "kast" field. -func (suo *StatsUpdateOne) ClearKast() *StatsUpdateOne { - suo.mutation.ClearKast() - return suo -} - -// SetFlashDurationSelf sets the "flash_duration_self" field. -func (suo *StatsUpdateOne) SetFlashDurationSelf(f float32) *StatsUpdateOne { - suo.mutation.ResetFlashDurationSelf() - suo.mutation.SetFlashDurationSelf(f) - return suo -} - -// SetNillableFlashDurationSelf sets the "flash_duration_self" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableFlashDurationSelf(f *float32) *StatsUpdateOne { - if f != nil { - suo.SetFlashDurationSelf(*f) - } - return suo -} - -// AddFlashDurationSelf adds f to the "flash_duration_self" field. -func (suo *StatsUpdateOne) AddFlashDurationSelf(f float32) *StatsUpdateOne { - suo.mutation.AddFlashDurationSelf(f) - return suo -} - -// ClearFlashDurationSelf clears the value of the "flash_duration_self" field. -func (suo *StatsUpdateOne) ClearFlashDurationSelf() *StatsUpdateOne { - suo.mutation.ClearFlashDurationSelf() - return suo -} - -// SetFlashDurationTeam sets the "flash_duration_team" field. -func (suo *StatsUpdateOne) SetFlashDurationTeam(f float32) *StatsUpdateOne { - suo.mutation.ResetFlashDurationTeam() - suo.mutation.SetFlashDurationTeam(f) - return suo -} - -// SetNillableFlashDurationTeam sets the "flash_duration_team" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableFlashDurationTeam(f *float32) *StatsUpdateOne { - if f != nil { - suo.SetFlashDurationTeam(*f) - } - return suo -} - -// AddFlashDurationTeam adds f to the "flash_duration_team" field. -func (suo *StatsUpdateOne) AddFlashDurationTeam(f float32) *StatsUpdateOne { - suo.mutation.AddFlashDurationTeam(f) - return suo -} - -// ClearFlashDurationTeam clears the value of the "flash_duration_team" field. -func (suo *StatsUpdateOne) ClearFlashDurationTeam() *StatsUpdateOne { - suo.mutation.ClearFlashDurationTeam() - return suo -} - -// SetFlashDurationEnemy sets the "flash_duration_enemy" field. -func (suo *StatsUpdateOne) SetFlashDurationEnemy(f float32) *StatsUpdateOne { - suo.mutation.ResetFlashDurationEnemy() - suo.mutation.SetFlashDurationEnemy(f) - return suo -} - -// SetNillableFlashDurationEnemy sets the "flash_duration_enemy" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableFlashDurationEnemy(f *float32) *StatsUpdateOne { - if f != nil { - suo.SetFlashDurationEnemy(*f) - } - return suo -} - -// AddFlashDurationEnemy adds f to the "flash_duration_enemy" field. -func (suo *StatsUpdateOne) AddFlashDurationEnemy(f float32) *StatsUpdateOne { - suo.mutation.AddFlashDurationEnemy(f) - return suo -} - -// ClearFlashDurationEnemy clears the value of the "flash_duration_enemy" field. -func (suo *StatsUpdateOne) ClearFlashDurationEnemy() *StatsUpdateOne { - suo.mutation.ClearFlashDurationEnemy() - return suo -} - -// SetFlashTotalSelf sets the "flash_total_self" field. -func (suo *StatsUpdateOne) SetFlashTotalSelf(u uint) *StatsUpdateOne { - suo.mutation.ResetFlashTotalSelf() - suo.mutation.SetFlashTotalSelf(u) - return suo -} - -// SetNillableFlashTotalSelf sets the "flash_total_self" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableFlashTotalSelf(u *uint) *StatsUpdateOne { - if u != nil { - suo.SetFlashTotalSelf(*u) - } - return suo -} - -// AddFlashTotalSelf adds u to the "flash_total_self" field. -func (suo *StatsUpdateOne) AddFlashTotalSelf(u uint) *StatsUpdateOne { - suo.mutation.AddFlashTotalSelf(u) - return suo -} - -// ClearFlashTotalSelf clears the value of the "flash_total_self" field. -func (suo *StatsUpdateOne) ClearFlashTotalSelf() *StatsUpdateOne { - suo.mutation.ClearFlashTotalSelf() - return suo -} - -// SetFlashTotalTeam sets the "flash_total_team" field. -func (suo *StatsUpdateOne) SetFlashTotalTeam(u uint) *StatsUpdateOne { - suo.mutation.ResetFlashTotalTeam() - suo.mutation.SetFlashTotalTeam(u) - return suo -} - -// SetNillableFlashTotalTeam sets the "flash_total_team" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableFlashTotalTeam(u *uint) *StatsUpdateOne { - if u != nil { - suo.SetFlashTotalTeam(*u) - } - return suo -} - -// AddFlashTotalTeam adds u to the "flash_total_team" field. -func (suo *StatsUpdateOne) AddFlashTotalTeam(u uint) *StatsUpdateOne { - suo.mutation.AddFlashTotalTeam(u) - return suo -} - -// ClearFlashTotalTeam clears the value of the "flash_total_team" field. -func (suo *StatsUpdateOne) ClearFlashTotalTeam() *StatsUpdateOne { - suo.mutation.ClearFlashTotalTeam() - return suo -} - -// SetFlashTotalEnemy sets the "flash_total_enemy" field. -func (suo *StatsUpdateOne) SetFlashTotalEnemy(u uint) *StatsUpdateOne { - suo.mutation.ResetFlashTotalEnemy() - suo.mutation.SetFlashTotalEnemy(u) - return suo -} - -// SetNillableFlashTotalEnemy sets the "flash_total_enemy" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableFlashTotalEnemy(u *uint) *StatsUpdateOne { - if u != nil { - suo.SetFlashTotalEnemy(*u) - } - return suo -} - -// AddFlashTotalEnemy adds u to the "flash_total_enemy" field. -func (suo *StatsUpdateOne) AddFlashTotalEnemy(u uint) *StatsUpdateOne { - suo.mutation.AddFlashTotalEnemy(u) - return suo -} - -// ClearFlashTotalEnemy clears the value of the "flash_total_enemy" field. -func (suo *StatsUpdateOne) ClearFlashTotalEnemy() *StatsUpdateOne { - suo.mutation.ClearFlashTotalEnemy() - return suo -} - -// SetMatchStats sets the "match_stats" field. -func (suo *StatsUpdateOne) SetMatchStats(u uint64) *StatsUpdateOne { - suo.mutation.SetMatchStats(u) - return suo -} - -// SetNillableMatchStats sets the "match_stats" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableMatchStats(u *uint64) *StatsUpdateOne { - if u != nil { - suo.SetMatchStats(*u) - } - return suo -} - -// ClearMatchStats clears the value of the "match_stats" field. -func (suo *StatsUpdateOne) ClearMatchStats() *StatsUpdateOne { - suo.mutation.ClearMatchStats() - return suo -} - -// SetPlayerStats sets the "player_stats" field. -func (suo *StatsUpdateOne) SetPlayerStats(u uint64) *StatsUpdateOne { - suo.mutation.SetPlayerStats(u) - return suo -} - -// SetNillablePlayerStats sets the "player_stats" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillablePlayerStats(u *uint64) *StatsUpdateOne { - if u != nil { - suo.SetPlayerStats(*u) - } - return suo -} - -// ClearPlayerStats clears the value of the "player_stats" field. -func (suo *StatsUpdateOne) ClearPlayerStats() *StatsUpdateOne { - suo.mutation.ClearPlayerStats() - return suo -} - -// SetMatchesID sets the "matches" edge to the Match entity by ID. -func (suo *StatsUpdateOne) SetMatchesID(id uint64) *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 *uint64) *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 uint64) *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 *uint64) *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) -} - -// AddWeaponStatIDs adds the "weapon_stats" edge to the WeaponStats entity by IDs. -func (suo *StatsUpdateOne) AddWeaponStatIDs(ids ...int) *StatsUpdateOne { - suo.mutation.AddWeaponStatIDs(ids...) - return suo -} - -// AddWeaponStats adds the "weapon_stats" edges to the WeaponStats entity. -func (suo *StatsUpdateOne) AddWeaponStats(w ...*WeaponStats) *StatsUpdateOne { - ids := make([]int, len(w)) - for i := range w { - ids[i] = w[i].ID - } - return suo.AddWeaponStatIDs(ids...) -} - -// AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by IDs. -func (suo *StatsUpdateOne) AddRoundStatIDs(ids ...int) *StatsUpdateOne { - suo.mutation.AddRoundStatIDs(ids...) - return suo -} - -// AddRoundStats adds the "round_stats" edges to the RoundStats entity. -func (suo *StatsUpdateOne) AddRoundStats(r ...*RoundStats) *StatsUpdateOne { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID - } - return suo.AddRoundStatIDs(ids...) -} - -// 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 -} - -// ClearWeaponStats clears all "weapon_stats" edges to the WeaponStats entity. -func (suo *StatsUpdateOne) ClearWeaponStats() *StatsUpdateOne { - suo.mutation.ClearWeaponStats() - return suo -} - -// RemoveWeaponStatIDs removes the "weapon_stats" edge to WeaponStats entities by IDs. -func (suo *StatsUpdateOne) RemoveWeaponStatIDs(ids ...int) *StatsUpdateOne { - suo.mutation.RemoveWeaponStatIDs(ids...) - return suo -} - -// RemoveWeaponStats removes "weapon_stats" edges to WeaponStats entities. -func (suo *StatsUpdateOne) RemoveWeaponStats(w ...*WeaponStats) *StatsUpdateOne { - ids := make([]int, len(w)) - for i := range w { - ids[i] = w[i].ID - } - return suo.RemoveWeaponStatIDs(ids...) -} - -// ClearRoundStats clears all "round_stats" edges to the RoundStats entity. -func (suo *StatsUpdateOne) ClearRoundStats() *StatsUpdateOne { - suo.mutation.ClearRoundStats() - return suo -} - -// RemoveRoundStatIDs removes the "round_stats" edge to RoundStats entities by IDs. -func (suo *StatsUpdateOne) RemoveRoundStatIDs(ids ...int) *StatsUpdateOne { - suo.mutation.RemoveRoundStatIDs(ids...) - return suo -} - -// RemoveRoundStats removes "round_stats" edges to RoundStats entities. -func (suo *StatsUpdateOne) RemoveRoundStats(r ...*RoundStats) *StatsUpdateOne { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID - } - return suo.RemoveRoundStatIDs(ids...) -} - -// 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 { - if err = suo.check(); err != nil { - return nil, err - } - 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) - } - if err = suo.check(); err != nil { - return nil, err - } - 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) - } -} - -// check runs all checks and user-defined validators on the builder. -func (suo *StatsUpdateOne) check() error { - if v, ok := suo.mutation.Color(); ok { - if err := stats.ColorValidator(v); err != nil { - return &ValidationError{Name: "color", err: fmt.Errorf("ent: validator failed for field \"color\": %w", err)} - } - } - return nil -} - -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.TypeUint, - Value: value, - Column: stats.FieldMvp, - }) - } - if value, ok := suo.mutation.AddedMvp(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - 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.RankNew(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldRankNew, - }) - } - if value, ok := suo.mutation.AddedRankNew(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldRankNew, - }) - } - if suo.mutation.RankNewCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: stats.FieldRankNew, - }) - } - if value, ok := suo.mutation.RankOld(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldRankOld, - }) - } - if value, ok := suo.mutation.AddedRankOld(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldRankOld, - }) - } - if suo.mutation.RankOldCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: stats.FieldRankOld, - }) - } - if value, ok := suo.mutation.Mk2(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk2, - }) - } - if value, ok := suo.mutation.AddedMk2(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk2, - }) - } - if suo.mutation.Mk2Cleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldMk2, - }) - } - if value, ok := suo.mutation.Mk3(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk3, - }) - } - if value, ok := suo.mutation.AddedMk3(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk3, - }) - } - if suo.mutation.Mk3Cleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldMk3, - }) - } - if value, ok := suo.mutation.Mk4(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk4, - }) - } - if value, ok := suo.mutation.AddedMk4(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk4, - }) - } - if suo.mutation.Mk4Cleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldMk4, - }) - } - if value, ok := suo.mutation.Mk5(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk5, - }) - } - if value, ok := suo.mutation.AddedMk5(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldMk5, - }) - } - if suo.mutation.Mk5Cleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldMk5, - }) - } - if value, ok := suo.mutation.DmgEnemy(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldDmgEnemy, - }) - } - if value, ok := suo.mutation.AddedDmgEnemy(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldDmgEnemy, - }) - } - if suo.mutation.DmgEnemyCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldDmgEnemy, - }) - } - if value, ok := suo.mutation.DmgTeam(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldDmgTeam, - }) - } - if value, ok := suo.mutation.AddedDmgTeam(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldDmgTeam, - }) - } - if suo.mutation.DmgTeamCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldDmgTeam, - }) - } - if value, ok := suo.mutation.UdHe(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdHe, - }) - } - if value, ok := suo.mutation.AddedUdHe(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdHe, - }) - } - if suo.mutation.UdHeCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldUdHe, - }) - } - if value, ok := suo.mutation.UdFlames(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdFlames, - }) - } - if value, ok := suo.mutation.AddedUdFlames(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdFlames, - }) - } - if suo.mutation.UdFlamesCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldUdFlames, - }) - } - if value, ok := suo.mutation.UdFlash(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdFlash, - }) - } - if value, ok := suo.mutation.AddedUdFlash(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdFlash, - }) - } - if suo.mutation.UdFlashCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldUdFlash, - }) - } - if value, ok := suo.mutation.UdDecoy(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdDecoy, - }) - } - if value, ok := suo.mutation.AddedUdDecoy(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdDecoy, - }) - } - if suo.mutation.UdDecoyCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldUdDecoy, - }) - } - if value, ok := suo.mutation.UdSmoke(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdSmoke, - }) - } - if value, ok := suo.mutation.AddedUdSmoke(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldUdSmoke, - }) - } - if suo.mutation.UdSmokeCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldUdSmoke, - }) - } - if value, ok := suo.mutation.Crosshair(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: stats.FieldCrosshair, - }) - } - if suo.mutation.CrosshairCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: stats.FieldCrosshair, - }) - } - if value, ok := suo.mutation.Color(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeEnum, - Value: value, - Column: stats.FieldColor, - }) - } - if suo.mutation.ColorCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeEnum, - Column: stats.FieldColor, - }) - } - if value, ok := suo.mutation.Kast(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldKast, - }) - } - if value, ok := suo.mutation.AddedKast(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: stats.FieldKast, - }) - } - if suo.mutation.KastCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: stats.FieldKast, - }) - } - if value, ok := suo.mutation.FlashDurationSelf(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Value: value, - Column: stats.FieldFlashDurationSelf, - }) - } - if value, ok := suo.mutation.AddedFlashDurationSelf(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Value: value, - Column: stats.FieldFlashDurationSelf, - }) - } - if suo.mutation.FlashDurationSelfCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Column: stats.FieldFlashDurationSelf, - }) - } - if value, ok := suo.mutation.FlashDurationTeam(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Value: value, - Column: stats.FieldFlashDurationTeam, - }) - } - if value, ok := suo.mutation.AddedFlashDurationTeam(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Value: value, - Column: stats.FieldFlashDurationTeam, - }) - } - if suo.mutation.FlashDurationTeamCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Column: stats.FieldFlashDurationTeam, - }) - } - if value, ok := suo.mutation.FlashDurationEnemy(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Value: value, - Column: stats.FieldFlashDurationEnemy, - }) - } - if value, ok := suo.mutation.AddedFlashDurationEnemy(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Value: value, - Column: stats.FieldFlashDurationEnemy, - }) - } - if suo.mutation.FlashDurationEnemyCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeFloat32, - Column: stats.FieldFlashDurationEnemy, - }) - } - if value, ok := suo.mutation.FlashTotalSelf(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldFlashTotalSelf, - }) - } - if value, ok := suo.mutation.AddedFlashTotalSelf(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldFlashTotalSelf, - }) - } - if suo.mutation.FlashTotalSelfCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldFlashTotalSelf, - }) - } - if value, ok := suo.mutation.FlashTotalTeam(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldFlashTotalTeam, - }) - } - if value, ok := suo.mutation.AddedFlashTotalTeam(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldFlashTotalTeam, - }) - } - if suo.mutation.FlashTotalTeamCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldFlashTotalTeam, - }) - } - if value, ok := suo.mutation.FlashTotalEnemy(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldFlashTotalEnemy, - }) - } - if value, ok := suo.mutation.AddedFlashTotalEnemy(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: stats.FieldFlashTotalEnemy, - }) - } - if suo.mutation.FlashTotalEnemyCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Column: stats.FieldFlashTotalEnemy, - }) - } - 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.TypeUint64, - 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.TypeUint64, - 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.TypeUint64, - 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.TypeUint64, - Column: player.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if suo.mutation.WeaponStatsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: stats.WeaponStatsTable, - Columns: []string{stats.WeaponStatsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: weaponstats.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := suo.mutation.RemovedWeaponStatsIDs(); len(nodes) > 0 && !suo.mutation.WeaponStatsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: stats.WeaponStatsTable, - Columns: []string{stats.WeaponStatsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: weaponstats.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := suo.mutation.WeaponStatsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: stats.WeaponStatsTable, - Columns: []string{stats.WeaponStatsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: weaponstats.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if suo.mutation.RoundStatsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: stats.RoundStatsTable, - Columns: []string{stats.RoundStatsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: roundstats.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := suo.mutation.RemovedRoundStatsIDs(); len(nodes) > 0 && !suo.mutation.RoundStatsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: stats.RoundStatsTable, - Columns: []string{stats.RoundStatsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: roundstats.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := suo.mutation.RoundStatsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: stats.RoundStatsTable, - Columns: []string{stats.RoundStatsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: roundstats.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 -} diff --git a/ent/tx.go b/ent/tx.go index 559cd52..6630e78 100644 --- a/ent/tx.go +++ b/ent/tx.go @@ -14,14 +14,16 @@ type Tx struct { config // Match is the client for interacting with the Match builders. Match *MatchClient + // MatchPlayer is the client for interacting with the MatchPlayer builders. + MatchPlayer *MatchPlayerClient // Player is the client for interacting with the Player builders. Player *PlayerClient // RoundStats is the client for interacting with the RoundStats builders. RoundStats *RoundStatsClient - // Stats is the client for interacting with the Stats builders. - Stats *StatsClient - // WeaponStats is the client for interacting with the WeaponStats builders. - WeaponStats *WeaponStatsClient + // Spray is the client for interacting with the Spray builders. + Spray *SprayClient + // Weapon is the client for interacting with the Weapon builders. + Weapon *WeaponClient // lazily loaded. client *Client @@ -158,10 +160,11 @@ func (tx *Tx) Client() *Client { func (tx *Tx) init() { tx.Match = NewMatchClient(tx.config) + tx.MatchPlayer = NewMatchPlayerClient(tx.config) tx.Player = NewPlayerClient(tx.config) tx.RoundStats = NewRoundStatsClient(tx.config) - tx.Stats = NewStatsClient(tx.config) - tx.WeaponStats = NewWeaponStatsClient(tx.config) + tx.Spray = NewSprayClient(tx.config) + tx.Weapon = NewWeaponClient(tx.config) } // txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. diff --git a/ent/weaponstats.go b/ent/weapon.go similarity index 51% rename from ent/weaponstats.go rename to ent/weapon.go index fd8808d..e50c5fd 100644 --- a/ent/weaponstats.go +++ b/ent/weapon.go @@ -3,16 +3,16 @@ package ent import ( - "csgowtfd/ent/stats" - "csgowtfd/ent/weaponstats" + "csgowtfd/ent/matchplayer" + "csgowtfd/ent/weapon" "fmt" "strings" "entgo.io/ent/dialect/sql" ) -// WeaponStats is the model entity for the WeaponStats schema. -type WeaponStats struct { +// Weapon is the model entity for the Weapon schema. +type Weapon struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` @@ -25,15 +25,15 @@ type WeaponStats struct { // HitGroup holds the value of the "hit_group" field. HitGroup int `json:"hit_group,omitempty"` // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the WeaponStatsQuery when eager-loading is set. - Edges WeaponStatsEdges `json:"edges"` - stats_weapon_stats *int + // The values are being populated by the WeaponQuery when eager-loading is set. + Edges WeaponEdges `json:"edges"` + match_player_weapon_stats *int } -// WeaponStatsEdges holds the relations/edges for other nodes in the graph. -type WeaponStatsEdges struct { +// WeaponEdges holds the relations/edges for other nodes in the graph. +type WeaponEdges struct { // Stat holds the value of the stat edge. - Stat *Stats `json:"stat,omitempty"` + Stat *MatchPlayer `json:"stat,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [1]bool @@ -41,12 +41,12 @@ type WeaponStatsEdges struct { // StatOrErr returns the Stat value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. -func (e WeaponStatsEdges) StatOrErr() (*Stats, error) { +func (e WeaponEdges) StatOrErr() (*MatchPlayer, error) { if e.loadedTypes[0] { if e.Stat == nil { // The edge stat was loaded in eager-loading, // but was not found. - return nil, &NotFoundError{label: stats.Label} + return nil, &NotFoundError{label: matchplayer.Label} } return e.Stat, nil } @@ -54,116 +54,116 @@ func (e WeaponStatsEdges) StatOrErr() (*Stats, error) { } // scanValues returns the types for scanning values from sql.Rows. -func (*WeaponStats) scanValues(columns []string) ([]interface{}, error) { +func (*Weapon) scanValues(columns []string) ([]interface{}, error) { values := make([]interface{}, len(columns)) for i := range columns { switch columns[i] { - case weaponstats.FieldID, weaponstats.FieldVictim, weaponstats.FieldDmg, weaponstats.FieldEqType, weaponstats.FieldHitGroup: + case weapon.FieldID, weapon.FieldVictim, weapon.FieldDmg, weapon.FieldEqType, weapon.FieldHitGroup: values[i] = new(sql.NullInt64) - case weaponstats.ForeignKeys[0]: // stats_weapon_stats + case weapon.ForeignKeys[0]: // match_player_weapon_stats values[i] = new(sql.NullInt64) default: - return nil, fmt.Errorf("unexpected column %q for type WeaponStats", columns[i]) + return nil, fmt.Errorf("unexpected column %q for type Weapon", columns[i]) } } return values, nil } // assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the WeaponStats fields. -func (ws *WeaponStats) assignValues(columns []string, values []interface{}) error { +// to the Weapon fields. +func (w *Weapon) assignValues(columns []string, values []interface{}) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } for i := range columns { switch columns[i] { - case weaponstats.FieldID: + case weapon.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - ws.ID = int(value.Int64) - case weaponstats.FieldVictim: + w.ID = int(value.Int64) + case weapon.FieldVictim: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field victim", values[i]) } else if value.Valid { - ws.Victim = uint64(value.Int64) + w.Victim = uint64(value.Int64) } - case weaponstats.FieldDmg: + case weapon.FieldDmg: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field dmg", values[i]) } else if value.Valid { - ws.Dmg = uint(value.Int64) + w.Dmg = uint(value.Int64) } - case weaponstats.FieldEqType: + case weapon.FieldEqType: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field eq_type", values[i]) } else if value.Valid { - ws.EqType = int(value.Int64) + w.EqType = int(value.Int64) } - case weaponstats.FieldHitGroup: + case weapon.FieldHitGroup: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field hit_group", values[i]) } else if value.Valid { - ws.HitGroup = int(value.Int64) + w.HitGroup = int(value.Int64) } - case weaponstats.ForeignKeys[0]: + case weapon.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field stats_weapon_stats", value) + return fmt.Errorf("unexpected type %T for edge-field match_player_weapon_stats", value) } else if value.Valid { - ws.stats_weapon_stats = new(int) - *ws.stats_weapon_stats = int(value.Int64) + w.match_player_weapon_stats = new(int) + *w.match_player_weapon_stats = int(value.Int64) } } } return nil } -// QueryStat queries the "stat" edge of the WeaponStats entity. -func (ws *WeaponStats) QueryStat() *StatsQuery { - return (&WeaponStatsClient{config: ws.config}).QueryStat(ws) +// QueryStat queries the "stat" edge of the Weapon entity. +func (w *Weapon) QueryStat() *MatchPlayerQuery { + return (&WeaponClient{config: w.config}).QueryStat(w) } -// Update returns a builder for updating this WeaponStats. -// Note that you need to call WeaponStats.Unwrap() before calling this method if this WeaponStats +// Update returns a builder for updating this Weapon. +// Note that you need to call Weapon.Unwrap() before calling this method if this Weapon // was returned from a transaction, and the transaction was committed or rolled back. -func (ws *WeaponStats) Update() *WeaponStatsUpdateOne { - return (&WeaponStatsClient{config: ws.config}).UpdateOne(ws) +func (w *Weapon) Update() *WeaponUpdateOne { + return (&WeaponClient{config: w.config}).UpdateOne(w) } -// Unwrap unwraps the WeaponStats entity that was returned from a transaction after it was closed, +// Unwrap unwraps the Weapon entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (ws *WeaponStats) Unwrap() *WeaponStats { - tx, ok := ws.config.driver.(*txDriver) +func (w *Weapon) Unwrap() *Weapon { + tx, ok := w.config.driver.(*txDriver) if !ok { - panic("ent: WeaponStats is not a transactional entity") + panic("ent: Weapon is not a transactional entity") } - ws.config.driver = tx.drv - return ws + w.config.driver = tx.drv + return w } // String implements the fmt.Stringer. -func (ws *WeaponStats) String() string { +func (w *Weapon) String() string { var builder strings.Builder - builder.WriteString("WeaponStats(") - builder.WriteString(fmt.Sprintf("id=%v", ws.ID)) + builder.WriteString("Weapon(") + builder.WriteString(fmt.Sprintf("id=%v", w.ID)) builder.WriteString(", victim=") - builder.WriteString(fmt.Sprintf("%v", ws.Victim)) + builder.WriteString(fmt.Sprintf("%v", w.Victim)) builder.WriteString(", dmg=") - builder.WriteString(fmt.Sprintf("%v", ws.Dmg)) + builder.WriteString(fmt.Sprintf("%v", w.Dmg)) builder.WriteString(", eq_type=") - builder.WriteString(fmt.Sprintf("%v", ws.EqType)) + builder.WriteString(fmt.Sprintf("%v", w.EqType)) builder.WriteString(", hit_group=") - builder.WriteString(fmt.Sprintf("%v", ws.HitGroup)) + builder.WriteString(fmt.Sprintf("%v", w.HitGroup)) builder.WriteByte(')') return builder.String() } -// WeaponStatsSlice is a parsable slice of WeaponStats. -type WeaponStatsSlice []*WeaponStats +// Weapons is a parsable slice of Weapon. +type Weapons []*Weapon -func (ws WeaponStatsSlice) config(cfg config) { - for _i := range ws { - ws[_i].config = cfg +func (w Weapons) config(cfg config) { + for _i := range w { + w[_i].config = cfg } } diff --git a/ent/weaponstats/weaponstats.go b/ent/weapon/weapon.go similarity index 73% rename from ent/weaponstats/weaponstats.go rename to ent/weapon/weapon.go index 8d32055..4643f8b 100644 --- a/ent/weaponstats/weaponstats.go +++ b/ent/weapon/weapon.go @@ -1,10 +1,10 @@ // Code generated by entc, DO NOT EDIT. -package weaponstats +package weapon const ( - // Label holds the string label denoting the weaponstats type in the database. - Label = "weapon_stats" + // Label holds the string label denoting the weapon type in the database. + Label = "weapon" // FieldID holds the string denoting the id field in the database. FieldID = "id" // FieldVictim holds the string denoting the victim field in the database. @@ -17,18 +17,18 @@ const ( FieldHitGroup = "hit_group" // EdgeStat holds the string denoting the stat edge name in mutations. EdgeStat = "stat" - // Table holds the table name of the weaponstats in the database. - Table = "weapon_stats" + // Table holds the table name of the weapon in the database. + Table = "weapons" // StatTable is the table that holds the stat relation/edge. - StatTable = "weapon_stats" - // StatInverseTable is the table name for the Stats entity. - // It exists in this package in order to avoid circular dependency with the "stats" package. - StatInverseTable = "stats" + StatTable = "weapons" + // StatInverseTable is the table name for the MatchPlayer entity. + // It exists in this package in order to avoid circular dependency with the "matchplayer" package. + StatInverseTable = "match_players" // StatColumn is the table column denoting the stat relation/edge. - StatColumn = "stats_weapon_stats" + StatColumn = "match_player_weapon_stats" ) -// Columns holds all SQL columns for weaponstats fields. +// Columns holds all SQL columns for weapon fields. var Columns = []string{ FieldID, FieldVictim, @@ -37,10 +37,10 @@ var Columns = []string{ FieldHitGroup, } -// ForeignKeys holds the SQL foreign-keys that are owned by the "weapon_stats" +// ForeignKeys holds the SQL foreign-keys that are owned by the "weapons" // table and are not defined as standalone fields in the schema. var ForeignKeys = []string{ - "stats_weapon_stats", + "match_player_weapon_stats", } // ValidColumn reports if the column name is valid (part of the table columns). diff --git a/ent/weaponstats/where.go b/ent/weapon/where.go similarity index 63% rename from ent/weaponstats/where.go rename to ent/weapon/where.go index f5e1615..5be7106 100644 --- a/ent/weaponstats/where.go +++ b/ent/weapon/where.go @@ -1,6 +1,6 @@ // Code generated by entc, DO NOT EDIT. -package weaponstats +package weapon import ( "csgowtfd/ent/predicate" @@ -10,29 +10,29 @@ import ( ) // ID filters vertices based on their ID field. -func ID(id int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func ID(id int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldID), id)) }) } // IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func IDEQ(id int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldID), id)) }) } // IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func IDNEQ(id int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldID), id)) }) } // IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func IDIn(ids ...int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(ids) == 0 { @@ -48,8 +48,8 @@ func IDIn(ids ...int) predicate.WeaponStats { } // IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func IDNotIn(ids ...int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(ids) == 0 { @@ -65,82 +65,82 @@ func IDNotIn(ids ...int) predicate.WeaponStats { } // IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func IDGT(id int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldID), id)) }) } // IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func IDGTE(id int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldID), id)) }) } // IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func IDLT(id int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldID), id)) }) } // IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func IDLTE(id int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldID), id)) }) } // Victim applies equality check predicate on the "victim" field. It's identical to VictimEQ. -func Victim(v uint64) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func Victim(v uint64) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldVictim), v)) }) } // Dmg applies equality check predicate on the "dmg" field. It's identical to DmgEQ. -func Dmg(v uint) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func Dmg(v uint) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldDmg), v)) }) } // EqType applies equality check predicate on the "eq_type" field. It's identical to EqTypeEQ. -func EqType(v int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func EqType(v int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldEqType), v)) }) } // HitGroup applies equality check predicate on the "hit_group" field. It's identical to HitGroupEQ. -func HitGroup(v int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func HitGroup(v int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldHitGroup), v)) }) } // VictimEQ applies the EQ predicate on the "victim" field. -func VictimEQ(v uint64) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func VictimEQ(v uint64) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldVictim), v)) }) } // VictimNEQ applies the NEQ predicate on the "victim" field. -func VictimNEQ(v uint64) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func VictimNEQ(v uint64) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldVictim), v)) }) } // VictimIn applies the In predicate on the "victim" field. -func VictimIn(vs ...uint64) predicate.WeaponStats { +func VictimIn(vs ...uint64) predicate.Weapon { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.WeaponStats(func(s *sql.Selector) { + return predicate.Weapon(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -152,12 +152,12 @@ func VictimIn(vs ...uint64) predicate.WeaponStats { } // VictimNotIn applies the NotIn predicate on the "victim" field. -func VictimNotIn(vs ...uint64) predicate.WeaponStats { +func VictimNotIn(vs ...uint64) predicate.Weapon { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.WeaponStats(func(s *sql.Selector) { + return predicate.Weapon(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -169,54 +169,54 @@ func VictimNotIn(vs ...uint64) predicate.WeaponStats { } // VictimGT applies the GT predicate on the "victim" field. -func VictimGT(v uint64) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func VictimGT(v uint64) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldVictim), v)) }) } // VictimGTE applies the GTE predicate on the "victim" field. -func VictimGTE(v uint64) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func VictimGTE(v uint64) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldVictim), v)) }) } // VictimLT applies the LT predicate on the "victim" field. -func VictimLT(v uint64) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func VictimLT(v uint64) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldVictim), v)) }) } // VictimLTE applies the LTE predicate on the "victim" field. -func VictimLTE(v uint64) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func VictimLTE(v uint64) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldVictim), v)) }) } // DmgEQ applies the EQ predicate on the "dmg" field. -func DmgEQ(v uint) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func DmgEQ(v uint) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldDmg), v)) }) } // DmgNEQ applies the NEQ predicate on the "dmg" field. -func DmgNEQ(v uint) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func DmgNEQ(v uint) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldDmg), v)) }) } // DmgIn applies the In predicate on the "dmg" field. -func DmgIn(vs ...uint) predicate.WeaponStats { +func DmgIn(vs ...uint) predicate.Weapon { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.WeaponStats(func(s *sql.Selector) { + return predicate.Weapon(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -228,12 +228,12 @@ func DmgIn(vs ...uint) predicate.WeaponStats { } // DmgNotIn applies the NotIn predicate on the "dmg" field. -func DmgNotIn(vs ...uint) predicate.WeaponStats { +func DmgNotIn(vs ...uint) predicate.Weapon { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.WeaponStats(func(s *sql.Selector) { + return predicate.Weapon(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -245,54 +245,54 @@ func DmgNotIn(vs ...uint) predicate.WeaponStats { } // DmgGT applies the GT predicate on the "dmg" field. -func DmgGT(v uint) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func DmgGT(v uint) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldDmg), v)) }) } // DmgGTE applies the GTE predicate on the "dmg" field. -func DmgGTE(v uint) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func DmgGTE(v uint) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldDmg), v)) }) } // DmgLT applies the LT predicate on the "dmg" field. -func DmgLT(v uint) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func DmgLT(v uint) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldDmg), v)) }) } // DmgLTE applies the LTE predicate on the "dmg" field. -func DmgLTE(v uint) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func DmgLTE(v uint) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldDmg), v)) }) } // EqTypeEQ applies the EQ predicate on the "eq_type" field. -func EqTypeEQ(v int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func EqTypeEQ(v int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldEqType), v)) }) } // EqTypeNEQ applies the NEQ predicate on the "eq_type" field. -func EqTypeNEQ(v int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func EqTypeNEQ(v int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldEqType), v)) }) } // EqTypeIn applies the In predicate on the "eq_type" field. -func EqTypeIn(vs ...int) predicate.WeaponStats { +func EqTypeIn(vs ...int) predicate.Weapon { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.WeaponStats(func(s *sql.Selector) { + return predicate.Weapon(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -304,12 +304,12 @@ func EqTypeIn(vs ...int) predicate.WeaponStats { } // EqTypeNotIn applies the NotIn predicate on the "eq_type" field. -func EqTypeNotIn(vs ...int) predicate.WeaponStats { +func EqTypeNotIn(vs ...int) predicate.Weapon { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.WeaponStats(func(s *sql.Selector) { + return predicate.Weapon(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -321,54 +321,54 @@ func EqTypeNotIn(vs ...int) predicate.WeaponStats { } // EqTypeGT applies the GT predicate on the "eq_type" field. -func EqTypeGT(v int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func EqTypeGT(v int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldEqType), v)) }) } // EqTypeGTE applies the GTE predicate on the "eq_type" field. -func EqTypeGTE(v int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func EqTypeGTE(v int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldEqType), v)) }) } // EqTypeLT applies the LT predicate on the "eq_type" field. -func EqTypeLT(v int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func EqTypeLT(v int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldEqType), v)) }) } // EqTypeLTE applies the LTE predicate on the "eq_type" field. -func EqTypeLTE(v int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func EqTypeLTE(v int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldEqType), v)) }) } // HitGroupEQ applies the EQ predicate on the "hit_group" field. -func HitGroupEQ(v int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func HitGroupEQ(v int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldHitGroup), v)) }) } // HitGroupNEQ applies the NEQ predicate on the "hit_group" field. -func HitGroupNEQ(v int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func HitGroupNEQ(v int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldHitGroup), v)) }) } // HitGroupIn applies the In predicate on the "hit_group" field. -func HitGroupIn(vs ...int) predicate.WeaponStats { +func HitGroupIn(vs ...int) predicate.Weapon { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.WeaponStats(func(s *sql.Selector) { + return predicate.Weapon(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -380,12 +380,12 @@ func HitGroupIn(vs ...int) predicate.WeaponStats { } // HitGroupNotIn applies the NotIn predicate on the "hit_group" field. -func HitGroupNotIn(vs ...int) predicate.WeaponStats { +func HitGroupNotIn(vs ...int) predicate.Weapon { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] } - return predicate.WeaponStats(func(s *sql.Selector) { + return predicate.Weapon(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. if len(v) == 0 { @@ -397,36 +397,36 @@ func HitGroupNotIn(vs ...int) predicate.WeaponStats { } // HitGroupGT applies the GT predicate on the "hit_group" field. -func HitGroupGT(v int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func HitGroupGT(v int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldHitGroup), v)) }) } // HitGroupGTE applies the GTE predicate on the "hit_group" field. -func HitGroupGTE(v int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func HitGroupGTE(v int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldHitGroup), v)) }) } // HitGroupLT applies the LT predicate on the "hit_group" field. -func HitGroupLT(v int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func HitGroupLT(v int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldHitGroup), v)) }) } // HitGroupLTE applies the LTE predicate on the "hit_group" field. -func HitGroupLTE(v int) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func HitGroupLTE(v int) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldHitGroup), v)) }) } // HasStat applies the HasEdge predicate on the "stat" edge. -func HasStat() predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func HasStat() predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(StatTable, FieldID), @@ -437,8 +437,8 @@ func HasStat() predicate.WeaponStats { } // HasStatWith applies the HasEdge predicate on the "stat" edge with a given conditions (other predicates). -func HasStatWith(preds ...predicate.Stats) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func HasStatWith(preds ...predicate.MatchPlayer) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(StatInverseTable, FieldID), @@ -453,8 +453,8 @@ func HasStatWith(preds ...predicate.Stats) predicate.WeaponStats { } // And groups predicates with the AND operator between them. -func And(predicates ...predicate.WeaponStats) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func And(predicates ...predicate.Weapon) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s1 := s.Clone().SetP(nil) for _, p := range predicates { p(s1) @@ -464,8 +464,8 @@ func And(predicates ...predicate.WeaponStats) predicate.WeaponStats { } // Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.WeaponStats) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func Or(predicates ...predicate.Weapon) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { s1 := s.Clone().SetP(nil) for i, p := range predicates { if i > 0 { @@ -478,8 +478,8 @@ func Or(predicates ...predicate.WeaponStats) predicate.WeaponStats { } // Not applies the not operator on the given predicate. -func Not(p predicate.WeaponStats) predicate.WeaponStats { - return predicate.WeaponStats(func(s *sql.Selector) { +func Not(p predicate.Weapon) predicate.Weapon { + return predicate.Weapon(func(s *sql.Selector) { p(s.Not()) }) } diff --git a/ent/weapon_create.go b/ent/weapon_create.go new file mode 100644 index 0000000..24e339c --- /dev/null +++ b/ent/weapon_create.go @@ -0,0 +1,311 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "csgowtfd/ent/matchplayer" + "csgowtfd/ent/weapon" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WeaponCreate is the builder for creating a Weapon entity. +type WeaponCreate struct { + config + mutation *WeaponMutation + hooks []Hook +} + +// SetVictim sets the "victim" field. +func (wc *WeaponCreate) SetVictim(u uint64) *WeaponCreate { + wc.mutation.SetVictim(u) + return wc +} + +// SetDmg sets the "dmg" field. +func (wc *WeaponCreate) SetDmg(u uint) *WeaponCreate { + wc.mutation.SetDmg(u) + return wc +} + +// SetEqType sets the "eq_type" field. +func (wc *WeaponCreate) SetEqType(i int) *WeaponCreate { + wc.mutation.SetEqType(i) + return wc +} + +// SetHitGroup sets the "hit_group" field. +func (wc *WeaponCreate) SetHitGroup(i int) *WeaponCreate { + wc.mutation.SetHitGroup(i) + return wc +} + +// SetStatID sets the "stat" edge to the MatchPlayer entity by ID. +func (wc *WeaponCreate) SetStatID(id int) *WeaponCreate { + wc.mutation.SetStatID(id) + return wc +} + +// SetNillableStatID sets the "stat" edge to the MatchPlayer entity by ID if the given value is not nil. +func (wc *WeaponCreate) SetNillableStatID(id *int) *WeaponCreate { + if id != nil { + wc = wc.SetStatID(*id) + } + return wc +} + +// SetStat sets the "stat" edge to the MatchPlayer entity. +func (wc *WeaponCreate) SetStat(m *MatchPlayer) *WeaponCreate { + return wc.SetStatID(m.ID) +} + +// Mutation returns the WeaponMutation object of the builder. +func (wc *WeaponCreate) Mutation() *WeaponMutation { + return wc.mutation +} + +// Save creates the Weapon in the database. +func (wc *WeaponCreate) Save(ctx context.Context) (*Weapon, error) { + var ( + err error + node *Weapon + ) + if len(wc.hooks) == 0 { + if err = wc.check(); err != nil { + return nil, err + } + node, err = wc.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WeaponMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err = wc.check(); err != nil { + return nil, err + } + wc.mutation = mutation + if node, err = wc.sqlSave(ctx); err != nil { + return nil, err + } + mutation.id = &node.ID + mutation.done = true + return node, err + }) + for i := len(wc.hooks) - 1; i >= 0; i-- { + if wc.hooks[i] == nil { + return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = wc.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, wc.mutation); err != nil { + return nil, err + } + } + return node, err +} + +// SaveX calls Save and panics if Save returns an error. +func (wc *WeaponCreate) SaveX(ctx context.Context) *Weapon { + v, err := wc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (wc *WeaponCreate) Exec(ctx context.Context) error { + _, err := wc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wc *WeaponCreate) ExecX(ctx context.Context) { + if err := wc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (wc *WeaponCreate) check() error { + if _, ok := wc.mutation.Victim(); !ok { + return &ValidationError{Name: "victim", err: errors.New(`ent: missing required field "victim"`)} + } + if _, ok := wc.mutation.Dmg(); !ok { + return &ValidationError{Name: "dmg", err: errors.New(`ent: missing required field "dmg"`)} + } + if _, ok := wc.mutation.EqType(); !ok { + return &ValidationError{Name: "eq_type", err: errors.New(`ent: missing required field "eq_type"`)} + } + if _, ok := wc.mutation.HitGroup(); !ok { + return &ValidationError{Name: "hit_group", err: errors.New(`ent: missing required field "hit_group"`)} + } + return nil +} + +func (wc *WeaponCreate) sqlSave(ctx context.Context) (*Weapon, error) { + _node, _spec := wc.createSpec() + if err := sqlgraph.CreateNode(ctx, wc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + return _node, nil +} + +func (wc *WeaponCreate) createSpec() (*Weapon, *sqlgraph.CreateSpec) { + var ( + _node = &Weapon{config: wc.config} + _spec = &sqlgraph.CreateSpec{ + Table: weapon.Table, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weapon.FieldID, + }, + } + ) + if value, ok := wc.mutation.Victim(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: value, + Column: weapon.FieldVictim, + }) + _node.Victim = value + } + if value, ok := wc.mutation.Dmg(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: weapon.FieldDmg, + }) + _node.Dmg = value + } + if value, ok := wc.mutation.EqType(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weapon.FieldEqType, + }) + _node.EqType = value + } + if value, ok := wc.mutation.HitGroup(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weapon.FieldHitGroup, + }) + _node.HitGroup = value + } + if nodes := wc.mutation.StatIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: weapon.StatTable, + Columns: []string{weapon.StatColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.match_player_weapon_stats = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// WeaponCreateBulk is the builder for creating many Weapon entities in bulk. +type WeaponCreateBulk struct { + config + builders []*WeaponCreate +} + +// Save creates the Weapon entities in the database. +func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) { + specs := make([]*sqlgraph.CreateSpec, len(wcb.builders)) + nodes := make([]*Weapon, len(wcb.builders)) + mutators := make([]Mutator, len(wcb.builders)) + for i := range wcb.builders { + func(i int, root context.Context) { + builder := wcb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WeaponMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + nodes[i], specs[i] = builder.createSpec() + var err error + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, wcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, wcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, wcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (wcb *WeaponCreateBulk) SaveX(ctx context.Context) []*Weapon { + v, err := wcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (wcb *WeaponCreateBulk) Exec(ctx context.Context) error { + _, err := wcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wcb *WeaponCreateBulk) ExecX(ctx context.Context) { + if err := wcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/weapon_delete.go b/ent/weapon_delete.go new file mode 100644 index 0000000..6a36375 --- /dev/null +++ b/ent/weapon_delete.go @@ -0,0 +1,111 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "csgowtfd/ent/predicate" + "csgowtfd/ent/weapon" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// 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) { + var ( + err error + affected int + ) + if len(wd.hooks) == 0 { + affected, err = wd.sqlExec(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WeaponMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + wd.mutation = mutation + affected, err = wd.sqlExec(ctx) + mutation.done = true + return affected, err + }) + for i := len(wd.hooks) - 1; i >= 0; i-- { + if wd.hooks[i] == nil { + return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = wd.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, wd.mutation); err != nil { + return 0, err + } + } + return affected, err +} + +// 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.DeleteSpec{ + Node: &sqlgraph.NodeSpec{ + Table: weapon.Table, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weapon.FieldID, + }, + }, + } + if ps := wd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return sqlgraph.DeleteNodes(ctx, wd.driver, _spec) +} + +// WeaponDeleteOne is the builder for deleting a single Weapon entity. +type WeaponDeleteOne struct { + wd *WeaponDelete +} + +// 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) { + wdo.wd.ExecX(ctx) +} diff --git a/ent/weapon_query.go b/ent/weapon_query.go new file mode 100644 index 0000000..8783d19 --- /dev/null +++ b/ent/weapon_query.go @@ -0,0 +1,1016 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "csgowtfd/ent/matchplayer" + "csgowtfd/ent/predicate" + "csgowtfd/ent/weapon" + "errors" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WeaponQuery is the builder for querying Weapon entities. +type WeaponQuery struct { + config + limit *int + offset *int + unique *bool + order []OrderFunc + fields []string + predicates []predicate.Weapon + // eager-loading edges. + withStat *MatchPlayerQuery + withFKs bool + modifiers []func(s *sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the WeaponQuery builder. +func (wq *WeaponQuery) Where(ps ...predicate.Weapon) *WeaponQuery { + wq.predicates = append(wq.predicates, ps...) + return wq +} + +// Limit adds a limit step to the query. +func (wq *WeaponQuery) Limit(limit int) *WeaponQuery { + wq.limit = &limit + return wq +} + +// Offset adds an offset step to the query. +func (wq *WeaponQuery) Offset(offset int) *WeaponQuery { + wq.offset = &offset + return wq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (wq *WeaponQuery) Unique(unique bool) *WeaponQuery { + wq.unique = &unique + return wq +} + +// Order adds an order step to the query. +func (wq *WeaponQuery) Order(o ...OrderFunc) *WeaponQuery { + wq.order = append(wq.order, o...) + return wq +} + +// QueryStat chains the current query on the "stat" edge. +func (wq *WeaponQuery) QueryStat() *MatchPlayerQuery { + query := &MatchPlayerQuery{config: wq.config} + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := wq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := wq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(weapon.Table, weapon.FieldID, selector), + sqlgraph.To(matchplayer.Table, matchplayer.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, weapon.StatTable, weapon.StatColumn), + ) + fromU = sqlgraph.SetNeighbors(wq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Weapon entity from the query. +// Returns a *NotFoundError when no Weapon was found. +func (wq *WeaponQuery) First(ctx context.Context) (*Weapon, error) { + nodes, err := wq.Limit(1).All(ctx) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{weapon.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (wq *WeaponQuery) FirstX(ctx context.Context) *Weapon { + node, err := wq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Weapon ID from the query. +// Returns a *NotFoundError when no Weapon ID was found. +func (wq *WeaponQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = wq.Limit(1).IDs(ctx); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{weapon.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (wq *WeaponQuery) FirstIDX(ctx context.Context) int { + id, err := wq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Weapon entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when exactly one Weapon entity is not found. +// Returns a *NotFoundError when no Weapon entities are found. +func (wq *WeaponQuery) Only(ctx context.Context) (*Weapon, error) { + nodes, err := wq.Limit(2).All(ctx) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{weapon.Label} + default: + return nil, &NotSingularError{weapon.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (wq *WeaponQuery) OnlyX(ctx context.Context) *Weapon { + node, err := wq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Weapon ID in the query. +// Returns a *NotSingularError when exactly one Weapon ID is not found. +// Returns a *NotFoundError when no entities are found. +func (wq *WeaponQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = wq.Limit(2).IDs(ctx); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{weapon.Label} + default: + err = &NotSingularError{weapon.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (wq *WeaponQuery) OnlyIDX(ctx context.Context) int { + id, err := wq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Weapons. +func (wq *WeaponQuery) All(ctx context.Context) ([]*Weapon, error) { + if err := wq.prepareQuery(ctx); err != nil { + return nil, err + } + return wq.sqlAll(ctx) +} + +// AllX is like All, but panics if an error occurs. +func (wq *WeaponQuery) AllX(ctx context.Context) []*Weapon { + nodes, err := wq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Weapon IDs. +func (wq *WeaponQuery) IDs(ctx context.Context) ([]int, error) { + var ids []int + if err := wq.Select(weapon.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (wq *WeaponQuery) IDsX(ctx context.Context) []int { + ids, err := wq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (wq *WeaponQuery) Count(ctx context.Context) (int, error) { + if err := wq.prepareQuery(ctx); err != nil { + return 0, err + } + return wq.sqlCount(ctx) +} + +// CountX is like Count, but panics if an error occurs. +func (wq *WeaponQuery) CountX(ctx context.Context) int { + count, err := wq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (wq *WeaponQuery) Exist(ctx context.Context) (bool, error) { + if err := wq.prepareQuery(ctx); err != nil { + return false, err + } + return wq.sqlExist(ctx) +} + +// ExistX is like Exist, but panics if an error occurs. +func (wq *WeaponQuery) ExistX(ctx context.Context) bool { + exist, err := wq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the WeaponQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (wq *WeaponQuery) Clone() *WeaponQuery { + if wq == nil { + return nil + } + return &WeaponQuery{ + config: wq.config, + limit: wq.limit, + offset: wq.offset, + order: append([]OrderFunc{}, wq.order...), + predicates: append([]predicate.Weapon{}, wq.predicates...), + withStat: wq.withStat.Clone(), + // clone intermediate query. + sql: wq.sql.Clone(), + path: wq.path, + } +} + +// WithStat tells the query-builder to eager-load the nodes that are connected to +// the "stat" edge. The optional arguments are used to configure the query builder of the edge. +func (wq *WeaponQuery) WithStat(opts ...func(*MatchPlayerQuery)) *WeaponQuery { + query := &MatchPlayerQuery{config: wq.config} + for _, opt := range opts { + opt(query) + } + wq.withStat = query + return wq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Victim uint64 `json:"victim,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Weapon.Query(). +// GroupBy(weapon.FieldVictim). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +// +func (wq *WeaponQuery) GroupBy(field string, fields ...string) *WeaponGroupBy { + group := &WeaponGroupBy{config: wq.config} + group.fields = append([]string{field}, fields...) + group.path = func(ctx context.Context) (prev *sql.Selector, err error) { + if err := wq.prepareQuery(ctx); err != nil { + return nil, err + } + return wq.sqlQuery(ctx), nil + } + return group +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Victim uint64 `json:"victim,omitempty"` +// } +// +// client.Weapon.Query(). +// Select(weapon.FieldVictim). +// Scan(ctx, &v) +// +func (wq *WeaponQuery) Select(fields ...string) *WeaponSelect { + wq.fields = append(wq.fields, fields...) + return &WeaponSelect{WeaponQuery: wq} +} + +func (wq *WeaponQuery) prepareQuery(ctx context.Context) error { + for _, f := range wq.fields { + if !weapon.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if wq.path != nil { + prev, err := wq.path(ctx) + if err != nil { + return err + } + wq.sql = prev + } + return nil +} + +func (wq *WeaponQuery) sqlAll(ctx context.Context) ([]*Weapon, error) { + var ( + nodes = []*Weapon{} + withFKs = wq.withFKs + _spec = wq.querySpec() + loadedTypes = [1]bool{ + wq.withStat != nil, + } + ) + if wq.withStat != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, weapon.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]interface{}, error) { + node := &Weapon{config: wq.config} + nodes = append(nodes, node) + return node.scanValues(columns) + } + _spec.Assign = func(columns []string, values []interface{}) error { + if len(nodes) == 0 { + return fmt.Errorf("ent: Assign called without calling ScanValues") + } + node := nodes[len(nodes)-1] + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(wq.modifiers) > 0 { + _spec.Modifiers = wq.modifiers + } + if err := sqlgraph.QueryNodes(ctx, wq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + + if query := wq.withStat; query != nil { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*Weapon) + for i := range nodes { + if nodes[i].match_player_weapon_stats == nil { + continue + } + fk := *nodes[i].match_player_weapon_stats + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + query.Where(matchplayer.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return nil, err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return nil, fmt.Errorf(`unexpected foreign-key "match_player_weapon_stats" returned %v`, n.ID) + } + for i := range nodes { + nodes[i].Edges.Stat = n + } + } + } + + return nodes, nil +} + +func (wq *WeaponQuery) sqlCount(ctx context.Context) (int, error) { + _spec := wq.querySpec() + if len(wq.modifiers) > 0 { + _spec.Modifiers = wq.modifiers + } + return sqlgraph.CountNodes(ctx, wq.driver, _spec) +} + +func (wq *WeaponQuery) sqlExist(ctx context.Context) (bool, error) { + n, err := wq.sqlCount(ctx) + if err != nil { + return false, fmt.Errorf("ent: check existence: %w", err) + } + return n > 0, nil +} + +func (wq *WeaponQuery) querySpec() *sqlgraph.QuerySpec { + _spec := &sqlgraph.QuerySpec{ + Node: &sqlgraph.NodeSpec{ + Table: weapon.Table, + Columns: weapon.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weapon.FieldID, + }, + }, + From: wq.sql, + Unique: true, + } + if unique := wq.unique; unique != nil { + _spec.Unique = *unique + } + if fields := wq.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, weapon.FieldID) + for i := range fields { + if fields[i] != weapon.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := wq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := wq.limit; limit != nil { + _spec.Limit = *limit + } + if offset := wq.offset; offset != nil { + _spec.Offset = *offset + } + if ps := wq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (wq *WeaponQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(wq.driver.Dialect()) + t1 := builder.Table(weapon.Table) + columns := wq.fields + if len(columns) == 0 { + columns = weapon.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if wq.sql != nil { + selector = wq.sql + selector.Select(selector.Columns(columns...)...) + } + for _, m := range wq.modifiers { + m(selector) + } + for _, p := range wq.predicates { + p(selector) + } + for _, p := range wq.order { + p(selector) + } + if offset := wq.offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := wq.limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (wq *WeaponQuery) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect { + wq.modifiers = append(wq.modifiers, modifiers...) + return wq.Select() +} + +// WeaponGroupBy is the group-by builder for Weapon entities. +type WeaponGroupBy struct { + config + fields []string + fns []AggregateFunc + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (wgb *WeaponGroupBy) Aggregate(fns ...AggregateFunc) *WeaponGroupBy { + wgb.fns = append(wgb.fns, fns...) + return wgb +} + +// Scan applies the group-by query and scans the result into the given value. +func (wgb *WeaponGroupBy) Scan(ctx context.Context, v interface{}) error { + query, err := wgb.path(ctx) + if err != nil { + return err + } + wgb.sql = query + return wgb.sqlScan(ctx, v) +} + +// ScanX is like Scan, but panics if an error occurs. +func (wgb *WeaponGroupBy) ScanX(ctx context.Context, v interface{}) { + if err := wgb.Scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from group-by. +// It is only allowed when executing a group-by query with one field. +func (wgb *WeaponGroupBy) Strings(ctx context.Context) ([]string, error) { + if len(wgb.fields) > 1 { + return nil, errors.New("ent: WeaponGroupBy.Strings is not achievable when grouping more than 1 field") + } + var v []string + if err := wgb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (wgb *WeaponGroupBy) StringsX(ctx context.Context) []string { + v, err := wgb.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (wgb *WeaponGroupBy) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = wgb.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{weapon.Label} + default: + err = fmt.Errorf("ent: WeaponGroupBy.Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (wgb *WeaponGroupBy) StringX(ctx context.Context) string { + v, err := wgb.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from group-by. +// It is only allowed when executing a group-by query with one field. +func (wgb *WeaponGroupBy) Ints(ctx context.Context) ([]int, error) { + if len(wgb.fields) > 1 { + return nil, errors.New("ent: WeaponGroupBy.Ints is not achievable when grouping more than 1 field") + } + var v []int + if err := wgb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (wgb *WeaponGroupBy) IntsX(ctx context.Context) []int { + v, err := wgb.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (wgb *WeaponGroupBy) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = wgb.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{weapon.Label} + default: + err = fmt.Errorf("ent: WeaponGroupBy.Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (wgb *WeaponGroupBy) IntX(ctx context.Context) int { + v, err := wgb.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from group-by. +// It is only allowed when executing a group-by query with one field. +func (wgb *WeaponGroupBy) Float64s(ctx context.Context) ([]float64, error) { + if len(wgb.fields) > 1 { + return nil, errors.New("ent: WeaponGroupBy.Float64s is not achievable when grouping more than 1 field") + } + var v []float64 + if err := wgb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (wgb *WeaponGroupBy) Float64sX(ctx context.Context) []float64 { + v, err := wgb.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (wgb *WeaponGroupBy) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = wgb.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{weapon.Label} + default: + err = fmt.Errorf("ent: WeaponGroupBy.Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (wgb *WeaponGroupBy) Float64X(ctx context.Context) float64 { + v, err := wgb.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from group-by. +// It is only allowed when executing a group-by query with one field. +func (wgb *WeaponGroupBy) Bools(ctx context.Context) ([]bool, error) { + if len(wgb.fields) > 1 { + return nil, errors.New("ent: WeaponGroupBy.Bools is not achievable when grouping more than 1 field") + } + var v []bool + if err := wgb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (wgb *WeaponGroupBy) BoolsX(ctx context.Context) []bool { + v, err := wgb.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (wgb *WeaponGroupBy) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = wgb.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{weapon.Label} + default: + err = fmt.Errorf("ent: WeaponGroupBy.Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (wgb *WeaponGroupBy) BoolX(ctx context.Context) bool { + v, err := wgb.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +func (wgb *WeaponGroupBy) sqlScan(ctx context.Context, v interface{}) error { + for _, f := range wgb.fields { + if !weapon.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} + } + } + selector := wgb.sqlQuery() + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := wgb.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +func (wgb *WeaponGroupBy) sqlQuery() *sql.Selector { + selector := wgb.sql.Select() + aggregation := make([]string, 0, len(wgb.fns)) + for _, fn := range wgb.fns { + aggregation = append(aggregation, fn(selector)) + } + // If no columns were selected in a custom aggregation function, the default + // selection is the fields used for "group-by", and the aggregation functions. + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(wgb.fields)+len(wgb.fns)) + for _, f := range wgb.fields { + columns = append(columns, selector.C(f)) + } + for _, c := range aggregation { + columns = append(columns, c) + } + selector.Select(columns...) + } + return selector.GroupBy(selector.Columns(wgb.fields...)...) +} + +// WeaponSelect is the builder for selecting fields of Weapon entities. +type WeaponSelect struct { + *WeaponQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector +} + +// Scan applies the selector query and scans the result into the given value. +func (ws *WeaponSelect) Scan(ctx context.Context, v interface{}) error { + if err := ws.prepareQuery(ctx); err != nil { + return err + } + ws.sql = ws.WeaponQuery.sqlQuery(ctx) + return ws.sqlScan(ctx, v) +} + +// ScanX is like Scan, but panics if an error occurs. +func (ws *WeaponSelect) ScanX(ctx context.Context, v interface{}) { + if err := ws.Scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from a selector. It is only allowed when selecting one field. +func (ws *WeaponSelect) Strings(ctx context.Context) ([]string, error) { + if len(ws.fields) > 1 { + return nil, errors.New("ent: WeaponSelect.Strings is not achievable when selecting more than 1 field") + } + var v []string + if err := ws.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (ws *WeaponSelect) StringsX(ctx context.Context) []string { + v, err := ws.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a selector. It is only allowed when selecting one field. +func (ws *WeaponSelect) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = ws.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{weapon.Label} + default: + err = fmt.Errorf("ent: WeaponSelect.Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (ws *WeaponSelect) StringX(ctx context.Context) string { + v, err := ws.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from a selector. It is only allowed when selecting one field. +func (ws *WeaponSelect) Ints(ctx context.Context) ([]int, error) { + if len(ws.fields) > 1 { + return nil, errors.New("ent: WeaponSelect.Ints is not achievable when selecting more than 1 field") + } + var v []int + if err := ws.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (ws *WeaponSelect) IntsX(ctx context.Context) []int { + v, err := ws.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a selector. It is only allowed when selecting one field. +func (ws *WeaponSelect) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = ws.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{weapon.Label} + default: + err = fmt.Errorf("ent: WeaponSelect.Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (ws *WeaponSelect) IntX(ctx context.Context) int { + v, err := ws.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. +func (ws *WeaponSelect) Float64s(ctx context.Context) ([]float64, error) { + if len(ws.fields) > 1 { + return nil, errors.New("ent: WeaponSelect.Float64s is not achievable when selecting more than 1 field") + } + var v []float64 + if err := ws.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (ws *WeaponSelect) Float64sX(ctx context.Context) []float64 { + v, err := ws.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. +func (ws *WeaponSelect) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = ws.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{weapon.Label} + default: + err = fmt.Errorf("ent: WeaponSelect.Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (ws *WeaponSelect) Float64X(ctx context.Context) float64 { + v, err := ws.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from a selector. It is only allowed when selecting one field. +func (ws *WeaponSelect) Bools(ctx context.Context) ([]bool, error) { + if len(ws.fields) > 1 { + return nil, errors.New("ent: WeaponSelect.Bools is not achievable when selecting more than 1 field") + } + var v []bool + if err := ws.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (ws *WeaponSelect) BoolsX(ctx context.Context) []bool { + v, err := ws.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a selector. It is only allowed when selecting one field. +func (ws *WeaponSelect) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = ws.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{weapon.Label} + default: + err = fmt.Errorf("ent: WeaponSelect.Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (ws *WeaponSelect) BoolX(ctx context.Context) bool { + v, err := ws.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +func (ws *WeaponSelect) sqlScan(ctx context.Context, v interface{}) error { + rows := &sql.Rows{} + query, args := ws.sql.Query() + if err := ws.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (ws *WeaponSelect) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect { + ws.modifiers = append(ws.modifiers, modifiers...) + return ws +} diff --git a/ent/weapon_update.go b/ent/weapon_update.go new file mode 100644 index 0000000..1d9cd25 --- /dev/null +++ b/ent/weapon_update.go @@ -0,0 +1,575 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "csgowtfd/ent/matchplayer" + "csgowtfd/ent/predicate" + "csgowtfd/ent/weapon" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WeaponUpdate is the builder for updating Weapon entities. +type WeaponUpdate struct { + config + hooks []Hook + mutation *WeaponMutation +} + +// Where appends a list predicates to the WeaponUpdate builder. +func (wu *WeaponUpdate) Where(ps ...predicate.Weapon) *WeaponUpdate { + wu.mutation.Where(ps...) + return wu +} + +// SetVictim sets the "victim" field. +func (wu *WeaponUpdate) SetVictim(u uint64) *WeaponUpdate { + wu.mutation.ResetVictim() + wu.mutation.SetVictim(u) + return wu +} + +// AddVictim adds u to the "victim" field. +func (wu *WeaponUpdate) AddVictim(u uint64) *WeaponUpdate { + wu.mutation.AddVictim(u) + return wu +} + +// SetDmg sets the "dmg" field. +func (wu *WeaponUpdate) SetDmg(u uint) *WeaponUpdate { + wu.mutation.ResetDmg() + wu.mutation.SetDmg(u) + return wu +} + +// AddDmg adds u to the "dmg" field. +func (wu *WeaponUpdate) AddDmg(u uint) *WeaponUpdate { + wu.mutation.AddDmg(u) + return wu +} + +// SetEqType sets the "eq_type" field. +func (wu *WeaponUpdate) SetEqType(i int) *WeaponUpdate { + wu.mutation.ResetEqType() + wu.mutation.SetEqType(i) + return wu +} + +// AddEqType adds i to the "eq_type" field. +func (wu *WeaponUpdate) AddEqType(i int) *WeaponUpdate { + wu.mutation.AddEqType(i) + return wu +} + +// SetHitGroup sets the "hit_group" field. +func (wu *WeaponUpdate) SetHitGroup(i int) *WeaponUpdate { + wu.mutation.ResetHitGroup() + wu.mutation.SetHitGroup(i) + return wu +} + +// AddHitGroup adds i to the "hit_group" field. +func (wu *WeaponUpdate) AddHitGroup(i int) *WeaponUpdate { + wu.mutation.AddHitGroup(i) + return wu +} + +// SetStatID sets the "stat" edge to the MatchPlayer entity by ID. +func (wu *WeaponUpdate) SetStatID(id int) *WeaponUpdate { + wu.mutation.SetStatID(id) + return wu +} + +// SetNillableStatID sets the "stat" edge to the MatchPlayer entity by ID if the given value is not nil. +func (wu *WeaponUpdate) SetNillableStatID(id *int) *WeaponUpdate { + if id != nil { + wu = wu.SetStatID(*id) + } + return wu +} + +// SetStat sets the "stat" edge to the MatchPlayer entity. +func (wu *WeaponUpdate) SetStat(m *MatchPlayer) *WeaponUpdate { + return wu.SetStatID(m.ID) +} + +// Mutation returns the WeaponMutation object of the builder. +func (wu *WeaponUpdate) Mutation() *WeaponMutation { + return wu.mutation +} + +// ClearStat clears the "stat" edge to the MatchPlayer entity. +func (wu *WeaponUpdate) ClearStat() *WeaponUpdate { + wu.mutation.ClearStat() + return wu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (wu *WeaponUpdate) Save(ctx context.Context) (int, error) { + var ( + err error + affected int + ) + if len(wu.hooks) == 0 { + affected, err = wu.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WeaponMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + wu.mutation = mutation + affected, err = wu.sqlSave(ctx) + mutation.done = true + return affected, err + }) + for i := len(wu.hooks) - 1; i >= 0; i-- { + if wu.hooks[i] == nil { + return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = wu.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, wu.mutation); err != nil { + return 0, err + } + } + return affected, err +} + +// SaveX is like Save, but panics if an error occurs. +func (wu *WeaponUpdate) SaveX(ctx context.Context) int { + affected, err := wu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (wu *WeaponUpdate) Exec(ctx context.Context) error { + _, err := wu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wu *WeaponUpdate) ExecX(ctx context.Context) { + if err := wu.Exec(ctx); err != nil { + panic(err) + } +} + +func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: weapon.Table, + Columns: weapon.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weapon.FieldID, + }, + }, + } + if ps := wu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := wu.mutation.Victim(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: value, + Column: weapon.FieldVictim, + }) + } + if value, ok := wu.mutation.AddedVictim(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: value, + Column: weapon.FieldVictim, + }) + } + if value, ok := wu.mutation.Dmg(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: weapon.FieldDmg, + }) + } + if value, ok := wu.mutation.AddedDmg(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: weapon.FieldDmg, + }) + } + if value, ok := wu.mutation.EqType(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weapon.FieldEqType, + }) + } + if value, ok := wu.mutation.AddedEqType(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weapon.FieldEqType, + }) + } + if value, ok := wu.mutation.HitGroup(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weapon.FieldHitGroup, + }) + } + if value, ok := wu.mutation.AddedHitGroup(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weapon.FieldHitGroup, + }) + } + if wu.mutation.StatCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: weapon.StatTable, + Columns: []string{weapon.StatColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := wu.mutation.StatIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: weapon.StatTable, + Columns: []string{weapon.StatColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.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, wu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{weapon.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} + } + return 0, err + } + return n, nil +} + +// WeaponUpdateOne is the builder for updating a single Weapon entity. +type WeaponUpdateOne struct { + config + fields []string + hooks []Hook + mutation *WeaponMutation +} + +// SetVictim sets the "victim" field. +func (wuo *WeaponUpdateOne) SetVictim(u uint64) *WeaponUpdateOne { + wuo.mutation.ResetVictim() + wuo.mutation.SetVictim(u) + return wuo +} + +// AddVictim adds u to the "victim" field. +func (wuo *WeaponUpdateOne) AddVictim(u uint64) *WeaponUpdateOne { + wuo.mutation.AddVictim(u) + return wuo +} + +// SetDmg sets the "dmg" field. +func (wuo *WeaponUpdateOne) SetDmg(u uint) *WeaponUpdateOne { + wuo.mutation.ResetDmg() + wuo.mutation.SetDmg(u) + return wuo +} + +// AddDmg adds u to the "dmg" field. +func (wuo *WeaponUpdateOne) AddDmg(u uint) *WeaponUpdateOne { + wuo.mutation.AddDmg(u) + return wuo +} + +// SetEqType sets the "eq_type" field. +func (wuo *WeaponUpdateOne) SetEqType(i int) *WeaponUpdateOne { + wuo.mutation.ResetEqType() + wuo.mutation.SetEqType(i) + return wuo +} + +// AddEqType adds i to the "eq_type" field. +func (wuo *WeaponUpdateOne) AddEqType(i int) *WeaponUpdateOne { + wuo.mutation.AddEqType(i) + return wuo +} + +// SetHitGroup sets the "hit_group" field. +func (wuo *WeaponUpdateOne) SetHitGroup(i int) *WeaponUpdateOne { + wuo.mutation.ResetHitGroup() + wuo.mutation.SetHitGroup(i) + return wuo +} + +// AddHitGroup adds i to the "hit_group" field. +func (wuo *WeaponUpdateOne) AddHitGroup(i int) *WeaponUpdateOne { + wuo.mutation.AddHitGroup(i) + return wuo +} + +// SetStatID sets the "stat" edge to the MatchPlayer entity by ID. +func (wuo *WeaponUpdateOne) SetStatID(id int) *WeaponUpdateOne { + wuo.mutation.SetStatID(id) + return wuo +} + +// SetNillableStatID sets the "stat" edge to the MatchPlayer entity by ID if the given value is not nil. +func (wuo *WeaponUpdateOne) SetNillableStatID(id *int) *WeaponUpdateOne { + if id != nil { + wuo = wuo.SetStatID(*id) + } + return wuo +} + +// SetStat sets the "stat" edge to the MatchPlayer entity. +func (wuo *WeaponUpdateOne) SetStat(m *MatchPlayer) *WeaponUpdateOne { + return wuo.SetStatID(m.ID) +} + +// Mutation returns the WeaponMutation object of the builder. +func (wuo *WeaponUpdateOne) Mutation() *WeaponMutation { + return wuo.mutation +} + +// ClearStat clears the "stat" edge to the MatchPlayer entity. +func (wuo *WeaponUpdateOne) ClearStat() *WeaponUpdateOne { + wuo.mutation.ClearStat() + return wuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (wuo *WeaponUpdateOne) Select(field string, fields ...string) *WeaponUpdateOne { + wuo.fields = append([]string{field}, fields...) + return wuo +} + +// Save executes the query and returns the updated Weapon entity. +func (wuo *WeaponUpdateOne) Save(ctx context.Context) (*Weapon, error) { + var ( + err error + node *Weapon + ) + if len(wuo.hooks) == 0 { + node, err = wuo.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WeaponMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + wuo.mutation = mutation + node, err = wuo.sqlSave(ctx) + mutation.done = true + return node, err + }) + for i := len(wuo.hooks) - 1; i >= 0; i-- { + if wuo.hooks[i] == nil { + return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = wuo.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, wuo.mutation); err != nil { + return nil, err + } + } + return node, err +} + +// SaveX is like Save, but panics if an error occurs. +func (wuo *WeaponUpdateOne) SaveX(ctx context.Context) *Weapon { + node, err := wuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (wuo *WeaponUpdateOne) Exec(ctx context.Context) error { + _, err := wuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wuo *WeaponUpdateOne) ExecX(ctx context.Context) { + if err := wuo.Exec(ctx); err != nil { + panic(err) + } +} + +func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: weapon.Table, + Columns: weapon.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weapon.FieldID, + }, + }, + } + id, ok := wuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Weapon.ID for update")} + } + _spec.Node.ID.Value = id + if fields := wuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, weapon.FieldID) + for _, f := range fields { + if !weapon.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != weapon.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := wuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := wuo.mutation.Victim(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: value, + Column: weapon.FieldVictim, + }) + } + if value, ok := wuo.mutation.AddedVictim(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: value, + Column: weapon.FieldVictim, + }) + } + if value, ok := wuo.mutation.Dmg(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: weapon.FieldDmg, + }) + } + if value, ok := wuo.mutation.AddedDmg(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: weapon.FieldDmg, + }) + } + if value, ok := wuo.mutation.EqType(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weapon.FieldEqType, + }) + } + if value, ok := wuo.mutation.AddedEqType(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weapon.FieldEqType, + }) + } + if value, ok := wuo.mutation.HitGroup(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weapon.FieldHitGroup, + }) + } + if value, ok := wuo.mutation.AddedHitGroup(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weapon.FieldHitGroup, + }) + } + if wuo.mutation.StatCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: weapon.StatTable, + Columns: []string{weapon.StatColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := wuo.mutation.StatIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: weapon.StatTable, + Columns: []string{weapon.StatColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: matchplayer.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Weapon{config: wuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, wuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{weapon.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} + } + return nil, err + } + return _node, nil +} diff --git a/ent/weaponstats_create.go b/ent/weaponstats_create.go deleted file mode 100644 index 2169b2d..0000000 --- a/ent/weaponstats_create.go +++ /dev/null @@ -1,311 +0,0 @@ -// Code generated by entc, DO NOT EDIT. - -package ent - -import ( - "context" - "csgowtfd/ent/stats" - "csgowtfd/ent/weaponstats" - "errors" - "fmt" - - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// WeaponStatsCreate is the builder for creating a WeaponStats entity. -type WeaponStatsCreate struct { - config - mutation *WeaponStatsMutation - hooks []Hook -} - -// SetVictim sets the "victim" field. -func (wsc *WeaponStatsCreate) SetVictim(u uint64) *WeaponStatsCreate { - wsc.mutation.SetVictim(u) - return wsc -} - -// SetDmg sets the "dmg" field. -func (wsc *WeaponStatsCreate) SetDmg(u uint) *WeaponStatsCreate { - wsc.mutation.SetDmg(u) - return wsc -} - -// SetEqType sets the "eq_type" field. -func (wsc *WeaponStatsCreate) SetEqType(i int) *WeaponStatsCreate { - wsc.mutation.SetEqType(i) - return wsc -} - -// SetHitGroup sets the "hit_group" field. -func (wsc *WeaponStatsCreate) SetHitGroup(i int) *WeaponStatsCreate { - wsc.mutation.SetHitGroup(i) - return wsc -} - -// SetStatID sets the "stat" edge to the Stats entity by ID. -func (wsc *WeaponStatsCreate) SetStatID(id int) *WeaponStatsCreate { - wsc.mutation.SetStatID(id) - return wsc -} - -// SetNillableStatID sets the "stat" edge to the Stats entity by ID if the given value is not nil. -func (wsc *WeaponStatsCreate) SetNillableStatID(id *int) *WeaponStatsCreate { - if id != nil { - wsc = wsc.SetStatID(*id) - } - return wsc -} - -// SetStat sets the "stat" edge to the Stats entity. -func (wsc *WeaponStatsCreate) SetStat(s *Stats) *WeaponStatsCreate { - return wsc.SetStatID(s.ID) -} - -// Mutation returns the WeaponStatsMutation object of the builder. -func (wsc *WeaponStatsCreate) Mutation() *WeaponStatsMutation { - return wsc.mutation -} - -// Save creates the WeaponStats in the database. -func (wsc *WeaponStatsCreate) Save(ctx context.Context) (*WeaponStats, error) { - var ( - err error - node *WeaponStats - ) - if len(wsc.hooks) == 0 { - if err = wsc.check(); err != nil { - return nil, err - } - node, err = wsc.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) - } - if err = wsc.check(); err != nil { - return nil, err - } - wsc.mutation = mutation - if node, err = wsc.sqlSave(ctx); err != nil { - return nil, err - } - mutation.id = &node.ID - mutation.done = true - return node, err - }) - for i := len(wsc.hooks) - 1; i >= 0; i-- { - if wsc.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = wsc.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, wsc.mutation); err != nil { - return nil, err - } - } - return node, err -} - -// SaveX calls Save and panics if Save returns an error. -func (wsc *WeaponStatsCreate) SaveX(ctx context.Context) *WeaponStats { - v, err := wsc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (wsc *WeaponStatsCreate) Exec(ctx context.Context) error { - _, err := wsc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (wsc *WeaponStatsCreate) ExecX(ctx context.Context) { - if err := wsc.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (wsc *WeaponStatsCreate) check() error { - if _, ok := wsc.mutation.Victim(); !ok { - return &ValidationError{Name: "victim", err: errors.New(`ent: missing required field "victim"`)} - } - if _, ok := wsc.mutation.Dmg(); !ok { - return &ValidationError{Name: "dmg", err: errors.New(`ent: missing required field "dmg"`)} - } - if _, ok := wsc.mutation.EqType(); !ok { - return &ValidationError{Name: "eq_type", err: errors.New(`ent: missing required field "eq_type"`)} - } - if _, ok := wsc.mutation.HitGroup(); !ok { - return &ValidationError{Name: "hit_group", err: errors.New(`ent: missing required field "hit_group"`)} - } - return nil -} - -func (wsc *WeaponStatsCreate) sqlSave(ctx context.Context) (*WeaponStats, error) { - _node, _spec := wsc.createSpec() - if err := sqlgraph.CreateNode(ctx, wsc.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{err.Error(), err} - } - return nil, err - } - id := _spec.ID.Value.(int64) - _node.ID = int(id) - return _node, nil -} - -func (wsc *WeaponStatsCreate) createSpec() (*WeaponStats, *sqlgraph.CreateSpec) { - var ( - _node = &WeaponStats{config: wsc.config} - _spec = &sqlgraph.CreateSpec{ - Table: weaponstats.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: weaponstats.FieldID, - }, - } - ) - if value, ok := wsc.mutation.Victim(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeUint64, - Value: value, - Column: weaponstats.FieldVictim, - }) - _node.Victim = value - } - if value, ok := wsc.mutation.Dmg(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeUint, - Value: value, - Column: weaponstats.FieldDmg, - }) - _node.Dmg = value - } - if value, ok := wsc.mutation.EqType(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: weaponstats.FieldEqType, - }) - _node.EqType = value - } - if value, ok := wsc.mutation.HitGroup(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: weaponstats.FieldHitGroup, - }) - _node.HitGroup = value - } - if nodes := wsc.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) - } - _node.stats_weapon_stats = &nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// WeaponStatsCreateBulk is the builder for creating many WeaponStats entities in bulk. -type WeaponStatsCreateBulk struct { - config - builders []*WeaponStatsCreate -} - -// Save creates the WeaponStats entities in the database. -func (wscb *WeaponStatsCreateBulk) Save(ctx context.Context) ([]*WeaponStats, error) { - specs := make([]*sqlgraph.CreateSpec, len(wscb.builders)) - nodes := make([]*WeaponStats, len(wscb.builders)) - mutators := make([]Mutator, len(wscb.builders)) - for i := range wscb.builders { - func(i int, root context.Context) { - builder := wscb.builders[i] - 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) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - nodes[i], specs[i] = builder.createSpec() - var err error - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, wscb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, wscb.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{err.Error(), err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - mutation.done = true - if specs[i].ID.Value != nil { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int(id) - } - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, wscb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (wscb *WeaponStatsCreateBulk) SaveX(ctx context.Context) []*WeaponStats { - v, err := wscb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (wscb *WeaponStatsCreateBulk) Exec(ctx context.Context) error { - _, err := wscb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (wscb *WeaponStatsCreateBulk) ExecX(ctx context.Context) { - if err := wscb.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/ent/weaponstats_delete.go b/ent/weaponstats_delete.go deleted file mode 100644 index 3e31fbc..0000000 --- a/ent/weaponstats_delete.go +++ /dev/null @@ -1,111 +0,0 @@ -// 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) -} diff --git a/ent/weaponstats_query.go b/ent/weaponstats_query.go deleted file mode 100644 index 1951478..0000000 --- a/ent/weaponstats_query.go +++ /dev/null @@ -1,1016 +0,0 @@ -// Code generated by entc, DO NOT EDIT. - -package ent - -import ( - "context" - "csgowtfd/ent/predicate" - "csgowtfd/ent/stats" - "csgowtfd/ent/weaponstats" - "errors" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// WeaponStatsQuery is the builder for querying WeaponStats entities. -type WeaponStatsQuery struct { - config - limit *int - offset *int - unique *bool - order []OrderFunc - fields []string - predicates []predicate.WeaponStats - // eager-loading edges. - withStat *StatsQuery - withFKs bool - modifiers []func(s *sql.Selector) - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the WeaponStatsQuery builder. -func (wsq *WeaponStatsQuery) Where(ps ...predicate.WeaponStats) *WeaponStatsQuery { - wsq.predicates = append(wsq.predicates, ps...) - return wsq -} - -// Limit adds a limit step to the query. -func (wsq *WeaponStatsQuery) Limit(limit int) *WeaponStatsQuery { - wsq.limit = &limit - return wsq -} - -// Offset adds an offset step to the query. -func (wsq *WeaponStatsQuery) Offset(offset int) *WeaponStatsQuery { - wsq.offset = &offset - return wsq -} - -// Unique configures the query builder to filter duplicate records on query. -// By default, unique is set to true, and can be disabled using this method. -func (wsq *WeaponStatsQuery) Unique(unique bool) *WeaponStatsQuery { - wsq.unique = &unique - return wsq -} - -// Order adds an order step to the query. -func (wsq *WeaponStatsQuery) Order(o ...OrderFunc) *WeaponStatsQuery { - wsq.order = append(wsq.order, o...) - return wsq -} - -// QueryStat chains the current query on the "stat" edge. -func (wsq *WeaponStatsQuery) QueryStat() *StatsQuery { - query := &StatsQuery{config: wsq.config} - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := wsq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := wsq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(weaponstats.Table, weaponstats.FieldID, selector), - sqlgraph.To(stats.Table, stats.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, weaponstats.StatTable, weaponstats.StatColumn), - ) - fromU = sqlgraph.SetNeighbors(wsq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first WeaponStats entity from the query. -// Returns a *NotFoundError when no WeaponStats was found. -func (wsq *WeaponStatsQuery) First(ctx context.Context) (*WeaponStats, error) { - nodes, err := wsq.Limit(1).All(ctx) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{weaponstats.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (wsq *WeaponStatsQuery) FirstX(ctx context.Context) *WeaponStats { - node, err := wsq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first WeaponStats ID from the query. -// Returns a *NotFoundError when no WeaponStats ID was found. -func (wsq *WeaponStatsQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = wsq.Limit(1).IDs(ctx); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{weaponstats.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (wsq *WeaponStatsQuery) FirstIDX(ctx context.Context) int { - id, err := wsq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single WeaponStats entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when exactly one WeaponStats entity is not found. -// Returns a *NotFoundError when no WeaponStats entities are found. -func (wsq *WeaponStatsQuery) Only(ctx context.Context) (*WeaponStats, error) { - nodes, err := wsq.Limit(2).All(ctx) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{weaponstats.Label} - default: - return nil, &NotSingularError{weaponstats.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (wsq *WeaponStatsQuery) OnlyX(ctx context.Context) *WeaponStats { - node, err := wsq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only WeaponStats ID in the query. -// Returns a *NotSingularError when exactly one WeaponStats ID is not found. -// Returns a *NotFoundError when no entities are found. -func (wsq *WeaponStatsQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = wsq.Limit(2).IDs(ctx); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{weaponstats.Label} - default: - err = &NotSingularError{weaponstats.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (wsq *WeaponStatsQuery) OnlyIDX(ctx context.Context) int { - id, err := wsq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of WeaponStatsSlice. -func (wsq *WeaponStatsQuery) All(ctx context.Context) ([]*WeaponStats, error) { - if err := wsq.prepareQuery(ctx); err != nil { - return nil, err - } - return wsq.sqlAll(ctx) -} - -// AllX is like All, but panics if an error occurs. -func (wsq *WeaponStatsQuery) AllX(ctx context.Context) []*WeaponStats { - nodes, err := wsq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of WeaponStats IDs. -func (wsq *WeaponStatsQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int - if err := wsq.Select(weaponstats.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (wsq *WeaponStatsQuery) IDsX(ctx context.Context) []int { - ids, err := wsq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (wsq *WeaponStatsQuery) Count(ctx context.Context) (int, error) { - if err := wsq.prepareQuery(ctx); err != nil { - return 0, err - } - return wsq.sqlCount(ctx) -} - -// CountX is like Count, but panics if an error occurs. -func (wsq *WeaponStatsQuery) CountX(ctx context.Context) int { - count, err := wsq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (wsq *WeaponStatsQuery) Exist(ctx context.Context) (bool, error) { - if err := wsq.prepareQuery(ctx); err != nil { - return false, err - } - return wsq.sqlExist(ctx) -} - -// ExistX is like Exist, but panics if an error occurs. -func (wsq *WeaponStatsQuery) ExistX(ctx context.Context) bool { - exist, err := wsq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the WeaponStatsQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (wsq *WeaponStatsQuery) Clone() *WeaponStatsQuery { - if wsq == nil { - return nil - } - return &WeaponStatsQuery{ - config: wsq.config, - limit: wsq.limit, - offset: wsq.offset, - order: append([]OrderFunc{}, wsq.order...), - predicates: append([]predicate.WeaponStats{}, wsq.predicates...), - withStat: wsq.withStat.Clone(), - // clone intermediate query. - sql: wsq.sql.Clone(), - path: wsq.path, - } -} - -// WithStat tells the query-builder to eager-load the nodes that are connected to -// the "stat" edge. The optional arguments are used to configure the query builder of the edge. -func (wsq *WeaponStatsQuery) WithStat(opts ...func(*StatsQuery)) *WeaponStatsQuery { - query := &StatsQuery{config: wsq.config} - for _, opt := range opts { - opt(query) - } - wsq.withStat = query - return wsq -} - -// GroupBy is used to group vertices by one or more fields/columns. -// It is often used with aggregate functions, like: count, max, mean, min, sum. -// -// Example: -// -// var v []struct { -// Victim uint64 `json:"victim,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.WeaponStats.Query(). -// GroupBy(weaponstats.FieldVictim). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -// -func (wsq *WeaponStatsQuery) GroupBy(field string, fields ...string) *WeaponStatsGroupBy { - group := &WeaponStatsGroupBy{config: wsq.config} - group.fields = append([]string{field}, fields...) - group.path = func(ctx context.Context) (prev *sql.Selector, err error) { - if err := wsq.prepareQuery(ctx); err != nil { - return nil, err - } - return wsq.sqlQuery(ctx), nil - } - return group -} - -// Select allows the selection one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// -// Example: -// -// var v []struct { -// Victim uint64 `json:"victim,omitempty"` -// } -// -// client.WeaponStats.Query(). -// Select(weaponstats.FieldVictim). -// Scan(ctx, &v) -// -func (wsq *WeaponStatsQuery) Select(fields ...string) *WeaponStatsSelect { - wsq.fields = append(wsq.fields, fields...) - return &WeaponStatsSelect{WeaponStatsQuery: wsq} -} - -func (wsq *WeaponStatsQuery) prepareQuery(ctx context.Context) error { - for _, f := range wsq.fields { - if !weaponstats.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if wsq.path != nil { - prev, err := wsq.path(ctx) - if err != nil { - return err - } - wsq.sql = prev - } - return nil -} - -func (wsq *WeaponStatsQuery) sqlAll(ctx context.Context) ([]*WeaponStats, error) { - var ( - nodes = []*WeaponStats{} - withFKs = wsq.withFKs - _spec = wsq.querySpec() - loadedTypes = [1]bool{ - wsq.withStat != nil, - } - ) - if wsq.withStat != nil { - withFKs = true - } - if withFKs { - _spec.Node.Columns = append(_spec.Node.Columns, weaponstats.ForeignKeys...) - } - _spec.ScanValues = func(columns []string) ([]interface{}, error) { - node := &WeaponStats{config: wsq.config} - nodes = append(nodes, node) - return node.scanValues(columns) - } - _spec.Assign = func(columns []string, values []interface{}) error { - if len(nodes) == 0 { - return fmt.Errorf("ent: Assign called without calling ScanValues") - } - node := nodes[len(nodes)-1] - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(wsq.modifiers) > 0 { - _spec.Modifiers = wsq.modifiers - } - if err := sqlgraph.QueryNodes(ctx, wsq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - - if query := wsq.withStat; query != nil { - ids := make([]int, 0, len(nodes)) - nodeids := make(map[int][]*WeaponStats) - for i := range nodes { - if nodes[i].stats_weapon_stats == nil { - continue - } - fk := *nodes[i].stats_weapon_stats - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - query.Where(stats.IDIn(ids...)) - neighbors, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, n := range neighbors { - nodes, ok := nodeids[n.ID] - if !ok { - return nil, fmt.Errorf(`unexpected foreign-key "stats_weapon_stats" returned %v`, n.ID) - } - for i := range nodes { - nodes[i].Edges.Stat = n - } - } - } - - return nodes, nil -} - -func (wsq *WeaponStatsQuery) sqlCount(ctx context.Context) (int, error) { - _spec := wsq.querySpec() - if len(wsq.modifiers) > 0 { - _spec.Modifiers = wsq.modifiers - } - return sqlgraph.CountNodes(ctx, wsq.driver, _spec) -} - -func (wsq *WeaponStatsQuery) sqlExist(ctx context.Context) (bool, error) { - n, err := wsq.sqlCount(ctx) - if err != nil { - return false, fmt.Errorf("ent: check existence: %w", err) - } - return n > 0, nil -} - -func (wsq *WeaponStatsQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: weaponstats.Table, - Columns: weaponstats.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: weaponstats.FieldID, - }, - }, - From: wsq.sql, - Unique: true, - } - if unique := wsq.unique; unique != nil { - _spec.Unique = *unique - } - if fields := wsq.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, weaponstats.FieldID) - for i := range fields { - if fields[i] != weaponstats.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := wsq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := wsq.limit; limit != nil { - _spec.Limit = *limit - } - if offset := wsq.offset; offset != nil { - _spec.Offset = *offset - } - if ps := wsq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (wsq *WeaponStatsQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(wsq.driver.Dialect()) - t1 := builder.Table(weaponstats.Table) - columns := wsq.fields - if len(columns) == 0 { - columns = weaponstats.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if wsq.sql != nil { - selector = wsq.sql - selector.Select(selector.Columns(columns...)...) - } - for _, m := range wsq.modifiers { - m(selector) - } - for _, p := range wsq.predicates { - p(selector) - } - for _, p := range wsq.order { - p(selector) - } - if offset := wsq.offset; offset != nil { - // limit is mandatory for offset clause. We start - // with default value, and override it below if needed. - selector.Offset(*offset).Limit(math.MaxInt32) - } - if limit := wsq.limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (wsq *WeaponStatsQuery) Modify(modifiers ...func(s *sql.Selector)) *WeaponStatsSelect { - wsq.modifiers = append(wsq.modifiers, modifiers...) - return wsq.Select() -} - -// WeaponStatsGroupBy is the group-by builder for WeaponStats entities. -type WeaponStatsGroupBy struct { - config - fields []string - fns []AggregateFunc - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (wsgb *WeaponStatsGroupBy) Aggregate(fns ...AggregateFunc) *WeaponStatsGroupBy { - wsgb.fns = append(wsgb.fns, fns...) - return wsgb -} - -// Scan applies the group-by query and scans the result into the given value. -func (wsgb *WeaponStatsGroupBy) Scan(ctx context.Context, v interface{}) error { - query, err := wsgb.path(ctx) - if err != nil { - return err - } - wsgb.sql = query - return wsgb.sqlScan(ctx, v) -} - -// ScanX is like Scan, but panics if an error occurs. -func (wsgb *WeaponStatsGroupBy) ScanX(ctx context.Context, v interface{}) { - if err := wsgb.Scan(ctx, v); err != nil { - panic(err) - } -} - -// Strings returns list of strings from group-by. -// It is only allowed when executing a group-by query with one field. -func (wsgb *WeaponStatsGroupBy) Strings(ctx context.Context) ([]string, error) { - if len(wsgb.fields) > 1 { - return nil, errors.New("ent: WeaponStatsGroupBy.Strings is not achievable when grouping more than 1 field") - } - var v []string - if err := wsgb.Scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// StringsX is like Strings, but panics if an error occurs. -func (wsgb *WeaponStatsGroupBy) StringsX(ctx context.Context) []string { - v, err := wsgb.Strings(ctx) - if err != nil { - panic(err) - } - return v -} - -// String returns a single string from a group-by query. -// It is only allowed when executing a group-by query with one field. -func (wsgb *WeaponStatsGroupBy) String(ctx context.Context) (_ string, err error) { - var v []string - if v, err = wsgb.Strings(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{weaponstats.Label} - default: - err = fmt.Errorf("ent: WeaponStatsGroupBy.Strings returned %d results when one was expected", len(v)) - } - return -} - -// StringX is like String, but panics if an error occurs. -func (wsgb *WeaponStatsGroupBy) StringX(ctx context.Context) string { - v, err := wsgb.String(ctx) - if err != nil { - panic(err) - } - return v -} - -// Ints returns list of ints from group-by. -// It is only allowed when executing a group-by query with one field. -func (wsgb *WeaponStatsGroupBy) Ints(ctx context.Context) ([]int, error) { - if len(wsgb.fields) > 1 { - return nil, errors.New("ent: WeaponStatsGroupBy.Ints is not achievable when grouping more than 1 field") - } - var v []int - if err := wsgb.Scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// IntsX is like Ints, but panics if an error occurs. -func (wsgb *WeaponStatsGroupBy) IntsX(ctx context.Context) []int { - v, err := wsgb.Ints(ctx) - if err != nil { - panic(err) - } - return v -} - -// Int returns a single int from a group-by query. -// It is only allowed when executing a group-by query with one field. -func (wsgb *WeaponStatsGroupBy) Int(ctx context.Context) (_ int, err error) { - var v []int - if v, err = wsgb.Ints(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{weaponstats.Label} - default: - err = fmt.Errorf("ent: WeaponStatsGroupBy.Ints returned %d results when one was expected", len(v)) - } - return -} - -// IntX is like Int, but panics if an error occurs. -func (wsgb *WeaponStatsGroupBy) IntX(ctx context.Context) int { - v, err := wsgb.Int(ctx) - if err != nil { - panic(err) - } - return v -} - -// Float64s returns list of float64s from group-by. -// It is only allowed when executing a group-by query with one field. -func (wsgb *WeaponStatsGroupBy) Float64s(ctx context.Context) ([]float64, error) { - if len(wsgb.fields) > 1 { - return nil, errors.New("ent: WeaponStatsGroupBy.Float64s is not achievable when grouping more than 1 field") - } - var v []float64 - if err := wsgb.Scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// Float64sX is like Float64s, but panics if an error occurs. -func (wsgb *WeaponStatsGroupBy) Float64sX(ctx context.Context) []float64 { - v, err := wsgb.Float64s(ctx) - if err != nil { - panic(err) - } - return v -} - -// Float64 returns a single float64 from a group-by query. -// It is only allowed when executing a group-by query with one field. -func (wsgb *WeaponStatsGroupBy) Float64(ctx context.Context) (_ float64, err error) { - var v []float64 - if v, err = wsgb.Float64s(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{weaponstats.Label} - default: - err = fmt.Errorf("ent: WeaponStatsGroupBy.Float64s returned %d results when one was expected", len(v)) - } - return -} - -// Float64X is like Float64, but panics if an error occurs. -func (wsgb *WeaponStatsGroupBy) Float64X(ctx context.Context) float64 { - v, err := wsgb.Float64(ctx) - if err != nil { - panic(err) - } - return v -} - -// Bools returns list of bools from group-by. -// It is only allowed when executing a group-by query with one field. -func (wsgb *WeaponStatsGroupBy) Bools(ctx context.Context) ([]bool, error) { - if len(wsgb.fields) > 1 { - return nil, errors.New("ent: WeaponStatsGroupBy.Bools is not achievable when grouping more than 1 field") - } - var v []bool - if err := wsgb.Scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// BoolsX is like Bools, but panics if an error occurs. -func (wsgb *WeaponStatsGroupBy) BoolsX(ctx context.Context) []bool { - v, err := wsgb.Bools(ctx) - if err != nil { - panic(err) - } - return v -} - -// Bool returns a single bool from a group-by query. -// It is only allowed when executing a group-by query with one field. -func (wsgb *WeaponStatsGroupBy) Bool(ctx context.Context) (_ bool, err error) { - var v []bool - if v, err = wsgb.Bools(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{weaponstats.Label} - default: - err = fmt.Errorf("ent: WeaponStatsGroupBy.Bools returned %d results when one was expected", len(v)) - } - return -} - -// BoolX is like Bool, but panics if an error occurs. -func (wsgb *WeaponStatsGroupBy) BoolX(ctx context.Context) bool { - v, err := wsgb.Bool(ctx) - if err != nil { - panic(err) - } - return v -} - -func (wsgb *WeaponStatsGroupBy) sqlScan(ctx context.Context, v interface{}) error { - for _, f := range wsgb.fields { - if !weaponstats.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} - } - } - selector := wsgb.sqlQuery() - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := wsgb.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -func (wsgb *WeaponStatsGroupBy) sqlQuery() *sql.Selector { - selector := wsgb.sql.Select() - aggregation := make([]string, 0, len(wsgb.fns)) - for _, fn := range wsgb.fns { - aggregation = append(aggregation, fn(selector)) - } - // If no columns were selected in a custom aggregation function, the default - // selection is the fields used for "group-by", and the aggregation functions. - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(wsgb.fields)+len(wsgb.fns)) - for _, f := range wsgb.fields { - columns = append(columns, selector.C(f)) - } - for _, c := range aggregation { - columns = append(columns, c) - } - selector.Select(columns...) - } - return selector.GroupBy(selector.Columns(wsgb.fields...)...) -} - -// WeaponStatsSelect is the builder for selecting fields of WeaponStats entities. -type WeaponStatsSelect struct { - *WeaponStatsQuery - // intermediate query (i.e. traversal path). - sql *sql.Selector -} - -// Scan applies the selector query and scans the result into the given value. -func (wss *WeaponStatsSelect) Scan(ctx context.Context, v interface{}) error { - if err := wss.prepareQuery(ctx); err != nil { - return err - } - wss.sql = wss.WeaponStatsQuery.sqlQuery(ctx) - return wss.sqlScan(ctx, v) -} - -// ScanX is like Scan, but panics if an error occurs. -func (wss *WeaponStatsSelect) ScanX(ctx context.Context, v interface{}) { - if err := wss.Scan(ctx, v); err != nil { - panic(err) - } -} - -// Strings returns list of strings from a selector. It is only allowed when selecting one field. -func (wss *WeaponStatsSelect) Strings(ctx context.Context) ([]string, error) { - if len(wss.fields) > 1 { - return nil, errors.New("ent: WeaponStatsSelect.Strings is not achievable when selecting more than 1 field") - } - var v []string - if err := wss.Scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// StringsX is like Strings, but panics if an error occurs. -func (wss *WeaponStatsSelect) StringsX(ctx context.Context) []string { - v, err := wss.Strings(ctx) - if err != nil { - panic(err) - } - return v -} - -// String returns a single string from a selector. It is only allowed when selecting one field. -func (wss *WeaponStatsSelect) String(ctx context.Context) (_ string, err error) { - var v []string - if v, err = wss.Strings(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{weaponstats.Label} - default: - err = fmt.Errorf("ent: WeaponStatsSelect.Strings returned %d results when one was expected", len(v)) - } - return -} - -// StringX is like String, but panics if an error occurs. -func (wss *WeaponStatsSelect) StringX(ctx context.Context) string { - v, err := wss.String(ctx) - if err != nil { - panic(err) - } - return v -} - -// Ints returns list of ints from a selector. It is only allowed when selecting one field. -func (wss *WeaponStatsSelect) Ints(ctx context.Context) ([]int, error) { - if len(wss.fields) > 1 { - return nil, errors.New("ent: WeaponStatsSelect.Ints is not achievable when selecting more than 1 field") - } - var v []int - if err := wss.Scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// IntsX is like Ints, but panics if an error occurs. -func (wss *WeaponStatsSelect) IntsX(ctx context.Context) []int { - v, err := wss.Ints(ctx) - if err != nil { - panic(err) - } - return v -} - -// Int returns a single int from a selector. It is only allowed when selecting one field. -func (wss *WeaponStatsSelect) Int(ctx context.Context) (_ int, err error) { - var v []int - if v, err = wss.Ints(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{weaponstats.Label} - default: - err = fmt.Errorf("ent: WeaponStatsSelect.Ints returned %d results when one was expected", len(v)) - } - return -} - -// IntX is like Int, but panics if an error occurs. -func (wss *WeaponStatsSelect) IntX(ctx context.Context) int { - v, err := wss.Int(ctx) - if err != nil { - panic(err) - } - return v -} - -// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. -func (wss *WeaponStatsSelect) Float64s(ctx context.Context) ([]float64, error) { - if len(wss.fields) > 1 { - return nil, errors.New("ent: WeaponStatsSelect.Float64s is not achievable when selecting more than 1 field") - } - var v []float64 - if err := wss.Scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// Float64sX is like Float64s, but panics if an error occurs. -func (wss *WeaponStatsSelect) Float64sX(ctx context.Context) []float64 { - v, err := wss.Float64s(ctx) - if err != nil { - panic(err) - } - return v -} - -// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. -func (wss *WeaponStatsSelect) Float64(ctx context.Context) (_ float64, err error) { - var v []float64 - if v, err = wss.Float64s(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{weaponstats.Label} - default: - err = fmt.Errorf("ent: WeaponStatsSelect.Float64s returned %d results when one was expected", len(v)) - } - return -} - -// Float64X is like Float64, but panics if an error occurs. -func (wss *WeaponStatsSelect) Float64X(ctx context.Context) float64 { - v, err := wss.Float64(ctx) - if err != nil { - panic(err) - } - return v -} - -// Bools returns list of bools from a selector. It is only allowed when selecting one field. -func (wss *WeaponStatsSelect) Bools(ctx context.Context) ([]bool, error) { - if len(wss.fields) > 1 { - return nil, errors.New("ent: WeaponStatsSelect.Bools is not achievable when selecting more than 1 field") - } - var v []bool - if err := wss.Scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// BoolsX is like Bools, but panics if an error occurs. -func (wss *WeaponStatsSelect) BoolsX(ctx context.Context) []bool { - v, err := wss.Bools(ctx) - if err != nil { - panic(err) - } - return v -} - -// Bool returns a single bool from a selector. It is only allowed when selecting one field. -func (wss *WeaponStatsSelect) Bool(ctx context.Context) (_ bool, err error) { - var v []bool - if v, err = wss.Bools(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{weaponstats.Label} - default: - err = fmt.Errorf("ent: WeaponStatsSelect.Bools returned %d results when one was expected", len(v)) - } - return -} - -// BoolX is like Bool, but panics if an error occurs. -func (wss *WeaponStatsSelect) BoolX(ctx context.Context) bool { - v, err := wss.Bool(ctx) - if err != nil { - panic(err) - } - return v -} - -func (wss *WeaponStatsSelect) sqlScan(ctx context.Context, v interface{}) error { - rows := &sql.Rows{} - query, args := wss.sql.Query() - if err := wss.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (wss *WeaponStatsSelect) Modify(modifiers ...func(s *sql.Selector)) *WeaponStatsSelect { - wss.modifiers = append(wss.modifiers, modifiers...) - return wss -} diff --git a/ent/weaponstats_update.go b/ent/weaponstats_update.go deleted file mode 100644 index c66933a..0000000 --- a/ent/weaponstats_update.go +++ /dev/null @@ -1,575 +0,0 @@ -// 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 -} diff --git a/go.mod b/go.mod index b211ac0..744d7c2 100644 --- a/go.mod +++ b/go.mod @@ -45,8 +45,8 @@ require ( github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect - golang.org/x/exp v0.0.0-20211025140241-8418b01e8c3b // indirect + golang.org/x/exp v0.0.0-20211029182501-9b944d235b9d // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect - golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359 // indirect + golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 // indirect golang.org/x/text v0.3.7 // indirect ) diff --git a/go.sum b/go.sum index bfa9db7..d96af7f 100644 --- a/go.sum +++ b/go.sum @@ -53,7 +53,6 @@ github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJm github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= @@ -120,6 +119,7 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= +github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4= github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= github.com/go-redis/cache/v8 v8.4.3 h1:+RZ0pQM+zOd6h/oWCsOl3+nsCgii9rn26oCYmU87kN8= github.com/go-redis/cache/v8 v8.4.3/go.mod h1:5lQPQ63uyBt4aZuRmdvUJOJRRjPxfLtJtlcJ/z8o1jA= @@ -228,7 +228,6 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= @@ -249,7 +248,6 @@ github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5W github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= -github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A= github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= @@ -331,6 +329,7 @@ github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -363,6 +362,7 @@ github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtb github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -449,10 +449,12 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= @@ -541,8 +543,8 @@ golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9t golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20210916165020-5cb4fee858ee/go.mod h1:a3o/VtDNHN+dCVLEpzjjUHOzR+Ln3DHX056ZPzoZGGA= -golang.org/x/exp v0.0.0-20211025140241-8418b01e8c3b h1:AHIXEGqpPGg/yJCO803Q+UbBiq/vkCe/OPwMSVE7psI= -golang.org/x/exp v0.0.0-20211025140241-8418b01e8c3b/go.mod h1:a3o/VtDNHN+dCVLEpzjjUHOzR+Ln3DHX056ZPzoZGGA= +golang.org/x/exp v0.0.0-20211029182501-9b944d235b9d h1:MKwb3mzSy4CTpgAm10+7Ru8Hq8ZnHOGgWAjo9fNVK+o= +golang.org/x/exp v0.0.0-20211029182501-9b944d235b9d/go.mod h1:OyI624f2tQ/aU3IMa7GB16Hk54CHURAfHfj6tMqtyhA= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -564,6 +566,7 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.1-0.20210830214625-1b1db11ec8f4/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57 h1:LQmS1nU0twXLA96Kt7U9qtHJEbBk3z6Q0V4UXjZkpr4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -640,8 +643,8 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359 h1:2B5p2L5IfGiD7+b9BOoRMC6DgObAVZV+Fsp050NqXik= -golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 h1:M69LAlWZCshgp0QSzyDcSsSIejIEeuaCVpmwcKwyLMk= +golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -688,6 +691,7 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023 h1:0c3L82FDQ5rt1bjTBlchS8t6RQ6299/+5bWMnRLh+uI= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/main.go b/main.go index 2422be6..15f0da9 100644 --- a/main.go +++ b/main.go @@ -1,14 +1,16 @@ package main import ( + "bytes" "context" "csgowtfd/csgo" "csgowtfd/ent" "csgowtfd/ent/match" + "csgowtfd/ent/matchplayer" "csgowtfd/ent/migrate" "csgowtfd/ent/player" - "csgowtfd/ent/stats" "csgowtfd/utils" + "encoding/gob" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "flag" @@ -304,7 +306,12 @@ func getPlayer(w http.ResponseWriter, r *http.Request) { GameBanDate: tPlayer.GameBanDate.Unix(), VanityURL: tPlayer.VanityURLReal, Tracked: tPlayer.AuthCode != "", - Matches: []*utils.MatchResponse{}, + MatchStats: &utils.MatchStats{ + Win: tPlayer.Wins, + Tie: tPlayer.Ties, + Loss: tPlayer.Looses, + }, + Matches: []*utils.MatchResponse{}, } var tMatches []*ent.Match @@ -324,44 +331,6 @@ func getPlayer(w http.ResponseWriter, r *http.Request) { return } - metaStats := new(utils.MatchStats) - err = rdc.Get(context.Background(), fmt.Sprintf(utils.MatchMetaCacheKey, tPlayer.ID), &metaStats) - if err != nil { - wins, ties, losses, err := utils.GetMatchStats(tPlayer) - if err != nil { - log.Errorf("[GP] Error retrieving match-stats for player %s: %v", id, err) - w.WriteHeader(http.StatusInternalServerError) - return - } - - response.MatchStats = &utils.MatchStats{ - Win: wins, - Loss: losses, - Tie: ties, - } - - err = rdc.Set(&cache.Item{ - Ctx: context.Background(), - Key: fmt.Sprintf(utils.MatchMetaCacheKey, tPlayer.ID), - Value: response.MatchStats, - TTL: time.Hour * 24 * 30, - }) - if err != nil { - log.Errorf("[GP] Failure saving to cache: %v", err) - w.WriteHeader(http.StatusInternalServerError) - return - } - log.Debugf("[GP] Metastats for %d saved to cache", tPlayer.ID) - } else { - log.Debugf("[GP] Metastats for %d from cache", tPlayer.ID) - - response.MatchStats = &utils.MatchStats{ - Win: metaStats.Win, - Tie: metaStats.Tie, - Loss: metaStats.Loss, - } - } - for _, iMatch := range tMatches { mResponse := &utils.MatchResponse{ MatchId: iMatch.ID, @@ -377,10 +346,10 @@ func getPlayer(w http.ResponseWriter, r *http.Request) { } tStats, err := iMatch.QueryStats().Modify(func(s *sql.Selector) { - s.Select(stats.FieldTeamID, stats.FieldKills, stats.FieldDeaths, stats.FieldAssists, stats.FieldHeadshot, - stats.FieldMvp, stats.FieldScore, stats.FieldMk2, stats.FieldMk3, stats.FieldMk4, stats.FieldMk5, - stats.FieldRankOld, stats.FieldRankNew, stats.FieldDmgTeam, stats.FieldDmgEnemy) - s.Where(sql.EQ(s.C(stats.PlayersColumn), tPlayer.ID)) + s.Select(matchplayer.FieldTeamID, matchplayer.FieldKills, matchplayer.FieldDeaths, matchplayer.FieldAssists, matchplayer.FieldHeadshot, + matchplayer.FieldMvp, matchplayer.FieldScore, matchplayer.FieldMk2, matchplayer.FieldMk3, matchplayer.FieldMk4, matchplayer.FieldMk5, + matchplayer.FieldRankOld, matchplayer.FieldRankNew, matchplayer.FieldDmgTeam, matchplayer.FieldDmgEnemy) + s.Where(sql.EQ(s.C(matchplayer.PlayersColumn), tPlayer.ID)) }).Only(context.Background()) if err != nil { response.Matches = append(response.Matches, mResponse) @@ -571,7 +540,7 @@ func getMatchRounds(w http.ResponseWriter, r *http.Request) { return } - tStats, err := db.Stats.Query().Where(stats.HasMatchesWith(match.ID(matchId))).All(context.Background()) + tStats, err := db.MatchPlayer.Query().Where(matchplayer.HasMatchesWith(match.ID(matchId))).All(context.Background()) if err != nil { log.Infof("[GMR] match %d not found: %+v", matchId, err) w.WriteHeader(http.StatusNotFound) @@ -618,7 +587,7 @@ func getMatchWeapons(w http.ResponseWriter, r *http.Request) { return } - tStats, err := db.Stats.Query().Where(stats.HasMatchesWith(match.ID(matchId))).All(context.Background()) + tStats, err := db.MatchPlayer.Query().Where(matchplayer.HasMatchesWith(match.ID(matchId))).All(context.Background()) if err != nil { log.Infof("[GMW] match %d not found: %+v", matchId, err) w.WriteHeader(http.StatusNotFound) @@ -626,11 +595,13 @@ func getMatchWeapons(w http.ResponseWriter, r *http.Request) { } mResponse := struct { - EquipmentMap map[int]string `json:"equipment_map,omitempty"` - Stats []map[string]map[string][][]int `json:"stats,omitempty"` + EquipmentMap map[int]string `json:"equipment_map,omitempty"` + Stats []map[string]map[string][][]int `json:"stats,omitempty"` + Spray []map[string]map[int][][]float32 `json:"spray,omitempty"` }{ EquipmentMap: map[int]string{}, Stats: []map[string]map[string][][]int{}, + Spray: []map[string]map[int][][]float32{}, } for _, stat := range tStats { @@ -644,7 +615,7 @@ func getMatchWeapons(w http.ResponseWriter, r *http.Request) { playerId := strconv.FormatUint(stat.PlayerStats, 10) for _, wr := range mWs { - if _, exists := mWr[strconv.FormatUint(stat.PlayerStats, 10)]; !exists { + if _, exists := mWr[playerId]; !exists { mWr[playerId] = map[string][][]int{} } @@ -656,6 +627,32 @@ func getMatchWeapons(w http.ResponseWriter, r *http.Request) { } } mResponse.Stats = append(mResponse.Stats, mWr) + + mSprays, err := stat.QuerySpray().All(context.Background()) + if err != nil { + log.Warningf("[GMW] Unable to get Sprays for player %d: %v", stat.PlayerStats, err) + continue + } + + rSprays := map[string]map[int][][]float32{} + for _, spray := range mSprays { + if _, exists := rSprays[playerId]; !exists { + rSprays[playerId] = map[int][][]float32{} + } + + bBuf := bytes.NewBuffer(spray.Spray) + dec := gob.NewDecoder(bBuf) + var dSpray [][]float32 + err := dec.Decode(&dSpray) + if err != nil { + log.Warningf("[GMW] Unable to decode Sprays for player %d: %v", stat.PlayerStats, err) + continue + } + log.Debugf("%+v", dSpray) + + rSprays[playerId][spray.Weapon] = dSpray + } + mResponse.Spray = append(mResponse.Spray, rSprays) } err = utils.SendJSON(mResponse, w) diff --git a/utils/utils.go b/utils/utils.go index 9c1ff7c..e6df868 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -4,9 +4,9 @@ import ( "context" "csgowtfd/ent" "csgowtfd/ent/match" + "csgowtfd/ent/matchplayer" "csgowtfd/ent/player" - "csgowtfd/ent/stats" - "csgowtfd/ent/weaponstats" + "csgowtfd/ent/weapon" "encoding/json" "entgo.io/ent/dialect/sql" "errors" @@ -198,7 +198,6 @@ type ( const ( shareCodeURLEntry = "https://api.steampowered.com/ICSGOPlayers_730/GetNextMatchSharingCode/v1?key=%s&steamid=%d&steamidkey=%s&knowncode=%s" SideMetaCacheKey = "csgowtfd_side_meta_%d" - MatchMetaCacheKey = "csgowtfd_match_meta_%d" ) //goland:noinspection SpellCheckingInspection @@ -222,15 +221,6 @@ func SendJSON(data interface{}, w http.ResponseWriter) error { return nil } -func GetMatchStats(dbPlayer *ent.Player) (int, int, int, error) { - wins, loss, ties, err := getWinLossTieFromPlayer(dbPlayer) - if err != nil { - return 0, 0, 0, err - } - - return wins, ties, loss, nil -} - func GetMetaStats(dbPlayer *ent.Player) (*MetaStatsResponse, error) { mResponse := new(MetaStatsResponse) mResponse.Player = &PlayerResponse{SteamID64: dbPlayer.ID} @@ -267,7 +257,7 @@ func GetMetaStats(dbPlayer *ent.Player) (*MetaStatsResponse, error) { Select(match.FieldID, match.FieldMatchResult, match.FieldMap). Where(match.IDIn(matchIDs...)). WithStats(). - Where(match.HasStatsWith(stats.Or(stats.PlayerStats(dbPlayer.ID), stats.PlayerStats(s.ID)))). + Where(match.HasStatsWith(matchplayer.Or(matchplayer.PlayerStats(dbPlayer.ID), matchplayer.PlayerStats(s.ID)))). All(context.Background()) if err != nil { return nil, err @@ -278,8 +268,8 @@ func GetMetaStats(dbPlayer *ent.Player) (*MetaStatsResponse, error) { var ties int for _, pm := range pMatches { - var subjectStats *ent.Stats - var currentStats *ent.Stats + var subjectStats *ent.MatchPlayer + var currentStats *ent.MatchPlayer for _, ps := range pm.Edges.Stats { if ps.PlayerStats == dbPlayer.ID { @@ -303,7 +293,7 @@ func GetMetaStats(dbPlayer *ent.Player) (*MetaStatsResponse, error) { } wSs, err := subjectStats.QueryWeaponStats(). - Select(weaponstats.FieldEqType, weaponstats.FieldDmg).All(context.Background()) + Select(weapon.FieldEqType, weapon.FieldDmg).All(context.Background()) if err != nil { return nil, err } @@ -389,41 +379,36 @@ func GetMetaStats(dbPlayer *ent.Player) (*MetaStatsResponse, error) { return mResponse, nil } -func getWinLossTieFromPlayer(dbPlayer *ent.Player) (int, int, int, error) { +func GetWinLossTieForPlayer(dbPlayer *ent.Player) (wins int, looses int, ties int, err error) { var res []struct { MatchResult int `json:"match_result"` Count int `json:"count"` } - err := dbPlayer.QueryMatches().GroupBy(match.FieldMatchResult).Aggregate(func(s *sql.Selector) string { - sT := sql.Table(stats.Table) + err = dbPlayer.QueryMatches().GroupBy(match.FieldMatchResult).Aggregate(func(s *sql.Selector) string { + sT := sql.Table(matchplayer.Table) - s.Join(sT).On(s.C(match.FieldID), sT.C(stats.MatchesColumn)) + s.Join(sT).On(s.C(match.FieldID), sT.C(matchplayer.MatchesColumn)) s.Where(sql.And( sql.Or( - sql.ColumnsEQ(match.FieldMatchResult, stats.FieldTeamID), + sql.ColumnsEQ(match.FieldMatchResult, matchplayer.FieldTeamID), sql.EQ(s.C(match.FieldMatchResult), 0), ), - sql.EQ(sT.C(stats.PlayersColumn), dbPlayer.ID), + sql.EQ(sT.C(matchplayer.PlayersColumn), dbPlayer.ID), )) return sql.Count("*") }).Scan(context.Background(), &res) if err != nil { - return 0, 0, 0, err + return } total, err := dbPlayer.QueryMatches().Modify(func(s *sql.Selector) { s.Select("COUNT(*)") }).Int(context.Background()) if err != nil { - return 0, 0, 0, err + return } - var ( - wins int - ties int - ) - for _, r := range res { switch r.MatchResult { case 0: @@ -432,8 +417,9 @@ func getWinLossTieFromPlayer(dbPlayer *ent.Player) (int, int, int, error) { wins += r.Count } } + looses = total - wins - ties - return wins, total - wins - ties, ties, nil + return } func IsAuthCodeValid(player *ent.Player, apiKey string, shareCode string, authCode string, rl ratelimit.Limiter) (bool, error) {