Files
csgowtfd/ent/mutation.go

7521 lines
209 KiB
Go

// Code generated by entc, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/match"
"csgowtfd/ent/player"
"csgowtfd/ent/predicate"
"csgowtfd/ent/roundstats"
"csgowtfd/ent/stats"
"csgowtfd/ent/weaponstats"
"fmt"
"sync"
"time"
"entgo.io/ent"
)
const (
// Operation types.
OpCreate = ent.OpCreate
OpDelete = ent.OpDelete
OpDeleteOne = ent.OpDeleteOne
OpUpdate = ent.OpUpdate
OpUpdateOne = ent.OpUpdateOne
// Node types.
TypeMatch = "Match"
TypePlayer = "Player"
TypeRoundStats = "RoundStats"
TypeStats = "Stats"
TypeWeaponStats = "WeaponStats"
)
// MatchMutation represents an operation that mutates the Match nodes in the graph.
type MatchMutation struct {
config
op Op
typ string
id *uint64
share_code *string
_map *string
date *time.Time
score_team_a *int
addscore_team_a *int
score_team_b *int
addscore_team_b *int
replay_url *string
duration *int
addduration *int
match_result *int
addmatch_result *int
max_rounds *int
addmax_rounds *int
demo_parsed *bool
clearedFields map[string]struct{}
stats map[int]struct{}
removedstats map[int]struct{}
clearedstats bool
players map[uint64]struct{}
removedplayers map[uint64]struct{}
clearedplayers bool
done bool
oldValue func(context.Context) (*Match, error)
predicates []predicate.Match
}
var _ ent.Mutation = (*MatchMutation)(nil)
// matchOption allows management of the mutation configuration using functional options.
type matchOption func(*MatchMutation)
// newMatchMutation creates new mutation for the Match entity.
func newMatchMutation(c config, op Op, opts ...matchOption) *MatchMutation {
m := &MatchMutation{
config: c,
op: op,
typ: TypeMatch,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withMatchID sets the ID field of the mutation.
func withMatchID(id uint64) matchOption {
return func(m *MatchMutation) {
var (
err error
once sync.Once
value *Match
)
m.oldValue = func(ctx context.Context) (*Match, error) {
once.Do(func() {
if m.done {
err = fmt.Errorf("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Match.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withMatch sets the old Match of the mutation.
func withMatch(node *Match) matchOption {
return func(m *MatchMutation) {
m.oldValue = func(context.Context) (*Match, error) {
return node, nil
}
m.id = &node.ID
}
}
// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m MatchMutation) Client() *Client {
client := &Client{config: m.config}
client.init()
return client
}
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m MatchMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, fmt.Errorf("ent: mutation is not running in a transaction")
}
tx := &Tx{config: m.config}
tx.init()
return tx, nil
}
// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of Match entities.
func (m *MatchMutation) SetID(id uint64) {
m.id = &id
}
// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *MatchMutation) ID() (id uint64, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// SetShareCode sets the "share_code" field.
func (m *MatchMutation) SetShareCode(s string) {
m.share_code = &s
}
// ShareCode returns the value of the "share_code" field in the mutation.
func (m *MatchMutation) ShareCode() (r string, exists bool) {
v := m.share_code
if v == nil {
return
}
return *v, true
}
// OldShareCode returns the old "share_code" field's value of the Match entity.
// If the Match object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *MatchMutation) OldShareCode(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldShareCode is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldShareCode requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldShareCode: %w", err)
}
return oldValue.ShareCode, nil
}
// ResetShareCode resets all changes to the "share_code" field.
func (m *MatchMutation) ResetShareCode() {
m.share_code = nil
}
// SetMap sets the "map" field.
func (m *MatchMutation) SetMap(s string) {
m._map = &s
}
// Map returns the value of the "map" field in the mutation.
func (m *MatchMutation) Map() (r string, exists bool) {
v := m._map
if v == nil {
return
}
return *v, true
}
// OldMap returns the old "map" field's value of the Match entity.
// If the Match object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *MatchMutation) OldMap(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldMap is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldMap requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMap: %w", err)
}
return oldValue.Map, nil
}
// ClearMap clears the value of the "map" field.
func (m *MatchMutation) ClearMap() {
m._map = nil
m.clearedFields[match.FieldMap] = struct{}{}
}
// MapCleared returns if the "map" field was cleared in this mutation.
func (m *MatchMutation) MapCleared() bool {
_, ok := m.clearedFields[match.FieldMap]
return ok
}
// ResetMap resets all changes to the "map" field.
func (m *MatchMutation) ResetMap() {
m._map = nil
delete(m.clearedFields, match.FieldMap)
}
// SetDate sets the "date" field.
func (m *MatchMutation) SetDate(t time.Time) {
m.date = &t
}
// Date returns the value of the "date" field in the mutation.
func (m *MatchMutation) Date() (r time.Time, exists bool) {
v := m.date
if v == nil {
return
}
return *v, true
}
// OldDate returns the old "date" field's value of the Match entity.
// If the Match object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *MatchMutation) OldDate(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldDate is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldDate requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDate: %w", err)
}
return oldValue.Date, nil
}
// ResetDate resets all changes to the "date" field.
func (m *MatchMutation) ResetDate() {
m.date = nil
}
// SetScoreTeamA sets the "score_team_a" field.
func (m *MatchMutation) SetScoreTeamA(i int) {
m.score_team_a = &i
m.addscore_team_a = nil
}
// ScoreTeamA returns the value of the "score_team_a" field in the mutation.
func (m *MatchMutation) ScoreTeamA() (r int, exists bool) {
v := m.score_team_a
if v == nil {
return
}
return *v, true
}
// OldScoreTeamA returns the old "score_team_a" field's value of the Match entity.
// If the Match object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *MatchMutation) OldScoreTeamA(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldScoreTeamA is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldScoreTeamA requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldScoreTeamA: %w", err)
}
return oldValue.ScoreTeamA, nil
}
// AddScoreTeamA adds i to the "score_team_a" field.
func (m *MatchMutation) AddScoreTeamA(i int) {
if m.addscore_team_a != nil {
*m.addscore_team_a += i
} else {
m.addscore_team_a = &i
}
}
// AddedScoreTeamA returns the value that was added to the "score_team_a" field in this mutation.
func (m *MatchMutation) AddedScoreTeamA() (r int, exists bool) {
v := m.addscore_team_a
if v == nil {
return
}
return *v, true
}
// ResetScoreTeamA resets all changes to the "score_team_a" field.
func (m *MatchMutation) ResetScoreTeamA() {
m.score_team_a = nil
m.addscore_team_a = nil
}
// SetScoreTeamB sets the "score_team_b" field.
func (m *MatchMutation) SetScoreTeamB(i int) {
m.score_team_b = &i
m.addscore_team_b = nil
}
// ScoreTeamB returns the value of the "score_team_b" field in the mutation.
func (m *MatchMutation) ScoreTeamB() (r int, exists bool) {
v := m.score_team_b
if v == nil {
return
}
return *v, true
}
// OldScoreTeamB returns the old "score_team_b" field's value of the Match entity.
// If the Match object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *MatchMutation) OldScoreTeamB(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldScoreTeamB is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldScoreTeamB requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldScoreTeamB: %w", err)
}
return oldValue.ScoreTeamB, nil
}
// AddScoreTeamB adds i to the "score_team_b" field.
func (m *MatchMutation) AddScoreTeamB(i int) {
if m.addscore_team_b != nil {
*m.addscore_team_b += i
} else {
m.addscore_team_b = &i
}
}
// AddedScoreTeamB returns the value that was added to the "score_team_b" field in this mutation.
func (m *MatchMutation) AddedScoreTeamB() (r int, exists bool) {
v := m.addscore_team_b
if v == nil {
return
}
return *v, true
}
// ResetScoreTeamB resets all changes to the "score_team_b" field.
func (m *MatchMutation) ResetScoreTeamB() {
m.score_team_b = nil
m.addscore_team_b = nil
}
// SetReplayURL sets the "replay_url" field.
func (m *MatchMutation) SetReplayURL(s string) {
m.replay_url = &s
}
// ReplayURL returns the value of the "replay_url" field in the mutation.
func (m *MatchMutation) ReplayURL() (r string, exists bool) {
v := m.replay_url
if v == nil {
return
}
return *v, true
}
// OldReplayURL returns the old "replay_url" field's value of the Match entity.
// If the Match object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *MatchMutation) OldReplayURL(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldReplayURL is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldReplayURL requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldReplayURL: %w", err)
}
return oldValue.ReplayURL, nil
}
// ClearReplayURL clears the value of the "replay_url" field.
func (m *MatchMutation) ClearReplayURL() {
m.replay_url = nil
m.clearedFields[match.FieldReplayURL] = struct{}{}
}
// ReplayURLCleared returns if the "replay_url" field was cleared in this mutation.
func (m *MatchMutation) ReplayURLCleared() bool {
_, ok := m.clearedFields[match.FieldReplayURL]
return ok
}
// ResetReplayURL resets all changes to the "replay_url" field.
func (m *MatchMutation) ResetReplayURL() {
m.replay_url = nil
delete(m.clearedFields, match.FieldReplayURL)
}
// SetDuration sets the "duration" field.
func (m *MatchMutation) SetDuration(i int) {
m.duration = &i
m.addduration = nil
}
// Duration returns the value of the "duration" field in the mutation.
func (m *MatchMutation) Duration() (r int, exists bool) {
v := m.duration
if v == nil {
return
}
return *v, true
}
// OldDuration returns the old "duration" field's value of the Match entity.
// If the Match object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *MatchMutation) OldDuration(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldDuration is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldDuration requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDuration: %w", err)
}
return oldValue.Duration, nil
}
// AddDuration adds i to the "duration" field.
func (m *MatchMutation) AddDuration(i int) {
if m.addduration != nil {
*m.addduration += i
} else {
m.addduration = &i
}
}
// AddedDuration returns the value that was added to the "duration" field in this mutation.
func (m *MatchMutation) AddedDuration() (r int, exists bool) {
v := m.addduration
if v == nil {
return
}
return *v, true
}
// ResetDuration resets all changes to the "duration" field.
func (m *MatchMutation) ResetDuration() {
m.duration = nil
m.addduration = nil
}
// SetMatchResult sets the "match_result" field.
func (m *MatchMutation) SetMatchResult(i int) {
m.match_result = &i
m.addmatch_result = nil
}
// MatchResult returns the value of the "match_result" field in the mutation.
func (m *MatchMutation) MatchResult() (r int, exists bool) {
v := m.match_result
if v == nil {
return
}
return *v, true
}
// OldMatchResult returns the old "match_result" field's value of the Match entity.
// If the Match object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *MatchMutation) OldMatchResult(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldMatchResult is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldMatchResult requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMatchResult: %w", err)
}
return oldValue.MatchResult, nil
}
// AddMatchResult adds i to the "match_result" field.
func (m *MatchMutation) AddMatchResult(i int) {
if m.addmatch_result != nil {
*m.addmatch_result += i
} else {
m.addmatch_result = &i
}
}
// AddedMatchResult returns the value that was added to the "match_result" field in this mutation.
func (m *MatchMutation) AddedMatchResult() (r int, exists bool) {
v := m.addmatch_result
if v == nil {
return
}
return *v, true
}
// ResetMatchResult resets all changes to the "match_result" field.
func (m *MatchMutation) ResetMatchResult() {
m.match_result = nil
m.addmatch_result = nil
}
// SetMaxRounds sets the "max_rounds" field.
func (m *MatchMutation) SetMaxRounds(i int) {
m.max_rounds = &i
m.addmax_rounds = nil
}
// MaxRounds returns the value of the "max_rounds" field in the mutation.
func (m *MatchMutation) MaxRounds() (r int, exists bool) {
v := m.max_rounds
if v == nil {
return
}
return *v, true
}
// OldMaxRounds returns the old "max_rounds" field's value of the Match entity.
// If the Match object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *MatchMutation) OldMaxRounds(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldMaxRounds is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldMaxRounds requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMaxRounds: %w", err)
}
return oldValue.MaxRounds, nil
}
// AddMaxRounds adds i to the "max_rounds" field.
func (m *MatchMutation) AddMaxRounds(i int) {
if m.addmax_rounds != nil {
*m.addmax_rounds += i
} else {
m.addmax_rounds = &i
}
}
// AddedMaxRounds returns the value that was added to the "max_rounds" field in this mutation.
func (m *MatchMutation) AddedMaxRounds() (r int, exists bool) {
v := m.addmax_rounds
if v == nil {
return
}
return *v, true
}
// ResetMaxRounds resets all changes to the "max_rounds" field.
func (m *MatchMutation) ResetMaxRounds() {
m.max_rounds = nil
m.addmax_rounds = nil
}
// SetDemoParsed sets the "demo_parsed" field.
func (m *MatchMutation) SetDemoParsed(b bool) {
m.demo_parsed = &b
}
// DemoParsed returns the value of the "demo_parsed" field in the mutation.
func (m *MatchMutation) DemoParsed() (r bool, exists bool) {
v := m.demo_parsed
if v == nil {
return
}
return *v, true
}
// OldDemoParsed returns the old "demo_parsed" field's value of the Match entity.
// If the Match object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *MatchMutation) OldDemoParsed(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldDemoParsed is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldDemoParsed requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDemoParsed: %w", err)
}
return oldValue.DemoParsed, nil
}
// ResetDemoParsed resets all changes to the "demo_parsed" field.
func (m *MatchMutation) ResetDemoParsed() {
m.demo_parsed = nil
}
// AddStatIDs adds the "stats" edge to the Stats entity by ids.
func (m *MatchMutation) AddStatIDs(ids ...int) {
if m.stats == nil {
m.stats = make(map[int]struct{})
}
for i := range ids {
m.stats[ids[i]] = struct{}{}
}
}
// ClearStats clears the "stats" edge to the Stats entity.
func (m *MatchMutation) ClearStats() {
m.clearedstats = true
}
// StatsCleared reports if the "stats" edge to the Stats entity was cleared.
func (m *MatchMutation) StatsCleared() bool {
return m.clearedstats
}
// RemoveStatIDs removes the "stats" edge to the Stats entity by IDs.
func (m *MatchMutation) RemoveStatIDs(ids ...int) {
if m.removedstats == nil {
m.removedstats = make(map[int]struct{})
}
for i := range ids {
delete(m.stats, ids[i])
m.removedstats[ids[i]] = struct{}{}
}
}
// RemovedStats returns the removed IDs of the "stats" edge to the Stats entity.
func (m *MatchMutation) RemovedStatsIDs() (ids []int) {
for id := range m.removedstats {
ids = append(ids, id)
}
return
}
// StatsIDs returns the "stats" edge IDs in the mutation.
func (m *MatchMutation) StatsIDs() (ids []int) {
for id := range m.stats {
ids = append(ids, id)
}
return
}
// ResetStats resets all changes to the "stats" edge.
func (m *MatchMutation) ResetStats() {
m.stats = nil
m.clearedstats = false
m.removedstats = nil
}
// AddPlayerIDs adds the "players" edge to the Player entity by ids.
func (m *MatchMutation) AddPlayerIDs(ids ...uint64) {
if m.players == nil {
m.players = make(map[uint64]struct{})
}
for i := range ids {
m.players[ids[i]] = struct{}{}
}
}
// ClearPlayers clears the "players" edge to the Player entity.
func (m *MatchMutation) ClearPlayers() {
m.clearedplayers = true
}
// PlayersCleared reports if the "players" edge to the Player entity was cleared.
func (m *MatchMutation) PlayersCleared() bool {
return m.clearedplayers
}
// RemovePlayerIDs removes the "players" edge to the Player entity by IDs.
func (m *MatchMutation) RemovePlayerIDs(ids ...uint64) {
if m.removedplayers == nil {
m.removedplayers = make(map[uint64]struct{})
}
for i := range ids {
delete(m.players, ids[i])
m.removedplayers[ids[i]] = struct{}{}
}
}
// RemovedPlayers returns the removed IDs of the "players" edge to the Player entity.
func (m *MatchMutation) RemovedPlayersIDs() (ids []uint64) {
for id := range m.removedplayers {
ids = append(ids, id)
}
return
}
// PlayersIDs returns the "players" edge IDs in the mutation.
func (m *MatchMutation) PlayersIDs() (ids []uint64) {
for id := range m.players {
ids = append(ids, id)
}
return
}
// ResetPlayers resets all changes to the "players" edge.
func (m *MatchMutation) ResetPlayers() {
m.players = nil
m.clearedplayers = false
m.removedplayers = nil
}
// Where appends a list predicates to the MatchMutation builder.
func (m *MatchMutation) Where(ps ...predicate.Match) {
m.predicates = append(m.predicates, ps...)
}
// Op returns the operation name.
func (m *MatchMutation) Op() Op {
return m.op
}
// Type returns the node type of this mutation (Match).
func (m *MatchMutation) Type() string {
return m.typ
}
// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *MatchMutation) Fields() []string {
fields := make([]string, 0, 10)
if m.share_code != nil {
fields = append(fields, match.FieldShareCode)
}
if m._map != nil {
fields = append(fields, match.FieldMap)
}
if m.date != nil {
fields = append(fields, match.FieldDate)
}
if m.score_team_a != nil {
fields = append(fields, match.FieldScoreTeamA)
}
if m.score_team_b != nil {
fields = append(fields, match.FieldScoreTeamB)
}
if m.replay_url != nil {
fields = append(fields, match.FieldReplayURL)
}
if m.duration != nil {
fields = append(fields, match.FieldDuration)
}
if m.match_result != nil {
fields = append(fields, match.FieldMatchResult)
}
if m.max_rounds != nil {
fields = append(fields, match.FieldMaxRounds)
}
if m.demo_parsed != nil {
fields = append(fields, match.FieldDemoParsed)
}
return fields
}
// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *MatchMutation) Field(name string) (ent.Value, bool) {
switch name {
case match.FieldShareCode:
return m.ShareCode()
case match.FieldMap:
return m.Map()
case match.FieldDate:
return m.Date()
case match.FieldScoreTeamA:
return m.ScoreTeamA()
case match.FieldScoreTeamB:
return m.ScoreTeamB()
case match.FieldReplayURL:
return m.ReplayURL()
case match.FieldDuration:
return m.Duration()
case match.FieldMatchResult:
return m.MatchResult()
case match.FieldMaxRounds:
return m.MaxRounds()
case match.FieldDemoParsed:
return m.DemoParsed()
}
return nil, false
}
// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *MatchMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case match.FieldShareCode:
return m.OldShareCode(ctx)
case match.FieldMap:
return m.OldMap(ctx)
case match.FieldDate:
return m.OldDate(ctx)
case match.FieldScoreTeamA:
return m.OldScoreTeamA(ctx)
case match.FieldScoreTeamB:
return m.OldScoreTeamB(ctx)
case match.FieldReplayURL:
return m.OldReplayURL(ctx)
case match.FieldDuration:
return m.OldDuration(ctx)
case match.FieldMatchResult:
return m.OldMatchResult(ctx)
case match.FieldMaxRounds:
return m.OldMaxRounds(ctx)
case match.FieldDemoParsed:
return m.OldDemoParsed(ctx)
}
return nil, fmt.Errorf("unknown Match field %s", name)
}
// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *MatchMutation) SetField(name string, value ent.Value) error {
switch name {
case match.FieldShareCode:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetShareCode(v)
return nil
case match.FieldMap:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMap(v)
return nil
case match.FieldDate:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDate(v)
return nil
case match.FieldScoreTeamA:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetScoreTeamA(v)
return nil
case match.FieldScoreTeamB:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetScoreTeamB(v)
return nil
case match.FieldReplayURL:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetReplayURL(v)
return nil
case match.FieldDuration:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDuration(v)
return nil
case match.FieldMatchResult:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMatchResult(v)
return nil
case match.FieldMaxRounds:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMaxRounds(v)
return nil
case match.FieldDemoParsed:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDemoParsed(v)
return nil
}
return fmt.Errorf("unknown Match field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *MatchMutation) AddedFields() []string {
var fields []string
if m.addscore_team_a != nil {
fields = append(fields, match.FieldScoreTeamA)
}
if m.addscore_team_b != nil {
fields = append(fields, match.FieldScoreTeamB)
}
if m.addduration != nil {
fields = append(fields, match.FieldDuration)
}
if m.addmatch_result != nil {
fields = append(fields, match.FieldMatchResult)
}
if m.addmax_rounds != nil {
fields = append(fields, match.FieldMaxRounds)
}
return fields
}
// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *MatchMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case match.FieldScoreTeamA:
return m.AddedScoreTeamA()
case match.FieldScoreTeamB:
return m.AddedScoreTeamB()
case match.FieldDuration:
return m.AddedDuration()
case match.FieldMatchResult:
return m.AddedMatchResult()
case match.FieldMaxRounds:
return m.AddedMaxRounds()
}
return nil, false
}
// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *MatchMutation) AddField(name string, value ent.Value) error {
switch name {
case match.FieldScoreTeamA:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddScoreTeamA(v)
return nil
case match.FieldScoreTeamB:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddScoreTeamB(v)
return nil
case match.FieldDuration:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddDuration(v)
return nil
case match.FieldMatchResult:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddMatchResult(v)
return nil
case match.FieldMaxRounds:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddMaxRounds(v)
return nil
}
return fmt.Errorf("unknown Match numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *MatchMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(match.FieldMap) {
fields = append(fields, match.FieldMap)
}
if m.FieldCleared(match.FieldReplayURL) {
fields = append(fields, match.FieldReplayURL)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *MatchMutation) FieldCleared(name string) bool {
_, ok := m.clearedFields[name]
return ok
}
// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *MatchMutation) ClearField(name string) error {
switch name {
case match.FieldMap:
m.ClearMap()
return nil
case match.FieldReplayURL:
m.ClearReplayURL()
return nil
}
return fmt.Errorf("unknown Match nullable field %s", name)
}
// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *MatchMutation) ResetField(name string) error {
switch name {
case match.FieldShareCode:
m.ResetShareCode()
return nil
case match.FieldMap:
m.ResetMap()
return nil
case match.FieldDate:
m.ResetDate()
return nil
case match.FieldScoreTeamA:
m.ResetScoreTeamA()
return nil
case match.FieldScoreTeamB:
m.ResetScoreTeamB()
return nil
case match.FieldReplayURL:
m.ResetReplayURL()
return nil
case match.FieldDuration:
m.ResetDuration()
return nil
case match.FieldMatchResult:
m.ResetMatchResult()
return nil
case match.FieldMaxRounds:
m.ResetMaxRounds()
return nil
case match.FieldDemoParsed:
m.ResetDemoParsed()
return nil
}
return fmt.Errorf("unknown Match field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *MatchMutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.stats != nil {
edges = append(edges, match.EdgeStats)
}
if m.players != nil {
edges = append(edges, match.EdgePlayers)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *MatchMutation) AddedIDs(name string) []ent.Value {
switch name {
case match.EdgeStats:
ids := make([]ent.Value, 0, len(m.stats))
for id := range m.stats {
ids = append(ids, id)
}
return ids
case match.EdgePlayers:
ids := make([]ent.Value, 0, len(m.players))
for id := range m.players {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *MatchMutation) RemovedEdges() []string {
edges := make([]string, 0, 2)
if m.removedstats != nil {
edges = append(edges, match.EdgeStats)
}
if m.removedplayers != nil {
edges = append(edges, match.EdgePlayers)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *MatchMutation) RemovedIDs(name string) []ent.Value {
switch name {
case match.EdgeStats:
ids := make([]ent.Value, 0, len(m.removedstats))
for id := range m.removedstats {
ids = append(ids, id)
}
return ids
case match.EdgePlayers:
ids := make([]ent.Value, 0, len(m.removedplayers))
for id := range m.removedplayers {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *MatchMutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.clearedstats {
edges = append(edges, match.EdgeStats)
}
if m.clearedplayers {
edges = append(edges, match.EdgePlayers)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *MatchMutation) EdgeCleared(name string) bool {
switch name {
case match.EdgeStats:
return m.clearedstats
case match.EdgePlayers:
return m.clearedplayers
}
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *MatchMutation) ClearEdge(name string) error {
switch name {
}
return fmt.Errorf("unknown Match unique edge %s", name)
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *MatchMutation) ResetEdge(name string) error {
switch name {
case match.EdgeStats:
m.ResetStats()
return nil
case match.EdgePlayers:
m.ResetPlayers()
return nil
}
return fmt.Errorf("unknown Match edge %s", name)
}
// PlayerMutation represents an operation that mutates the Player nodes in the graph.
type PlayerMutation struct {
config
op Op
typ string
id *uint64
name *string
avatar *string
vanity_url *string
vanity_url_real *string
vac_date *time.Time
vac_count *int
addvac_count *int
game_ban_date *time.Time
game_ban_count *int
addgame_ban_count *int
steam_updated *time.Time
sharecode_updated *time.Time
auth_code *string
profile_created *time.Time
oldest_sharecode_seen *string
clearedFields map[string]struct{}
stats map[int]struct{}
removedstats map[int]struct{}
clearedstats bool
matches map[uint64]struct{}
removedmatches map[uint64]struct{}
clearedmatches bool
done bool
oldValue func(context.Context) (*Player, error)
predicates []predicate.Player
}
var _ ent.Mutation = (*PlayerMutation)(nil)
// playerOption allows management of the mutation configuration using functional options.
type playerOption func(*PlayerMutation)
// newPlayerMutation creates new mutation for the Player entity.
func newPlayerMutation(c config, op Op, opts ...playerOption) *PlayerMutation {
m := &PlayerMutation{
config: c,
op: op,
typ: TypePlayer,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withPlayerID sets the ID field of the mutation.
func withPlayerID(id uint64) playerOption {
return func(m *PlayerMutation) {
var (
err error
once sync.Once
value *Player
)
m.oldValue = func(ctx context.Context) (*Player, error) {
once.Do(func() {
if m.done {
err = fmt.Errorf("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Player.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withPlayer sets the old Player of the mutation.
func withPlayer(node *Player) playerOption {
return func(m *PlayerMutation) {
m.oldValue = func(context.Context) (*Player, error) {
return node, nil
}
m.id = &node.ID
}
}
// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m PlayerMutation) Client() *Client {
client := &Client{config: m.config}
client.init()
return client
}
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m PlayerMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, fmt.Errorf("ent: mutation is not running in a transaction")
}
tx := &Tx{config: m.config}
tx.init()
return tx, nil
}
// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of Player entities.
func (m *PlayerMutation) SetID(id uint64) {
m.id = &id
}
// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *PlayerMutation) ID() (id uint64, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// SetName sets the "name" field.
func (m *PlayerMutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
func (m *PlayerMutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
return
}
return *v, true
}
// OldName returns the old "name" field's value of the Player entity.
// If the Player object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PlayerMutation) OldName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldName is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldName requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldName: %w", err)
}
return oldValue.Name, nil
}
// ClearName clears the value of the "name" field.
func (m *PlayerMutation) ClearName() {
m.name = nil
m.clearedFields[player.FieldName] = struct{}{}
}
// NameCleared returns if the "name" field was cleared in this mutation.
func (m *PlayerMutation) NameCleared() bool {
_, ok := m.clearedFields[player.FieldName]
return ok
}
// ResetName resets all changes to the "name" field.
func (m *PlayerMutation) ResetName() {
m.name = nil
delete(m.clearedFields, player.FieldName)
}
// SetAvatar sets the "avatar" field.
func (m *PlayerMutation) SetAvatar(s string) {
m.avatar = &s
}
// Avatar returns the value of the "avatar" field in the mutation.
func (m *PlayerMutation) Avatar() (r string, exists bool) {
v := m.avatar
if v == nil {
return
}
return *v, true
}
// OldAvatar returns the old "avatar" field's value of the Player entity.
// If the Player object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PlayerMutation) OldAvatar(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldAvatar is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldAvatar requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
}
return oldValue.Avatar, nil
}
// ClearAvatar clears the value of the "avatar" field.
func (m *PlayerMutation) ClearAvatar() {
m.avatar = nil
m.clearedFields[player.FieldAvatar] = struct{}{}
}
// AvatarCleared returns if the "avatar" field was cleared in this mutation.
func (m *PlayerMutation) AvatarCleared() bool {
_, ok := m.clearedFields[player.FieldAvatar]
return ok
}
// ResetAvatar resets all changes to the "avatar" field.
func (m *PlayerMutation) ResetAvatar() {
m.avatar = nil
delete(m.clearedFields, player.FieldAvatar)
}
// SetVanityURL sets the "vanity_url" field.
func (m *PlayerMutation) SetVanityURL(s string) {
m.vanity_url = &s
}
// VanityURL returns the value of the "vanity_url" field in the mutation.
func (m *PlayerMutation) VanityURL() (r string, exists bool) {
v := m.vanity_url
if v == nil {
return
}
return *v, true
}
// OldVanityURL returns the old "vanity_url" field's value of the Player entity.
// If the Player object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PlayerMutation) OldVanityURL(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldVanityURL is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldVanityURL requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldVanityURL: %w", err)
}
return oldValue.VanityURL, nil
}
// ClearVanityURL clears the value of the "vanity_url" field.
func (m *PlayerMutation) ClearVanityURL() {
m.vanity_url = nil
m.clearedFields[player.FieldVanityURL] = struct{}{}
}
// VanityURLCleared returns if the "vanity_url" field was cleared in this mutation.
func (m *PlayerMutation) VanityURLCleared() bool {
_, ok := m.clearedFields[player.FieldVanityURL]
return ok
}
// ResetVanityURL resets all changes to the "vanity_url" field.
func (m *PlayerMutation) ResetVanityURL() {
m.vanity_url = nil
delete(m.clearedFields, player.FieldVanityURL)
}
// SetVanityURLReal sets the "vanity_url_real" field.
func (m *PlayerMutation) SetVanityURLReal(s string) {
m.vanity_url_real = &s
}
// VanityURLReal returns the value of the "vanity_url_real" field in the mutation.
func (m *PlayerMutation) VanityURLReal() (r string, exists bool) {
v := m.vanity_url_real
if v == nil {
return
}
return *v, true
}
// OldVanityURLReal returns the old "vanity_url_real" field's value of the Player entity.
// If the Player object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PlayerMutation) OldVanityURLReal(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldVanityURLReal is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldVanityURLReal requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldVanityURLReal: %w", err)
}
return oldValue.VanityURLReal, nil
}
// ClearVanityURLReal clears the value of the "vanity_url_real" field.
func (m *PlayerMutation) ClearVanityURLReal() {
m.vanity_url_real = nil
m.clearedFields[player.FieldVanityURLReal] = struct{}{}
}
// VanityURLRealCleared returns if the "vanity_url_real" field was cleared in this mutation.
func (m *PlayerMutation) VanityURLRealCleared() bool {
_, ok := m.clearedFields[player.FieldVanityURLReal]
return ok
}
// ResetVanityURLReal resets all changes to the "vanity_url_real" field.
func (m *PlayerMutation) ResetVanityURLReal() {
m.vanity_url_real = nil
delete(m.clearedFields, player.FieldVanityURLReal)
}
// SetVacDate sets the "vac_date" field.
func (m *PlayerMutation) SetVacDate(t time.Time) {
m.vac_date = &t
}
// VacDate returns the value of the "vac_date" field in the mutation.
func (m *PlayerMutation) VacDate() (r time.Time, exists bool) {
v := m.vac_date
if v == nil {
return
}
return *v, true
}
// OldVacDate returns the old "vac_date" field's value of the Player entity.
// If the Player object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PlayerMutation) OldVacDate(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldVacDate is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldVacDate requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldVacDate: %w", err)
}
return oldValue.VacDate, nil
}
// ClearVacDate clears the value of the "vac_date" field.
func (m *PlayerMutation) ClearVacDate() {
m.vac_date = nil
m.clearedFields[player.FieldVacDate] = struct{}{}
}
// VacDateCleared returns if the "vac_date" field was cleared in this mutation.
func (m *PlayerMutation) VacDateCleared() bool {
_, ok := m.clearedFields[player.FieldVacDate]
return ok
}
// ResetVacDate resets all changes to the "vac_date" field.
func (m *PlayerMutation) ResetVacDate() {
m.vac_date = nil
delete(m.clearedFields, player.FieldVacDate)
}
// SetVacCount sets the "vac_count" field.
func (m *PlayerMutation) SetVacCount(i int) {
m.vac_count = &i
m.addvac_count = nil
}
// VacCount returns the value of the "vac_count" field in the mutation.
func (m *PlayerMutation) VacCount() (r int, exists bool) {
v := m.vac_count
if v == nil {
return
}
return *v, true
}
// OldVacCount returns the old "vac_count" field's value of the Player entity.
// If the Player object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PlayerMutation) OldVacCount(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldVacCount is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldVacCount requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldVacCount: %w", err)
}
return oldValue.VacCount, nil
}
// AddVacCount adds i to the "vac_count" field.
func (m *PlayerMutation) AddVacCount(i int) {
if m.addvac_count != nil {
*m.addvac_count += i
} else {
m.addvac_count = &i
}
}
// AddedVacCount returns the value that was added to the "vac_count" field in this mutation.
func (m *PlayerMutation) AddedVacCount() (r int, exists bool) {
v := m.addvac_count
if v == nil {
return
}
return *v, true
}
// ClearVacCount clears the value of the "vac_count" field.
func (m *PlayerMutation) ClearVacCount() {
m.vac_count = nil
m.addvac_count = nil
m.clearedFields[player.FieldVacCount] = struct{}{}
}
// VacCountCleared returns if the "vac_count" field was cleared in this mutation.
func (m *PlayerMutation) VacCountCleared() bool {
_, ok := m.clearedFields[player.FieldVacCount]
return ok
}
// ResetVacCount resets all changes to the "vac_count" field.
func (m *PlayerMutation) ResetVacCount() {
m.vac_count = nil
m.addvac_count = nil
delete(m.clearedFields, player.FieldVacCount)
}
// SetGameBanDate sets the "game_ban_date" field.
func (m *PlayerMutation) SetGameBanDate(t time.Time) {
m.game_ban_date = &t
}
// GameBanDate returns the value of the "game_ban_date" field in the mutation.
func (m *PlayerMutation) GameBanDate() (r time.Time, exists bool) {
v := m.game_ban_date
if v == nil {
return
}
return *v, true
}
// OldGameBanDate returns the old "game_ban_date" field's value of the Player entity.
// If the Player object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PlayerMutation) OldGameBanDate(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldGameBanDate is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldGameBanDate requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldGameBanDate: %w", err)
}
return oldValue.GameBanDate, nil
}
// ClearGameBanDate clears the value of the "game_ban_date" field.
func (m *PlayerMutation) ClearGameBanDate() {
m.game_ban_date = nil
m.clearedFields[player.FieldGameBanDate] = struct{}{}
}
// GameBanDateCleared returns if the "game_ban_date" field was cleared in this mutation.
func (m *PlayerMutation) GameBanDateCleared() bool {
_, ok := m.clearedFields[player.FieldGameBanDate]
return ok
}
// ResetGameBanDate resets all changes to the "game_ban_date" field.
func (m *PlayerMutation) ResetGameBanDate() {
m.game_ban_date = nil
delete(m.clearedFields, player.FieldGameBanDate)
}
// SetGameBanCount sets the "game_ban_count" field.
func (m *PlayerMutation) SetGameBanCount(i int) {
m.game_ban_count = &i
m.addgame_ban_count = nil
}
// GameBanCount returns the value of the "game_ban_count" field in the mutation.
func (m *PlayerMutation) GameBanCount() (r int, exists bool) {
v := m.game_ban_count
if v == nil {
return
}
return *v, true
}
// OldGameBanCount returns the old "game_ban_count" field's value of the Player entity.
// If the Player object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PlayerMutation) OldGameBanCount(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldGameBanCount is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldGameBanCount requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldGameBanCount: %w", err)
}
return oldValue.GameBanCount, nil
}
// AddGameBanCount adds i to the "game_ban_count" field.
func (m *PlayerMutation) AddGameBanCount(i int) {
if m.addgame_ban_count != nil {
*m.addgame_ban_count += i
} else {
m.addgame_ban_count = &i
}
}
// AddedGameBanCount returns the value that was added to the "game_ban_count" field in this mutation.
func (m *PlayerMutation) AddedGameBanCount() (r int, exists bool) {
v := m.addgame_ban_count
if v == nil {
return
}
return *v, true
}
// ClearGameBanCount clears the value of the "game_ban_count" field.
func (m *PlayerMutation) ClearGameBanCount() {
m.game_ban_count = nil
m.addgame_ban_count = nil
m.clearedFields[player.FieldGameBanCount] = struct{}{}
}
// GameBanCountCleared returns if the "game_ban_count" field was cleared in this mutation.
func (m *PlayerMutation) GameBanCountCleared() bool {
_, ok := m.clearedFields[player.FieldGameBanCount]
return ok
}
// ResetGameBanCount resets all changes to the "game_ban_count" field.
func (m *PlayerMutation) ResetGameBanCount() {
m.game_ban_count = nil
m.addgame_ban_count = nil
delete(m.clearedFields, player.FieldGameBanCount)
}
// SetSteamUpdated sets the "steam_updated" field.
func (m *PlayerMutation) SetSteamUpdated(t time.Time) {
m.steam_updated = &t
}
// SteamUpdated returns the value of the "steam_updated" field in the mutation.
func (m *PlayerMutation) SteamUpdated() (r time.Time, exists bool) {
v := m.steam_updated
if v == nil {
return
}
return *v, true
}
// OldSteamUpdated returns the old "steam_updated" field's value of the Player entity.
// If the Player object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PlayerMutation) OldSteamUpdated(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldSteamUpdated is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldSteamUpdated requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSteamUpdated: %w", err)
}
return oldValue.SteamUpdated, nil
}
// ResetSteamUpdated resets all changes to the "steam_updated" field.
func (m *PlayerMutation) ResetSteamUpdated() {
m.steam_updated = nil
}
// SetSharecodeUpdated sets the "sharecode_updated" field.
func (m *PlayerMutation) SetSharecodeUpdated(t time.Time) {
m.sharecode_updated = &t
}
// SharecodeUpdated returns the value of the "sharecode_updated" field in the mutation.
func (m *PlayerMutation) SharecodeUpdated() (r time.Time, exists bool) {
v := m.sharecode_updated
if v == nil {
return
}
return *v, true
}
// OldSharecodeUpdated returns the old "sharecode_updated" field's value of the Player entity.
// If the Player object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PlayerMutation) OldSharecodeUpdated(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldSharecodeUpdated is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldSharecodeUpdated requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSharecodeUpdated: %w", err)
}
return oldValue.SharecodeUpdated, nil
}
// ClearSharecodeUpdated clears the value of the "sharecode_updated" field.
func (m *PlayerMutation) ClearSharecodeUpdated() {
m.sharecode_updated = nil
m.clearedFields[player.FieldSharecodeUpdated] = struct{}{}
}
// SharecodeUpdatedCleared returns if the "sharecode_updated" field was cleared in this mutation.
func (m *PlayerMutation) SharecodeUpdatedCleared() bool {
_, ok := m.clearedFields[player.FieldSharecodeUpdated]
return ok
}
// ResetSharecodeUpdated resets all changes to the "sharecode_updated" field.
func (m *PlayerMutation) ResetSharecodeUpdated() {
m.sharecode_updated = nil
delete(m.clearedFields, player.FieldSharecodeUpdated)
}
// SetAuthCode sets the "auth_code" field.
func (m *PlayerMutation) SetAuthCode(s string) {
m.auth_code = &s
}
// AuthCode returns the value of the "auth_code" field in the mutation.
func (m *PlayerMutation) AuthCode() (r string, exists bool) {
v := m.auth_code
if v == nil {
return
}
return *v, true
}
// OldAuthCode returns the old "auth_code" field's value of the Player entity.
// If the Player object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PlayerMutation) OldAuthCode(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldAuthCode is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldAuthCode requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAuthCode: %w", err)
}
return oldValue.AuthCode, nil
}
// ClearAuthCode clears the value of the "auth_code" field.
func (m *PlayerMutation) ClearAuthCode() {
m.auth_code = nil
m.clearedFields[player.FieldAuthCode] = struct{}{}
}
// AuthCodeCleared returns if the "auth_code" field was cleared in this mutation.
func (m *PlayerMutation) AuthCodeCleared() bool {
_, ok := m.clearedFields[player.FieldAuthCode]
return ok
}
// ResetAuthCode resets all changes to the "auth_code" field.
func (m *PlayerMutation) ResetAuthCode() {
m.auth_code = nil
delete(m.clearedFields, player.FieldAuthCode)
}
// SetProfileCreated sets the "profile_created" field.
func (m *PlayerMutation) SetProfileCreated(t time.Time) {
m.profile_created = &t
}
// ProfileCreated returns the value of the "profile_created" field in the mutation.
func (m *PlayerMutation) ProfileCreated() (r time.Time, exists bool) {
v := m.profile_created
if v == nil {
return
}
return *v, true
}
// OldProfileCreated returns the old "profile_created" field's value of the Player entity.
// If the Player object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PlayerMutation) OldProfileCreated(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldProfileCreated is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldProfileCreated requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldProfileCreated: %w", err)
}
return oldValue.ProfileCreated, nil
}
// ClearProfileCreated clears the value of the "profile_created" field.
func (m *PlayerMutation) ClearProfileCreated() {
m.profile_created = nil
m.clearedFields[player.FieldProfileCreated] = struct{}{}
}
// ProfileCreatedCleared returns if the "profile_created" field was cleared in this mutation.
func (m *PlayerMutation) ProfileCreatedCleared() bool {
_, ok := m.clearedFields[player.FieldProfileCreated]
return ok
}
// ResetProfileCreated resets all changes to the "profile_created" field.
func (m *PlayerMutation) ResetProfileCreated() {
m.profile_created = nil
delete(m.clearedFields, player.FieldProfileCreated)
}
// SetOldestSharecodeSeen sets the "oldest_sharecode_seen" field.
func (m *PlayerMutation) SetOldestSharecodeSeen(s string) {
m.oldest_sharecode_seen = &s
}
// OldestSharecodeSeen returns the value of the "oldest_sharecode_seen" field in the mutation.
func (m *PlayerMutation) OldestSharecodeSeen() (r string, exists bool) {
v := m.oldest_sharecode_seen
if v == nil {
return
}
return *v, true
}
// OldOldestSharecodeSeen returns the old "oldest_sharecode_seen" field's value of the Player entity.
// If the Player object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PlayerMutation) OldOldestSharecodeSeen(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldOldestSharecodeSeen is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldOldestSharecodeSeen requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOldestSharecodeSeen: %w", err)
}
return oldValue.OldestSharecodeSeen, nil
}
// ClearOldestSharecodeSeen clears the value of the "oldest_sharecode_seen" field.
func (m *PlayerMutation) ClearOldestSharecodeSeen() {
m.oldest_sharecode_seen = nil
m.clearedFields[player.FieldOldestSharecodeSeen] = struct{}{}
}
// OldestSharecodeSeenCleared returns if the "oldest_sharecode_seen" field was cleared in this mutation.
func (m *PlayerMutation) OldestSharecodeSeenCleared() bool {
_, ok := m.clearedFields[player.FieldOldestSharecodeSeen]
return ok
}
// ResetOldestSharecodeSeen resets all changes to the "oldest_sharecode_seen" field.
func (m *PlayerMutation) ResetOldestSharecodeSeen() {
m.oldest_sharecode_seen = nil
delete(m.clearedFields, player.FieldOldestSharecodeSeen)
}
// AddStatIDs adds the "stats" edge to the Stats entity by ids.
func (m *PlayerMutation) AddStatIDs(ids ...int) {
if m.stats == nil {
m.stats = make(map[int]struct{})
}
for i := range ids {
m.stats[ids[i]] = struct{}{}
}
}
// ClearStats clears the "stats" edge to the Stats entity.
func (m *PlayerMutation) ClearStats() {
m.clearedstats = true
}
// StatsCleared reports if the "stats" edge to the Stats entity was cleared.
func (m *PlayerMutation) StatsCleared() bool {
return m.clearedstats
}
// RemoveStatIDs removes the "stats" edge to the Stats entity by IDs.
func (m *PlayerMutation) RemoveStatIDs(ids ...int) {
if m.removedstats == nil {
m.removedstats = make(map[int]struct{})
}
for i := range ids {
delete(m.stats, ids[i])
m.removedstats[ids[i]] = struct{}{}
}
}
// RemovedStats returns the removed IDs of the "stats" edge to the Stats entity.
func (m *PlayerMutation) RemovedStatsIDs() (ids []int) {
for id := range m.removedstats {
ids = append(ids, id)
}
return
}
// StatsIDs returns the "stats" edge IDs in the mutation.
func (m *PlayerMutation) StatsIDs() (ids []int) {
for id := range m.stats {
ids = append(ids, id)
}
return
}
// ResetStats resets all changes to the "stats" edge.
func (m *PlayerMutation) ResetStats() {
m.stats = nil
m.clearedstats = false
m.removedstats = nil
}
// AddMatchIDs adds the "matches" edge to the Match entity by ids.
func (m *PlayerMutation) AddMatchIDs(ids ...uint64) {
if m.matches == nil {
m.matches = make(map[uint64]struct{})
}
for i := range ids {
m.matches[ids[i]] = struct{}{}
}
}
// ClearMatches clears the "matches" edge to the Match entity.
func (m *PlayerMutation) ClearMatches() {
m.clearedmatches = true
}
// MatchesCleared reports if the "matches" edge to the Match entity was cleared.
func (m *PlayerMutation) MatchesCleared() bool {
return m.clearedmatches
}
// RemoveMatchIDs removes the "matches" edge to the Match entity by IDs.
func (m *PlayerMutation) RemoveMatchIDs(ids ...uint64) {
if m.removedmatches == nil {
m.removedmatches = make(map[uint64]struct{})
}
for i := range ids {
delete(m.matches, ids[i])
m.removedmatches[ids[i]] = struct{}{}
}
}
// RemovedMatches returns the removed IDs of the "matches" edge to the Match entity.
func (m *PlayerMutation) RemovedMatchesIDs() (ids []uint64) {
for id := range m.removedmatches {
ids = append(ids, id)
}
return
}
// MatchesIDs returns the "matches" edge IDs in the mutation.
func (m *PlayerMutation) MatchesIDs() (ids []uint64) {
for id := range m.matches {
ids = append(ids, id)
}
return
}
// ResetMatches resets all changes to the "matches" edge.
func (m *PlayerMutation) ResetMatches() {
m.matches = nil
m.clearedmatches = false
m.removedmatches = nil
}
// Where appends a list predicates to the PlayerMutation builder.
func (m *PlayerMutation) Where(ps ...predicate.Player) {
m.predicates = append(m.predicates, ps...)
}
// Op returns the operation name.
func (m *PlayerMutation) Op() Op {
return m.op
}
// Type returns the node type of this mutation (Player).
func (m *PlayerMutation) Type() string {
return m.typ
}
// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *PlayerMutation) Fields() []string {
fields := make([]string, 0, 13)
if m.name != nil {
fields = append(fields, player.FieldName)
}
if m.avatar != nil {
fields = append(fields, player.FieldAvatar)
}
if m.vanity_url != nil {
fields = append(fields, player.FieldVanityURL)
}
if m.vanity_url_real != nil {
fields = append(fields, player.FieldVanityURLReal)
}
if m.vac_date != nil {
fields = append(fields, player.FieldVacDate)
}
if m.vac_count != nil {
fields = append(fields, player.FieldVacCount)
}
if m.game_ban_date != nil {
fields = append(fields, player.FieldGameBanDate)
}
if m.game_ban_count != nil {
fields = append(fields, player.FieldGameBanCount)
}
if m.steam_updated != nil {
fields = append(fields, player.FieldSteamUpdated)
}
if m.sharecode_updated != nil {
fields = append(fields, player.FieldSharecodeUpdated)
}
if m.auth_code != nil {
fields = append(fields, player.FieldAuthCode)
}
if m.profile_created != nil {
fields = append(fields, player.FieldProfileCreated)
}
if m.oldest_sharecode_seen != nil {
fields = append(fields, player.FieldOldestSharecodeSeen)
}
return fields
}
// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *PlayerMutation) Field(name string) (ent.Value, bool) {
switch name {
case player.FieldName:
return m.Name()
case player.FieldAvatar:
return m.Avatar()
case player.FieldVanityURL:
return m.VanityURL()
case player.FieldVanityURLReal:
return m.VanityURLReal()
case player.FieldVacDate:
return m.VacDate()
case player.FieldVacCount:
return m.VacCount()
case player.FieldGameBanDate:
return m.GameBanDate()
case player.FieldGameBanCount:
return m.GameBanCount()
case player.FieldSteamUpdated:
return m.SteamUpdated()
case player.FieldSharecodeUpdated:
return m.SharecodeUpdated()
case player.FieldAuthCode:
return m.AuthCode()
case player.FieldProfileCreated:
return m.ProfileCreated()
case player.FieldOldestSharecodeSeen:
return m.OldestSharecodeSeen()
}
return nil, false
}
// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *PlayerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case player.FieldName:
return m.OldName(ctx)
case player.FieldAvatar:
return m.OldAvatar(ctx)
case player.FieldVanityURL:
return m.OldVanityURL(ctx)
case player.FieldVanityURLReal:
return m.OldVanityURLReal(ctx)
case player.FieldVacDate:
return m.OldVacDate(ctx)
case player.FieldVacCount:
return m.OldVacCount(ctx)
case player.FieldGameBanDate:
return m.OldGameBanDate(ctx)
case player.FieldGameBanCount:
return m.OldGameBanCount(ctx)
case player.FieldSteamUpdated:
return m.OldSteamUpdated(ctx)
case player.FieldSharecodeUpdated:
return m.OldSharecodeUpdated(ctx)
case player.FieldAuthCode:
return m.OldAuthCode(ctx)
case player.FieldProfileCreated:
return m.OldProfileCreated(ctx)
case player.FieldOldestSharecodeSeen:
return m.OldOldestSharecodeSeen(ctx)
}
return nil, fmt.Errorf("unknown Player field %s", name)
}
// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *PlayerMutation) SetField(name string, value ent.Value) error {
switch name {
case player.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
case player.FieldAvatar:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAvatar(v)
return nil
case player.FieldVanityURL:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetVanityURL(v)
return nil
case player.FieldVanityURLReal:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetVanityURLReal(v)
return nil
case player.FieldVacDate:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetVacDate(v)
return nil
case player.FieldVacCount:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetVacCount(v)
return nil
case player.FieldGameBanDate:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetGameBanDate(v)
return nil
case player.FieldGameBanCount:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetGameBanCount(v)
return nil
case player.FieldSteamUpdated:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSteamUpdated(v)
return nil
case player.FieldSharecodeUpdated:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSharecodeUpdated(v)
return nil
case player.FieldAuthCode:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAuthCode(v)
return nil
case player.FieldProfileCreated:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetProfileCreated(v)
return nil
case player.FieldOldestSharecodeSeen:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetOldestSharecodeSeen(v)
return nil
}
return fmt.Errorf("unknown Player field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *PlayerMutation) AddedFields() []string {
var fields []string
if m.addvac_count != nil {
fields = append(fields, player.FieldVacCount)
}
if m.addgame_ban_count != nil {
fields = append(fields, player.FieldGameBanCount)
}
return fields
}
// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *PlayerMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case player.FieldVacCount:
return m.AddedVacCount()
case player.FieldGameBanCount:
return m.AddedGameBanCount()
}
return nil, false
}
// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *PlayerMutation) AddField(name string, value ent.Value) error {
switch name {
case player.FieldVacCount:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddVacCount(v)
return nil
case player.FieldGameBanCount:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddGameBanCount(v)
return nil
}
return fmt.Errorf("unknown Player numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *PlayerMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(player.FieldName) {
fields = append(fields, player.FieldName)
}
if m.FieldCleared(player.FieldAvatar) {
fields = append(fields, player.FieldAvatar)
}
if m.FieldCleared(player.FieldVanityURL) {
fields = append(fields, player.FieldVanityURL)
}
if m.FieldCleared(player.FieldVanityURLReal) {
fields = append(fields, player.FieldVanityURLReal)
}
if m.FieldCleared(player.FieldVacDate) {
fields = append(fields, player.FieldVacDate)
}
if m.FieldCleared(player.FieldVacCount) {
fields = append(fields, player.FieldVacCount)
}
if m.FieldCleared(player.FieldGameBanDate) {
fields = append(fields, player.FieldGameBanDate)
}
if m.FieldCleared(player.FieldGameBanCount) {
fields = append(fields, player.FieldGameBanCount)
}
if m.FieldCleared(player.FieldSharecodeUpdated) {
fields = append(fields, player.FieldSharecodeUpdated)
}
if m.FieldCleared(player.FieldAuthCode) {
fields = append(fields, player.FieldAuthCode)
}
if m.FieldCleared(player.FieldProfileCreated) {
fields = append(fields, player.FieldProfileCreated)
}
if m.FieldCleared(player.FieldOldestSharecodeSeen) {
fields = append(fields, player.FieldOldestSharecodeSeen)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *PlayerMutation) FieldCleared(name string) bool {
_, ok := m.clearedFields[name]
return ok
}
// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *PlayerMutation) ClearField(name string) error {
switch name {
case player.FieldName:
m.ClearName()
return nil
case player.FieldAvatar:
m.ClearAvatar()
return nil
case player.FieldVanityURL:
m.ClearVanityURL()
return nil
case player.FieldVanityURLReal:
m.ClearVanityURLReal()
return nil
case player.FieldVacDate:
m.ClearVacDate()
return nil
case player.FieldVacCount:
m.ClearVacCount()
return nil
case player.FieldGameBanDate:
m.ClearGameBanDate()
return nil
case player.FieldGameBanCount:
m.ClearGameBanCount()
return nil
case player.FieldSharecodeUpdated:
m.ClearSharecodeUpdated()
return nil
case player.FieldAuthCode:
m.ClearAuthCode()
return nil
case player.FieldProfileCreated:
m.ClearProfileCreated()
return nil
case player.FieldOldestSharecodeSeen:
m.ClearOldestSharecodeSeen()
return nil
}
return fmt.Errorf("unknown Player nullable field %s", name)
}
// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *PlayerMutation) ResetField(name string) error {
switch name {
case player.FieldName:
m.ResetName()
return nil
case player.FieldAvatar:
m.ResetAvatar()
return nil
case player.FieldVanityURL:
m.ResetVanityURL()
return nil
case player.FieldVanityURLReal:
m.ResetVanityURLReal()
return nil
case player.FieldVacDate:
m.ResetVacDate()
return nil
case player.FieldVacCount:
m.ResetVacCount()
return nil
case player.FieldGameBanDate:
m.ResetGameBanDate()
return nil
case player.FieldGameBanCount:
m.ResetGameBanCount()
return nil
case player.FieldSteamUpdated:
m.ResetSteamUpdated()
return nil
case player.FieldSharecodeUpdated:
m.ResetSharecodeUpdated()
return nil
case player.FieldAuthCode:
m.ResetAuthCode()
return nil
case player.FieldProfileCreated:
m.ResetProfileCreated()
return nil
case player.FieldOldestSharecodeSeen:
m.ResetOldestSharecodeSeen()
return nil
}
return fmt.Errorf("unknown Player field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *PlayerMutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.stats != nil {
edges = append(edges, player.EdgeStats)
}
if m.matches != nil {
edges = append(edges, player.EdgeMatches)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *PlayerMutation) AddedIDs(name string) []ent.Value {
switch name {
case player.EdgeStats:
ids := make([]ent.Value, 0, len(m.stats))
for id := range m.stats {
ids = append(ids, id)
}
return ids
case player.EdgeMatches:
ids := make([]ent.Value, 0, len(m.matches))
for id := range m.matches {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *PlayerMutation) RemovedEdges() []string {
edges := make([]string, 0, 2)
if m.removedstats != nil {
edges = append(edges, player.EdgeStats)
}
if m.removedmatches != nil {
edges = append(edges, player.EdgeMatches)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *PlayerMutation) RemovedIDs(name string) []ent.Value {
switch name {
case player.EdgeStats:
ids := make([]ent.Value, 0, len(m.removedstats))
for id := range m.removedstats {
ids = append(ids, id)
}
return ids
case player.EdgeMatches:
ids := make([]ent.Value, 0, len(m.removedmatches))
for id := range m.removedmatches {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *PlayerMutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.clearedstats {
edges = append(edges, player.EdgeStats)
}
if m.clearedmatches {
edges = append(edges, player.EdgeMatches)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *PlayerMutation) EdgeCleared(name string) bool {
switch name {
case player.EdgeStats:
return m.clearedstats
case player.EdgeMatches:
return m.clearedmatches
}
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *PlayerMutation) ClearEdge(name string) error {
switch name {
}
return fmt.Errorf("unknown Player unique edge %s", name)
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *PlayerMutation) ResetEdge(name string) error {
switch name {
case player.EdgeStats:
m.ResetStats()
return nil
case player.EdgeMatches:
m.ResetMatches()
return nil
}
return fmt.Errorf("unknown Player edge %s", name)
}
// RoundStatsMutation represents an operation that mutates the RoundStats nodes in the graph.
type RoundStatsMutation struct {
config
op Op
typ string
id *int
round *uint
addround *uint
bank *uint
addbank *uint
equipment *uint
addequipment *uint
spent *uint
addspent *uint
clearedFields map[string]struct{}
stat *int
clearedstat bool
done bool
oldValue func(context.Context) (*RoundStats, error)
predicates []predicate.RoundStats
}
var _ ent.Mutation = (*RoundStatsMutation)(nil)
// roundstatsOption allows management of the mutation configuration using functional options.
type roundstatsOption func(*RoundStatsMutation)
// newRoundStatsMutation creates new mutation for the RoundStats entity.
func newRoundStatsMutation(c config, op Op, opts ...roundstatsOption) *RoundStatsMutation {
m := &RoundStatsMutation{
config: c,
op: op,
typ: TypeRoundStats,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withRoundStatsID sets the ID field of the mutation.
func withRoundStatsID(id int) roundstatsOption {
return func(m *RoundStatsMutation) {
var (
err error
once sync.Once
value *RoundStats
)
m.oldValue = func(ctx context.Context) (*RoundStats, error) {
once.Do(func() {
if m.done {
err = fmt.Errorf("querying old values post mutation is not allowed")
} else {
value, err = m.Client().RoundStats.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withRoundStats sets the old RoundStats of the mutation.
func withRoundStats(node *RoundStats) roundstatsOption {
return func(m *RoundStatsMutation) {
m.oldValue = func(context.Context) (*RoundStats, error) {
return node, nil
}
m.id = &node.ID
}
}
// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m RoundStatsMutation) Client() *Client {
client := &Client{config: m.config}
client.init()
return client
}
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m RoundStatsMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, fmt.Errorf("ent: mutation is not running in a transaction")
}
tx := &Tx{config: m.config}
tx.init()
return tx, nil
}
// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *RoundStatsMutation) ID() (id int, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// SetRound sets the "round" field.
func (m *RoundStatsMutation) SetRound(u uint) {
m.round = &u
m.addround = nil
}
// Round returns the value of the "round" field in the mutation.
func (m *RoundStatsMutation) Round() (r uint, exists bool) {
v := m.round
if v == nil {
return
}
return *v, true
}
// OldRound returns the old "round" field's value of the RoundStats entity.
// If the RoundStats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *RoundStatsMutation) OldRound(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldRound is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldRound requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRound: %w", err)
}
return oldValue.Round, nil
}
// AddRound adds u to the "round" field.
func (m *RoundStatsMutation) AddRound(u uint) {
if m.addround != nil {
*m.addround += u
} else {
m.addround = &u
}
}
// AddedRound returns the value that was added to the "round" field in this mutation.
func (m *RoundStatsMutation) AddedRound() (r uint, exists bool) {
v := m.addround
if v == nil {
return
}
return *v, true
}
// ResetRound resets all changes to the "round" field.
func (m *RoundStatsMutation) ResetRound() {
m.round = nil
m.addround = nil
}
// SetBank sets the "bank" field.
func (m *RoundStatsMutation) SetBank(u uint) {
m.bank = &u
m.addbank = nil
}
// Bank returns the value of the "bank" field in the mutation.
func (m *RoundStatsMutation) Bank() (r uint, exists bool) {
v := m.bank
if v == nil {
return
}
return *v, true
}
// OldBank returns the old "bank" field's value of the RoundStats entity.
// If the RoundStats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *RoundStatsMutation) OldBank(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldBank is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldBank requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldBank: %w", err)
}
return oldValue.Bank, nil
}
// AddBank adds u to the "bank" field.
func (m *RoundStatsMutation) AddBank(u uint) {
if m.addbank != nil {
*m.addbank += u
} else {
m.addbank = &u
}
}
// AddedBank returns the value that was added to the "bank" field in this mutation.
func (m *RoundStatsMutation) AddedBank() (r uint, exists bool) {
v := m.addbank
if v == nil {
return
}
return *v, true
}
// ResetBank resets all changes to the "bank" field.
func (m *RoundStatsMutation) ResetBank() {
m.bank = nil
m.addbank = nil
}
// SetEquipment sets the "equipment" field.
func (m *RoundStatsMutation) SetEquipment(u uint) {
m.equipment = &u
m.addequipment = nil
}
// Equipment returns the value of the "equipment" field in the mutation.
func (m *RoundStatsMutation) Equipment() (r uint, exists bool) {
v := m.equipment
if v == nil {
return
}
return *v, true
}
// OldEquipment returns the old "equipment" field's value of the RoundStats entity.
// If the RoundStats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *RoundStatsMutation) OldEquipment(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldEquipment is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldEquipment requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEquipment: %w", err)
}
return oldValue.Equipment, nil
}
// AddEquipment adds u to the "equipment" field.
func (m *RoundStatsMutation) AddEquipment(u uint) {
if m.addequipment != nil {
*m.addequipment += u
} else {
m.addequipment = &u
}
}
// AddedEquipment returns the value that was added to the "equipment" field in this mutation.
func (m *RoundStatsMutation) AddedEquipment() (r uint, exists bool) {
v := m.addequipment
if v == nil {
return
}
return *v, true
}
// ResetEquipment resets all changes to the "equipment" field.
func (m *RoundStatsMutation) ResetEquipment() {
m.equipment = nil
m.addequipment = nil
}
// SetSpent sets the "spent" field.
func (m *RoundStatsMutation) SetSpent(u uint) {
m.spent = &u
m.addspent = nil
}
// Spent returns the value of the "spent" field in the mutation.
func (m *RoundStatsMutation) Spent() (r uint, exists bool) {
v := m.spent
if v == nil {
return
}
return *v, true
}
// OldSpent returns the old "spent" field's value of the RoundStats entity.
// If the RoundStats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *RoundStatsMutation) OldSpent(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldSpent is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldSpent requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSpent: %w", err)
}
return oldValue.Spent, nil
}
// AddSpent adds u to the "spent" field.
func (m *RoundStatsMutation) AddSpent(u uint) {
if m.addspent != nil {
*m.addspent += u
} else {
m.addspent = &u
}
}
// AddedSpent returns the value that was added to the "spent" field in this mutation.
func (m *RoundStatsMutation) AddedSpent() (r uint, exists bool) {
v := m.addspent
if v == nil {
return
}
return *v, true
}
// ResetSpent resets all changes to the "spent" field.
func (m *RoundStatsMutation) ResetSpent() {
m.spent = nil
m.addspent = nil
}
// SetStatID sets the "stat" edge to the Stats entity by id.
func (m *RoundStatsMutation) SetStatID(id int) {
m.stat = &id
}
// ClearStat clears the "stat" edge to the Stats entity.
func (m *RoundStatsMutation) ClearStat() {
m.clearedstat = true
}
// StatCleared reports if the "stat" edge to the Stats entity was cleared.
func (m *RoundStatsMutation) StatCleared() bool {
return m.clearedstat
}
// StatID returns the "stat" edge ID in the mutation.
func (m *RoundStatsMutation) StatID() (id int, exists bool) {
if m.stat != nil {
return *m.stat, true
}
return
}
// StatIDs returns the "stat" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// StatID instead. It exists only for internal usage by the builders.
func (m *RoundStatsMutation) StatIDs() (ids []int) {
if id := m.stat; id != nil {
ids = append(ids, *id)
}
return
}
// ResetStat resets all changes to the "stat" edge.
func (m *RoundStatsMutation) ResetStat() {
m.stat = nil
m.clearedstat = false
}
// Where appends a list predicates to the RoundStatsMutation builder.
func (m *RoundStatsMutation) Where(ps ...predicate.RoundStats) {
m.predicates = append(m.predicates, ps...)
}
// Op returns the operation name.
func (m *RoundStatsMutation) Op() Op {
return m.op
}
// Type returns the node type of this mutation (RoundStats).
func (m *RoundStatsMutation) Type() string {
return m.typ
}
// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *RoundStatsMutation) Fields() []string {
fields := make([]string, 0, 4)
if m.round != nil {
fields = append(fields, roundstats.FieldRound)
}
if m.bank != nil {
fields = append(fields, roundstats.FieldBank)
}
if m.equipment != nil {
fields = append(fields, roundstats.FieldEquipment)
}
if m.spent != nil {
fields = append(fields, roundstats.FieldSpent)
}
return fields
}
// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *RoundStatsMutation) Field(name string) (ent.Value, bool) {
switch name {
case roundstats.FieldRound:
return m.Round()
case roundstats.FieldBank:
return m.Bank()
case roundstats.FieldEquipment:
return m.Equipment()
case roundstats.FieldSpent:
return m.Spent()
}
return nil, false
}
// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *RoundStatsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case roundstats.FieldRound:
return m.OldRound(ctx)
case roundstats.FieldBank:
return m.OldBank(ctx)
case roundstats.FieldEquipment:
return m.OldEquipment(ctx)
case roundstats.FieldSpent:
return m.OldSpent(ctx)
}
return nil, fmt.Errorf("unknown RoundStats field %s", name)
}
// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *RoundStatsMutation) SetField(name string, value ent.Value) error {
switch name {
case roundstats.FieldRound:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRound(v)
return nil
case roundstats.FieldBank:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetBank(v)
return nil
case roundstats.FieldEquipment:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEquipment(v)
return nil
case roundstats.FieldSpent:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSpent(v)
return nil
}
return fmt.Errorf("unknown RoundStats field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *RoundStatsMutation) AddedFields() []string {
var fields []string
if m.addround != nil {
fields = append(fields, roundstats.FieldRound)
}
if m.addbank != nil {
fields = append(fields, roundstats.FieldBank)
}
if m.addequipment != nil {
fields = append(fields, roundstats.FieldEquipment)
}
if m.addspent != nil {
fields = append(fields, roundstats.FieldSpent)
}
return fields
}
// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *RoundStatsMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case roundstats.FieldRound:
return m.AddedRound()
case roundstats.FieldBank:
return m.AddedBank()
case roundstats.FieldEquipment:
return m.AddedEquipment()
case roundstats.FieldSpent:
return m.AddedSpent()
}
return nil, false
}
// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *RoundStatsMutation) AddField(name string, value ent.Value) error {
switch name {
case roundstats.FieldRound:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddRound(v)
return nil
case roundstats.FieldBank:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddBank(v)
return nil
case roundstats.FieldEquipment:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddEquipment(v)
return nil
case roundstats.FieldSpent:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddSpent(v)
return nil
}
return fmt.Errorf("unknown RoundStats numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *RoundStatsMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *RoundStatsMutation) FieldCleared(name string) bool {
_, ok := m.clearedFields[name]
return ok
}
// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *RoundStatsMutation) ClearField(name string) error {
return fmt.Errorf("unknown RoundStats nullable field %s", name)
}
// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *RoundStatsMutation) ResetField(name string) error {
switch name {
case roundstats.FieldRound:
m.ResetRound()
return nil
case roundstats.FieldBank:
m.ResetBank()
return nil
case roundstats.FieldEquipment:
m.ResetEquipment()
return nil
case roundstats.FieldSpent:
m.ResetSpent()
return nil
}
return fmt.Errorf("unknown RoundStats field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *RoundStatsMutation) AddedEdges() []string {
edges := make([]string, 0, 1)
if m.stat != nil {
edges = append(edges, roundstats.EdgeStat)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *RoundStatsMutation) AddedIDs(name string) []ent.Value {
switch name {
case roundstats.EdgeStat:
if id := m.stat; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *RoundStatsMutation) RemovedEdges() []string {
edges := make([]string, 0, 1)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *RoundStatsMutation) RemovedIDs(name string) []ent.Value {
switch name {
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *RoundStatsMutation) ClearedEdges() []string {
edges := make([]string, 0, 1)
if m.clearedstat {
edges = append(edges, roundstats.EdgeStat)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *RoundStatsMutation) EdgeCleared(name string) bool {
switch name {
case roundstats.EdgeStat:
return m.clearedstat
}
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *RoundStatsMutation) ClearEdge(name string) error {
switch name {
case roundstats.EdgeStat:
m.ClearStat()
return nil
}
return fmt.Errorf("unknown RoundStats unique edge %s", name)
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *RoundStatsMutation) ResetEdge(name string) error {
switch name {
case roundstats.EdgeStat:
m.ResetStat()
return nil
}
return fmt.Errorf("unknown RoundStats edge %s", name)
}
// StatsMutation represents an operation that mutates the Stats nodes in the graph.
type StatsMutation struct {
config
op Op
typ string
id *int
team_id *int
addteam_id *int
kills *int
addkills *int
deaths *int
adddeaths *int
assists *int
addassists *int
headshot *int
addheadshot *int
mvp *uint
addmvp *uint
score *int
addscore *int
rank_new *int
addrank_new *int
rank_old *int
addrank_old *int
mk_2 *uint
addmk_2 *uint
mk_3 *uint
addmk_3 *uint
mk_4 *uint
addmk_4 *uint
mk_5 *uint
addmk_5 *uint
dmg_enemy *uint
adddmg_enemy *uint
dmg_team *uint
adddmg_team *uint
ud_he *uint
addud_he *uint
ud_flames *uint
addud_flames *uint
ud_flash *uint
addud_flash *uint
ud_decoy *uint
addud_decoy *uint
ud_smoke *uint
addud_smoke *uint
crosshair *string
color *stats.Color
kast *int
addkast *int
flash_duration_self *float32
addflash_duration_self *float32
flash_duration_team *float32
addflash_duration_team *float32
flash_duration_enemy *float32
addflash_duration_enemy *float32
flash_total_self *uint
addflash_total_self *uint
flash_total_team *uint
addflash_total_team *uint
flash_total_enemy *uint
addflash_total_enemy *uint
clearedFields map[string]struct{}
matches *uint64
clearedmatches bool
players *uint64
clearedplayers bool
weapon_stats map[int]struct{}
removedweapon_stats map[int]struct{}
clearedweapon_stats bool
round_stats map[int]struct{}
removedround_stats map[int]struct{}
clearedround_stats bool
done bool
oldValue func(context.Context) (*Stats, error)
predicates []predicate.Stats
}
var _ ent.Mutation = (*StatsMutation)(nil)
// statsOption allows management of the mutation configuration using functional options.
type statsOption func(*StatsMutation)
// newStatsMutation creates new mutation for the Stats entity.
func newStatsMutation(c config, op Op, opts ...statsOption) *StatsMutation {
m := &StatsMutation{
config: c,
op: op,
typ: TypeStats,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withStatsID sets the ID field of the mutation.
func withStatsID(id int) statsOption {
return func(m *StatsMutation) {
var (
err error
once sync.Once
value *Stats
)
m.oldValue = func(ctx context.Context) (*Stats, error) {
once.Do(func() {
if m.done {
err = fmt.Errorf("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Stats.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withStats sets the old Stats of the mutation.
func withStats(node *Stats) statsOption {
return func(m *StatsMutation) {
m.oldValue = func(context.Context) (*Stats, error) {
return node, nil
}
m.id = &node.ID
}
}
// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m StatsMutation) Client() *Client {
client := &Client{config: m.config}
client.init()
return client
}
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m StatsMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, fmt.Errorf("ent: mutation is not running in a transaction")
}
tx := &Tx{config: m.config}
tx.init()
return tx, nil
}
// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *StatsMutation) ID() (id int, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// SetTeamID sets the "team_id" field.
func (m *StatsMutation) SetTeamID(i int) {
m.team_id = &i
m.addteam_id = nil
}
// TeamID returns the value of the "team_id" field in the mutation.
func (m *StatsMutation) TeamID() (r int, exists bool) {
v := m.team_id
if v == nil {
return
}
return *v, true
}
// OldTeamID returns the old "team_id" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldTeamID(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldTeamID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldTeamID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTeamID: %w", err)
}
return oldValue.TeamID, nil
}
// AddTeamID adds i to the "team_id" field.
func (m *StatsMutation) AddTeamID(i int) {
if m.addteam_id != nil {
*m.addteam_id += i
} else {
m.addteam_id = &i
}
}
// AddedTeamID returns the value that was added to the "team_id" field in this mutation.
func (m *StatsMutation) AddedTeamID() (r int, exists bool) {
v := m.addteam_id
if v == nil {
return
}
return *v, true
}
// ResetTeamID resets all changes to the "team_id" field.
func (m *StatsMutation) ResetTeamID() {
m.team_id = nil
m.addteam_id = nil
}
// SetKills sets the "kills" field.
func (m *StatsMutation) SetKills(i int) {
m.kills = &i
m.addkills = nil
}
// Kills returns the value of the "kills" field in the mutation.
func (m *StatsMutation) Kills() (r int, exists bool) {
v := m.kills
if v == nil {
return
}
return *v, true
}
// OldKills returns the old "kills" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldKills(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldKills is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldKills requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldKills: %w", err)
}
return oldValue.Kills, nil
}
// AddKills adds i to the "kills" field.
func (m *StatsMutation) AddKills(i int) {
if m.addkills != nil {
*m.addkills += i
} else {
m.addkills = &i
}
}
// AddedKills returns the value that was added to the "kills" field in this mutation.
func (m *StatsMutation) AddedKills() (r int, exists bool) {
v := m.addkills
if v == nil {
return
}
return *v, true
}
// ResetKills resets all changes to the "kills" field.
func (m *StatsMutation) ResetKills() {
m.kills = nil
m.addkills = nil
}
// SetDeaths sets the "deaths" field.
func (m *StatsMutation) SetDeaths(i int) {
m.deaths = &i
m.adddeaths = nil
}
// Deaths returns the value of the "deaths" field in the mutation.
func (m *StatsMutation) Deaths() (r int, exists bool) {
v := m.deaths
if v == nil {
return
}
return *v, true
}
// OldDeaths returns the old "deaths" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldDeaths(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldDeaths is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldDeaths requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDeaths: %w", err)
}
return oldValue.Deaths, nil
}
// AddDeaths adds i to the "deaths" field.
func (m *StatsMutation) AddDeaths(i int) {
if m.adddeaths != nil {
*m.adddeaths += i
} else {
m.adddeaths = &i
}
}
// AddedDeaths returns the value that was added to the "deaths" field in this mutation.
func (m *StatsMutation) AddedDeaths() (r int, exists bool) {
v := m.adddeaths
if v == nil {
return
}
return *v, true
}
// ResetDeaths resets all changes to the "deaths" field.
func (m *StatsMutation) ResetDeaths() {
m.deaths = nil
m.adddeaths = nil
}
// SetAssists sets the "assists" field.
func (m *StatsMutation) SetAssists(i int) {
m.assists = &i
m.addassists = nil
}
// Assists returns the value of the "assists" field in the mutation.
func (m *StatsMutation) Assists() (r int, exists bool) {
v := m.assists
if v == nil {
return
}
return *v, true
}
// OldAssists returns the old "assists" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldAssists(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldAssists is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldAssists requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAssists: %w", err)
}
return oldValue.Assists, nil
}
// AddAssists adds i to the "assists" field.
func (m *StatsMutation) AddAssists(i int) {
if m.addassists != nil {
*m.addassists += i
} else {
m.addassists = &i
}
}
// AddedAssists returns the value that was added to the "assists" field in this mutation.
func (m *StatsMutation) AddedAssists() (r int, exists bool) {
v := m.addassists
if v == nil {
return
}
return *v, true
}
// ResetAssists resets all changes to the "assists" field.
func (m *StatsMutation) ResetAssists() {
m.assists = nil
m.addassists = nil
}
// SetHeadshot sets the "headshot" field.
func (m *StatsMutation) SetHeadshot(i int) {
m.headshot = &i
m.addheadshot = nil
}
// Headshot returns the value of the "headshot" field in the mutation.
func (m *StatsMutation) Headshot() (r int, exists bool) {
v := m.headshot
if v == nil {
return
}
return *v, true
}
// OldHeadshot returns the old "headshot" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldHeadshot(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldHeadshot is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldHeadshot requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldHeadshot: %w", err)
}
return oldValue.Headshot, nil
}
// AddHeadshot adds i to the "headshot" field.
func (m *StatsMutation) AddHeadshot(i int) {
if m.addheadshot != nil {
*m.addheadshot += i
} else {
m.addheadshot = &i
}
}
// AddedHeadshot returns the value that was added to the "headshot" field in this mutation.
func (m *StatsMutation) AddedHeadshot() (r int, exists bool) {
v := m.addheadshot
if v == nil {
return
}
return *v, true
}
// ResetHeadshot resets all changes to the "headshot" field.
func (m *StatsMutation) ResetHeadshot() {
m.headshot = nil
m.addheadshot = nil
}
// SetMvp sets the "mvp" field.
func (m *StatsMutation) SetMvp(u uint) {
m.mvp = &u
m.addmvp = nil
}
// Mvp returns the value of the "mvp" field in the mutation.
func (m *StatsMutation) Mvp() (r uint, exists bool) {
v := m.mvp
if v == nil {
return
}
return *v, true
}
// OldMvp returns the old "mvp" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldMvp(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldMvp is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldMvp requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMvp: %w", err)
}
return oldValue.Mvp, nil
}
// AddMvp adds u to the "mvp" field.
func (m *StatsMutation) AddMvp(u uint) {
if m.addmvp != nil {
*m.addmvp += u
} else {
m.addmvp = &u
}
}
// AddedMvp returns the value that was added to the "mvp" field in this mutation.
func (m *StatsMutation) AddedMvp() (r uint, exists bool) {
v := m.addmvp
if v == nil {
return
}
return *v, true
}
// ResetMvp resets all changes to the "mvp" field.
func (m *StatsMutation) ResetMvp() {
m.mvp = nil
m.addmvp = nil
}
// SetScore sets the "score" field.
func (m *StatsMutation) SetScore(i int) {
m.score = &i
m.addscore = nil
}
// Score returns the value of the "score" field in the mutation.
func (m *StatsMutation) Score() (r int, exists bool) {
v := m.score
if v == nil {
return
}
return *v, true
}
// OldScore returns the old "score" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldScore(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldScore is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldScore requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldScore: %w", err)
}
return oldValue.Score, nil
}
// AddScore adds i to the "score" field.
func (m *StatsMutation) AddScore(i int) {
if m.addscore != nil {
*m.addscore += i
} else {
m.addscore = &i
}
}
// AddedScore returns the value that was added to the "score" field in this mutation.
func (m *StatsMutation) AddedScore() (r int, exists bool) {
v := m.addscore
if v == nil {
return
}
return *v, true
}
// ResetScore resets all changes to the "score" field.
func (m *StatsMutation) ResetScore() {
m.score = nil
m.addscore = nil
}
// SetRankNew sets the "rank_new" field.
func (m *StatsMutation) SetRankNew(i int) {
m.rank_new = &i
m.addrank_new = nil
}
// RankNew returns the value of the "rank_new" field in the mutation.
func (m *StatsMutation) RankNew() (r int, exists bool) {
v := m.rank_new
if v == nil {
return
}
return *v, true
}
// OldRankNew returns the old "rank_new" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldRankNew(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldRankNew is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldRankNew requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRankNew: %w", err)
}
return oldValue.RankNew, nil
}
// AddRankNew adds i to the "rank_new" field.
func (m *StatsMutation) AddRankNew(i int) {
if m.addrank_new != nil {
*m.addrank_new += i
} else {
m.addrank_new = &i
}
}
// AddedRankNew returns the value that was added to the "rank_new" field in this mutation.
func (m *StatsMutation) AddedRankNew() (r int, exists bool) {
v := m.addrank_new
if v == nil {
return
}
return *v, true
}
// ClearRankNew clears the value of the "rank_new" field.
func (m *StatsMutation) ClearRankNew() {
m.rank_new = nil
m.addrank_new = nil
m.clearedFields[stats.FieldRankNew] = struct{}{}
}
// RankNewCleared returns if the "rank_new" field was cleared in this mutation.
func (m *StatsMutation) RankNewCleared() bool {
_, ok := m.clearedFields[stats.FieldRankNew]
return ok
}
// ResetRankNew resets all changes to the "rank_new" field.
func (m *StatsMutation) ResetRankNew() {
m.rank_new = nil
m.addrank_new = nil
delete(m.clearedFields, stats.FieldRankNew)
}
// SetRankOld sets the "rank_old" field.
func (m *StatsMutation) SetRankOld(i int) {
m.rank_old = &i
m.addrank_old = nil
}
// RankOld returns the value of the "rank_old" field in the mutation.
func (m *StatsMutation) RankOld() (r int, exists bool) {
v := m.rank_old
if v == nil {
return
}
return *v, true
}
// OldRankOld returns the old "rank_old" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldRankOld(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldRankOld is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldRankOld requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRankOld: %w", err)
}
return oldValue.RankOld, nil
}
// AddRankOld adds i to the "rank_old" field.
func (m *StatsMutation) AddRankOld(i int) {
if m.addrank_old != nil {
*m.addrank_old += i
} else {
m.addrank_old = &i
}
}
// AddedRankOld returns the value that was added to the "rank_old" field in this mutation.
func (m *StatsMutation) AddedRankOld() (r int, exists bool) {
v := m.addrank_old
if v == nil {
return
}
return *v, true
}
// ClearRankOld clears the value of the "rank_old" field.
func (m *StatsMutation) ClearRankOld() {
m.rank_old = nil
m.addrank_old = nil
m.clearedFields[stats.FieldRankOld] = struct{}{}
}
// RankOldCleared returns if the "rank_old" field was cleared in this mutation.
func (m *StatsMutation) RankOldCleared() bool {
_, ok := m.clearedFields[stats.FieldRankOld]
return ok
}
// ResetRankOld resets all changes to the "rank_old" field.
func (m *StatsMutation) ResetRankOld() {
m.rank_old = nil
m.addrank_old = nil
delete(m.clearedFields, stats.FieldRankOld)
}
// SetMk2 sets the "mk_2" field.
func (m *StatsMutation) SetMk2(u uint) {
m.mk_2 = &u
m.addmk_2 = nil
}
// Mk2 returns the value of the "mk_2" field in the mutation.
func (m *StatsMutation) Mk2() (r uint, exists bool) {
v := m.mk_2
if v == nil {
return
}
return *v, true
}
// OldMk2 returns the old "mk_2" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldMk2(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldMk2 is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldMk2 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMk2: %w", err)
}
return oldValue.Mk2, nil
}
// AddMk2 adds u to the "mk_2" field.
func (m *StatsMutation) AddMk2(u uint) {
if m.addmk_2 != nil {
*m.addmk_2 += u
} else {
m.addmk_2 = &u
}
}
// AddedMk2 returns the value that was added to the "mk_2" field in this mutation.
func (m *StatsMutation) AddedMk2() (r uint, exists bool) {
v := m.addmk_2
if v == nil {
return
}
return *v, true
}
// ClearMk2 clears the value of the "mk_2" field.
func (m *StatsMutation) ClearMk2() {
m.mk_2 = nil
m.addmk_2 = nil
m.clearedFields[stats.FieldMk2] = struct{}{}
}
// Mk2Cleared returns if the "mk_2" field was cleared in this mutation.
func (m *StatsMutation) Mk2Cleared() bool {
_, ok := m.clearedFields[stats.FieldMk2]
return ok
}
// ResetMk2 resets all changes to the "mk_2" field.
func (m *StatsMutation) ResetMk2() {
m.mk_2 = nil
m.addmk_2 = nil
delete(m.clearedFields, stats.FieldMk2)
}
// SetMk3 sets the "mk_3" field.
func (m *StatsMutation) SetMk3(u uint) {
m.mk_3 = &u
m.addmk_3 = nil
}
// Mk3 returns the value of the "mk_3" field in the mutation.
func (m *StatsMutation) Mk3() (r uint, exists bool) {
v := m.mk_3
if v == nil {
return
}
return *v, true
}
// OldMk3 returns the old "mk_3" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldMk3(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldMk3 is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldMk3 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMk3: %w", err)
}
return oldValue.Mk3, nil
}
// AddMk3 adds u to the "mk_3" field.
func (m *StatsMutation) AddMk3(u uint) {
if m.addmk_3 != nil {
*m.addmk_3 += u
} else {
m.addmk_3 = &u
}
}
// AddedMk3 returns the value that was added to the "mk_3" field in this mutation.
func (m *StatsMutation) AddedMk3() (r uint, exists bool) {
v := m.addmk_3
if v == nil {
return
}
return *v, true
}
// ClearMk3 clears the value of the "mk_3" field.
func (m *StatsMutation) ClearMk3() {
m.mk_3 = nil
m.addmk_3 = nil
m.clearedFields[stats.FieldMk3] = struct{}{}
}
// Mk3Cleared returns if the "mk_3" field was cleared in this mutation.
func (m *StatsMutation) Mk3Cleared() bool {
_, ok := m.clearedFields[stats.FieldMk3]
return ok
}
// ResetMk3 resets all changes to the "mk_3" field.
func (m *StatsMutation) ResetMk3() {
m.mk_3 = nil
m.addmk_3 = nil
delete(m.clearedFields, stats.FieldMk3)
}
// SetMk4 sets the "mk_4" field.
func (m *StatsMutation) SetMk4(u uint) {
m.mk_4 = &u
m.addmk_4 = nil
}
// Mk4 returns the value of the "mk_4" field in the mutation.
func (m *StatsMutation) Mk4() (r uint, exists bool) {
v := m.mk_4
if v == nil {
return
}
return *v, true
}
// OldMk4 returns the old "mk_4" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldMk4(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldMk4 is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldMk4 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMk4: %w", err)
}
return oldValue.Mk4, nil
}
// AddMk4 adds u to the "mk_4" field.
func (m *StatsMutation) AddMk4(u uint) {
if m.addmk_4 != nil {
*m.addmk_4 += u
} else {
m.addmk_4 = &u
}
}
// AddedMk4 returns the value that was added to the "mk_4" field in this mutation.
func (m *StatsMutation) AddedMk4() (r uint, exists bool) {
v := m.addmk_4
if v == nil {
return
}
return *v, true
}
// ClearMk4 clears the value of the "mk_4" field.
func (m *StatsMutation) ClearMk4() {
m.mk_4 = nil
m.addmk_4 = nil
m.clearedFields[stats.FieldMk4] = struct{}{}
}
// Mk4Cleared returns if the "mk_4" field was cleared in this mutation.
func (m *StatsMutation) Mk4Cleared() bool {
_, ok := m.clearedFields[stats.FieldMk4]
return ok
}
// ResetMk4 resets all changes to the "mk_4" field.
func (m *StatsMutation) ResetMk4() {
m.mk_4 = nil
m.addmk_4 = nil
delete(m.clearedFields, stats.FieldMk4)
}
// SetMk5 sets the "mk_5" field.
func (m *StatsMutation) SetMk5(u uint) {
m.mk_5 = &u
m.addmk_5 = nil
}
// Mk5 returns the value of the "mk_5" field in the mutation.
func (m *StatsMutation) Mk5() (r uint, exists bool) {
v := m.mk_5
if v == nil {
return
}
return *v, true
}
// OldMk5 returns the old "mk_5" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldMk5(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldMk5 is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldMk5 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMk5: %w", err)
}
return oldValue.Mk5, nil
}
// AddMk5 adds u to the "mk_5" field.
func (m *StatsMutation) AddMk5(u uint) {
if m.addmk_5 != nil {
*m.addmk_5 += u
} else {
m.addmk_5 = &u
}
}
// AddedMk5 returns the value that was added to the "mk_5" field in this mutation.
func (m *StatsMutation) AddedMk5() (r uint, exists bool) {
v := m.addmk_5
if v == nil {
return
}
return *v, true
}
// ClearMk5 clears the value of the "mk_5" field.
func (m *StatsMutation) ClearMk5() {
m.mk_5 = nil
m.addmk_5 = nil
m.clearedFields[stats.FieldMk5] = struct{}{}
}
// Mk5Cleared returns if the "mk_5" field was cleared in this mutation.
func (m *StatsMutation) Mk5Cleared() bool {
_, ok := m.clearedFields[stats.FieldMk5]
return ok
}
// ResetMk5 resets all changes to the "mk_5" field.
func (m *StatsMutation) ResetMk5() {
m.mk_5 = nil
m.addmk_5 = nil
delete(m.clearedFields, stats.FieldMk5)
}
// SetDmgEnemy sets the "dmg_enemy" field.
func (m *StatsMutation) SetDmgEnemy(u uint) {
m.dmg_enemy = &u
m.adddmg_enemy = nil
}
// DmgEnemy returns the value of the "dmg_enemy" field in the mutation.
func (m *StatsMutation) DmgEnemy() (r uint, exists bool) {
v := m.dmg_enemy
if v == nil {
return
}
return *v, true
}
// OldDmgEnemy returns the old "dmg_enemy" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldDmgEnemy(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldDmgEnemy is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldDmgEnemy requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDmgEnemy: %w", err)
}
return oldValue.DmgEnemy, nil
}
// AddDmgEnemy adds u to the "dmg_enemy" field.
func (m *StatsMutation) AddDmgEnemy(u uint) {
if m.adddmg_enemy != nil {
*m.adddmg_enemy += u
} else {
m.adddmg_enemy = &u
}
}
// AddedDmgEnemy returns the value that was added to the "dmg_enemy" field in this mutation.
func (m *StatsMutation) AddedDmgEnemy() (r uint, exists bool) {
v := m.adddmg_enemy
if v == nil {
return
}
return *v, true
}
// ClearDmgEnemy clears the value of the "dmg_enemy" field.
func (m *StatsMutation) ClearDmgEnemy() {
m.dmg_enemy = nil
m.adddmg_enemy = nil
m.clearedFields[stats.FieldDmgEnemy] = struct{}{}
}
// DmgEnemyCleared returns if the "dmg_enemy" field was cleared in this mutation.
func (m *StatsMutation) DmgEnemyCleared() bool {
_, ok := m.clearedFields[stats.FieldDmgEnemy]
return ok
}
// ResetDmgEnemy resets all changes to the "dmg_enemy" field.
func (m *StatsMutation) ResetDmgEnemy() {
m.dmg_enemy = nil
m.adddmg_enemy = nil
delete(m.clearedFields, stats.FieldDmgEnemy)
}
// SetDmgTeam sets the "dmg_team" field.
func (m *StatsMutation) SetDmgTeam(u uint) {
m.dmg_team = &u
m.adddmg_team = nil
}
// DmgTeam returns the value of the "dmg_team" field in the mutation.
func (m *StatsMutation) DmgTeam() (r uint, exists bool) {
v := m.dmg_team
if v == nil {
return
}
return *v, true
}
// OldDmgTeam returns the old "dmg_team" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldDmgTeam(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldDmgTeam is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldDmgTeam requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDmgTeam: %w", err)
}
return oldValue.DmgTeam, nil
}
// AddDmgTeam adds u to the "dmg_team" field.
func (m *StatsMutation) AddDmgTeam(u uint) {
if m.adddmg_team != nil {
*m.adddmg_team += u
} else {
m.adddmg_team = &u
}
}
// AddedDmgTeam returns the value that was added to the "dmg_team" field in this mutation.
func (m *StatsMutation) AddedDmgTeam() (r uint, exists bool) {
v := m.adddmg_team
if v == nil {
return
}
return *v, true
}
// ClearDmgTeam clears the value of the "dmg_team" field.
func (m *StatsMutation) ClearDmgTeam() {
m.dmg_team = nil
m.adddmg_team = nil
m.clearedFields[stats.FieldDmgTeam] = struct{}{}
}
// DmgTeamCleared returns if the "dmg_team" field was cleared in this mutation.
func (m *StatsMutation) DmgTeamCleared() bool {
_, ok := m.clearedFields[stats.FieldDmgTeam]
return ok
}
// ResetDmgTeam resets all changes to the "dmg_team" field.
func (m *StatsMutation) ResetDmgTeam() {
m.dmg_team = nil
m.adddmg_team = nil
delete(m.clearedFields, stats.FieldDmgTeam)
}
// SetUdHe sets the "ud_he" field.
func (m *StatsMutation) SetUdHe(u uint) {
m.ud_he = &u
m.addud_he = nil
}
// UdHe returns the value of the "ud_he" field in the mutation.
func (m *StatsMutation) UdHe() (r uint, exists bool) {
v := m.ud_he
if v == nil {
return
}
return *v, true
}
// OldUdHe returns the old "ud_he" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldUdHe(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldUdHe is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldUdHe requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUdHe: %w", err)
}
return oldValue.UdHe, nil
}
// AddUdHe adds u to the "ud_he" field.
func (m *StatsMutation) AddUdHe(u uint) {
if m.addud_he != nil {
*m.addud_he += u
} else {
m.addud_he = &u
}
}
// AddedUdHe returns the value that was added to the "ud_he" field in this mutation.
func (m *StatsMutation) AddedUdHe() (r uint, exists bool) {
v := m.addud_he
if v == nil {
return
}
return *v, true
}
// ClearUdHe clears the value of the "ud_he" field.
func (m *StatsMutation) ClearUdHe() {
m.ud_he = nil
m.addud_he = nil
m.clearedFields[stats.FieldUdHe] = struct{}{}
}
// UdHeCleared returns if the "ud_he" field was cleared in this mutation.
func (m *StatsMutation) UdHeCleared() bool {
_, ok := m.clearedFields[stats.FieldUdHe]
return ok
}
// ResetUdHe resets all changes to the "ud_he" field.
func (m *StatsMutation) ResetUdHe() {
m.ud_he = nil
m.addud_he = nil
delete(m.clearedFields, stats.FieldUdHe)
}
// SetUdFlames sets the "ud_flames" field.
func (m *StatsMutation) SetUdFlames(u uint) {
m.ud_flames = &u
m.addud_flames = nil
}
// UdFlames returns the value of the "ud_flames" field in the mutation.
func (m *StatsMutation) UdFlames() (r uint, exists bool) {
v := m.ud_flames
if v == nil {
return
}
return *v, true
}
// OldUdFlames returns the old "ud_flames" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldUdFlames(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldUdFlames is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldUdFlames requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUdFlames: %w", err)
}
return oldValue.UdFlames, nil
}
// AddUdFlames adds u to the "ud_flames" field.
func (m *StatsMutation) AddUdFlames(u uint) {
if m.addud_flames != nil {
*m.addud_flames += u
} else {
m.addud_flames = &u
}
}
// AddedUdFlames returns the value that was added to the "ud_flames" field in this mutation.
func (m *StatsMutation) AddedUdFlames() (r uint, exists bool) {
v := m.addud_flames
if v == nil {
return
}
return *v, true
}
// ClearUdFlames clears the value of the "ud_flames" field.
func (m *StatsMutation) ClearUdFlames() {
m.ud_flames = nil
m.addud_flames = nil
m.clearedFields[stats.FieldUdFlames] = struct{}{}
}
// UdFlamesCleared returns if the "ud_flames" field was cleared in this mutation.
func (m *StatsMutation) UdFlamesCleared() bool {
_, ok := m.clearedFields[stats.FieldUdFlames]
return ok
}
// ResetUdFlames resets all changes to the "ud_flames" field.
func (m *StatsMutation) ResetUdFlames() {
m.ud_flames = nil
m.addud_flames = nil
delete(m.clearedFields, stats.FieldUdFlames)
}
// SetUdFlash sets the "ud_flash" field.
func (m *StatsMutation) SetUdFlash(u uint) {
m.ud_flash = &u
m.addud_flash = nil
}
// UdFlash returns the value of the "ud_flash" field in the mutation.
func (m *StatsMutation) UdFlash() (r uint, exists bool) {
v := m.ud_flash
if v == nil {
return
}
return *v, true
}
// OldUdFlash returns the old "ud_flash" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldUdFlash(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldUdFlash is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldUdFlash requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUdFlash: %w", err)
}
return oldValue.UdFlash, nil
}
// AddUdFlash adds u to the "ud_flash" field.
func (m *StatsMutation) AddUdFlash(u uint) {
if m.addud_flash != nil {
*m.addud_flash += u
} else {
m.addud_flash = &u
}
}
// AddedUdFlash returns the value that was added to the "ud_flash" field in this mutation.
func (m *StatsMutation) AddedUdFlash() (r uint, exists bool) {
v := m.addud_flash
if v == nil {
return
}
return *v, true
}
// ClearUdFlash clears the value of the "ud_flash" field.
func (m *StatsMutation) ClearUdFlash() {
m.ud_flash = nil
m.addud_flash = nil
m.clearedFields[stats.FieldUdFlash] = struct{}{}
}
// UdFlashCleared returns if the "ud_flash" field was cleared in this mutation.
func (m *StatsMutation) UdFlashCleared() bool {
_, ok := m.clearedFields[stats.FieldUdFlash]
return ok
}
// ResetUdFlash resets all changes to the "ud_flash" field.
func (m *StatsMutation) ResetUdFlash() {
m.ud_flash = nil
m.addud_flash = nil
delete(m.clearedFields, stats.FieldUdFlash)
}
// SetUdDecoy sets the "ud_decoy" field.
func (m *StatsMutation) SetUdDecoy(u uint) {
m.ud_decoy = &u
m.addud_decoy = nil
}
// UdDecoy returns the value of the "ud_decoy" field in the mutation.
func (m *StatsMutation) UdDecoy() (r uint, exists bool) {
v := m.ud_decoy
if v == nil {
return
}
return *v, true
}
// OldUdDecoy returns the old "ud_decoy" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldUdDecoy(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldUdDecoy is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldUdDecoy requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUdDecoy: %w", err)
}
return oldValue.UdDecoy, nil
}
// AddUdDecoy adds u to the "ud_decoy" field.
func (m *StatsMutation) AddUdDecoy(u uint) {
if m.addud_decoy != nil {
*m.addud_decoy += u
} else {
m.addud_decoy = &u
}
}
// AddedUdDecoy returns the value that was added to the "ud_decoy" field in this mutation.
func (m *StatsMutation) AddedUdDecoy() (r uint, exists bool) {
v := m.addud_decoy
if v == nil {
return
}
return *v, true
}
// ClearUdDecoy clears the value of the "ud_decoy" field.
func (m *StatsMutation) ClearUdDecoy() {
m.ud_decoy = nil
m.addud_decoy = nil
m.clearedFields[stats.FieldUdDecoy] = struct{}{}
}
// UdDecoyCleared returns if the "ud_decoy" field was cleared in this mutation.
func (m *StatsMutation) UdDecoyCleared() bool {
_, ok := m.clearedFields[stats.FieldUdDecoy]
return ok
}
// ResetUdDecoy resets all changes to the "ud_decoy" field.
func (m *StatsMutation) ResetUdDecoy() {
m.ud_decoy = nil
m.addud_decoy = nil
delete(m.clearedFields, stats.FieldUdDecoy)
}
// SetUdSmoke sets the "ud_smoke" field.
func (m *StatsMutation) SetUdSmoke(u uint) {
m.ud_smoke = &u
m.addud_smoke = nil
}
// UdSmoke returns the value of the "ud_smoke" field in the mutation.
func (m *StatsMutation) UdSmoke() (r uint, exists bool) {
v := m.ud_smoke
if v == nil {
return
}
return *v, true
}
// OldUdSmoke returns the old "ud_smoke" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldUdSmoke(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldUdSmoke is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldUdSmoke requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUdSmoke: %w", err)
}
return oldValue.UdSmoke, nil
}
// AddUdSmoke adds u to the "ud_smoke" field.
func (m *StatsMutation) AddUdSmoke(u uint) {
if m.addud_smoke != nil {
*m.addud_smoke += u
} else {
m.addud_smoke = &u
}
}
// AddedUdSmoke returns the value that was added to the "ud_smoke" field in this mutation.
func (m *StatsMutation) AddedUdSmoke() (r uint, exists bool) {
v := m.addud_smoke
if v == nil {
return
}
return *v, true
}
// ClearUdSmoke clears the value of the "ud_smoke" field.
func (m *StatsMutation) ClearUdSmoke() {
m.ud_smoke = nil
m.addud_smoke = nil
m.clearedFields[stats.FieldUdSmoke] = struct{}{}
}
// UdSmokeCleared returns if the "ud_smoke" field was cleared in this mutation.
func (m *StatsMutation) UdSmokeCleared() bool {
_, ok := m.clearedFields[stats.FieldUdSmoke]
return ok
}
// ResetUdSmoke resets all changes to the "ud_smoke" field.
func (m *StatsMutation) ResetUdSmoke() {
m.ud_smoke = nil
m.addud_smoke = nil
delete(m.clearedFields, stats.FieldUdSmoke)
}
// SetCrosshair sets the "crosshair" field.
func (m *StatsMutation) SetCrosshair(s string) {
m.crosshair = &s
}
// Crosshair returns the value of the "crosshair" field in the mutation.
func (m *StatsMutation) Crosshair() (r string, exists bool) {
v := m.crosshair
if v == nil {
return
}
return *v, true
}
// OldCrosshair returns the old "crosshair" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldCrosshair(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldCrosshair is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldCrosshair requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldCrosshair: %w", err)
}
return oldValue.Crosshair, nil
}
// ClearCrosshair clears the value of the "crosshair" field.
func (m *StatsMutation) ClearCrosshair() {
m.crosshair = nil
m.clearedFields[stats.FieldCrosshair] = struct{}{}
}
// CrosshairCleared returns if the "crosshair" field was cleared in this mutation.
func (m *StatsMutation) CrosshairCleared() bool {
_, ok := m.clearedFields[stats.FieldCrosshair]
return ok
}
// ResetCrosshair resets all changes to the "crosshair" field.
func (m *StatsMutation) ResetCrosshair() {
m.crosshair = nil
delete(m.clearedFields, stats.FieldCrosshair)
}
// SetColor sets the "color" field.
func (m *StatsMutation) SetColor(s stats.Color) {
m.color = &s
}
// Color returns the value of the "color" field in the mutation.
func (m *StatsMutation) Color() (r stats.Color, exists bool) {
v := m.color
if v == nil {
return
}
return *v, true
}
// OldColor returns the old "color" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldColor(ctx context.Context) (v stats.Color, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldColor is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldColor requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldColor: %w", err)
}
return oldValue.Color, nil
}
// ClearColor clears the value of the "color" field.
func (m *StatsMutation) ClearColor() {
m.color = nil
m.clearedFields[stats.FieldColor] = struct{}{}
}
// ColorCleared returns if the "color" field was cleared in this mutation.
func (m *StatsMutation) ColorCleared() bool {
_, ok := m.clearedFields[stats.FieldColor]
return ok
}
// ResetColor resets all changes to the "color" field.
func (m *StatsMutation) ResetColor() {
m.color = nil
delete(m.clearedFields, stats.FieldColor)
}
// SetKast sets the "kast" field.
func (m *StatsMutation) SetKast(i int) {
m.kast = &i
m.addkast = nil
}
// Kast returns the value of the "kast" field in the mutation.
func (m *StatsMutation) Kast() (r int, exists bool) {
v := m.kast
if v == nil {
return
}
return *v, true
}
// OldKast returns the old "kast" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldKast(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldKast is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldKast requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldKast: %w", err)
}
return oldValue.Kast, nil
}
// AddKast adds i to the "kast" field.
func (m *StatsMutation) AddKast(i int) {
if m.addkast != nil {
*m.addkast += i
} else {
m.addkast = &i
}
}
// AddedKast returns the value that was added to the "kast" field in this mutation.
func (m *StatsMutation) AddedKast() (r int, exists bool) {
v := m.addkast
if v == nil {
return
}
return *v, true
}
// ClearKast clears the value of the "kast" field.
func (m *StatsMutation) ClearKast() {
m.kast = nil
m.addkast = nil
m.clearedFields[stats.FieldKast] = struct{}{}
}
// KastCleared returns if the "kast" field was cleared in this mutation.
func (m *StatsMutation) KastCleared() bool {
_, ok := m.clearedFields[stats.FieldKast]
return ok
}
// ResetKast resets all changes to the "kast" field.
func (m *StatsMutation) ResetKast() {
m.kast = nil
m.addkast = nil
delete(m.clearedFields, stats.FieldKast)
}
// SetFlashDurationSelf sets the "flash_duration_self" field.
func (m *StatsMutation) SetFlashDurationSelf(f float32) {
m.flash_duration_self = &f
m.addflash_duration_self = nil
}
// FlashDurationSelf returns the value of the "flash_duration_self" field in the mutation.
func (m *StatsMutation) FlashDurationSelf() (r float32, exists bool) {
v := m.flash_duration_self
if v == nil {
return
}
return *v, true
}
// OldFlashDurationSelf returns the old "flash_duration_self" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldFlashDurationSelf(ctx context.Context) (v float32, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldFlashDurationSelf is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldFlashDurationSelf requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldFlashDurationSelf: %w", err)
}
return oldValue.FlashDurationSelf, nil
}
// AddFlashDurationSelf adds f to the "flash_duration_self" field.
func (m *StatsMutation) AddFlashDurationSelf(f float32) {
if m.addflash_duration_self != nil {
*m.addflash_duration_self += f
} else {
m.addflash_duration_self = &f
}
}
// AddedFlashDurationSelf returns the value that was added to the "flash_duration_self" field in this mutation.
func (m *StatsMutation) AddedFlashDurationSelf() (r float32, exists bool) {
v := m.addflash_duration_self
if v == nil {
return
}
return *v, true
}
// ClearFlashDurationSelf clears the value of the "flash_duration_self" field.
func (m *StatsMutation) ClearFlashDurationSelf() {
m.flash_duration_self = nil
m.addflash_duration_self = nil
m.clearedFields[stats.FieldFlashDurationSelf] = struct{}{}
}
// FlashDurationSelfCleared returns if the "flash_duration_self" field was cleared in this mutation.
func (m *StatsMutation) FlashDurationSelfCleared() bool {
_, ok := m.clearedFields[stats.FieldFlashDurationSelf]
return ok
}
// ResetFlashDurationSelf resets all changes to the "flash_duration_self" field.
func (m *StatsMutation) ResetFlashDurationSelf() {
m.flash_duration_self = nil
m.addflash_duration_self = nil
delete(m.clearedFields, stats.FieldFlashDurationSelf)
}
// SetFlashDurationTeam sets the "flash_duration_team" field.
func (m *StatsMutation) SetFlashDurationTeam(f float32) {
m.flash_duration_team = &f
m.addflash_duration_team = nil
}
// FlashDurationTeam returns the value of the "flash_duration_team" field in the mutation.
func (m *StatsMutation) FlashDurationTeam() (r float32, exists bool) {
v := m.flash_duration_team
if v == nil {
return
}
return *v, true
}
// OldFlashDurationTeam returns the old "flash_duration_team" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldFlashDurationTeam(ctx context.Context) (v float32, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldFlashDurationTeam is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldFlashDurationTeam requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldFlashDurationTeam: %w", err)
}
return oldValue.FlashDurationTeam, nil
}
// AddFlashDurationTeam adds f to the "flash_duration_team" field.
func (m *StatsMutation) AddFlashDurationTeam(f float32) {
if m.addflash_duration_team != nil {
*m.addflash_duration_team += f
} else {
m.addflash_duration_team = &f
}
}
// AddedFlashDurationTeam returns the value that was added to the "flash_duration_team" field in this mutation.
func (m *StatsMutation) AddedFlashDurationTeam() (r float32, exists bool) {
v := m.addflash_duration_team
if v == nil {
return
}
return *v, true
}
// ClearFlashDurationTeam clears the value of the "flash_duration_team" field.
func (m *StatsMutation) ClearFlashDurationTeam() {
m.flash_duration_team = nil
m.addflash_duration_team = nil
m.clearedFields[stats.FieldFlashDurationTeam] = struct{}{}
}
// FlashDurationTeamCleared returns if the "flash_duration_team" field was cleared in this mutation.
func (m *StatsMutation) FlashDurationTeamCleared() bool {
_, ok := m.clearedFields[stats.FieldFlashDurationTeam]
return ok
}
// ResetFlashDurationTeam resets all changes to the "flash_duration_team" field.
func (m *StatsMutation) ResetFlashDurationTeam() {
m.flash_duration_team = nil
m.addflash_duration_team = nil
delete(m.clearedFields, stats.FieldFlashDurationTeam)
}
// SetFlashDurationEnemy sets the "flash_duration_enemy" field.
func (m *StatsMutation) SetFlashDurationEnemy(f float32) {
m.flash_duration_enemy = &f
m.addflash_duration_enemy = nil
}
// FlashDurationEnemy returns the value of the "flash_duration_enemy" field in the mutation.
func (m *StatsMutation) FlashDurationEnemy() (r float32, exists bool) {
v := m.flash_duration_enemy
if v == nil {
return
}
return *v, true
}
// OldFlashDurationEnemy returns the old "flash_duration_enemy" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldFlashDurationEnemy(ctx context.Context) (v float32, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldFlashDurationEnemy is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldFlashDurationEnemy requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldFlashDurationEnemy: %w", err)
}
return oldValue.FlashDurationEnemy, nil
}
// AddFlashDurationEnemy adds f to the "flash_duration_enemy" field.
func (m *StatsMutation) AddFlashDurationEnemy(f float32) {
if m.addflash_duration_enemy != nil {
*m.addflash_duration_enemy += f
} else {
m.addflash_duration_enemy = &f
}
}
// AddedFlashDurationEnemy returns the value that was added to the "flash_duration_enemy" field in this mutation.
func (m *StatsMutation) AddedFlashDurationEnemy() (r float32, exists bool) {
v := m.addflash_duration_enemy
if v == nil {
return
}
return *v, true
}
// ClearFlashDurationEnemy clears the value of the "flash_duration_enemy" field.
func (m *StatsMutation) ClearFlashDurationEnemy() {
m.flash_duration_enemy = nil
m.addflash_duration_enemy = nil
m.clearedFields[stats.FieldFlashDurationEnemy] = struct{}{}
}
// FlashDurationEnemyCleared returns if the "flash_duration_enemy" field was cleared in this mutation.
func (m *StatsMutation) FlashDurationEnemyCleared() bool {
_, ok := m.clearedFields[stats.FieldFlashDurationEnemy]
return ok
}
// ResetFlashDurationEnemy resets all changes to the "flash_duration_enemy" field.
func (m *StatsMutation) ResetFlashDurationEnemy() {
m.flash_duration_enemy = nil
m.addflash_duration_enemy = nil
delete(m.clearedFields, stats.FieldFlashDurationEnemy)
}
// SetFlashTotalSelf sets the "flash_total_self" field.
func (m *StatsMutation) SetFlashTotalSelf(u uint) {
m.flash_total_self = &u
m.addflash_total_self = nil
}
// FlashTotalSelf returns the value of the "flash_total_self" field in the mutation.
func (m *StatsMutation) FlashTotalSelf() (r uint, exists bool) {
v := m.flash_total_self
if v == nil {
return
}
return *v, true
}
// OldFlashTotalSelf returns the old "flash_total_self" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldFlashTotalSelf(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldFlashTotalSelf is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldFlashTotalSelf requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldFlashTotalSelf: %w", err)
}
return oldValue.FlashTotalSelf, nil
}
// AddFlashTotalSelf adds u to the "flash_total_self" field.
func (m *StatsMutation) AddFlashTotalSelf(u uint) {
if m.addflash_total_self != nil {
*m.addflash_total_self += u
} else {
m.addflash_total_self = &u
}
}
// AddedFlashTotalSelf returns the value that was added to the "flash_total_self" field in this mutation.
func (m *StatsMutation) AddedFlashTotalSelf() (r uint, exists bool) {
v := m.addflash_total_self
if v == nil {
return
}
return *v, true
}
// ClearFlashTotalSelf clears the value of the "flash_total_self" field.
func (m *StatsMutation) ClearFlashTotalSelf() {
m.flash_total_self = nil
m.addflash_total_self = nil
m.clearedFields[stats.FieldFlashTotalSelf] = struct{}{}
}
// FlashTotalSelfCleared returns if the "flash_total_self" field was cleared in this mutation.
func (m *StatsMutation) FlashTotalSelfCleared() bool {
_, ok := m.clearedFields[stats.FieldFlashTotalSelf]
return ok
}
// ResetFlashTotalSelf resets all changes to the "flash_total_self" field.
func (m *StatsMutation) ResetFlashTotalSelf() {
m.flash_total_self = nil
m.addflash_total_self = nil
delete(m.clearedFields, stats.FieldFlashTotalSelf)
}
// SetFlashTotalTeam sets the "flash_total_team" field.
func (m *StatsMutation) SetFlashTotalTeam(u uint) {
m.flash_total_team = &u
m.addflash_total_team = nil
}
// FlashTotalTeam returns the value of the "flash_total_team" field in the mutation.
func (m *StatsMutation) FlashTotalTeam() (r uint, exists bool) {
v := m.flash_total_team
if v == nil {
return
}
return *v, true
}
// OldFlashTotalTeam returns the old "flash_total_team" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldFlashTotalTeam(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldFlashTotalTeam is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldFlashTotalTeam requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldFlashTotalTeam: %w", err)
}
return oldValue.FlashTotalTeam, nil
}
// AddFlashTotalTeam adds u to the "flash_total_team" field.
func (m *StatsMutation) AddFlashTotalTeam(u uint) {
if m.addflash_total_team != nil {
*m.addflash_total_team += u
} else {
m.addflash_total_team = &u
}
}
// AddedFlashTotalTeam returns the value that was added to the "flash_total_team" field in this mutation.
func (m *StatsMutation) AddedFlashTotalTeam() (r uint, exists bool) {
v := m.addflash_total_team
if v == nil {
return
}
return *v, true
}
// ClearFlashTotalTeam clears the value of the "flash_total_team" field.
func (m *StatsMutation) ClearFlashTotalTeam() {
m.flash_total_team = nil
m.addflash_total_team = nil
m.clearedFields[stats.FieldFlashTotalTeam] = struct{}{}
}
// FlashTotalTeamCleared returns if the "flash_total_team" field was cleared in this mutation.
func (m *StatsMutation) FlashTotalTeamCleared() bool {
_, ok := m.clearedFields[stats.FieldFlashTotalTeam]
return ok
}
// ResetFlashTotalTeam resets all changes to the "flash_total_team" field.
func (m *StatsMutation) ResetFlashTotalTeam() {
m.flash_total_team = nil
m.addflash_total_team = nil
delete(m.clearedFields, stats.FieldFlashTotalTeam)
}
// SetFlashTotalEnemy sets the "flash_total_enemy" field.
func (m *StatsMutation) SetFlashTotalEnemy(u uint) {
m.flash_total_enemy = &u
m.addflash_total_enemy = nil
}
// FlashTotalEnemy returns the value of the "flash_total_enemy" field in the mutation.
func (m *StatsMutation) FlashTotalEnemy() (r uint, exists bool) {
v := m.flash_total_enemy
if v == nil {
return
}
return *v, true
}
// OldFlashTotalEnemy returns the old "flash_total_enemy" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldFlashTotalEnemy(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldFlashTotalEnemy is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldFlashTotalEnemy requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldFlashTotalEnemy: %w", err)
}
return oldValue.FlashTotalEnemy, nil
}
// AddFlashTotalEnemy adds u to the "flash_total_enemy" field.
func (m *StatsMutation) AddFlashTotalEnemy(u uint) {
if m.addflash_total_enemy != nil {
*m.addflash_total_enemy += u
} else {
m.addflash_total_enemy = &u
}
}
// AddedFlashTotalEnemy returns the value that was added to the "flash_total_enemy" field in this mutation.
func (m *StatsMutation) AddedFlashTotalEnemy() (r uint, exists bool) {
v := m.addflash_total_enemy
if v == nil {
return
}
return *v, true
}
// ClearFlashTotalEnemy clears the value of the "flash_total_enemy" field.
func (m *StatsMutation) ClearFlashTotalEnemy() {
m.flash_total_enemy = nil
m.addflash_total_enemy = nil
m.clearedFields[stats.FieldFlashTotalEnemy] = struct{}{}
}
// FlashTotalEnemyCleared returns if the "flash_total_enemy" field was cleared in this mutation.
func (m *StatsMutation) FlashTotalEnemyCleared() bool {
_, ok := m.clearedFields[stats.FieldFlashTotalEnemy]
return ok
}
// ResetFlashTotalEnemy resets all changes to the "flash_total_enemy" field.
func (m *StatsMutation) ResetFlashTotalEnemy() {
m.flash_total_enemy = nil
m.addflash_total_enemy = nil
delete(m.clearedFields, stats.FieldFlashTotalEnemy)
}
// SetMatchStats sets the "match_stats" field.
func (m *StatsMutation) SetMatchStats(u uint64) {
m.matches = &u
}
// MatchStats returns the value of the "match_stats" field in the mutation.
func (m *StatsMutation) MatchStats() (r uint64, exists bool) {
v := m.matches
if v == nil {
return
}
return *v, true
}
// OldMatchStats returns the old "match_stats" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldMatchStats(ctx context.Context) (v uint64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldMatchStats is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldMatchStats requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMatchStats: %w", err)
}
return oldValue.MatchStats, nil
}
// ClearMatchStats clears the value of the "match_stats" field.
func (m *StatsMutation) ClearMatchStats() {
m.matches = nil
m.clearedFields[stats.FieldMatchStats] = struct{}{}
}
// MatchStatsCleared returns if the "match_stats" field was cleared in this mutation.
func (m *StatsMutation) MatchStatsCleared() bool {
_, ok := m.clearedFields[stats.FieldMatchStats]
return ok
}
// ResetMatchStats resets all changes to the "match_stats" field.
func (m *StatsMutation) ResetMatchStats() {
m.matches = nil
delete(m.clearedFields, stats.FieldMatchStats)
}
// SetPlayerStats sets the "player_stats" field.
func (m *StatsMutation) SetPlayerStats(u uint64) {
m.players = &u
}
// PlayerStats returns the value of the "player_stats" field in the mutation.
func (m *StatsMutation) PlayerStats() (r uint64, exists bool) {
v := m.players
if v == nil {
return
}
return *v, true
}
// OldPlayerStats returns the old "player_stats" field's value of the Stats entity.
// If the Stats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *StatsMutation) OldPlayerStats(ctx context.Context) (v uint64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldPlayerStats is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldPlayerStats requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPlayerStats: %w", err)
}
return oldValue.PlayerStats, nil
}
// ClearPlayerStats clears the value of the "player_stats" field.
func (m *StatsMutation) ClearPlayerStats() {
m.players = nil
m.clearedFields[stats.FieldPlayerStats] = struct{}{}
}
// PlayerStatsCleared returns if the "player_stats" field was cleared in this mutation.
func (m *StatsMutation) PlayerStatsCleared() bool {
_, ok := m.clearedFields[stats.FieldPlayerStats]
return ok
}
// ResetPlayerStats resets all changes to the "player_stats" field.
func (m *StatsMutation) ResetPlayerStats() {
m.players = nil
delete(m.clearedFields, stats.FieldPlayerStats)
}
// SetMatchesID sets the "matches" edge to the Match entity by id.
func (m *StatsMutation) SetMatchesID(id uint64) {
m.matches = &id
}
// ClearMatches clears the "matches" edge to the Match entity.
func (m *StatsMutation) ClearMatches() {
m.clearedmatches = true
}
// MatchesCleared reports if the "matches" edge to the Match entity was cleared.
func (m *StatsMutation) MatchesCleared() bool {
return m.MatchStatsCleared() || m.clearedmatches
}
// MatchesID returns the "matches" edge ID in the mutation.
func (m *StatsMutation) MatchesID() (id uint64, exists bool) {
if m.matches != nil {
return *m.matches, true
}
return
}
// MatchesIDs returns the "matches" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// MatchesID instead. It exists only for internal usage by the builders.
func (m *StatsMutation) MatchesIDs() (ids []uint64) {
if id := m.matches; id != nil {
ids = append(ids, *id)
}
return
}
// ResetMatches resets all changes to the "matches" edge.
func (m *StatsMutation) ResetMatches() {
m.matches = nil
m.clearedmatches = false
}
// SetPlayersID sets the "players" edge to the Player entity by id.
func (m *StatsMutation) SetPlayersID(id uint64) {
m.players = &id
}
// ClearPlayers clears the "players" edge to the Player entity.
func (m *StatsMutation) ClearPlayers() {
m.clearedplayers = true
}
// PlayersCleared reports if the "players" edge to the Player entity was cleared.
func (m *StatsMutation) PlayersCleared() bool {
return m.PlayerStatsCleared() || m.clearedplayers
}
// PlayersID returns the "players" edge ID in the mutation.
func (m *StatsMutation) PlayersID() (id uint64, exists bool) {
if m.players != nil {
return *m.players, true
}
return
}
// PlayersIDs returns the "players" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// PlayersID instead. It exists only for internal usage by the builders.
func (m *StatsMutation) PlayersIDs() (ids []uint64) {
if id := m.players; id != nil {
ids = append(ids, *id)
}
return
}
// ResetPlayers resets all changes to the "players" edge.
func (m *StatsMutation) ResetPlayers() {
m.players = nil
m.clearedplayers = false
}
// AddWeaponStatIDs adds the "weapon_stats" edge to the WeaponStats entity by ids.
func (m *StatsMutation) AddWeaponStatIDs(ids ...int) {
if m.weapon_stats == nil {
m.weapon_stats = make(map[int]struct{})
}
for i := range ids {
m.weapon_stats[ids[i]] = struct{}{}
}
}
// ClearWeaponStats clears the "weapon_stats" edge to the WeaponStats entity.
func (m *StatsMutation) ClearWeaponStats() {
m.clearedweapon_stats = true
}
// WeaponStatsCleared reports if the "weapon_stats" edge to the WeaponStats entity was cleared.
func (m *StatsMutation) WeaponStatsCleared() bool {
return m.clearedweapon_stats
}
// RemoveWeaponStatIDs removes the "weapon_stats" edge to the WeaponStats entity by IDs.
func (m *StatsMutation) RemoveWeaponStatIDs(ids ...int) {
if m.removedweapon_stats == nil {
m.removedweapon_stats = make(map[int]struct{})
}
for i := range ids {
delete(m.weapon_stats, ids[i])
m.removedweapon_stats[ids[i]] = struct{}{}
}
}
// RemovedWeaponStats returns the removed IDs of the "weapon_stats" edge to the WeaponStats entity.
func (m *StatsMutation) RemovedWeaponStatsIDs() (ids []int) {
for id := range m.removedweapon_stats {
ids = append(ids, id)
}
return
}
// WeaponStatsIDs returns the "weapon_stats" edge IDs in the mutation.
func (m *StatsMutation) WeaponStatsIDs() (ids []int) {
for id := range m.weapon_stats {
ids = append(ids, id)
}
return
}
// ResetWeaponStats resets all changes to the "weapon_stats" edge.
func (m *StatsMutation) ResetWeaponStats() {
m.weapon_stats = nil
m.clearedweapon_stats = false
m.removedweapon_stats = nil
}
// AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by ids.
func (m *StatsMutation) AddRoundStatIDs(ids ...int) {
if m.round_stats == nil {
m.round_stats = make(map[int]struct{})
}
for i := range ids {
m.round_stats[ids[i]] = struct{}{}
}
}
// ClearRoundStats clears the "round_stats" edge to the RoundStats entity.
func (m *StatsMutation) ClearRoundStats() {
m.clearedround_stats = true
}
// RoundStatsCleared reports if the "round_stats" edge to the RoundStats entity was cleared.
func (m *StatsMutation) RoundStatsCleared() bool {
return m.clearedround_stats
}
// RemoveRoundStatIDs removes the "round_stats" edge to the RoundStats entity by IDs.
func (m *StatsMutation) RemoveRoundStatIDs(ids ...int) {
if m.removedround_stats == nil {
m.removedround_stats = make(map[int]struct{})
}
for i := range ids {
delete(m.round_stats, ids[i])
m.removedround_stats[ids[i]] = struct{}{}
}
}
// RemovedRoundStats returns the removed IDs of the "round_stats" edge to the RoundStats entity.
func (m *StatsMutation) RemovedRoundStatsIDs() (ids []int) {
for id := range m.removedround_stats {
ids = append(ids, id)
}
return
}
// RoundStatsIDs returns the "round_stats" edge IDs in the mutation.
func (m *StatsMutation) RoundStatsIDs() (ids []int) {
for id := range m.round_stats {
ids = append(ids, id)
}
return
}
// ResetRoundStats resets all changes to the "round_stats" edge.
func (m *StatsMutation) ResetRoundStats() {
m.round_stats = nil
m.clearedround_stats = false
m.removedround_stats = nil
}
// Where appends a list predicates to the StatsMutation builder.
func (m *StatsMutation) Where(ps ...predicate.Stats) {
m.predicates = append(m.predicates, ps...)
}
// Op returns the operation name.
func (m *StatsMutation) Op() Op {
return m.op
}
// Type returns the node type of this mutation (Stats).
func (m *StatsMutation) Type() string {
return m.typ
}
// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *StatsMutation) Fields() []string {
fields := make([]string, 0, 31)
if m.team_id != nil {
fields = append(fields, stats.FieldTeamID)
}
if m.kills != nil {
fields = append(fields, stats.FieldKills)
}
if m.deaths != nil {
fields = append(fields, stats.FieldDeaths)
}
if m.assists != nil {
fields = append(fields, stats.FieldAssists)
}
if m.headshot != nil {
fields = append(fields, stats.FieldHeadshot)
}
if m.mvp != nil {
fields = append(fields, stats.FieldMvp)
}
if m.score != nil {
fields = append(fields, stats.FieldScore)
}
if m.rank_new != nil {
fields = append(fields, stats.FieldRankNew)
}
if m.rank_old != nil {
fields = append(fields, stats.FieldRankOld)
}
if m.mk_2 != nil {
fields = append(fields, stats.FieldMk2)
}
if m.mk_3 != nil {
fields = append(fields, stats.FieldMk3)
}
if m.mk_4 != nil {
fields = append(fields, stats.FieldMk4)
}
if m.mk_5 != nil {
fields = append(fields, stats.FieldMk5)
}
if m.dmg_enemy != nil {
fields = append(fields, stats.FieldDmgEnemy)
}
if m.dmg_team != nil {
fields = append(fields, stats.FieldDmgTeam)
}
if m.ud_he != nil {
fields = append(fields, stats.FieldUdHe)
}
if m.ud_flames != nil {
fields = append(fields, stats.FieldUdFlames)
}
if m.ud_flash != nil {
fields = append(fields, stats.FieldUdFlash)
}
if m.ud_decoy != nil {
fields = append(fields, stats.FieldUdDecoy)
}
if m.ud_smoke != nil {
fields = append(fields, stats.FieldUdSmoke)
}
if m.crosshair != nil {
fields = append(fields, stats.FieldCrosshair)
}
if m.color != nil {
fields = append(fields, stats.FieldColor)
}
if m.kast != nil {
fields = append(fields, stats.FieldKast)
}
if m.flash_duration_self != nil {
fields = append(fields, stats.FieldFlashDurationSelf)
}
if m.flash_duration_team != nil {
fields = append(fields, stats.FieldFlashDurationTeam)
}
if m.flash_duration_enemy != nil {
fields = append(fields, stats.FieldFlashDurationEnemy)
}
if m.flash_total_self != nil {
fields = append(fields, stats.FieldFlashTotalSelf)
}
if m.flash_total_team != nil {
fields = append(fields, stats.FieldFlashTotalTeam)
}
if m.flash_total_enemy != nil {
fields = append(fields, stats.FieldFlashTotalEnemy)
}
if m.matches != nil {
fields = append(fields, stats.FieldMatchStats)
}
if m.players != nil {
fields = append(fields, stats.FieldPlayerStats)
}
return fields
}
// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *StatsMutation) Field(name string) (ent.Value, bool) {
switch name {
case stats.FieldTeamID:
return m.TeamID()
case stats.FieldKills:
return m.Kills()
case stats.FieldDeaths:
return m.Deaths()
case stats.FieldAssists:
return m.Assists()
case stats.FieldHeadshot:
return m.Headshot()
case stats.FieldMvp:
return m.Mvp()
case stats.FieldScore:
return m.Score()
case stats.FieldRankNew:
return m.RankNew()
case stats.FieldRankOld:
return m.RankOld()
case stats.FieldMk2:
return m.Mk2()
case stats.FieldMk3:
return m.Mk3()
case stats.FieldMk4:
return m.Mk4()
case stats.FieldMk5:
return m.Mk5()
case stats.FieldDmgEnemy:
return m.DmgEnemy()
case stats.FieldDmgTeam:
return m.DmgTeam()
case stats.FieldUdHe:
return m.UdHe()
case stats.FieldUdFlames:
return m.UdFlames()
case stats.FieldUdFlash:
return m.UdFlash()
case stats.FieldUdDecoy:
return m.UdDecoy()
case stats.FieldUdSmoke:
return m.UdSmoke()
case stats.FieldCrosshair:
return m.Crosshair()
case stats.FieldColor:
return m.Color()
case stats.FieldKast:
return m.Kast()
case stats.FieldFlashDurationSelf:
return m.FlashDurationSelf()
case stats.FieldFlashDurationTeam:
return m.FlashDurationTeam()
case stats.FieldFlashDurationEnemy:
return m.FlashDurationEnemy()
case stats.FieldFlashTotalSelf:
return m.FlashTotalSelf()
case stats.FieldFlashTotalTeam:
return m.FlashTotalTeam()
case stats.FieldFlashTotalEnemy:
return m.FlashTotalEnemy()
case stats.FieldMatchStats:
return m.MatchStats()
case stats.FieldPlayerStats:
return m.PlayerStats()
}
return nil, false
}
// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *StatsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case stats.FieldTeamID:
return m.OldTeamID(ctx)
case stats.FieldKills:
return m.OldKills(ctx)
case stats.FieldDeaths:
return m.OldDeaths(ctx)
case stats.FieldAssists:
return m.OldAssists(ctx)
case stats.FieldHeadshot:
return m.OldHeadshot(ctx)
case stats.FieldMvp:
return m.OldMvp(ctx)
case stats.FieldScore:
return m.OldScore(ctx)
case stats.FieldRankNew:
return m.OldRankNew(ctx)
case stats.FieldRankOld:
return m.OldRankOld(ctx)
case stats.FieldMk2:
return m.OldMk2(ctx)
case stats.FieldMk3:
return m.OldMk3(ctx)
case stats.FieldMk4:
return m.OldMk4(ctx)
case stats.FieldMk5:
return m.OldMk5(ctx)
case stats.FieldDmgEnemy:
return m.OldDmgEnemy(ctx)
case stats.FieldDmgTeam:
return m.OldDmgTeam(ctx)
case stats.FieldUdHe:
return m.OldUdHe(ctx)
case stats.FieldUdFlames:
return m.OldUdFlames(ctx)
case stats.FieldUdFlash:
return m.OldUdFlash(ctx)
case stats.FieldUdDecoy:
return m.OldUdDecoy(ctx)
case stats.FieldUdSmoke:
return m.OldUdSmoke(ctx)
case stats.FieldCrosshair:
return m.OldCrosshair(ctx)
case stats.FieldColor:
return m.OldColor(ctx)
case stats.FieldKast:
return m.OldKast(ctx)
case stats.FieldFlashDurationSelf:
return m.OldFlashDurationSelf(ctx)
case stats.FieldFlashDurationTeam:
return m.OldFlashDurationTeam(ctx)
case stats.FieldFlashDurationEnemy:
return m.OldFlashDurationEnemy(ctx)
case stats.FieldFlashTotalSelf:
return m.OldFlashTotalSelf(ctx)
case stats.FieldFlashTotalTeam:
return m.OldFlashTotalTeam(ctx)
case stats.FieldFlashTotalEnemy:
return m.OldFlashTotalEnemy(ctx)
case stats.FieldMatchStats:
return m.OldMatchStats(ctx)
case stats.FieldPlayerStats:
return m.OldPlayerStats(ctx)
}
return nil, fmt.Errorf("unknown Stats field %s", name)
}
// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *StatsMutation) SetField(name string, value ent.Value) error {
switch name {
case stats.FieldTeamID:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTeamID(v)
return nil
case stats.FieldKills:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetKills(v)
return nil
case stats.FieldDeaths:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDeaths(v)
return nil
case stats.FieldAssists:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAssists(v)
return nil
case stats.FieldHeadshot:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetHeadshot(v)
return nil
case stats.FieldMvp:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMvp(v)
return nil
case stats.FieldScore:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetScore(v)
return nil
case stats.FieldRankNew:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRankNew(v)
return nil
case stats.FieldRankOld:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRankOld(v)
return nil
case stats.FieldMk2:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMk2(v)
return nil
case stats.FieldMk3:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMk3(v)
return nil
case stats.FieldMk4:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMk4(v)
return nil
case stats.FieldMk5:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMk5(v)
return nil
case stats.FieldDmgEnemy:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDmgEnemy(v)
return nil
case stats.FieldDmgTeam:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDmgTeam(v)
return nil
case stats.FieldUdHe:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUdHe(v)
return nil
case stats.FieldUdFlames:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUdFlames(v)
return nil
case stats.FieldUdFlash:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUdFlash(v)
return nil
case stats.FieldUdDecoy:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUdDecoy(v)
return nil
case stats.FieldUdSmoke:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUdSmoke(v)
return nil
case stats.FieldCrosshair:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCrosshair(v)
return nil
case stats.FieldColor:
v, ok := value.(stats.Color)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetColor(v)
return nil
case stats.FieldKast:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetKast(v)
return nil
case stats.FieldFlashDurationSelf:
v, ok := value.(float32)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetFlashDurationSelf(v)
return nil
case stats.FieldFlashDurationTeam:
v, ok := value.(float32)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetFlashDurationTeam(v)
return nil
case stats.FieldFlashDurationEnemy:
v, ok := value.(float32)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetFlashDurationEnemy(v)
return nil
case stats.FieldFlashTotalSelf:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetFlashTotalSelf(v)
return nil
case stats.FieldFlashTotalTeam:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetFlashTotalTeam(v)
return nil
case stats.FieldFlashTotalEnemy:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetFlashTotalEnemy(v)
return nil
case stats.FieldMatchStats:
v, ok := value.(uint64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMatchStats(v)
return nil
case stats.FieldPlayerStats:
v, ok := value.(uint64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetPlayerStats(v)
return nil
}
return fmt.Errorf("unknown Stats field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *StatsMutation) AddedFields() []string {
var fields []string
if m.addteam_id != nil {
fields = append(fields, stats.FieldTeamID)
}
if m.addkills != nil {
fields = append(fields, stats.FieldKills)
}
if m.adddeaths != nil {
fields = append(fields, stats.FieldDeaths)
}
if m.addassists != nil {
fields = append(fields, stats.FieldAssists)
}
if m.addheadshot != nil {
fields = append(fields, stats.FieldHeadshot)
}
if m.addmvp != nil {
fields = append(fields, stats.FieldMvp)
}
if m.addscore != nil {
fields = append(fields, stats.FieldScore)
}
if m.addrank_new != nil {
fields = append(fields, stats.FieldRankNew)
}
if m.addrank_old != nil {
fields = append(fields, stats.FieldRankOld)
}
if m.addmk_2 != nil {
fields = append(fields, stats.FieldMk2)
}
if m.addmk_3 != nil {
fields = append(fields, stats.FieldMk3)
}
if m.addmk_4 != nil {
fields = append(fields, stats.FieldMk4)
}
if m.addmk_5 != nil {
fields = append(fields, stats.FieldMk5)
}
if m.adddmg_enemy != nil {
fields = append(fields, stats.FieldDmgEnemy)
}
if m.adddmg_team != nil {
fields = append(fields, stats.FieldDmgTeam)
}
if m.addud_he != nil {
fields = append(fields, stats.FieldUdHe)
}
if m.addud_flames != nil {
fields = append(fields, stats.FieldUdFlames)
}
if m.addud_flash != nil {
fields = append(fields, stats.FieldUdFlash)
}
if m.addud_decoy != nil {
fields = append(fields, stats.FieldUdDecoy)
}
if m.addud_smoke != nil {
fields = append(fields, stats.FieldUdSmoke)
}
if m.addkast != nil {
fields = append(fields, stats.FieldKast)
}
if m.addflash_duration_self != nil {
fields = append(fields, stats.FieldFlashDurationSelf)
}
if m.addflash_duration_team != nil {
fields = append(fields, stats.FieldFlashDurationTeam)
}
if m.addflash_duration_enemy != nil {
fields = append(fields, stats.FieldFlashDurationEnemy)
}
if m.addflash_total_self != nil {
fields = append(fields, stats.FieldFlashTotalSelf)
}
if m.addflash_total_team != nil {
fields = append(fields, stats.FieldFlashTotalTeam)
}
if m.addflash_total_enemy != nil {
fields = append(fields, stats.FieldFlashTotalEnemy)
}
return fields
}
// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *StatsMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case stats.FieldTeamID:
return m.AddedTeamID()
case stats.FieldKills:
return m.AddedKills()
case stats.FieldDeaths:
return m.AddedDeaths()
case stats.FieldAssists:
return m.AddedAssists()
case stats.FieldHeadshot:
return m.AddedHeadshot()
case stats.FieldMvp:
return m.AddedMvp()
case stats.FieldScore:
return m.AddedScore()
case stats.FieldRankNew:
return m.AddedRankNew()
case stats.FieldRankOld:
return m.AddedRankOld()
case stats.FieldMk2:
return m.AddedMk2()
case stats.FieldMk3:
return m.AddedMk3()
case stats.FieldMk4:
return m.AddedMk4()
case stats.FieldMk5:
return m.AddedMk5()
case stats.FieldDmgEnemy:
return m.AddedDmgEnemy()
case stats.FieldDmgTeam:
return m.AddedDmgTeam()
case stats.FieldUdHe:
return m.AddedUdHe()
case stats.FieldUdFlames:
return m.AddedUdFlames()
case stats.FieldUdFlash:
return m.AddedUdFlash()
case stats.FieldUdDecoy:
return m.AddedUdDecoy()
case stats.FieldUdSmoke:
return m.AddedUdSmoke()
case stats.FieldKast:
return m.AddedKast()
case stats.FieldFlashDurationSelf:
return m.AddedFlashDurationSelf()
case stats.FieldFlashDurationTeam:
return m.AddedFlashDurationTeam()
case stats.FieldFlashDurationEnemy:
return m.AddedFlashDurationEnemy()
case stats.FieldFlashTotalSelf:
return m.AddedFlashTotalSelf()
case stats.FieldFlashTotalTeam:
return m.AddedFlashTotalTeam()
case stats.FieldFlashTotalEnemy:
return m.AddedFlashTotalEnemy()
}
return nil, false
}
// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *StatsMutation) AddField(name string, value ent.Value) error {
switch name {
case stats.FieldTeamID:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddTeamID(v)
return nil
case stats.FieldKills:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddKills(v)
return nil
case stats.FieldDeaths:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddDeaths(v)
return nil
case stats.FieldAssists:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddAssists(v)
return nil
case stats.FieldHeadshot:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddHeadshot(v)
return nil
case stats.FieldMvp:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddMvp(v)
return nil
case stats.FieldScore:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddScore(v)
return nil
case stats.FieldRankNew:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddRankNew(v)
return nil
case stats.FieldRankOld:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddRankOld(v)
return nil
case stats.FieldMk2:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddMk2(v)
return nil
case stats.FieldMk3:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddMk3(v)
return nil
case stats.FieldMk4:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddMk4(v)
return nil
case stats.FieldMk5:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddMk5(v)
return nil
case stats.FieldDmgEnemy:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddDmgEnemy(v)
return nil
case stats.FieldDmgTeam:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddDmgTeam(v)
return nil
case stats.FieldUdHe:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddUdHe(v)
return nil
case stats.FieldUdFlames:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddUdFlames(v)
return nil
case stats.FieldUdFlash:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddUdFlash(v)
return nil
case stats.FieldUdDecoy:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddUdDecoy(v)
return nil
case stats.FieldUdSmoke:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddUdSmoke(v)
return nil
case stats.FieldKast:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddKast(v)
return nil
case stats.FieldFlashDurationSelf:
v, ok := value.(float32)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddFlashDurationSelf(v)
return nil
case stats.FieldFlashDurationTeam:
v, ok := value.(float32)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddFlashDurationTeam(v)
return nil
case stats.FieldFlashDurationEnemy:
v, ok := value.(float32)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddFlashDurationEnemy(v)
return nil
case stats.FieldFlashTotalSelf:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddFlashTotalSelf(v)
return nil
case stats.FieldFlashTotalTeam:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddFlashTotalTeam(v)
return nil
case stats.FieldFlashTotalEnemy:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddFlashTotalEnemy(v)
return nil
}
return fmt.Errorf("unknown Stats numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *StatsMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(stats.FieldRankNew) {
fields = append(fields, stats.FieldRankNew)
}
if m.FieldCleared(stats.FieldRankOld) {
fields = append(fields, stats.FieldRankOld)
}
if m.FieldCleared(stats.FieldMk2) {
fields = append(fields, stats.FieldMk2)
}
if m.FieldCleared(stats.FieldMk3) {
fields = append(fields, stats.FieldMk3)
}
if m.FieldCleared(stats.FieldMk4) {
fields = append(fields, stats.FieldMk4)
}
if m.FieldCleared(stats.FieldMk5) {
fields = append(fields, stats.FieldMk5)
}
if m.FieldCleared(stats.FieldDmgEnemy) {
fields = append(fields, stats.FieldDmgEnemy)
}
if m.FieldCleared(stats.FieldDmgTeam) {
fields = append(fields, stats.FieldDmgTeam)
}
if m.FieldCleared(stats.FieldUdHe) {
fields = append(fields, stats.FieldUdHe)
}
if m.FieldCleared(stats.FieldUdFlames) {
fields = append(fields, stats.FieldUdFlames)
}
if m.FieldCleared(stats.FieldUdFlash) {
fields = append(fields, stats.FieldUdFlash)
}
if m.FieldCleared(stats.FieldUdDecoy) {
fields = append(fields, stats.FieldUdDecoy)
}
if m.FieldCleared(stats.FieldUdSmoke) {
fields = append(fields, stats.FieldUdSmoke)
}
if m.FieldCleared(stats.FieldCrosshair) {
fields = append(fields, stats.FieldCrosshair)
}
if m.FieldCleared(stats.FieldColor) {
fields = append(fields, stats.FieldColor)
}
if m.FieldCleared(stats.FieldKast) {
fields = append(fields, stats.FieldKast)
}
if m.FieldCleared(stats.FieldFlashDurationSelf) {
fields = append(fields, stats.FieldFlashDurationSelf)
}
if m.FieldCleared(stats.FieldFlashDurationTeam) {
fields = append(fields, stats.FieldFlashDurationTeam)
}
if m.FieldCleared(stats.FieldFlashDurationEnemy) {
fields = append(fields, stats.FieldFlashDurationEnemy)
}
if m.FieldCleared(stats.FieldFlashTotalSelf) {
fields = append(fields, stats.FieldFlashTotalSelf)
}
if m.FieldCleared(stats.FieldFlashTotalTeam) {
fields = append(fields, stats.FieldFlashTotalTeam)
}
if m.FieldCleared(stats.FieldFlashTotalEnemy) {
fields = append(fields, stats.FieldFlashTotalEnemy)
}
if m.FieldCleared(stats.FieldMatchStats) {
fields = append(fields, stats.FieldMatchStats)
}
if m.FieldCleared(stats.FieldPlayerStats) {
fields = append(fields, stats.FieldPlayerStats)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *StatsMutation) FieldCleared(name string) bool {
_, ok := m.clearedFields[name]
return ok
}
// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *StatsMutation) ClearField(name string) error {
switch name {
case stats.FieldRankNew:
m.ClearRankNew()
return nil
case stats.FieldRankOld:
m.ClearRankOld()
return nil
case stats.FieldMk2:
m.ClearMk2()
return nil
case stats.FieldMk3:
m.ClearMk3()
return nil
case stats.FieldMk4:
m.ClearMk4()
return nil
case stats.FieldMk5:
m.ClearMk5()
return nil
case stats.FieldDmgEnemy:
m.ClearDmgEnemy()
return nil
case stats.FieldDmgTeam:
m.ClearDmgTeam()
return nil
case stats.FieldUdHe:
m.ClearUdHe()
return nil
case stats.FieldUdFlames:
m.ClearUdFlames()
return nil
case stats.FieldUdFlash:
m.ClearUdFlash()
return nil
case stats.FieldUdDecoy:
m.ClearUdDecoy()
return nil
case stats.FieldUdSmoke:
m.ClearUdSmoke()
return nil
case stats.FieldCrosshair:
m.ClearCrosshair()
return nil
case stats.FieldColor:
m.ClearColor()
return nil
case stats.FieldKast:
m.ClearKast()
return nil
case stats.FieldFlashDurationSelf:
m.ClearFlashDurationSelf()
return nil
case stats.FieldFlashDurationTeam:
m.ClearFlashDurationTeam()
return nil
case stats.FieldFlashDurationEnemy:
m.ClearFlashDurationEnemy()
return nil
case stats.FieldFlashTotalSelf:
m.ClearFlashTotalSelf()
return nil
case stats.FieldFlashTotalTeam:
m.ClearFlashTotalTeam()
return nil
case stats.FieldFlashTotalEnemy:
m.ClearFlashTotalEnemy()
return nil
case stats.FieldMatchStats:
m.ClearMatchStats()
return nil
case stats.FieldPlayerStats:
m.ClearPlayerStats()
return nil
}
return fmt.Errorf("unknown Stats nullable field %s", name)
}
// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *StatsMutation) ResetField(name string) error {
switch name {
case stats.FieldTeamID:
m.ResetTeamID()
return nil
case stats.FieldKills:
m.ResetKills()
return nil
case stats.FieldDeaths:
m.ResetDeaths()
return nil
case stats.FieldAssists:
m.ResetAssists()
return nil
case stats.FieldHeadshot:
m.ResetHeadshot()
return nil
case stats.FieldMvp:
m.ResetMvp()
return nil
case stats.FieldScore:
m.ResetScore()
return nil
case stats.FieldRankNew:
m.ResetRankNew()
return nil
case stats.FieldRankOld:
m.ResetRankOld()
return nil
case stats.FieldMk2:
m.ResetMk2()
return nil
case stats.FieldMk3:
m.ResetMk3()
return nil
case stats.FieldMk4:
m.ResetMk4()
return nil
case stats.FieldMk5:
m.ResetMk5()
return nil
case stats.FieldDmgEnemy:
m.ResetDmgEnemy()
return nil
case stats.FieldDmgTeam:
m.ResetDmgTeam()
return nil
case stats.FieldUdHe:
m.ResetUdHe()
return nil
case stats.FieldUdFlames:
m.ResetUdFlames()
return nil
case stats.FieldUdFlash:
m.ResetUdFlash()
return nil
case stats.FieldUdDecoy:
m.ResetUdDecoy()
return nil
case stats.FieldUdSmoke:
m.ResetUdSmoke()
return nil
case stats.FieldCrosshair:
m.ResetCrosshair()
return nil
case stats.FieldColor:
m.ResetColor()
return nil
case stats.FieldKast:
m.ResetKast()
return nil
case stats.FieldFlashDurationSelf:
m.ResetFlashDurationSelf()
return nil
case stats.FieldFlashDurationTeam:
m.ResetFlashDurationTeam()
return nil
case stats.FieldFlashDurationEnemy:
m.ResetFlashDurationEnemy()
return nil
case stats.FieldFlashTotalSelf:
m.ResetFlashTotalSelf()
return nil
case stats.FieldFlashTotalTeam:
m.ResetFlashTotalTeam()
return nil
case stats.FieldFlashTotalEnemy:
m.ResetFlashTotalEnemy()
return nil
case stats.FieldMatchStats:
m.ResetMatchStats()
return nil
case stats.FieldPlayerStats:
m.ResetPlayerStats()
return nil
}
return fmt.Errorf("unknown Stats field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *StatsMutation) AddedEdges() []string {
edges := make([]string, 0, 4)
if m.matches != nil {
edges = append(edges, stats.EdgeMatches)
}
if m.players != nil {
edges = append(edges, stats.EdgePlayers)
}
if m.weapon_stats != nil {
edges = append(edges, stats.EdgeWeaponStats)
}
if m.round_stats != nil {
edges = append(edges, stats.EdgeRoundStats)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *StatsMutation) AddedIDs(name string) []ent.Value {
switch name {
case stats.EdgeMatches:
if id := m.matches; id != nil {
return []ent.Value{*id}
}
case stats.EdgePlayers:
if id := m.players; id != nil {
return []ent.Value{*id}
}
case stats.EdgeWeaponStats:
ids := make([]ent.Value, 0, len(m.weapon_stats))
for id := range m.weapon_stats {
ids = append(ids, id)
}
return ids
case stats.EdgeRoundStats:
ids := make([]ent.Value, 0, len(m.round_stats))
for id := range m.round_stats {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *StatsMutation) RemovedEdges() []string {
edges := make([]string, 0, 4)
if m.removedweapon_stats != nil {
edges = append(edges, stats.EdgeWeaponStats)
}
if m.removedround_stats != nil {
edges = append(edges, stats.EdgeRoundStats)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *StatsMutation) RemovedIDs(name string) []ent.Value {
switch name {
case stats.EdgeWeaponStats:
ids := make([]ent.Value, 0, len(m.removedweapon_stats))
for id := range m.removedweapon_stats {
ids = append(ids, id)
}
return ids
case stats.EdgeRoundStats:
ids := make([]ent.Value, 0, len(m.removedround_stats))
for id := range m.removedround_stats {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *StatsMutation) ClearedEdges() []string {
edges := make([]string, 0, 4)
if m.clearedmatches {
edges = append(edges, stats.EdgeMatches)
}
if m.clearedplayers {
edges = append(edges, stats.EdgePlayers)
}
if m.clearedweapon_stats {
edges = append(edges, stats.EdgeWeaponStats)
}
if m.clearedround_stats {
edges = append(edges, stats.EdgeRoundStats)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *StatsMutation) EdgeCleared(name string) bool {
switch name {
case stats.EdgeMatches:
return m.clearedmatches
case stats.EdgePlayers:
return m.clearedplayers
case stats.EdgeWeaponStats:
return m.clearedweapon_stats
case stats.EdgeRoundStats:
return m.clearedround_stats
}
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *StatsMutation) ClearEdge(name string) error {
switch name {
case stats.EdgeMatches:
m.ClearMatches()
return nil
case stats.EdgePlayers:
m.ClearPlayers()
return nil
}
return fmt.Errorf("unknown Stats unique edge %s", name)
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *StatsMutation) ResetEdge(name string) error {
switch name {
case stats.EdgeMatches:
m.ResetMatches()
return nil
case stats.EdgePlayers:
m.ResetPlayers()
return nil
case stats.EdgeWeaponStats:
m.ResetWeaponStats()
return nil
case stats.EdgeRoundStats:
m.ResetRoundStats()
return nil
}
return fmt.Errorf("unknown Stats edge %s", name)
}
// WeaponStatsMutation represents an operation that mutates the WeaponStats nodes in the graph.
type WeaponStatsMutation struct {
config
op Op
typ string
id *int
victim *uint64
addvictim *uint64
dmg *uint
adddmg *uint
eq_type *int
addeq_type *int
hit_group *int
addhit_group *int
clearedFields map[string]struct{}
stat *int
clearedstat bool
done bool
oldValue func(context.Context) (*WeaponStats, error)
predicates []predicate.WeaponStats
}
var _ ent.Mutation = (*WeaponStatsMutation)(nil)
// weaponstatsOption allows management of the mutation configuration using functional options.
type weaponstatsOption func(*WeaponStatsMutation)
// newWeaponStatsMutation creates new mutation for the WeaponStats entity.
func newWeaponStatsMutation(c config, op Op, opts ...weaponstatsOption) *WeaponStatsMutation {
m := &WeaponStatsMutation{
config: c,
op: op,
typ: TypeWeaponStats,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withWeaponStatsID sets the ID field of the mutation.
func withWeaponStatsID(id int) weaponstatsOption {
return func(m *WeaponStatsMutation) {
var (
err error
once sync.Once
value *WeaponStats
)
m.oldValue = func(ctx context.Context) (*WeaponStats, error) {
once.Do(func() {
if m.done {
err = fmt.Errorf("querying old values post mutation is not allowed")
} else {
value, err = m.Client().WeaponStats.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withWeaponStats sets the old WeaponStats of the mutation.
func withWeaponStats(node *WeaponStats) weaponstatsOption {
return func(m *WeaponStatsMutation) {
m.oldValue = func(context.Context) (*WeaponStats, error) {
return node, nil
}
m.id = &node.ID
}
}
// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m WeaponStatsMutation) Client() *Client {
client := &Client{config: m.config}
client.init()
return client
}
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m WeaponStatsMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, fmt.Errorf("ent: mutation is not running in a transaction")
}
tx := &Tx{config: m.config}
tx.init()
return tx, nil
}
// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *WeaponStatsMutation) ID() (id int, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// SetVictim sets the "victim" field.
func (m *WeaponStatsMutation) SetVictim(u uint64) {
m.victim = &u
m.addvictim = nil
}
// Victim returns the value of the "victim" field in the mutation.
func (m *WeaponStatsMutation) Victim() (r uint64, exists bool) {
v := m.victim
if v == nil {
return
}
return *v, true
}
// OldVictim returns the old "victim" field's value of the WeaponStats entity.
// If the WeaponStats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *WeaponStatsMutation) OldVictim(ctx context.Context) (v uint64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldVictim is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldVictim requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldVictim: %w", err)
}
return oldValue.Victim, nil
}
// AddVictim adds u to the "victim" field.
func (m *WeaponStatsMutation) AddVictim(u uint64) {
if m.addvictim != nil {
*m.addvictim += u
} else {
m.addvictim = &u
}
}
// AddedVictim returns the value that was added to the "victim" field in this mutation.
func (m *WeaponStatsMutation) AddedVictim() (r uint64, exists bool) {
v := m.addvictim
if v == nil {
return
}
return *v, true
}
// ResetVictim resets all changes to the "victim" field.
func (m *WeaponStatsMutation) ResetVictim() {
m.victim = nil
m.addvictim = nil
}
// SetDmg sets the "dmg" field.
func (m *WeaponStatsMutation) SetDmg(u uint) {
m.dmg = &u
m.adddmg = nil
}
// Dmg returns the value of the "dmg" field in the mutation.
func (m *WeaponStatsMutation) Dmg() (r uint, exists bool) {
v := m.dmg
if v == nil {
return
}
return *v, true
}
// OldDmg returns the old "dmg" field's value of the WeaponStats entity.
// If the WeaponStats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *WeaponStatsMutation) OldDmg(ctx context.Context) (v uint, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldDmg is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldDmg requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDmg: %w", err)
}
return oldValue.Dmg, nil
}
// AddDmg adds u to the "dmg" field.
func (m *WeaponStatsMutation) AddDmg(u uint) {
if m.adddmg != nil {
*m.adddmg += u
} else {
m.adddmg = &u
}
}
// AddedDmg returns the value that was added to the "dmg" field in this mutation.
func (m *WeaponStatsMutation) AddedDmg() (r uint, exists bool) {
v := m.adddmg
if v == nil {
return
}
return *v, true
}
// ResetDmg resets all changes to the "dmg" field.
func (m *WeaponStatsMutation) ResetDmg() {
m.dmg = nil
m.adddmg = nil
}
// SetEqType sets the "eq_type" field.
func (m *WeaponStatsMutation) SetEqType(i int) {
m.eq_type = &i
m.addeq_type = nil
}
// EqType returns the value of the "eq_type" field in the mutation.
func (m *WeaponStatsMutation) EqType() (r int, exists bool) {
v := m.eq_type
if v == nil {
return
}
return *v, true
}
// OldEqType returns the old "eq_type" field's value of the WeaponStats entity.
// If the WeaponStats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *WeaponStatsMutation) OldEqType(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldEqType is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldEqType requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEqType: %w", err)
}
return oldValue.EqType, nil
}
// AddEqType adds i to the "eq_type" field.
func (m *WeaponStatsMutation) AddEqType(i int) {
if m.addeq_type != nil {
*m.addeq_type += i
} else {
m.addeq_type = &i
}
}
// AddedEqType returns the value that was added to the "eq_type" field in this mutation.
func (m *WeaponStatsMutation) AddedEqType() (r int, exists bool) {
v := m.addeq_type
if v == nil {
return
}
return *v, true
}
// ResetEqType resets all changes to the "eq_type" field.
func (m *WeaponStatsMutation) ResetEqType() {
m.eq_type = nil
m.addeq_type = nil
}
// SetHitGroup sets the "hit_group" field.
func (m *WeaponStatsMutation) SetHitGroup(i int) {
m.hit_group = &i
m.addhit_group = nil
}
// HitGroup returns the value of the "hit_group" field in the mutation.
func (m *WeaponStatsMutation) HitGroup() (r int, exists bool) {
v := m.hit_group
if v == nil {
return
}
return *v, true
}
// OldHitGroup returns the old "hit_group" field's value of the WeaponStats entity.
// If the WeaponStats object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *WeaponStatsMutation) OldHitGroup(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldHitGroup is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldHitGroup requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldHitGroup: %w", err)
}
return oldValue.HitGroup, nil
}
// AddHitGroup adds i to the "hit_group" field.
func (m *WeaponStatsMutation) AddHitGroup(i int) {
if m.addhit_group != nil {
*m.addhit_group += i
} else {
m.addhit_group = &i
}
}
// AddedHitGroup returns the value that was added to the "hit_group" field in this mutation.
func (m *WeaponStatsMutation) AddedHitGroup() (r int, exists bool) {
v := m.addhit_group
if v == nil {
return
}
return *v, true
}
// ResetHitGroup resets all changes to the "hit_group" field.
func (m *WeaponStatsMutation) ResetHitGroup() {
m.hit_group = nil
m.addhit_group = nil
}
// SetStatID sets the "stat" edge to the Stats entity by id.
func (m *WeaponStatsMutation) SetStatID(id int) {
m.stat = &id
}
// ClearStat clears the "stat" edge to the Stats entity.
func (m *WeaponStatsMutation) ClearStat() {
m.clearedstat = true
}
// StatCleared reports if the "stat" edge to the Stats entity was cleared.
func (m *WeaponStatsMutation) StatCleared() bool {
return m.clearedstat
}
// StatID returns the "stat" edge ID in the mutation.
func (m *WeaponStatsMutation) StatID() (id int, exists bool) {
if m.stat != nil {
return *m.stat, true
}
return
}
// StatIDs returns the "stat" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// StatID instead. It exists only for internal usage by the builders.
func (m *WeaponStatsMutation) StatIDs() (ids []int) {
if id := m.stat; id != nil {
ids = append(ids, *id)
}
return
}
// ResetStat resets all changes to the "stat" edge.
func (m *WeaponStatsMutation) ResetStat() {
m.stat = nil
m.clearedstat = false
}
// Where appends a list predicates to the WeaponStatsMutation builder.
func (m *WeaponStatsMutation) Where(ps ...predicate.WeaponStats) {
m.predicates = append(m.predicates, ps...)
}
// Op returns the operation name.
func (m *WeaponStatsMutation) Op() Op {
return m.op
}
// Type returns the node type of this mutation (WeaponStats).
func (m *WeaponStatsMutation) Type() string {
return m.typ
}
// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *WeaponStatsMutation) Fields() []string {
fields := make([]string, 0, 4)
if m.victim != nil {
fields = append(fields, weaponstats.FieldVictim)
}
if m.dmg != nil {
fields = append(fields, weaponstats.FieldDmg)
}
if m.eq_type != nil {
fields = append(fields, weaponstats.FieldEqType)
}
if m.hit_group != nil {
fields = append(fields, weaponstats.FieldHitGroup)
}
return fields
}
// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *WeaponStatsMutation) Field(name string) (ent.Value, bool) {
switch name {
case weaponstats.FieldVictim:
return m.Victim()
case weaponstats.FieldDmg:
return m.Dmg()
case weaponstats.FieldEqType:
return m.EqType()
case weaponstats.FieldHitGroup:
return m.HitGroup()
}
return nil, false
}
// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *WeaponStatsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case weaponstats.FieldVictim:
return m.OldVictim(ctx)
case weaponstats.FieldDmg:
return m.OldDmg(ctx)
case weaponstats.FieldEqType:
return m.OldEqType(ctx)
case weaponstats.FieldHitGroup:
return m.OldHitGroup(ctx)
}
return nil, fmt.Errorf("unknown WeaponStats field %s", name)
}
// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *WeaponStatsMutation) SetField(name string, value ent.Value) error {
switch name {
case weaponstats.FieldVictim:
v, ok := value.(uint64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetVictim(v)
return nil
case weaponstats.FieldDmg:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDmg(v)
return nil
case weaponstats.FieldEqType:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEqType(v)
return nil
case weaponstats.FieldHitGroup:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetHitGroup(v)
return nil
}
return fmt.Errorf("unknown WeaponStats field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *WeaponStatsMutation) AddedFields() []string {
var fields []string
if m.addvictim != nil {
fields = append(fields, weaponstats.FieldVictim)
}
if m.adddmg != nil {
fields = append(fields, weaponstats.FieldDmg)
}
if m.addeq_type != nil {
fields = append(fields, weaponstats.FieldEqType)
}
if m.addhit_group != nil {
fields = append(fields, weaponstats.FieldHitGroup)
}
return fields
}
// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *WeaponStatsMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case weaponstats.FieldVictim:
return m.AddedVictim()
case weaponstats.FieldDmg:
return m.AddedDmg()
case weaponstats.FieldEqType:
return m.AddedEqType()
case weaponstats.FieldHitGroup:
return m.AddedHitGroup()
}
return nil, false
}
// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *WeaponStatsMutation) AddField(name string, value ent.Value) error {
switch name {
case weaponstats.FieldVictim:
v, ok := value.(uint64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddVictim(v)
return nil
case weaponstats.FieldDmg:
v, ok := value.(uint)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddDmg(v)
return nil
case weaponstats.FieldEqType:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddEqType(v)
return nil
case weaponstats.FieldHitGroup:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddHitGroup(v)
return nil
}
return fmt.Errorf("unknown WeaponStats numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *WeaponStatsMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *WeaponStatsMutation) FieldCleared(name string) bool {
_, ok := m.clearedFields[name]
return ok
}
// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *WeaponStatsMutation) ClearField(name string) error {
return fmt.Errorf("unknown WeaponStats nullable field %s", name)
}
// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *WeaponStatsMutation) ResetField(name string) error {
switch name {
case weaponstats.FieldVictim:
m.ResetVictim()
return nil
case weaponstats.FieldDmg:
m.ResetDmg()
return nil
case weaponstats.FieldEqType:
m.ResetEqType()
return nil
case weaponstats.FieldHitGroup:
m.ResetHitGroup()
return nil
}
return fmt.Errorf("unknown WeaponStats field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *WeaponStatsMutation) AddedEdges() []string {
edges := make([]string, 0, 1)
if m.stat != nil {
edges = append(edges, weaponstats.EdgeStat)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *WeaponStatsMutation) AddedIDs(name string) []ent.Value {
switch name {
case weaponstats.EdgeStat:
if id := m.stat; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *WeaponStatsMutation) RemovedEdges() []string {
edges := make([]string, 0, 1)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *WeaponStatsMutation) RemovedIDs(name string) []ent.Value {
switch name {
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *WeaponStatsMutation) ClearedEdges() []string {
edges := make([]string, 0, 1)
if m.clearedstat {
edges = append(edges, weaponstats.EdgeStat)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *WeaponStatsMutation) EdgeCleared(name string) bool {
switch name {
case weaponstats.EdgeStat:
return m.clearedstat
}
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *WeaponStatsMutation) ClearEdge(name string) error {
switch name {
case weaponstats.EdgeStat:
m.ClearStat()
return nil
}
return fmt.Errorf("unknown WeaponStats unique edge %s", name)
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *WeaponStatsMutation) ResetEdge(name string) error {
switch name {
case weaponstats.EdgeStat:
m.ResetStat()
return nil
}
return fmt.Errorf("unknown WeaponStats edge %s", name)
}