Reviewed-on: https://git.harting.dev/CSGOWTF/csgowtfd/pulls/1 Co-authored-by: Giovanni Harting <539@idlegandalf.com> Co-committed-by: Giovanni Harting <539@idlegandalf.com>
170 lines
5.6 KiB
Go
170 lines
5.6 KiB
Go
// Code generated by entc, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"csgowtfd/ent/stats"
|
|
"csgowtfd/ent/weaponstats"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
// WeaponStats is the model entity for the WeaponStats schema.
|
|
type WeaponStats struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// Victim holds the value of the "victim" field.
|
|
Victim uint64 `json:"victim,omitempty"`
|
|
// Dmg holds the value of the "dmg" field.
|
|
Dmg uint `json:"dmg,omitempty"`
|
|
// EqType holds the value of the "eq_type" field.
|
|
EqType int `json:"eq_type,omitempty"`
|
|
// HitGroup holds the value of the "hit_group" field.
|
|
HitGroup int `json:"hit_group,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the WeaponStatsQuery when eager-loading is set.
|
|
Edges WeaponStatsEdges `json:"edges"`
|
|
stats_weapon_stats *int
|
|
}
|
|
|
|
// WeaponStatsEdges holds the relations/edges for other nodes in the graph.
|
|
type WeaponStatsEdges struct {
|
|
// Stat holds the value of the stat edge.
|
|
Stat *Stats `json:"stat,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [1]bool
|
|
}
|
|
|
|
// StatOrErr returns the Stat value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e WeaponStatsEdges) StatOrErr() (*Stats, error) {
|
|
if e.loadedTypes[0] {
|
|
if e.Stat == nil {
|
|
// The edge stat was loaded in eager-loading,
|
|
// but was not found.
|
|
return nil, &NotFoundError{label: stats.Label}
|
|
}
|
|
return e.Stat, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "stat"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*WeaponStats) scanValues(columns []string) ([]interface{}, error) {
|
|
values := make([]interface{}, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case weaponstats.FieldID, weaponstats.FieldVictim, weaponstats.FieldDmg, weaponstats.FieldEqType, weaponstats.FieldHitGroup:
|
|
values[i] = new(sql.NullInt64)
|
|
case weaponstats.ForeignKeys[0]: // stats_weapon_stats
|
|
values[i] = new(sql.NullInt64)
|
|
default:
|
|
return nil, fmt.Errorf("unexpected column %q for type WeaponStats", columns[i])
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the WeaponStats fields.
|
|
func (ws *WeaponStats) 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 weaponstats.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
ws.ID = int(value.Int64)
|
|
case weaponstats.FieldVictim:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field victim", values[i])
|
|
} else if value.Valid {
|
|
ws.Victim = uint64(value.Int64)
|
|
}
|
|
case weaponstats.FieldDmg:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field dmg", values[i])
|
|
} else if value.Valid {
|
|
ws.Dmg = uint(value.Int64)
|
|
}
|
|
case weaponstats.FieldEqType:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field eq_type", values[i])
|
|
} else if value.Valid {
|
|
ws.EqType = int(value.Int64)
|
|
}
|
|
case weaponstats.FieldHitGroup:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field hit_group", values[i])
|
|
} else if value.Valid {
|
|
ws.HitGroup = int(value.Int64)
|
|
}
|
|
case weaponstats.ForeignKeys[0]:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for edge-field stats_weapon_stats", value)
|
|
} else if value.Valid {
|
|
ws.stats_weapon_stats = new(int)
|
|
*ws.stats_weapon_stats = int(value.Int64)
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// QueryStat queries the "stat" edge of the WeaponStats entity.
|
|
func (ws *WeaponStats) QueryStat() *StatsQuery {
|
|
return (&WeaponStatsClient{config: ws.config}).QueryStat(ws)
|
|
}
|
|
|
|
// Update returns a builder for updating this WeaponStats.
|
|
// Note that you need to call WeaponStats.Unwrap() before calling this method if this WeaponStats
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (ws *WeaponStats) Update() *WeaponStatsUpdateOne {
|
|
return (&WeaponStatsClient{config: ws.config}).UpdateOne(ws)
|
|
}
|
|
|
|
// Unwrap unwraps the WeaponStats 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 (ws *WeaponStats) Unwrap() *WeaponStats {
|
|
tx, ok := ws.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: WeaponStats is not a transactional entity")
|
|
}
|
|
ws.config.driver = tx.drv
|
|
return ws
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (ws *WeaponStats) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("WeaponStats(")
|
|
builder.WriteString(fmt.Sprintf("id=%v", ws.ID))
|
|
builder.WriteString(", victim=")
|
|
builder.WriteString(fmt.Sprintf("%v", ws.Victim))
|
|
builder.WriteString(", dmg=")
|
|
builder.WriteString(fmt.Sprintf("%v", ws.Dmg))
|
|
builder.WriteString(", eq_type=")
|
|
builder.WriteString(fmt.Sprintf("%v", ws.EqType))
|
|
builder.WriteString(", hit_group=")
|
|
builder.WriteString(fmt.Sprintf("%v", ws.HitGroup))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// WeaponStatsSlice is a parsable slice of WeaponStats.
|
|
type WeaponStatsSlice []*WeaponStats
|
|
|
|
func (ws WeaponStatsSlice) config(cfg config) {
|
|
for _i := range ws {
|
|
ws[_i].config = cfg
|
|
}
|
|
}
|