// 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/weapon" ) // Weapon is the model entity for the Weapon schema. type Weapon 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 WeaponQuery when eager-loading is set. Edges WeaponEdges `json:"edges"` match_player_weapon_stats *int selectValues sql.SelectValues } // WeaponEdges holds the relations/edges for other nodes in the graph. type WeaponEdges struct { // Stat holds the value of the stat edge. Stat *MatchPlayer `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 WeaponEdges) StatOrErr() (*MatchPlayer, error) { if e.loadedTypes[0] { if e.Stat == nil { // Edge was loaded but was not found. return nil, &NotFoundError{label: matchplayer.Label} } return e.Stat, nil } return nil, &NotLoadedError{edge: "stat"} } // scanValues returns the types for scanning values from sql.Rows. func (*Weapon) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case weapon.FieldID, weapon.FieldVictim, weapon.FieldDmg, weapon.FieldEqType, weapon.FieldHitGroup: values[i] = new(sql.NullInt64) case weapon.ForeignKeys[0]: // match_player_weapon_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 Weapon fields. func (w *Weapon) 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 weapon.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } w.ID = int(value.Int64) case weapon.FieldVictim: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field victim", values[i]) } else if value.Valid { w.Victim = uint64(value.Int64) } case weapon.FieldDmg: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field dmg", values[i]) } else if value.Valid { w.Dmg = uint(value.Int64) } case weapon.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 { w.EqType = int(value.Int64) } case weapon.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 { w.HitGroup = int(value.Int64) } case weapon.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for edge-field match_player_weapon_stats", value) } else if value.Valid { w.match_player_weapon_stats = new(int) *w.match_player_weapon_stats = int(value.Int64) } default: w.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the Weapon. // This includes values selected through modifiers, order, etc. func (w *Weapon) Value(name string) (ent.Value, error) { return w.selectValues.Get(name) } // QueryStat queries the "stat" edge of the Weapon entity. func (w *Weapon) QueryStat() *MatchPlayerQuery { return NewWeaponClient(w.config).QueryStat(w) } // Update returns a builder for updating this Weapon. // Note that you need to call Weapon.Unwrap() before calling this method if this Weapon // was returned from a transaction, and the transaction was committed or rolled back. func (w *Weapon) Update() *WeaponUpdateOne { return NewWeaponClient(w.config).UpdateOne(w) } // Unwrap unwraps the Weapon 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 (w *Weapon) Unwrap() *Weapon { _tx, ok := w.config.driver.(*txDriver) if !ok { panic("ent: Weapon is not a transactional entity") } w.config.driver = _tx.drv return w } // String implements the fmt.Stringer. func (w *Weapon) String() string { var builder strings.Builder builder.WriteString("Weapon(") builder.WriteString(fmt.Sprintf("id=%v, ", w.ID)) builder.WriteString("victim=") builder.WriteString(fmt.Sprintf("%v", w.Victim)) builder.WriteString(", ") builder.WriteString("dmg=") builder.WriteString(fmt.Sprintf("%v", w.Dmg)) builder.WriteString(", ") builder.WriteString("eq_type=") builder.WriteString(fmt.Sprintf("%v", w.EqType)) builder.WriteString(", ") builder.WriteString("hit_group=") builder.WriteString(fmt.Sprintf("%v", w.HitGroup)) builder.WriteByte(')') return builder.String() } // Weapons is a parsable slice of Weapon. type Weapons []*Weapon