Files
csgowtfd/ent/messages.go

164 lines
5.3 KiB
Go

// Code generated by entc, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"entgo.io/ent/dialect/sql"
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
"git.harting.dev/csgowtf/csgowtfd/ent/messages"
)
// Messages is the model entity for the Messages schema.
type Messages struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// Message holds the value of the "message" field.
Message string `json:"message,omitempty"`
// AllChat holds the value of the "all_chat" field.
AllChat bool `json:"all_chat,omitempty"`
// Tick holds the value of the "tick" field.
Tick int `json:"tick,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the MessagesQuery when eager-loading is set.
Edges MessagesEdges `json:"edges"`
match_player_messages *int
}
// MessagesEdges holds the relations/edges for other nodes in the graph.
type MessagesEdges 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 MessagesEdges) MatchPlayerOrErr() (*MatchPlayer, error) {
if e.loadedTypes[0] {
if e.MatchPlayer == nil {
// The edge match_player was loaded in eager-loading,
// 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 (*Messages) scanValues(columns []string) ([]interface{}, error) {
values := make([]interface{}, len(columns))
for i := range columns {
switch columns[i] {
case messages.FieldAllChat:
values[i] = new(sql.NullBool)
case messages.FieldID, messages.FieldTick:
values[i] = new(sql.NullInt64)
case messages.FieldMessage:
values[i] = new(sql.NullString)
case messages.ForeignKeys[0]: // match_player_messages
values[i] = new(sql.NullInt64)
default:
return nil, fmt.Errorf("unexpected column %q for type Messages", columns[i])
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Messages fields.
func (m *Messages) 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 messages.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 messages.FieldMessage:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field message", values[i])
} else if value.Valid {
m.Message = value.String
}
case messages.FieldAllChat:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field all_chat", values[i])
} else if value.Valid {
m.AllChat = value.Bool
}
case messages.FieldTick:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field tick", values[i])
} else if value.Valid {
m.Tick = int(value.Int64)
}
case messages.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for edge-field match_player_messages", value)
} else if value.Valid {
m.match_player_messages = new(int)
*m.match_player_messages = int(value.Int64)
}
}
}
return nil
}
// QueryMatchPlayer queries the "match_player" edge of the Messages entity.
func (m *Messages) QueryMatchPlayer() *MatchPlayerQuery {
return (&MessagesClient{config: m.config}).QueryMatchPlayer(m)
}
// Update returns a builder for updating this Messages.
// Note that you need to call Messages.Unwrap() before calling this method if this Messages
// was returned from a transaction, and the transaction was committed or rolled back.
func (m *Messages) Update() *MessagesUpdateOne {
return (&MessagesClient{config: m.config}).UpdateOne(m)
}
// Unwrap unwraps the Messages 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 *Messages) Unwrap() *Messages {
tx, ok := m.config.driver.(*txDriver)
if !ok {
panic("ent: Messages is not a transactional entity")
}
m.config.driver = tx.drv
return m
}
// String implements the fmt.Stringer.
func (m *Messages) String() string {
var builder strings.Builder
builder.WriteString("Messages(")
builder.WriteString(fmt.Sprintf("id=%v", m.ID))
builder.WriteString(", message=")
builder.WriteString(m.Message)
builder.WriteString(", all_chat=")
builder.WriteString(fmt.Sprintf("%v", m.AllChat))
builder.WriteString(", tick=")
builder.WriteString(fmt.Sprintf("%v", m.Tick))
builder.WriteByte(')')
return builder.String()
}
// MessagesSlice is a parsable slice of Messages.
type MessagesSlice []*Messages
func (m MessagesSlice) config(cfg config) {
for _i := range m {
m[_i].config = cfg
}
}