// Code generated by entc, DO NOT EDIT. package ent import ( "csgowtfd/ent/match" "csgowtfd/ent/player" "csgowtfd/ent/stats" "encoding/json" "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 int `json:"mvp,omitempty"` // Score holds the value of the "score" field. Score int `json:"score,omitempty"` // Extended holds the value of the "extended" field. Extended struct { MultiKills struct { Duo int "json:\"duo,omitempty\"" Triple int "json:\"triple,omitempty\"" Quad int "json:\"quad,omitempty\"" Pent int "json:\"pent,omitempty\"" } "json:\"multi_kills,omitempty\"" Dmg struct { Enemy int "json:\"enemy,omitempty\"" Team int "json:\"team,omitempty\"" UD struct { HE int "json:\"he,omitempty\"" Flames int "json:\"flames,omitempty\"" Flash int "json:\"flash,omitempty\"" Decoy int "json:\"decoy,omitempty\"" Smoke int "json:\"smoke,omitempty\"" } "json:\"ud,omitempty\"" HitGroup struct { Head int "json:\"head,omitempty\"" Chest int "json:\"chest,omitempty\"" Stomach int "json:\"stomach,omitempty\"" LeftArm int "json:\"left_arm,omitempty\"" RightArm int "json:\"right_arm,omitempty\"" LeftLeg int "json:\"left_leg,omitempty\"" RightLeg int "json:\"right_leg,omitempty\"" Gear int "json:\"gear,omitempty\"" } "json:\"hit_group,omitempty\"" } "json:\"dmg,omitempty\"" Crosshair string "json:\"crosshair,omitempty\"" Color string "json:\"color,omitempty\"" KAST int "json:\"kast,omitempty\"" Rank struct { Old int "json:\"old,omitempty\"" New int "json:\"new,omitempty\"" } "json:\"rank,omitempty\"" Flash struct { Duration struct { Self float32 "json:\"self,omitempty\"" Team float32 "json:\"team,omitempty\"" Enemy float32 "json:\"enemy,omitempty\"" } "json:\"duration,omitempty\"" Total struct { Team int "json:\"team,omitempty\"" Enemy int "json:\"enemy,omitempty\"" Self int "json:\"self,omitempty\"" } "json:\"total,omitempty\"" } "json:\"flash,omitempty\"" } `json:"extended,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"` match_stats *uint64 player_stats *uint64 } // 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"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [2]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"} } // 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.FieldExtended: values[i] = new([]byte) case stats.FieldID, stats.FieldTeamID, stats.FieldKills, stats.FieldDeaths, stats.FieldAssists, stats.FieldHeadshot, stats.FieldMvp, stats.FieldScore: values[i] = new(sql.NullInt64) case stats.ForeignKeys[0]: // match_stats values[i] = new(sql.NullInt64) case stats.ForeignKeys[1]: // player_stats values[i] = new(sql.NullInt64) 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 = int(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.FieldExtended: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field extended", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &s.Extended); err != nil { return fmt.Errorf("unmarshal field extended: %w", err) } } case stats.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for edge-field match_stats", value) } else if value.Valid { s.match_stats = new(uint64) *s.match_stats = uint64(value.Int64) } case stats.ForeignKeys[1]: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for edge-field player_stats", value) } else if value.Valid { s.player_stats = new(uint64) *s.player_stats = 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) } // 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(", extended=") builder.WriteString(fmt.Sprintf("%v", s.Extended)) 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 } }