// Code generated by ent, DO NOT EDIT. package ent import ( "fmt" "strings" "entgo.io/ent/dialect/sql" "git.harting.dev/csgowtf/csgowtfd/ent/match" "git.harting.dev/csgowtf/csgowtfd/ent/matchplayer" "git.harting.dev/csgowtf/csgowtfd/ent/player" ) // MatchPlayer is the model entity for the MatchPlayer schema. type MatchPlayer 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 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. 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"` // 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 MatchPlayerQuery when eager-loading is set. Edges MatchPlayerEdges `json:"edges"` } // 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 []*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"` // Messages holds the value of the messages edge. Messages []*Messages `json:"messages,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [6]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 MatchPlayerEdges) MatchesOrErr() (*Match, error) { if e.loadedTypes[0] { if e.Matches == nil { // Edge was loaded 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 MatchPlayerEdges) PlayersOrErr() (*Player, error) { if e.loadedTypes[1] { if e.Players == nil { // Edge was loaded 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 MatchPlayerEdges) WeaponStatsOrErr() ([]*Weapon, 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 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"} } // MessagesOrErr returns the Messages value or an error if the edge // was not loaded in eager-loading. func (e MatchPlayerEdges) MessagesOrErr() ([]*Messages, error) { if e.loadedTypes[5] { return e.Messages, nil } return nil, &NotLoadedError{edge: "messages"} } // scanValues returns the types for scanning values from sql.Rows. func (*MatchPlayer) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case matchplayer.FieldFlashDurationSelf, matchplayer.FieldFlashDurationTeam, matchplayer.FieldFlashDurationEnemy: values[i] = new(sql.NullFloat64) 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 matchplayer.FieldCrosshair, matchplayer.FieldColor: values[i] = new(sql.NullString) default: 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 MatchPlayer fields. func (mp *MatchPlayer) assignValues(columns []string, values []any) 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 matchplayer.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } 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 { mp.TeamID = int(value.Int64) } 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 { mp.Kills = int(value.Int64) } 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 { mp.Deaths = int(value.Int64) } 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 { mp.Assists = int(value.Int64) } 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 { mp.Headshot = int(value.Int64) } 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 { mp.Mvp = uint(value.Int64) } 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 { mp.Score = int(value.Int64) } 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 { mp.RankNew = int(value.Int64) } 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 { mp.RankOld = int(value.Int64) } 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 { mp.Mk2 = uint(value.Int64) } 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 { mp.Mk3 = uint(value.Int64) } 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 { mp.Mk4 = uint(value.Int64) } 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 { mp.Mk5 = uint(value.Int64) } 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 { mp.DmgEnemy = uint(value.Int64) } 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 { mp.DmgTeam = uint(value.Int64) } 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 { mp.UdHe = uint(value.Int64) } 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 { mp.UdFlames = uint(value.Int64) } 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 { mp.UdFlash = uint(value.Int64) } 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 { mp.UdDecoy = uint(value.Int64) } 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 { mp.UdSmoke = uint(value.Int64) } 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 { mp.Crosshair = value.String } 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 { mp.Color = matchplayer.Color(value.String) } 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 { mp.Kast = int(value.Int64) } 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 { mp.FlashDurationSelf = float32(value.Float64) } 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 { mp.FlashDurationTeam = float32(value.Float64) } 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 { mp.FlashDurationEnemy = float32(value.Float64) } 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 { mp.FlashTotalSelf = uint(value.Int64) } 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 { mp.FlashTotalTeam = uint(value.Int64) } 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 { mp.FlashTotalEnemy = uint(value.Int64) } 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 { mp.MatchStats = uint64(value.Int64) } 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 { 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 MatchPlayer entity. func (mp *MatchPlayer) QueryMatches() *MatchQuery { return (&MatchPlayerClient{config: mp.config}).QueryMatches(mp) } // 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 MatchPlayer entity. func (mp *MatchPlayer) QueryWeaponStats() *WeaponQuery { return (&MatchPlayerClient{config: mp.config}).QueryWeaponStats(mp) } // QueryRoundStats queries the "round_stats" edge of the MatchPlayer entity. func (mp *MatchPlayer) QueryRoundStats() *RoundStatsQuery { return (&MatchPlayerClient{config: mp.config}).QueryRoundStats(mp) } // QuerySpray queries the "spray" edge of the MatchPlayer entity. func (mp *MatchPlayer) QuerySpray() *SprayQuery { return (&MatchPlayerClient{config: mp.config}).QuerySpray(mp) } // QueryMessages queries the "messages" edge of the MatchPlayer entity. func (mp *MatchPlayer) QueryMessages() *MessagesQuery { return (&MatchPlayerClient{config: mp.config}).QueryMessages(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 (mp *MatchPlayer) Update() *MatchPlayerUpdateOne { return (&MatchPlayerClient{config: mp.config}).UpdateOne(mp) } // 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 (mp *MatchPlayer) Unwrap() *MatchPlayer { _tx, ok := mp.config.driver.(*txDriver) if !ok { panic("ent: MatchPlayer is not a transactional entity") } mp.config.driver = _tx.drv return mp } // String implements the fmt.Stringer. func (mp *MatchPlayer) String() string { var builder strings.Builder builder.WriteString("MatchPlayer(") builder.WriteString(fmt.Sprintf("id=%v, ", mp.ID)) builder.WriteString("team_id=") builder.WriteString(fmt.Sprintf("%v", mp.TeamID)) builder.WriteString(", ") builder.WriteString("kills=") builder.WriteString(fmt.Sprintf("%v", mp.Kills)) builder.WriteString(", ") builder.WriteString("deaths=") builder.WriteString(fmt.Sprintf("%v", mp.Deaths)) builder.WriteString(", ") builder.WriteString("assists=") builder.WriteString(fmt.Sprintf("%v", mp.Assists)) builder.WriteString(", ") builder.WriteString("headshot=") builder.WriteString(fmt.Sprintf("%v", mp.Headshot)) builder.WriteString(", ") builder.WriteString("mvp=") builder.WriteString(fmt.Sprintf("%v", mp.Mvp)) builder.WriteString(", ") builder.WriteString("score=") builder.WriteString(fmt.Sprintf("%v", mp.Score)) builder.WriteString(", ") builder.WriteString("rank_new=") builder.WriteString(fmt.Sprintf("%v", mp.RankNew)) builder.WriteString(", ") builder.WriteString("rank_old=") builder.WriteString(fmt.Sprintf("%v", mp.RankOld)) builder.WriteString(", ") builder.WriteString("mk_2=") builder.WriteString(fmt.Sprintf("%v", mp.Mk2)) builder.WriteString(", ") builder.WriteString("mk_3=") builder.WriteString(fmt.Sprintf("%v", mp.Mk3)) builder.WriteString(", ") builder.WriteString("mk_4=") builder.WriteString(fmt.Sprintf("%v", mp.Mk4)) builder.WriteString(", ") builder.WriteString("mk_5=") builder.WriteString(fmt.Sprintf("%v", mp.Mk5)) builder.WriteString(", ") builder.WriteString("dmg_enemy=") builder.WriteString(fmt.Sprintf("%v", mp.DmgEnemy)) builder.WriteString(", ") builder.WriteString("dmg_team=") builder.WriteString(fmt.Sprintf("%v", mp.DmgTeam)) builder.WriteString(", ") builder.WriteString("ud_he=") builder.WriteString(fmt.Sprintf("%v", mp.UdHe)) builder.WriteString(", ") builder.WriteString("ud_flames=") builder.WriteString(fmt.Sprintf("%v", mp.UdFlames)) builder.WriteString(", ") builder.WriteString("ud_flash=") builder.WriteString(fmt.Sprintf("%v", mp.UdFlash)) builder.WriteString(", ") builder.WriteString("ud_decoy=") builder.WriteString(fmt.Sprintf("%v", mp.UdDecoy)) builder.WriteString(", ") builder.WriteString("ud_smoke=") builder.WriteString(fmt.Sprintf("%v", mp.UdSmoke)) builder.WriteString(", ") builder.WriteString("crosshair=") builder.WriteString(mp.Crosshair) builder.WriteString(", ") builder.WriteString("color=") builder.WriteString(fmt.Sprintf("%v", mp.Color)) builder.WriteString(", ") builder.WriteString("kast=") builder.WriteString(fmt.Sprintf("%v", mp.Kast)) builder.WriteString(", ") builder.WriteString("flash_duration_self=") builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationSelf)) builder.WriteString(", ") builder.WriteString("flash_duration_team=") builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationTeam)) builder.WriteString(", ") builder.WriteString("flash_duration_enemy=") builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationEnemy)) builder.WriteString(", ") builder.WriteString("flash_total_self=") builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalSelf)) builder.WriteString(", ") builder.WriteString("flash_total_team=") builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalTeam)) builder.WriteString(", ") builder.WriteString("flash_total_enemy=") builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalEnemy)) builder.WriteString(", ") builder.WriteString("match_stats=") builder.WriteString(fmt.Sprintf("%v", mp.MatchStats)) builder.WriteString(", ") builder.WriteString("player_stats=") builder.WriteString(fmt.Sprintf("%v", mp.PlayerStats)) builder.WriteString(", ") builder.WriteString("flash_assists=") builder.WriteString(fmt.Sprintf("%v", mp.FlashAssists)) builder.WriteByte(')') return builder.String() } // MatchPlayers is a parsable slice of MatchPlayer. type MatchPlayers []*MatchPlayer func (mp MatchPlayers) config(cfg config) { for _i := range mp { mp[_i].config = cfg } }