// Code generated by entc, DO NOT EDIT. package ent import ( "csgowtfd/ent/match" "fmt" "strings" "time" "entgo.io/ent/dialect/sql" ) // Match is the model entity for the Match schema. type Match struct { config `json:"-"` // ID of the ent. ID uint64 `json:"match_id,string"` // ShareCode holds the value of the "share_code" field. ShareCode string `json:"share_code,omitempty"` // Map holds the value of the "map" field. Map string `json:"map,omitempty"` // Date holds the value of the "date" field. Date time.Time `json:"date,omitempty"` // ScoreTeamA holds the value of the "score_team_a" field. ScoreTeamA int `json:"score_team_a,omitempty"` // ScoreTeamB holds the value of the "score_team_b" field. ScoreTeamB int `json:"score_team_b,omitempty"` // ReplayURL holds the value of the "replay_url" field. ReplayURL string `json:"-"` // Duration holds the value of the "duration" field. Duration int `json:"duration,omitempty"` // MatchResult holds the value of the "match_result" field. MatchResult int `json:"match_result,omitempty"` // MaxRounds holds the value of the "max_rounds" field. MaxRounds int `json:"max_rounds,omitempty"` // DemoParsed holds the value of the "demo_parsed" field. DemoParsed bool `json:"demo_parsed,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the MatchQuery when eager-loading is set. Edges MatchEdges `json:"edges"` } // 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"` // 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 } // StatsOrErr returns the Stats value or an error if the edge // was not loaded in eager-loading. func (e MatchEdges) StatsOrErr() ([]*Stats, error) { if e.loadedTypes[0] { return e.Stats, nil } return nil, &NotLoadedError{edge: "stats"} } // PlayersOrErr returns the Players value or an error if the edge // was not loaded in eager-loading. func (e MatchEdges) PlayersOrErr() ([]*Player, error) { if e.loadedTypes[1] { return e.Players, nil } return nil, &NotLoadedError{edge: "players"} } // scanValues returns the types for scanning values from sql.Rows. func (*Match) scanValues(columns []string) ([]interface{}, error) { values := make([]interface{}, len(columns)) for i := range columns { switch columns[i] { case match.FieldDemoParsed: values[i] = new(sql.NullBool) case match.FieldID, match.FieldScoreTeamA, match.FieldScoreTeamB, match.FieldDuration, match.FieldMatchResult, match.FieldMaxRounds: values[i] = new(sql.NullInt64) case match.FieldShareCode, match.FieldMap, match.FieldReplayURL: values[i] = new(sql.NullString) case match.FieldDate: values[i] = new(sql.NullTime) default: return nil, fmt.Errorf("unexpected column %q for type Match", columns[i]) } } return values, nil } // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Match fields. func (m *Match) 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 match.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } m.ID = uint64(value.Int64) case match.FieldShareCode: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field share_code", values[i]) } else if value.Valid { m.ShareCode = value.String } case match.FieldMap: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field map", values[i]) } else if value.Valid { m.Map = value.String } case match.FieldDate: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field date", values[i]) } else if value.Valid { m.Date = value.Time } case match.FieldScoreTeamA: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field score_team_a", values[i]) } else if value.Valid { m.ScoreTeamA = int(value.Int64) } case match.FieldScoreTeamB: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field score_team_b", values[i]) } else if value.Valid { m.ScoreTeamB = int(value.Int64) } case match.FieldReplayURL: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field replay_url", values[i]) } else if value.Valid { m.ReplayURL = value.String } case match.FieldDuration: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field duration", values[i]) } else if value.Valid { m.Duration = int(value.Int64) } case match.FieldMatchResult: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field match_result", values[i]) } else if value.Valid { m.MatchResult = int(value.Int64) } case match.FieldMaxRounds: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field max_rounds", values[i]) } else if value.Valid { m.MaxRounds = int(value.Int64) } case match.FieldDemoParsed: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field demo_parsed", values[i]) } else if value.Valid { m.DemoParsed = value.Bool } } } return nil } // QueryStats queries the "stats" edge of the Match entity. func (m *Match) QueryStats() *StatsQuery { return (&MatchClient{config: m.config}).QueryStats(m) } // QueryPlayers queries the "players" edge of the Match entity. func (m *Match) QueryPlayers() *PlayerQuery { return (&MatchClient{config: m.config}).QueryPlayers(m) } // Update returns a builder for updating this Match. // Note that you need to call Match.Unwrap() before calling this method if this Match // was returned from a transaction, and the transaction was committed or rolled back. func (m *Match) Update() *MatchUpdateOne { return (&MatchClient{config: m.config}).UpdateOne(m) } // Unwrap unwraps the Match 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 (m *Match) Unwrap() *Match { tx, ok := m.config.driver.(*txDriver) if !ok { panic("ent: Match is not a transactional entity") } m.config.driver = tx.drv return m } // String implements the fmt.Stringer. func (m *Match) String() string { var builder strings.Builder builder.WriteString("Match(") builder.WriteString(fmt.Sprintf("id=%v", m.ID)) builder.WriteString(", share_code=") builder.WriteString(m.ShareCode) builder.WriteString(", map=") builder.WriteString(m.Map) builder.WriteString(", date=") builder.WriteString(m.Date.Format(time.ANSIC)) builder.WriteString(", score_team_a=") builder.WriteString(fmt.Sprintf("%v", m.ScoreTeamA)) builder.WriteString(", score_team_b=") builder.WriteString(fmt.Sprintf("%v", m.ScoreTeamB)) builder.WriteString(", replay_url=") builder.WriteString(m.ReplayURL) builder.WriteString(", duration=") builder.WriteString(fmt.Sprintf("%v", m.Duration)) builder.WriteString(", match_result=") builder.WriteString(fmt.Sprintf("%v", m.MatchResult)) builder.WriteString(", max_rounds=") builder.WriteString(fmt.Sprintf("%v", m.MaxRounds)) builder.WriteString(", demo_parsed=") builder.WriteString(fmt.Sprintf("%v", m.DemoParsed)) builder.WriteByte(')') return builder.String() } // Matches is a parsable slice of Match. type Matches []*Match func (m Matches) config(cfg config) { for _i := range m { m[_i].config = cfg } }