Files
csgowtfd/ent/roundstats.go
2025-10-26 05:09:47 +01:00

174 lines
5.9 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/roundstats"
)
// RoundStats is the model entity for the RoundStats schema.
type RoundStats struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// Round holds the value of the "round" field.
Round uint `json:"round,omitempty"`
// Bank holds the value of the "bank" field.
Bank uint `json:"bank,omitempty"`
// Equipment holds the value of the "equipment" field.
Equipment uint `json:"equipment,omitempty"`
// Spent holds the value of the "spent" field.
Spent uint `json:"spent,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the RoundStatsQuery when eager-loading is set.
Edges RoundStatsEdges `json:"edges"`
match_player_round_stats *int
selectValues sql.SelectValues
}
// RoundStatsEdges holds the relations/edges for other nodes in the graph.
type RoundStatsEdges struct {
// MatchPlayer holds the value of the match_player edge.
MatchPlayer *MatchPlayer `json:"match_player,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool
}
// MatchPlayerOrErr returns the MatchPlayer value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e RoundStatsEdges) MatchPlayerOrErr() (*MatchPlayer, error) {
if e.MatchPlayer != nil {
return e.MatchPlayer, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: matchplayer.Label}
}
return nil, &NotLoadedError{edge: "match_player"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*RoundStats) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case roundstats.FieldID, roundstats.FieldRound, roundstats.FieldBank, roundstats.FieldEquipment, roundstats.FieldSpent:
values[i] = new(sql.NullInt64)
case roundstats.ForeignKeys[0]: // match_player_round_stats
values[i] = new(sql.NullInt64)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the RoundStats fields.
func (_m *RoundStats) 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 roundstats.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = int(value.Int64)
case roundstats.FieldRound:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field round", values[i])
} else if value.Valid {
_m.Round = uint(value.Int64)
}
case roundstats.FieldBank:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field bank", values[i])
} else if value.Valid {
_m.Bank = uint(value.Int64)
}
case roundstats.FieldEquipment:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field equipment", values[i])
} else if value.Valid {
_m.Equipment = uint(value.Int64)
}
case roundstats.FieldSpent:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field spent", values[i])
} else if value.Valid {
_m.Spent = uint(value.Int64)
}
case roundstats.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for edge-field match_player_round_stats", value)
} else if value.Valid {
_m.match_player_round_stats = new(int)
*_m.match_player_round_stats = int(value.Int64)
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the RoundStats.
// This includes values selected through modifiers, order, etc.
func (_m *RoundStats) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryMatchPlayer queries the "match_player" edge of the RoundStats entity.
func (_m *RoundStats) QueryMatchPlayer() *MatchPlayerQuery {
return NewRoundStatsClient(_m.config).QueryMatchPlayer(_m)
}
// Update returns a builder for updating this RoundStats.
// Note that you need to call RoundStats.Unwrap() before calling this method if this RoundStats
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *RoundStats) Update() *RoundStatsUpdateOne {
return NewRoundStatsClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the RoundStats 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 *RoundStats) Unwrap() *RoundStats {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: RoundStats is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *RoundStats) String() string {
var builder strings.Builder
builder.WriteString("RoundStats(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("round=")
builder.WriteString(fmt.Sprintf("%v", _m.Round))
builder.WriteString(", ")
builder.WriteString("bank=")
builder.WriteString(fmt.Sprintf("%v", _m.Bank))
builder.WriteString(", ")
builder.WriteString("equipment=")
builder.WriteString(fmt.Sprintf("%v", _m.Equipment))
builder.WriteString(", ")
builder.WriteString("spent=")
builder.WriteString(fmt.Sprintf("%v", _m.Spent))
builder.WriteByte(')')
return builder.String()
}
// RoundStatsSlice is a parsable slice of RoundStats.
type RoundStatsSlice []*RoundStats