3885 lines
108 KiB
Go
3885 lines
108 KiB
Go
// Code generated by entc, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"csgowtfd/ent/match"
|
|
"csgowtfd/ent/player"
|
|
"csgowtfd/ent/predicate"
|
|
"csgowtfd/ent/stats"
|
|
"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"
|
|
TypeStats = "Stats"
|
|
)
|
|
|
|
// 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
|
|
rounds *int
|
|
addrounds *int
|
|
demo_expired *bool
|
|
demo_parsed *bool
|
|
eco *struct {
|
|
Rounds []*struct {
|
|
Team int "json:\"team\""
|
|
Bank int "json:\"bank\""
|
|
Equipment int "json:\"equipment\""
|
|
} "json:\"rounds\""
|
|
}
|
|
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
|
|
}
|
|
|
|
// SetRounds sets the "rounds" field.
|
|
func (m *MatchMutation) SetRounds(i int) {
|
|
m.rounds = &i
|
|
m.addrounds = nil
|
|
}
|
|
|
|
// Rounds returns the value of the "rounds" field in the mutation.
|
|
func (m *MatchMutation) Rounds() (r int, exists bool) {
|
|
v := m.rounds
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldRounds returns the old "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) OldRounds(ctx context.Context) (v int, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, fmt.Errorf("OldRounds is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, fmt.Errorf("OldRounds requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldRounds: %w", err)
|
|
}
|
|
return oldValue.Rounds, nil
|
|
}
|
|
|
|
// AddRounds adds i to the "rounds" field.
|
|
func (m *MatchMutation) AddRounds(i int) {
|
|
if m.addrounds != nil {
|
|
*m.addrounds += i
|
|
} else {
|
|
m.addrounds = &i
|
|
}
|
|
}
|
|
|
|
// AddedRounds returns the value that was added to the "rounds" field in this mutation.
|
|
func (m *MatchMutation) AddedRounds() (r int, exists bool) {
|
|
v := m.addrounds
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ResetRounds resets all changes to the "rounds" field.
|
|
func (m *MatchMutation) ResetRounds() {
|
|
m.rounds = nil
|
|
m.addrounds = nil
|
|
}
|
|
|
|
// SetDemoExpired sets the "demo_expired" field.
|
|
func (m *MatchMutation) SetDemoExpired(b bool) {
|
|
m.demo_expired = &b
|
|
}
|
|
|
|
// DemoExpired returns the value of the "demo_expired" field in the mutation.
|
|
func (m *MatchMutation) DemoExpired() (r bool, exists bool) {
|
|
v := m.demo_expired
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldDemoExpired returns the old "demo_expired" 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) OldDemoExpired(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, fmt.Errorf("OldDemoExpired is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, fmt.Errorf("OldDemoExpired requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldDemoExpired: %w", err)
|
|
}
|
|
return oldValue.DemoExpired, nil
|
|
}
|
|
|
|
// ResetDemoExpired resets all changes to the "demo_expired" field.
|
|
func (m *MatchMutation) ResetDemoExpired() {
|
|
m.demo_expired = 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
|
|
}
|
|
|
|
// SetEco sets the "eco" field.
|
|
func (m *MatchMutation) SetEco(s struct {
|
|
Rounds []*struct {
|
|
Team int "json:\"team\""
|
|
Bank int "json:\"bank\""
|
|
Equipment int "json:\"equipment\""
|
|
} "json:\"rounds\""
|
|
}) {
|
|
m.eco = &s
|
|
}
|
|
|
|
// Eco returns the value of the "eco" field in the mutation.
|
|
func (m *MatchMutation) Eco() (r struct {
|
|
Rounds []*struct {
|
|
Team int "json:\"team\""
|
|
Bank int "json:\"bank\""
|
|
Equipment int "json:\"equipment\""
|
|
} "json:\"rounds\""
|
|
}, exists bool) {
|
|
v := m.eco
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldEco returns the old "eco" 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) OldEco(ctx context.Context) (v struct {
|
|
Rounds []*struct {
|
|
Team int "json:\"team\""
|
|
Bank int "json:\"bank\""
|
|
Equipment int "json:\"equipment\""
|
|
} "json:\"rounds\""
|
|
}, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, fmt.Errorf("OldEco is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, fmt.Errorf("OldEco requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldEco: %w", err)
|
|
}
|
|
return oldValue.Eco, nil
|
|
}
|
|
|
|
// ClearEco clears the value of the "eco" field.
|
|
func (m *MatchMutation) ClearEco() {
|
|
m.eco = nil
|
|
m.clearedFields[match.FieldEco] = struct{}{}
|
|
}
|
|
|
|
// EcoCleared returns if the "eco" field was cleared in this mutation.
|
|
func (m *MatchMutation) EcoCleared() bool {
|
|
_, ok := m.clearedFields[match.FieldEco]
|
|
return ok
|
|
}
|
|
|
|
// ResetEco resets all changes to the "eco" field.
|
|
func (m *MatchMutation) ResetEco() {
|
|
m.eco = nil
|
|
delete(m.clearedFields, match.FieldEco)
|
|
}
|
|
|
|
// 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, 13)
|
|
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.rounds != nil {
|
|
fields = append(fields, match.FieldRounds)
|
|
}
|
|
if m.demo_expired != nil {
|
|
fields = append(fields, match.FieldDemoExpired)
|
|
}
|
|
if m.demo_parsed != nil {
|
|
fields = append(fields, match.FieldDemoParsed)
|
|
}
|
|
if m.eco != nil {
|
|
fields = append(fields, match.FieldEco)
|
|
}
|
|
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.FieldRounds:
|
|
return m.Rounds()
|
|
case match.FieldDemoExpired:
|
|
return m.DemoExpired()
|
|
case match.FieldDemoParsed:
|
|
return m.DemoParsed()
|
|
case match.FieldEco:
|
|
return m.Eco()
|
|
}
|
|
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.FieldRounds:
|
|
return m.OldRounds(ctx)
|
|
case match.FieldDemoExpired:
|
|
return m.OldDemoExpired(ctx)
|
|
case match.FieldDemoParsed:
|
|
return m.OldDemoParsed(ctx)
|
|
case match.FieldEco:
|
|
return m.OldEco(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.FieldRounds:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetRounds(v)
|
|
return nil
|
|
case match.FieldDemoExpired:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetDemoExpired(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
|
|
case match.FieldEco:
|
|
v, ok := value.(struct {
|
|
Rounds []*struct {
|
|
Team int "json:\"team\""
|
|
Bank int "json:\"bank\""
|
|
Equipment int "json:\"equipment\""
|
|
} "json:\"rounds\""
|
|
})
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetEco(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)
|
|
}
|
|
if m.addrounds != nil {
|
|
fields = append(fields, match.FieldRounds)
|
|
}
|
|
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()
|
|
case match.FieldRounds:
|
|
return m.AddedRounds()
|
|
}
|
|
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
|
|
case match.FieldRounds:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddRounds(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)
|
|
}
|
|
if m.FieldCleared(match.FieldEco) {
|
|
fields = append(fields, match.FieldEco)
|
|
}
|
|
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
|
|
case match.FieldEco:
|
|
m.ClearEco()
|
|
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.FieldRounds:
|
|
m.ResetRounds()
|
|
return nil
|
|
case match.FieldDemoExpired:
|
|
m.ResetDemoExpired()
|
|
return nil
|
|
case match.FieldDemoParsed:
|
|
m.ResetDemoParsed()
|
|
return nil
|
|
case match.FieldEco:
|
|
m.ResetEco()
|
|
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_url *string
|
|
vanity_url *string
|
|
vanity_url_real *string
|
|
vac *bool
|
|
vac_date *time.Time
|
|
vac_count *int
|
|
addvac_count *int
|
|
steam_updated *time.Time
|
|
sharecode_updated *time.Time
|
|
auth_code *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)
|
|
}
|
|
|
|
// SetAvatarURL sets the "avatar_url" field.
|
|
func (m *PlayerMutation) SetAvatarURL(s string) {
|
|
m.avatar_url = &s
|
|
}
|
|
|
|
// AvatarURL returns the value of the "avatar_url" field in the mutation.
|
|
func (m *PlayerMutation) AvatarURL() (r string, exists bool) {
|
|
v := m.avatar_url
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldAvatarURL returns the old "avatar_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) OldAvatarURL(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, fmt.Errorf("OldAvatarURL is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, fmt.Errorf("OldAvatarURL requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldAvatarURL: %w", err)
|
|
}
|
|
return oldValue.AvatarURL, nil
|
|
}
|
|
|
|
// ClearAvatarURL clears the value of the "avatar_url" field.
|
|
func (m *PlayerMutation) ClearAvatarURL() {
|
|
m.avatar_url = nil
|
|
m.clearedFields[player.FieldAvatarURL] = struct{}{}
|
|
}
|
|
|
|
// AvatarURLCleared returns if the "avatar_url" field was cleared in this mutation.
|
|
func (m *PlayerMutation) AvatarURLCleared() bool {
|
|
_, ok := m.clearedFields[player.FieldAvatarURL]
|
|
return ok
|
|
}
|
|
|
|
// ResetAvatarURL resets all changes to the "avatar_url" field.
|
|
func (m *PlayerMutation) ResetAvatarURL() {
|
|
m.avatar_url = nil
|
|
delete(m.clearedFields, player.FieldAvatarURL)
|
|
}
|
|
|
|
// 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)
|
|
}
|
|
|
|
// SetVac sets the "vac" field.
|
|
func (m *PlayerMutation) SetVac(b bool) {
|
|
m.vac = &b
|
|
}
|
|
|
|
// Vac returns the value of the "vac" field in the mutation.
|
|
func (m *PlayerMutation) Vac() (r bool, exists bool) {
|
|
v := m.vac
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldVac returns the old "vac" 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) OldVac(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, fmt.Errorf("OldVac is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, fmt.Errorf("OldVac requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldVac: %w", err)
|
|
}
|
|
return oldValue.Vac, nil
|
|
}
|
|
|
|
// ResetVac resets all changes to the "vac" field.
|
|
func (m *PlayerMutation) ResetVac() {
|
|
m.vac = nil
|
|
}
|
|
|
|
// 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)
|
|
}
|
|
|
|
// 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)
|
|
}
|
|
|
|
// 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, 10)
|
|
if m.name != nil {
|
|
fields = append(fields, player.FieldName)
|
|
}
|
|
if m.avatar_url != nil {
|
|
fields = append(fields, player.FieldAvatarURL)
|
|
}
|
|
if m.vanity_url != nil {
|
|
fields = append(fields, player.FieldVanityURL)
|
|
}
|
|
if m.vanity_url_real != nil {
|
|
fields = append(fields, player.FieldVanityURLReal)
|
|
}
|
|
if m.vac != nil {
|
|
fields = append(fields, player.FieldVac)
|
|
}
|
|
if m.vac_date != nil {
|
|
fields = append(fields, player.FieldVacDate)
|
|
}
|
|
if m.vac_count != nil {
|
|
fields = append(fields, player.FieldVacCount)
|
|
}
|
|
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)
|
|
}
|
|
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.FieldAvatarURL:
|
|
return m.AvatarURL()
|
|
case player.FieldVanityURL:
|
|
return m.VanityURL()
|
|
case player.FieldVanityURLReal:
|
|
return m.VanityURLReal()
|
|
case player.FieldVac:
|
|
return m.Vac()
|
|
case player.FieldVacDate:
|
|
return m.VacDate()
|
|
case player.FieldVacCount:
|
|
return m.VacCount()
|
|
case player.FieldSteamUpdated:
|
|
return m.SteamUpdated()
|
|
case player.FieldSharecodeUpdated:
|
|
return m.SharecodeUpdated()
|
|
case player.FieldAuthCode:
|
|
return m.AuthCode()
|
|
}
|
|
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.FieldAvatarURL:
|
|
return m.OldAvatarURL(ctx)
|
|
case player.FieldVanityURL:
|
|
return m.OldVanityURL(ctx)
|
|
case player.FieldVanityURLReal:
|
|
return m.OldVanityURLReal(ctx)
|
|
case player.FieldVac:
|
|
return m.OldVac(ctx)
|
|
case player.FieldVacDate:
|
|
return m.OldVacDate(ctx)
|
|
case player.FieldVacCount:
|
|
return m.OldVacCount(ctx)
|
|
case player.FieldSteamUpdated:
|
|
return m.OldSteamUpdated(ctx)
|
|
case player.FieldSharecodeUpdated:
|
|
return m.OldSharecodeUpdated(ctx)
|
|
case player.FieldAuthCode:
|
|
return m.OldAuthCode(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.FieldAvatarURL:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetAvatarURL(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.FieldVac:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetVac(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.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
|
|
}
|
|
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)
|
|
}
|
|
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()
|
|
}
|
|
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
|
|
}
|
|
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.FieldAvatarURL) {
|
|
fields = append(fields, player.FieldAvatarURL)
|
|
}
|
|
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.FieldSharecodeUpdated) {
|
|
fields = append(fields, player.FieldSharecodeUpdated)
|
|
}
|
|
if m.FieldCleared(player.FieldAuthCode) {
|
|
fields = append(fields, player.FieldAuthCode)
|
|
}
|
|
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.FieldAvatarURL:
|
|
m.ClearAvatarURL()
|
|
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.FieldSharecodeUpdated:
|
|
m.ClearSharecodeUpdated()
|
|
return nil
|
|
case player.FieldAuthCode:
|
|
m.ClearAuthCode()
|
|
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.FieldAvatarURL:
|
|
m.ResetAvatarURL()
|
|
return nil
|
|
case player.FieldVanityURL:
|
|
m.ResetVanityURL()
|
|
return nil
|
|
case player.FieldVanityURLReal:
|
|
m.ResetVanityURLReal()
|
|
return nil
|
|
case player.FieldVac:
|
|
m.ResetVac()
|
|
return nil
|
|
case player.FieldVacDate:
|
|
m.ResetVacDate()
|
|
return nil
|
|
case player.FieldVacCount:
|
|
m.ResetVacCount()
|
|
return nil
|
|
case player.FieldSteamUpdated:
|
|
m.ResetSteamUpdated()
|
|
return nil
|
|
case player.FieldSharecodeUpdated:
|
|
m.ResetSharecodeUpdated()
|
|
return nil
|
|
case player.FieldAuthCode:
|
|
m.ResetAuthCode()
|
|
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)
|
|
}
|
|
|
|
// 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 *int
|
|
addmvp *int
|
|
score *int
|
|
addscore *int
|
|
extended *struct {
|
|
MultiKills struct {
|
|
Duo int "json:\"duo,omitempty\""
|
|
Triple int "json:\"triple,omitempty\""
|
|
Quad int "json:\"quad,omitempty\""
|
|
Pent int "json:\"pent,omitempty\""
|
|
} "json:\"multi_kills,omitempty\""
|
|
Dmg struct {
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Team int "json:\"team,omitempty\""
|
|
UD struct {
|
|
HE int "json:\"he,omitempty\""
|
|
Flames int "json:\"flames,omitempty\""
|
|
Flash int "json:\"flash,omitempty\""
|
|
Decoy int "json:\"decoy,omitempty\""
|
|
Smoke int "json:\"smoke,omitempty\""
|
|
} "json:\"ud,omitempty\""
|
|
HitGroup struct {
|
|
Head int "json:\"head,omitempty\""
|
|
Chest int "json:\"chest,omitempty\""
|
|
Stomach int "json:\"stomach,omitempty\""
|
|
LeftArm int "json:\"left_arm,omitempty\""
|
|
RightArm int "json:\"right_arm,omitempty\""
|
|
LeftLeg int "json:\"left_leg,omitempty\""
|
|
RightLeg int "json:\"right_leg,omitempty\""
|
|
Gear int "json:\"gear,omitempty\""
|
|
} "json:\"hit_group,omitempty\""
|
|
} "json:\"dmg,omitempty\""
|
|
Crosshair string "json:\"crosshair,omitempty\""
|
|
Color string "json:\"color,omitempty\""
|
|
KAST int "json:\"kast,omitempty\""
|
|
Rank struct {
|
|
Old int "json:\"old,omitempty\""
|
|
New int "json:\"new,omitempty\""
|
|
} "json:\"rank,omitempty\""
|
|
Flash struct {
|
|
Duration struct {
|
|
Self float32 "json:\"self,omitempty\""
|
|
Team float32 "json:\"team,omitempty\""
|
|
Enemy float32 "json:\"enemy,omitempty\""
|
|
} "json:\"duration,omitempty\""
|
|
Total struct {
|
|
Team int "json:\"team,omitempty\""
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Self int "json:\"self,omitempty\""
|
|
} "json:\"total,omitempty\""
|
|
} "json:\"flash,omitempty\""
|
|
}
|
|
clearedFields map[string]struct{}
|
|
matches *uint64
|
|
clearedmatches bool
|
|
players *uint64
|
|
clearedplayers 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(i int) {
|
|
m.mvp = &i
|
|
m.addmvp = nil
|
|
}
|
|
|
|
// Mvp returns the value of the "mvp" field in the mutation.
|
|
func (m *StatsMutation) Mvp() (r int, 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 int, 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 i to the "mvp" field.
|
|
func (m *StatsMutation) AddMvp(i int) {
|
|
if m.addmvp != nil {
|
|
*m.addmvp += i
|
|
} else {
|
|
m.addmvp = &i
|
|
}
|
|
}
|
|
|
|
// AddedMvp returns the value that was added to the "mvp" field in this mutation.
|
|
func (m *StatsMutation) AddedMvp() (r int, 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
|
|
}
|
|
|
|
// SetExtended sets the "extended" field.
|
|
func (m *StatsMutation) SetExtended(skkgaaaallllg struct {
|
|
MultiKills struct {
|
|
Duo int "json:\"duo,omitempty\""
|
|
Triple int "json:\"triple,omitempty\""
|
|
Quad int "json:\"quad,omitempty\""
|
|
Pent int "json:\"pent,omitempty\""
|
|
} "json:\"multi_kills,omitempty\""
|
|
Dmg struct {
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Team int "json:\"team,omitempty\""
|
|
UD struct {
|
|
HE int "json:\"he,omitempty\""
|
|
Flames int "json:\"flames,omitempty\""
|
|
Flash int "json:\"flash,omitempty\""
|
|
Decoy int "json:\"decoy,omitempty\""
|
|
Smoke int "json:\"smoke,omitempty\""
|
|
} "json:\"ud,omitempty\""
|
|
HitGroup struct {
|
|
Head int "json:\"head,omitempty\""
|
|
Chest int "json:\"chest,omitempty\""
|
|
Stomach int "json:\"stomach,omitempty\""
|
|
LeftArm int "json:\"left_arm,omitempty\""
|
|
RightArm int "json:\"right_arm,omitempty\""
|
|
LeftLeg int "json:\"left_leg,omitempty\""
|
|
RightLeg int "json:\"right_leg,omitempty\""
|
|
Gear int "json:\"gear,omitempty\""
|
|
} "json:\"hit_group,omitempty\""
|
|
} "json:\"dmg,omitempty\""
|
|
Crosshair string "json:\"crosshair,omitempty\""
|
|
Color string "json:\"color,omitempty\""
|
|
KAST int "json:\"kast,omitempty\""
|
|
Rank struct {
|
|
Old int "json:\"old,omitempty\""
|
|
New int "json:\"new,omitempty\""
|
|
} "json:\"rank,omitempty\""
|
|
Flash struct {
|
|
Duration struct {
|
|
Self float32 "json:\"self,omitempty\""
|
|
Team float32 "json:\"team,omitempty\""
|
|
Enemy float32 "json:\"enemy,omitempty\""
|
|
} "json:\"duration,omitempty\""
|
|
Total struct {
|
|
Team int "json:\"team,omitempty\""
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Self int "json:\"self,omitempty\""
|
|
} "json:\"total,omitempty\""
|
|
} "json:\"flash,omitempty\""
|
|
}) {
|
|
m.extended = &skkgaaaallllg
|
|
}
|
|
|
|
// Extended returns the value of the "extended" field in the mutation.
|
|
func (m *StatsMutation) Extended() (r struct {
|
|
MultiKills struct {
|
|
Duo int "json:\"duo,omitempty\""
|
|
Triple int "json:\"triple,omitempty\""
|
|
Quad int "json:\"quad,omitempty\""
|
|
Pent int "json:\"pent,omitempty\""
|
|
} "json:\"multi_kills,omitempty\""
|
|
Dmg struct {
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Team int "json:\"team,omitempty\""
|
|
UD struct {
|
|
HE int "json:\"he,omitempty\""
|
|
Flames int "json:\"flames,omitempty\""
|
|
Flash int "json:\"flash,omitempty\""
|
|
Decoy int "json:\"decoy,omitempty\""
|
|
Smoke int "json:\"smoke,omitempty\""
|
|
} "json:\"ud,omitempty\""
|
|
HitGroup struct {
|
|
Head int "json:\"head,omitempty\""
|
|
Chest int "json:\"chest,omitempty\""
|
|
Stomach int "json:\"stomach,omitempty\""
|
|
LeftArm int "json:\"left_arm,omitempty\""
|
|
RightArm int "json:\"right_arm,omitempty\""
|
|
LeftLeg int "json:\"left_leg,omitempty\""
|
|
RightLeg int "json:\"right_leg,omitempty\""
|
|
Gear int "json:\"gear,omitempty\""
|
|
} "json:\"hit_group,omitempty\""
|
|
} "json:\"dmg,omitempty\""
|
|
Crosshair string "json:\"crosshair,omitempty\""
|
|
Color string "json:\"color,omitempty\""
|
|
KAST int "json:\"kast,omitempty\""
|
|
Rank struct {
|
|
Old int "json:\"old,omitempty\""
|
|
New int "json:\"new,omitempty\""
|
|
} "json:\"rank,omitempty\""
|
|
Flash struct {
|
|
Duration struct {
|
|
Self float32 "json:\"self,omitempty\""
|
|
Team float32 "json:\"team,omitempty\""
|
|
Enemy float32 "json:\"enemy,omitempty\""
|
|
} "json:\"duration,omitempty\""
|
|
Total struct {
|
|
Team int "json:\"team,omitempty\""
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Self int "json:\"self,omitempty\""
|
|
} "json:\"total,omitempty\""
|
|
} "json:\"flash,omitempty\""
|
|
}, exists bool) {
|
|
v := m.extended
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldExtended returns the old "extended" 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) OldExtended(ctx context.Context) (v struct {
|
|
MultiKills struct {
|
|
Duo int "json:\"duo,omitempty\""
|
|
Triple int "json:\"triple,omitempty\""
|
|
Quad int "json:\"quad,omitempty\""
|
|
Pent int "json:\"pent,omitempty\""
|
|
} "json:\"multi_kills,omitempty\""
|
|
Dmg struct {
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Team int "json:\"team,omitempty\""
|
|
UD struct {
|
|
HE int "json:\"he,omitempty\""
|
|
Flames int "json:\"flames,omitempty\""
|
|
Flash int "json:\"flash,omitempty\""
|
|
Decoy int "json:\"decoy,omitempty\""
|
|
Smoke int "json:\"smoke,omitempty\""
|
|
} "json:\"ud,omitempty\""
|
|
HitGroup struct {
|
|
Head int "json:\"head,omitempty\""
|
|
Chest int "json:\"chest,omitempty\""
|
|
Stomach int "json:\"stomach,omitempty\""
|
|
LeftArm int "json:\"left_arm,omitempty\""
|
|
RightArm int "json:\"right_arm,omitempty\""
|
|
LeftLeg int "json:\"left_leg,omitempty\""
|
|
RightLeg int "json:\"right_leg,omitempty\""
|
|
Gear int "json:\"gear,omitempty\""
|
|
} "json:\"hit_group,omitempty\""
|
|
} "json:\"dmg,omitempty\""
|
|
Crosshair string "json:\"crosshair,omitempty\""
|
|
Color string "json:\"color,omitempty\""
|
|
KAST int "json:\"kast,omitempty\""
|
|
Rank struct {
|
|
Old int "json:\"old,omitempty\""
|
|
New int "json:\"new,omitempty\""
|
|
} "json:\"rank,omitempty\""
|
|
Flash struct {
|
|
Duration struct {
|
|
Self float32 "json:\"self,omitempty\""
|
|
Team float32 "json:\"team,omitempty\""
|
|
Enemy float32 "json:\"enemy,omitempty\""
|
|
} "json:\"duration,omitempty\""
|
|
Total struct {
|
|
Team int "json:\"team,omitempty\""
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Self int "json:\"self,omitempty\""
|
|
} "json:\"total,omitempty\""
|
|
} "json:\"flash,omitempty\""
|
|
}, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, fmt.Errorf("OldExtended is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, fmt.Errorf("OldExtended requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldExtended: %w", err)
|
|
}
|
|
return oldValue.Extended, nil
|
|
}
|
|
|
|
// ClearExtended clears the value of the "extended" field.
|
|
func (m *StatsMutation) ClearExtended() {
|
|
m.extended = nil
|
|
m.clearedFields[stats.FieldExtended] = struct{}{}
|
|
}
|
|
|
|
// ExtendedCleared returns if the "extended" field was cleared in this mutation.
|
|
func (m *StatsMutation) ExtendedCleared() bool {
|
|
_, ok := m.clearedFields[stats.FieldExtended]
|
|
return ok
|
|
}
|
|
|
|
// ResetExtended resets all changes to the "extended" field.
|
|
func (m *StatsMutation) ResetExtended() {
|
|
m.extended = nil
|
|
delete(m.clearedFields, stats.FieldExtended)
|
|
}
|
|
|
|
// 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.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.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
|
|
}
|
|
|
|
// 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, 8)
|
|
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.extended != nil {
|
|
fields = append(fields, stats.FieldExtended)
|
|
}
|
|
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.FieldExtended:
|
|
return m.Extended()
|
|
}
|
|
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.FieldExtended:
|
|
return m.OldExtended(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.(int)
|
|
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.FieldExtended:
|
|
v, ok := value.(struct {
|
|
MultiKills struct {
|
|
Duo int "json:\"duo,omitempty\""
|
|
Triple int "json:\"triple,omitempty\""
|
|
Quad int "json:\"quad,omitempty\""
|
|
Pent int "json:\"pent,omitempty\""
|
|
} "json:\"multi_kills,omitempty\""
|
|
Dmg struct {
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Team int "json:\"team,omitempty\""
|
|
UD struct {
|
|
HE int "json:\"he,omitempty\""
|
|
Flames int "json:\"flames,omitempty\""
|
|
Flash int "json:\"flash,omitempty\""
|
|
Decoy int "json:\"decoy,omitempty\""
|
|
Smoke int "json:\"smoke,omitempty\""
|
|
} "json:\"ud,omitempty\""
|
|
HitGroup struct {
|
|
Head int "json:\"head,omitempty\""
|
|
Chest int "json:\"chest,omitempty\""
|
|
Stomach int "json:\"stomach,omitempty\""
|
|
LeftArm int "json:\"left_arm,omitempty\""
|
|
RightArm int "json:\"right_arm,omitempty\""
|
|
LeftLeg int "json:\"left_leg,omitempty\""
|
|
RightLeg int "json:\"right_leg,omitempty\""
|
|
Gear int "json:\"gear,omitempty\""
|
|
} "json:\"hit_group,omitempty\""
|
|
} "json:\"dmg,omitempty\""
|
|
Crosshair string "json:\"crosshair,omitempty\""
|
|
Color string "json:\"color,omitempty\""
|
|
KAST int "json:\"kast,omitempty\""
|
|
Rank struct {
|
|
Old int "json:\"old,omitempty\""
|
|
New int "json:\"new,omitempty\""
|
|
} "json:\"rank,omitempty\""
|
|
Flash struct {
|
|
Duration struct {
|
|
Self float32 "json:\"self,omitempty\""
|
|
Team float32 "json:\"team,omitempty\""
|
|
Enemy float32 "json:\"enemy,omitempty\""
|
|
} "json:\"duration,omitempty\""
|
|
Total struct {
|
|
Team int "json:\"team,omitempty\""
|
|
Enemy int "json:\"enemy,omitempty\""
|
|
Self int "json:\"self,omitempty\""
|
|
} "json:\"total,omitempty\""
|
|
} "json:\"flash,omitempty\""
|
|
})
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetExtended(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)
|
|
}
|
|
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()
|
|
}
|
|
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.(int)
|
|
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
|
|
}
|
|
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.FieldExtended) {
|
|
fields = append(fields, stats.FieldExtended)
|
|
}
|
|
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.FieldExtended:
|
|
m.ClearExtended()
|
|
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.FieldExtended:
|
|
m.ResetExtended()
|
|
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, 2)
|
|
if m.matches != nil {
|
|
edges = append(edges, stats.EdgeMatches)
|
|
}
|
|
if m.players != nil {
|
|
edges = append(edges, stats.EdgePlayers)
|
|
}
|
|
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}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *StatsMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 2)
|
|
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 {
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *StatsMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 2)
|
|
if m.clearedmatches {
|
|
edges = append(edges, stats.EdgeMatches)
|
|
}
|
|
if m.clearedplayers {
|
|
edges = append(edges, stats.EdgePlayers)
|
|
}
|
|
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
|
|
}
|
|
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
|
|
}
|
|
return fmt.Errorf("unknown Stats edge %s", name)
|
|
}
|