// Code generated by ent, DO NOT EDIT. package ent import ( "fmt" "strings" "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 } // 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.loadedTypes[0] { if e.MatchPlayer == nil { // Edge was loaded but was not found. return nil, &NotFoundError{label: matchplayer.Label} } return e.MatchPlayer, nil } 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: return nil, fmt.Errorf("unexpected column %q for type RoundStats", columns[i]) } } return values, nil } // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the RoundStats fields. func (rs *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) } rs.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 { rs.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 { rs.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 { rs.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 { rs.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 { rs.match_player_round_stats = new(int) *rs.match_player_round_stats = int(value.Int64) } } } return nil } // QueryMatchPlayer queries the "match_player" edge of the RoundStats entity. func (rs *RoundStats) QueryMatchPlayer() *MatchPlayerQuery { return NewRoundStatsClient(rs.config).QueryMatchPlayer(rs) } // 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 (rs *RoundStats) Update() *RoundStatsUpdateOne { return NewRoundStatsClient(rs.config).UpdateOne(rs) } // 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 (rs *RoundStats) Unwrap() *RoundStats { _tx, ok := rs.config.driver.(*txDriver) if !ok { panic("ent: RoundStats is not a transactional entity") } rs.config.driver = _tx.drv return rs } // String implements the fmt.Stringer. func (rs *RoundStats) String() string { var builder strings.Builder builder.WriteString("RoundStats(") builder.WriteString(fmt.Sprintf("id=%v, ", rs.ID)) builder.WriteString("round=") builder.WriteString(fmt.Sprintf("%v", rs.Round)) builder.WriteString(", ") builder.WriteString("bank=") builder.WriteString(fmt.Sprintf("%v", rs.Bank)) builder.WriteString(", ") builder.WriteString("equipment=") builder.WriteString(fmt.Sprintf("%v", rs.Equipment)) builder.WriteString(", ") builder.WriteString("spent=") builder.WriteString(fmt.Sprintf("%v", rs.Spent)) builder.WriteByte(')') return builder.String() } // RoundStatsSlice is a parsable slice of RoundStats. type RoundStatsSlice []*RoundStats