156 lines
4.9 KiB
Go
156 lines
4.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/spray"
|
|
)
|
|
|
|
// Spray is the model entity for the Spray schema.
|
|
type Spray struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// Weapon holds the value of the "weapon" field.
|
|
Weapon int `json:"weapon,omitempty"`
|
|
// Spray holds the value of the "spray" field.
|
|
Spray []byte `json:"spray,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the SprayQuery when eager-loading is set.
|
|
Edges SprayEdges `json:"edges"`
|
|
match_player_spray *int
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// SprayEdges holds the relations/edges for other nodes in the graph.
|
|
type SprayEdges struct {
|
|
// MatchPlayers holds the value of the match_players edge.
|
|
MatchPlayers *MatchPlayer `json:"match_players,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [1]bool
|
|
}
|
|
|
|
// MatchPlayersOrErr returns the MatchPlayers value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e SprayEdges) MatchPlayersOrErr() (*MatchPlayer, error) {
|
|
if e.loadedTypes[0] {
|
|
if e.MatchPlayers == nil {
|
|
// Edge was loaded but was not found.
|
|
return nil, &NotFoundError{label: matchplayer.Label}
|
|
}
|
|
return e.MatchPlayers, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "match_players"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*Spray) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case spray.FieldSpray:
|
|
values[i] = new([]byte)
|
|
case spray.FieldID, spray.FieldWeapon:
|
|
values[i] = new(sql.NullInt64)
|
|
case spray.ForeignKeys[0]: // match_player_spray
|
|
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 Spray fields.
|
|
func (s *Spray) 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 spray.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
s.ID = int(value.Int64)
|
|
case spray.FieldWeapon:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field weapon", values[i])
|
|
} else if value.Valid {
|
|
s.Weapon = int(value.Int64)
|
|
}
|
|
case spray.FieldSpray:
|
|
if value, ok := values[i].(*[]byte); !ok {
|
|
return fmt.Errorf("unexpected type %T for field spray", values[i])
|
|
} else if value != nil {
|
|
s.Spray = *value
|
|
}
|
|
case spray.ForeignKeys[0]:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for edge-field match_player_spray", value)
|
|
} else if value.Valid {
|
|
s.match_player_spray = new(int)
|
|
*s.match_player_spray = int(value.Int64)
|
|
}
|
|
default:
|
|
s.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the Spray.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (s *Spray) Value(name string) (ent.Value, error) {
|
|
return s.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryMatchPlayers queries the "match_players" edge of the Spray entity.
|
|
func (s *Spray) QueryMatchPlayers() *MatchPlayerQuery {
|
|
return NewSprayClient(s.config).QueryMatchPlayers(s)
|
|
}
|
|
|
|
// Update returns a builder for updating this Spray.
|
|
// Note that you need to call Spray.Unwrap() before calling this method if this Spray
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (s *Spray) Update() *SprayUpdateOne {
|
|
return NewSprayClient(s.config).UpdateOne(s)
|
|
}
|
|
|
|
// Unwrap unwraps the Spray 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 (s *Spray) Unwrap() *Spray {
|
|
_tx, ok := s.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: Spray is not a transactional entity")
|
|
}
|
|
s.config.driver = _tx.drv
|
|
return s
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (s *Spray) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("Spray(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", s.ID))
|
|
builder.WriteString("weapon=")
|
|
builder.WriteString(fmt.Sprintf("%v", s.Weapon))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("spray=")
|
|
builder.WriteString(fmt.Sprintf("%v", s.Spray))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// Sprays is a parsable slice of Spray.
|
|
type Sprays []*Spray
|