Files
csgowtfd/ent/match.go

288 lines
10 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent/dialect/sql"
"somegit.dev/csgowtf/csgowtfd/ent/match"
)
// 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"`
// VacPresent holds the value of the "vac_present" field.
VacPresent bool `json:"vac_present,omitempty"`
// GamebanPresent holds the value of the "gameban_present" field.
GamebanPresent bool `json:"gameban_present,omitempty"`
// DecryptionKey holds the value of the "decryption_key" field.
DecryptionKey []byte `json:"decryption_key,omitempty"`
// TickRate holds the value of the "tick_rate" field.
TickRate float64 `json:"tick_rate,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 []*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
// 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() ([]*MatchPlayer, 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) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case match.FieldDecryptionKey:
values[i] = new([]byte)
case match.FieldDemoParsed, match.FieldVacPresent, match.FieldGamebanPresent:
values[i] = new(sql.NullBool)
case match.FieldTickRate:
values[i] = new(sql.NullFloat64)
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 []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 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
}
case match.FieldVacPresent:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field vac_present", values[i])
} else if value.Valid {
m.VacPresent = value.Bool
}
case match.FieldGamebanPresent:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field gameban_present", values[i])
} else if value.Valid {
m.GamebanPresent = value.Bool
}
case match.FieldDecryptionKey:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field decryption_key", values[i])
} else if value != nil {
m.DecryptionKey = *value
}
case match.FieldTickRate:
if value, ok := values[i].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field tick_rate", values[i])
} else if value.Valid {
m.TickRate = value.Float64
}
}
}
return nil
}
// QueryStats queries the "stats" edge of the Match entity.
func (m *Match) QueryStats() *MatchPlayerQuery {
return NewMatchClient(m.config).QueryStats(m)
}
// QueryPlayers queries the "players" edge of the Match entity.
func (m *Match) QueryPlayers() *PlayerQuery {
return NewMatchClient(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 NewMatchClient(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(", ")
builder.WriteString("map=")
builder.WriteString(m.Map)
builder.WriteString(", ")
builder.WriteString("date=")
builder.WriteString(m.Date.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("score_team_a=")
builder.WriteString(fmt.Sprintf("%v", m.ScoreTeamA))
builder.WriteString(", ")
builder.WriteString("score_team_b=")
builder.WriteString(fmt.Sprintf("%v", m.ScoreTeamB))
builder.WriteString(", ")
builder.WriteString("replay_url=")
builder.WriteString(m.ReplayURL)
builder.WriteString(", ")
builder.WriteString("duration=")
builder.WriteString(fmt.Sprintf("%v", m.Duration))
builder.WriteString(", ")
builder.WriteString("match_result=")
builder.WriteString(fmt.Sprintf("%v", m.MatchResult))
builder.WriteString(", ")
builder.WriteString("max_rounds=")
builder.WriteString(fmt.Sprintf("%v", m.MaxRounds))
builder.WriteString(", ")
builder.WriteString("demo_parsed=")
builder.WriteString(fmt.Sprintf("%v", m.DemoParsed))
builder.WriteString(", ")
builder.WriteString("vac_present=")
builder.WriteString(fmt.Sprintf("%v", m.VacPresent))
builder.WriteString(", ")
builder.WriteString("gameban_present=")
builder.WriteString(fmt.Sprintf("%v", m.GamebanPresent))
builder.WriteString(", ")
builder.WriteString("decryption_key=")
builder.WriteString(fmt.Sprintf("%v", m.DecryptionKey))
builder.WriteString(", ")
builder.WriteString("tick_rate=")
builder.WriteString(fmt.Sprintf("%v", m.TickRate))
builder.WriteByte(')')
return builder.String()
}
// Matches is a parsable slice of Match.
type Matches []*Match