// Code generated by entc, DO NOT EDIT. package ent import ( "csgowtfd/ent/match" "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 { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` // TeamID holds the value of the "team_id" field. TeamID int `json:"team_id,omitempty"` // Kills holds the value of the "kills" field. Kills int `json:"kills,omitempty"` // Deaths holds the value of the "deaths" field. Deaths int `json:"deaths,omitempty"` // Assists holds the value of the "assists" field. Assists int `json:"assists,omitempty"` // Headshot holds the value of the "headshot" field. Headshot int `json:"headshot,omitempty"` // Mvp holds the value of the "mvp" field. Mvp uint `json:"mvp,omitempty"` // Score holds the value of the "score" field. Score int `json:"score,omitempty"` // RankNew holds the value of the "rank_new" field. RankNew int `json:"rank_new,omitempty"` // RankOld holds the value of the "rank_old" field. RankOld int `json:"rank_old,omitempty"` // Mk2 holds the value of the "mk_2" field. Mk2 uint `json:"mk_2,omitempty"` // Mk3 holds the value of the "mk_3" field. Mk3 uint `json:"mk_3,omitempty"` // Mk4 holds the value of the "mk_4" field. Mk4 uint `json:"mk_4,omitempty"` // Mk5 holds the value of the "mk_5" field. Mk5 uint `json:"mk_5,omitempty"` // DmgEnemy holds the value of the "dmg_enemy" field. DmgEnemy uint `json:"dmg_enemy,omitempty"` // DmgTeam holds the value of the "dmg_team" field. DmgTeam uint `json:"dmg_team,omitempty"` // UdHe holds the value of the "ud_he" field. UdHe uint `json:"ud_he,omitempty"` // UdFlames holds the value of the "ud_flames" field. UdFlames uint `json:"ud_flames,omitempty"` // UdFlash holds the value of the "ud_flash" field. UdFlash uint `json:"ud_flash,omitempty"` // UdDecoy holds the value of the "ud_decoy" field. UdDecoy uint `json:"ud_decoy,omitempty"` // UdSmoke holds the value of the "ud_smoke" field. UdSmoke uint `json:"ud_smoke,omitempty"` // 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"` // Kast holds the value of the "kast" field. Kast int `json:"kast,omitempty"` // FlashDurationSelf holds the value of the "flash_duration_self" field. FlashDurationSelf float32 `json:"flash_duration_self,omitempty"` // FlashDurationTeam holds the value of the "flash_duration_team" field. FlashDurationTeam float32 `json:"flash_duration_team,omitempty"` // FlashDurationEnemy holds the value of the "flash_duration_enemy" field. FlashDurationEnemy float32 `json:"flash_duration_enemy,omitempty"` // FlashTotalSelf holds the value of the "flash_total_self" field. FlashTotalSelf uint `json:"flash_total_self,omitempty"` // FlashTotalTeam holds the value of the "flash_total_team" field. FlashTotalTeam uint `json:"flash_total_team,omitempty"` // FlashTotalEnemy holds the value of the "flash_total_enemy" field. FlashTotalEnemy uint `json:"flash_total_enemy,omitempty"` // MatchStats holds the value of the "match_stats" field. MatchStats uint64 `json:"match_stats,omitempty"` // PlayerStats holds the value of the "player_stats" field. PlayerStats uint64 `json:"player_stats,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"` } // StatsEdges holds the relations/edges for other nodes in the graph. type StatsEdges 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"` // RoundStats holds the value of the round_stats edge. RoundStats []*RoundStats `json:"round_stats,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [4]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) { if e.loadedTypes[0] { if e.Matches == nil { // The edge matches was loaded in eager-loading, // but was not found. return nil, &NotFoundError{label: match.Label} } return e.Matches, nil } return nil, &NotLoadedError{edge: "matches"} } // 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) { if e.loadedTypes[1] { if e.Players == nil { // The edge players was loaded in eager-loading, // but was not found. return nil, &NotFoundError{label: player.Label} } return e.Players, nil } return nil, &NotLoadedError{edge: "players"} } // WeaponStatsOrErr returns the WeaponStats value or an error if the edge // was not loaded in eager-loading. func (e StatsEdges) WeaponStatsOrErr() ([]*WeaponStats, error) { if e.loadedTypes[2] { return e.WeaponStats, nil } return nil, &NotLoadedError{edge: "weapon_stats"} } // RoundStatsOrErr returns the RoundStats value or an error if the edge // was not loaded in eager-loading. func (e StatsEdges) RoundStatsOrErr() ([]*RoundStats, error) { if e.loadedTypes[3] { return e.RoundStats, nil } return nil, &NotLoadedError{edge: "round_stats"} } // scanValues returns the types for scanning values from sql.Rows. func (*Stats) scanValues(columns []string) ([]interface{}, error) { values := make([]interface{}, len(columns)) for i := range columns { switch columns[i] { case stats.FieldFlashDurationSelf, stats.FieldFlashDurationTeam, stats.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: values[i] = new(sql.NullInt64) case stats.FieldCrosshair, stats.FieldColor: values[i] = new(sql.NullString) default: return nil, fmt.Errorf("unexpected column %q for type Stats", 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 { 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: 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: 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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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 } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } case stats.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) } } } return nil } // QueryMatches queries the "matches" edge of the Stats entity. func (s *Stats) QueryMatches() *MatchQuery { return (&StatsClient{config: s.config}).QueryMatches(s) } // QueryPlayers queries the "players" edge of the Stats entity. func (s *Stats) QueryPlayers() *PlayerQuery { return (&StatsClient{config: s.config}).QueryPlayers(s) } // QueryWeaponStats queries the "weapon_stats" edge of the Stats entity. func (s *Stats) QueryWeaponStats() *WeaponStatsQuery { return (&StatsClient{config: s.config}).QueryWeaponStats(s) } // QueryRoundStats queries the "round_stats" edge of the Stats entity. func (s *Stats) QueryRoundStats() *RoundStatsQuery { return (&StatsClient{config: s.config}).QueryRoundStats(s) } // Update returns a builder for updating this Stats. // Note that you need to call Stats.Unwrap() before calling this method if this Stats // 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) } // Unwrap unwraps the Stats 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) if !ok { panic("ent: Stats is not a transactional entity") } s.config.driver = tx.drv return s } // String implements the fmt.Stringer. func (s *Stats) String() string { var builder strings.Builder builder.WriteString("Stats(") builder.WriteString(fmt.Sprintf("id=%v", s.ID)) builder.WriteString(", team_id=") builder.WriteString(fmt.Sprintf("%v", s.TeamID)) builder.WriteString(", kills=") builder.WriteString(fmt.Sprintf("%v", s.Kills)) builder.WriteString(", deaths=") builder.WriteString(fmt.Sprintf("%v", s.Deaths)) builder.WriteString(", assists=") builder.WriteString(fmt.Sprintf("%v", s.Assists)) builder.WriteString(", headshot=") builder.WriteString(fmt.Sprintf("%v", s.Headshot)) builder.WriteString(", mvp=") builder.WriteString(fmt.Sprintf("%v", s.Mvp)) builder.WriteString(", score=") builder.WriteString(fmt.Sprintf("%v", s.Score)) builder.WriteString(", rank_new=") builder.WriteString(fmt.Sprintf("%v", s.RankNew)) builder.WriteString(", rank_old=") builder.WriteString(fmt.Sprintf("%v", s.RankOld)) builder.WriteString(", mk_2=") builder.WriteString(fmt.Sprintf("%v", s.Mk2)) builder.WriteString(", mk_3=") builder.WriteString(fmt.Sprintf("%v", s.Mk3)) builder.WriteString(", mk_4=") builder.WriteString(fmt.Sprintf("%v", s.Mk4)) builder.WriteString(", mk_5=") builder.WriteString(fmt.Sprintf("%v", s.Mk5)) builder.WriteString(", dmg_enemy=") builder.WriteString(fmt.Sprintf("%v", s.DmgEnemy)) builder.WriteString(", dmg_team=") builder.WriteString(fmt.Sprintf("%v", s.DmgTeam)) builder.WriteString(", ud_he=") builder.WriteString(fmt.Sprintf("%v", s.UdHe)) builder.WriteString(", ud_flames=") builder.WriteString(fmt.Sprintf("%v", s.UdFlames)) builder.WriteString(", ud_flash=") builder.WriteString(fmt.Sprintf("%v", s.UdFlash)) builder.WriteString(", ud_decoy=") builder.WriteString(fmt.Sprintf("%v", s.UdDecoy)) builder.WriteString(", ud_smoke=") builder.WriteString(fmt.Sprintf("%v", s.UdSmoke)) builder.WriteString(", crosshair=") builder.WriteString(s.Crosshair) builder.WriteString(", color=") builder.WriteString(fmt.Sprintf("%v", s.Color)) builder.WriteString(", kast=") builder.WriteString(fmt.Sprintf("%v", s.Kast)) builder.WriteString(", flash_duration_self=") builder.WriteString(fmt.Sprintf("%v", s.FlashDurationSelf)) builder.WriteString(", flash_duration_team=") builder.WriteString(fmt.Sprintf("%v", s.FlashDurationTeam)) builder.WriteString(", flash_duration_enemy=") builder.WriteString(fmt.Sprintf("%v", s.FlashDurationEnemy)) builder.WriteString(", flash_total_self=") builder.WriteString(fmt.Sprintf("%v", s.FlashTotalSelf)) builder.WriteString(", flash_total_team=") builder.WriteString(fmt.Sprintf("%v", s.FlashTotalTeam)) builder.WriteString(", flash_total_enemy=") builder.WriteString(fmt.Sprintf("%v", s.FlashTotalEnemy)) builder.WriteString(", match_stats=") builder.WriteString(fmt.Sprintf("%v", s.MatchStats)) builder.WriteString(", player_stats=") builder.WriteString(fmt.Sprintf("%v", s.PlayerStats)) builder.WriteByte(')') return builder.String() } // StatsSlice is a parsable slice of Stats. type StatsSlice []*Stats func (s StatsSlice) config(cfg config) { for _i := range s { s[_i].config = cfg } }