Files
csgowtfd/ent/player.go

303 lines
11 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent/dialect/sql"
"git.harting.dev/csgowtf/csgowtfd/ent/player"
)
// Player is the model entity for the Player schema.
type Player struct {
config `json:"-"`
// ID of the ent.
ID uint64 `json:"steamid,string"`
// Name holds the value of the "name" field.
Name string `json:"name,omitempty"`
// Avatar holds the value of the "avatar" field.
Avatar string `json:"avatar,omitempty"`
// VanityURL holds the value of the "vanity_url" field.
VanityURL string `json:"vanity_url,omitempty"`
// VanityURLReal holds the value of the "vanity_url_real" field.
VanityURLReal string `json:"vanity_url_real,omitempty"`
// VacDate holds the value of the "vac_date" field.
VacDate time.Time `json:"vac_date,omitempty"`
// VacCount holds the value of the "vac_count" field.
VacCount int `json:"vac_count,omitempty"`
// GameBanDate holds the value of the "game_ban_date" field.
GameBanDate time.Time `json:"game_ban_date,omitempty"`
// GameBanCount holds the value of the "game_ban_count" field.
GameBanCount int `json:"game_ban_count,omitempty"`
// SteamUpdated holds the value of the "steam_updated" field.
SteamUpdated time.Time `json:"-"`
// SharecodeUpdated holds the value of the "sharecode_updated" field.
SharecodeUpdated time.Time `json:"-"`
// AuthCode holds the value of the "auth_code" field.
AuthCode string `json:"-"`
// ProfileCreated holds the value of the "profile_created" field.
ProfileCreated time.Time `json:"profile_created,omitempty"`
// OldestSharecodeSeen holds the value of the "oldest_sharecode_seen" field.
OldestSharecodeSeen string `json:"oldest_sharecode_seen,omitempty"`
// Wins holds the value of the "wins" field.
Wins int `json:"wins,omitempty"`
// Looses holds the value of the "looses" field.
Looses int `json:"looses,omitempty"`
// Ties holds the value of the "ties" field.
Ties int `json:"ties,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the PlayerQuery when eager-loading is set.
Edges PlayerEdges `json:"edges"`
}
// PlayerEdges holds the relations/edges for other nodes in the graph.
type PlayerEdges struct {
// Stats holds the value of the stats edge.
Stats []*MatchPlayer `json:"stats,omitempty"`
// Matches holds the value of the matches edge.
Matches []*Match `json:"matches,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 PlayerEdges) StatsOrErr() ([]*MatchPlayer, error) {
if e.loadedTypes[0] {
return e.Stats, nil
}
return nil, &NotLoadedError{edge: "stats"}
}
// MatchesOrErr returns the Matches value or an error if the edge
// was not loaded in eager-loading.
func (e PlayerEdges) MatchesOrErr() ([]*Match, error) {
if e.loadedTypes[1] {
return e.Matches, nil
}
return nil, &NotLoadedError{edge: "matches"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Player) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case player.FieldID, player.FieldVacCount, player.FieldGameBanCount, player.FieldWins, player.FieldLooses, player.FieldTies:
values[i] = new(sql.NullInt64)
case player.FieldName, player.FieldAvatar, player.FieldVanityURL, player.FieldVanityURLReal, player.FieldAuthCode, player.FieldOldestSharecodeSeen:
values[i] = new(sql.NullString)
case player.FieldVacDate, player.FieldGameBanDate, player.FieldSteamUpdated, player.FieldSharecodeUpdated, player.FieldProfileCreated:
values[i] = new(sql.NullTime)
default:
return nil, fmt.Errorf("unexpected column %q for type Player", columns[i])
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Player fields.
func (pl *Player) 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 player.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
pl.ID = uint64(value.Int64)
case player.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
pl.Name = value.String
}
case player.FieldAvatar:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field avatar", values[i])
} else if value.Valid {
pl.Avatar = value.String
}
case player.FieldVanityURL:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field vanity_url", values[i])
} else if value.Valid {
pl.VanityURL = value.String
}
case player.FieldVanityURLReal:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field vanity_url_real", values[i])
} else if value.Valid {
pl.VanityURLReal = value.String
}
case player.FieldVacDate:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field vac_date", values[i])
} else if value.Valid {
pl.VacDate = value.Time
}
case player.FieldVacCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field vac_count", values[i])
} else if value.Valid {
pl.VacCount = int(value.Int64)
}
case player.FieldGameBanDate:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field game_ban_date", values[i])
} else if value.Valid {
pl.GameBanDate = value.Time
}
case player.FieldGameBanCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field game_ban_count", values[i])
} else if value.Valid {
pl.GameBanCount = int(value.Int64)
}
case player.FieldSteamUpdated:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field steam_updated", values[i])
} else if value.Valid {
pl.SteamUpdated = value.Time
}
case player.FieldSharecodeUpdated:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field sharecode_updated", values[i])
} else if value.Valid {
pl.SharecodeUpdated = value.Time
}
case player.FieldAuthCode:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field auth_code", values[i])
} else if value.Valid {
pl.AuthCode = value.String
}
case player.FieldProfileCreated:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field profile_created", values[i])
} else if value.Valid {
pl.ProfileCreated = value.Time
}
case player.FieldOldestSharecodeSeen:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field oldest_sharecode_seen", values[i])
} else if value.Valid {
pl.OldestSharecodeSeen = value.String
}
case player.FieldWins:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field wins", values[i])
} else if value.Valid {
pl.Wins = int(value.Int64)
}
case player.FieldLooses:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field looses", values[i])
} else if value.Valid {
pl.Looses = int(value.Int64)
}
case player.FieldTies:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field ties", values[i])
} else if value.Valid {
pl.Ties = int(value.Int64)
}
}
}
return nil
}
// QueryStats queries the "stats" edge of the Player entity.
func (pl *Player) QueryStats() *MatchPlayerQuery {
return NewPlayerClient(pl.config).QueryStats(pl)
}
// QueryMatches queries the "matches" edge of the Player entity.
func (pl *Player) QueryMatches() *MatchQuery {
return NewPlayerClient(pl.config).QueryMatches(pl)
}
// Update returns a builder for updating this Player.
// Note that you need to call Player.Unwrap() before calling this method if this Player
// was returned from a transaction, and the transaction was committed or rolled back.
func (pl *Player) Update() *PlayerUpdateOne {
return NewPlayerClient(pl.config).UpdateOne(pl)
}
// Unwrap unwraps the Player 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 (pl *Player) Unwrap() *Player {
_tx, ok := pl.config.driver.(*txDriver)
if !ok {
panic("ent: Player is not a transactional entity")
}
pl.config.driver = _tx.drv
return pl
}
// String implements the fmt.Stringer.
func (pl *Player) String() string {
var builder strings.Builder
builder.WriteString("Player(")
builder.WriteString(fmt.Sprintf("id=%v, ", pl.ID))
builder.WriteString("name=")
builder.WriteString(pl.Name)
builder.WriteString(", ")
builder.WriteString("avatar=")
builder.WriteString(pl.Avatar)
builder.WriteString(", ")
builder.WriteString("vanity_url=")
builder.WriteString(pl.VanityURL)
builder.WriteString(", ")
builder.WriteString("vanity_url_real=")
builder.WriteString(pl.VanityURLReal)
builder.WriteString(", ")
builder.WriteString("vac_date=")
builder.WriteString(pl.VacDate.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("vac_count=")
builder.WriteString(fmt.Sprintf("%v", pl.VacCount))
builder.WriteString(", ")
builder.WriteString("game_ban_date=")
builder.WriteString(pl.GameBanDate.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("game_ban_count=")
builder.WriteString(fmt.Sprintf("%v", pl.GameBanCount))
builder.WriteString(", ")
builder.WriteString("steam_updated=")
builder.WriteString(pl.SteamUpdated.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("sharecode_updated=")
builder.WriteString(pl.SharecodeUpdated.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("auth_code=<sensitive>")
builder.WriteString(", ")
builder.WriteString("profile_created=")
builder.WriteString(pl.ProfileCreated.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("oldest_sharecode_seen=")
builder.WriteString(pl.OldestSharecodeSeen)
builder.WriteString(", ")
builder.WriteString("wins=")
builder.WriteString(fmt.Sprintf("%v", pl.Wins))
builder.WriteString(", ")
builder.WriteString("looses=")
builder.WriteString(fmt.Sprintf("%v", pl.Looses))
builder.WriteString(", ")
builder.WriteString("ties=")
builder.WriteString(fmt.Sprintf("%v", pl.Ties))
builder.WriteByte(')')
return builder.String()
}
// Players is a parsable slice of Player.
type Players []*Player