// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "sync" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" "somegit.dev/csgowtf/csgowtfd/ent/match" "somegit.dev/csgowtf/csgowtfd/ent/matchplayer" "somegit.dev/csgowtf/csgowtfd/ent/messages" "somegit.dev/csgowtf/csgowtfd/ent/player" "somegit.dev/csgowtf/csgowtfd/ent/predicate" "somegit.dev/csgowtf/csgowtfd/ent/roundstats" "somegit.dev/csgowtf/csgowtfd/ent/spray" "somegit.dev/csgowtf/csgowtfd/ent/weapon" ) const ( // Operation types. OpCreate = ent.OpCreate OpDelete = ent.OpDelete OpDeleteOne = ent.OpDeleteOne OpUpdate = ent.OpUpdate OpUpdateOne = ent.OpUpdateOne // Node types. TypeMatch = "Match" TypeMatchPlayer = "MatchPlayer" TypeMessages = "Messages" TypePlayer = "Player" TypeRoundStats = "RoundStats" TypeSpray = "Spray" TypeWeapon = "Weapon" ) // MatchMutation represents an operation that mutates the Match nodes in the graph. type MatchMutation struct { config op Op typ string id *uint64 share_code *string _map *string date *time.Time score_team_a *int addscore_team_a *int score_team_b *int addscore_team_b *int replay_url *string duration *int addduration *int match_result *int addmatch_result *int max_rounds *int addmax_rounds *int demo_parsed *bool vac_present *bool gameban_present *bool decryption_key *[]byte tick_rate *float64 addtick_rate *float64 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 = errors.New("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, errors.New("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 } // IDs queries the database and returns the entity ids that match the mutation's predicate. // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. func (m *MatchMutation) IDs(ctx context.Context) ([]uint64, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { return []uint64{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): return m.Client().Match.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // 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, errors.New("OldShareCode is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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, errors.New("OldMap is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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, errors.New("OldDate is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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, errors.New("OldScoreTeamA is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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, errors.New("OldScoreTeamB is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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, errors.New("OldReplayURL is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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, errors.New("OldDuration is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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, errors.New("OldMatchResult is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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, errors.New("OldMaxRounds is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldMaxRounds requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldMaxRounds: %w", err) } return oldValue.MaxRounds, nil } // AddMaxRounds adds i to the "max_rounds" field. func (m *MatchMutation) AddMaxRounds(i int) { if m.addmax_rounds != nil { *m.addmax_rounds += i } else { m.addmax_rounds = &i } } // AddedMaxRounds returns the value that was added to the "max_rounds" field in this mutation. func (m *MatchMutation) AddedMaxRounds() (r int, exists bool) { v := m.addmax_rounds if v == nil { return } return *v, true } // ResetMaxRounds resets all changes to the "max_rounds" field. func (m *MatchMutation) ResetMaxRounds() { m.max_rounds = nil m.addmax_rounds = nil } // SetDemoParsed sets the "demo_parsed" field. func (m *MatchMutation) SetDemoParsed(b bool) { m.demo_parsed = &b } // DemoParsed returns the value of the "demo_parsed" field in the mutation. func (m *MatchMutation) DemoParsed() (r bool, exists bool) { v := m.demo_parsed if v == nil { return } return *v, true } // OldDemoParsed returns the old "demo_parsed" field's value of the Match entity. // If the Match object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *MatchMutation) OldDemoParsed(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldDemoParsed is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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 } // SetVacPresent sets the "vac_present" field. func (m *MatchMutation) SetVacPresent(b bool) { m.vac_present = &b } // VacPresent returns the value of the "vac_present" field in the mutation. func (m *MatchMutation) VacPresent() (r bool, exists bool) { v := m.vac_present if v == nil { return } return *v, true } // OldVacPresent returns the old "vac_present" 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) OldVacPresent(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldVacPresent is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldVacPresent requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldVacPresent: %w", err) } return oldValue.VacPresent, nil } // ResetVacPresent resets all changes to the "vac_present" field. func (m *MatchMutation) ResetVacPresent() { m.vac_present = nil } // SetGamebanPresent sets the "gameban_present" field. func (m *MatchMutation) SetGamebanPresent(b bool) { m.gameban_present = &b } // GamebanPresent returns the value of the "gameban_present" field in the mutation. func (m *MatchMutation) GamebanPresent() (r bool, exists bool) { v := m.gameban_present if v == nil { return } return *v, true } // OldGamebanPresent returns the old "gameban_present" 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) OldGamebanPresent(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldGamebanPresent is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldGamebanPresent requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldGamebanPresent: %w", err) } return oldValue.GamebanPresent, nil } // ResetGamebanPresent resets all changes to the "gameban_present" field. func (m *MatchMutation) ResetGamebanPresent() { m.gameban_present = nil } // SetDecryptionKey sets the "decryption_key" field. func (m *MatchMutation) SetDecryptionKey(b []byte) { m.decryption_key = &b } // DecryptionKey returns the value of the "decryption_key" field in the mutation. func (m *MatchMutation) DecryptionKey() (r []byte, exists bool) { v := m.decryption_key if v == nil { return } return *v, true } // OldDecryptionKey returns the old "decryption_key" 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) OldDecryptionKey(ctx context.Context) (v []byte, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldDecryptionKey is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldDecryptionKey requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldDecryptionKey: %w", err) } return oldValue.DecryptionKey, nil } // ClearDecryptionKey clears the value of the "decryption_key" field. func (m *MatchMutation) ClearDecryptionKey() { m.decryption_key = nil m.clearedFields[match.FieldDecryptionKey] = struct{}{} } // DecryptionKeyCleared returns if the "decryption_key" field was cleared in this mutation. func (m *MatchMutation) DecryptionKeyCleared() bool { _, ok := m.clearedFields[match.FieldDecryptionKey] return ok } // ResetDecryptionKey resets all changes to the "decryption_key" field. func (m *MatchMutation) ResetDecryptionKey() { m.decryption_key = nil delete(m.clearedFields, match.FieldDecryptionKey) } // SetTickRate sets the "tick_rate" field. func (m *MatchMutation) SetTickRate(f float64) { m.tick_rate = &f m.addtick_rate = nil } // TickRate returns the value of the "tick_rate" field in the mutation. func (m *MatchMutation) TickRate() (r float64, exists bool) { v := m.tick_rate if v == nil { return } return *v, true } // OldTickRate returns the old "tick_rate" 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) OldTickRate(ctx context.Context) (v float64, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldTickRate is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldTickRate requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldTickRate: %w", err) } return oldValue.TickRate, nil } // AddTickRate adds f to the "tick_rate" field. func (m *MatchMutation) AddTickRate(f float64) { if m.addtick_rate != nil { *m.addtick_rate += f } else { m.addtick_rate = &f } } // AddedTickRate returns the value that was added to the "tick_rate" field in this mutation. func (m *MatchMutation) AddedTickRate() (r float64, exists bool) { v := m.addtick_rate if v == nil { return } return *v, true } // ClearTickRate clears the value of the "tick_rate" field. func (m *MatchMutation) ClearTickRate() { m.tick_rate = nil m.addtick_rate = nil m.clearedFields[match.FieldTickRate] = struct{}{} } // TickRateCleared returns if the "tick_rate" field was cleared in this mutation. func (m *MatchMutation) TickRateCleared() bool { _, ok := m.clearedFields[match.FieldTickRate] return ok } // ResetTickRate resets all changes to the "tick_rate" field. func (m *MatchMutation) ResetTickRate() { m.tick_rate = nil m.addtick_rate = nil delete(m.clearedFields, match.FieldTickRate) } // AddStatIDs adds the "stats" edge to the MatchPlayer 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 MatchPlayer entity. func (m *MatchMutation) ClearStats() { m.clearedstats = true } // StatsCleared reports if the "stats" edge to the MatchPlayer entity was cleared. func (m *MatchMutation) StatsCleared() bool { return m.clearedstats } // RemoveStatIDs removes the "stats" edge to the MatchPlayer 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 MatchPlayer 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...) } // WhereP appends storage-level predicates to the MatchMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. func (m *MatchMutation) WhereP(ps ...func(*sql.Selector)) { p := make([]predicate.Match, len(ps)) for i := range ps { p[i] = ps[i] } m.Where(p...) } // Op returns the operation name. func (m *MatchMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. func (m *MatchMutation) SetOp(op Op) { m.op = 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, 14) if m.share_code != nil { fields = append(fields, match.FieldShareCode) } if m._map != nil { fields = append(fields, match.FieldMap) } if m.date != nil { fields = append(fields, match.FieldDate) } if m.score_team_a != nil { fields = append(fields, match.FieldScoreTeamA) } if m.score_team_b != nil { fields = append(fields, match.FieldScoreTeamB) } if m.replay_url != nil { fields = append(fields, match.FieldReplayURL) } if m.duration != nil { fields = append(fields, match.FieldDuration) } if m.match_result != nil { fields = append(fields, match.FieldMatchResult) } if m.max_rounds != nil { fields = append(fields, match.FieldMaxRounds) } if m.demo_parsed != nil { fields = append(fields, match.FieldDemoParsed) } if m.vac_present != nil { fields = append(fields, match.FieldVacPresent) } if m.gameban_present != nil { fields = append(fields, match.FieldGamebanPresent) } if m.decryption_key != nil { fields = append(fields, match.FieldDecryptionKey) } if m.tick_rate != nil { fields = append(fields, match.FieldTickRate) } return fields } // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. func (m *MatchMutation) Field(name string) (ent.Value, bool) { switch name { case match.FieldShareCode: return m.ShareCode() case match.FieldMap: return m.Map() case match.FieldDate: return m.Date() case match.FieldScoreTeamA: return m.ScoreTeamA() case match.FieldScoreTeamB: return m.ScoreTeamB() case match.FieldReplayURL: return m.ReplayURL() case match.FieldDuration: return m.Duration() case match.FieldMatchResult: return m.MatchResult() case match.FieldMaxRounds: return m.MaxRounds() case match.FieldDemoParsed: return m.DemoParsed() case match.FieldVacPresent: return m.VacPresent() case match.FieldGamebanPresent: return m.GamebanPresent() case match.FieldDecryptionKey: return m.DecryptionKey() case match.FieldTickRate: return m.TickRate() } return nil, false } // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. func (m *MatchMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { case match.FieldShareCode: return m.OldShareCode(ctx) case match.FieldMap: return m.OldMap(ctx) case match.FieldDate: return m.OldDate(ctx) case match.FieldScoreTeamA: return m.OldScoreTeamA(ctx) case match.FieldScoreTeamB: return m.OldScoreTeamB(ctx) case match.FieldReplayURL: return m.OldReplayURL(ctx) case match.FieldDuration: return m.OldDuration(ctx) case match.FieldMatchResult: return m.OldMatchResult(ctx) case match.FieldMaxRounds: return m.OldMaxRounds(ctx) case match.FieldDemoParsed: return m.OldDemoParsed(ctx) case match.FieldVacPresent: return m.OldVacPresent(ctx) case match.FieldGamebanPresent: return m.OldGamebanPresent(ctx) case match.FieldDecryptionKey: return m.OldDecryptionKey(ctx) case match.FieldTickRate: return m.OldTickRate(ctx) } return nil, fmt.Errorf("unknown Match field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. func (m *MatchMutation) SetField(name string, value ent.Value) error { switch name { case match.FieldShareCode: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetShareCode(v) return nil case match.FieldMap: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetMap(v) return nil case match.FieldDate: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDate(v) return nil case match.FieldScoreTeamA: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetScoreTeamA(v) return nil case match.FieldScoreTeamB: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetScoreTeamB(v) return nil case match.FieldReplayURL: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetReplayURL(v) return nil case match.FieldDuration: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDuration(v) return nil case match.FieldMatchResult: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetMatchResult(v) return nil case match.FieldMaxRounds: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetMaxRounds(v) return nil case match.FieldDemoParsed: v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDemoParsed(v) return nil case match.FieldVacPresent: v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetVacPresent(v) return nil case match.FieldGamebanPresent: v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetGamebanPresent(v) return nil case match.FieldDecryptionKey: v, ok := value.([]byte) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDecryptionKey(v) return nil case match.FieldTickRate: v, ok := value.(float64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetTickRate(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.addtick_rate != nil { fields = append(fields, match.FieldTickRate) } 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.FieldTickRate: return m.AddedTickRate() } 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.FieldTickRate: v, ok := value.(float64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddTickRate(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.FieldDecryptionKey) { fields = append(fields, match.FieldDecryptionKey) } if m.FieldCleared(match.FieldTickRate) { fields = append(fields, match.FieldTickRate) } 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.FieldDecryptionKey: m.ClearDecryptionKey() return nil case match.FieldTickRate: m.ClearTickRate() return nil } return fmt.Errorf("unknown Match nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. func (m *MatchMutation) ResetField(name string) error { switch name { case match.FieldShareCode: m.ResetShareCode() return nil case match.FieldMap: m.ResetMap() return nil case match.FieldDate: m.ResetDate() return nil case match.FieldScoreTeamA: m.ResetScoreTeamA() return nil case match.FieldScoreTeamB: m.ResetScoreTeamB() return nil case match.FieldReplayURL: m.ResetReplayURL() return nil case match.FieldDuration: m.ResetDuration() return nil case match.FieldMatchResult: m.ResetMatchResult() return nil case match.FieldMaxRounds: m.ResetMaxRounds() return nil case match.FieldDemoParsed: m.ResetDemoParsed() return nil case match.FieldVacPresent: m.ResetVacPresent() return nil case match.FieldGamebanPresent: m.ResetGamebanPresent() return nil case match.FieldDecryptionKey: m.ResetDecryptionKey() return nil case match.FieldTickRate: m.ResetTickRate() 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) } // MatchPlayerMutation represents an operation that mutates the MatchPlayer nodes in the graph. type MatchPlayerMutation struct { config op Op typ string id *int team_id *int addteam_id *int kills *int addkills *int deaths *int adddeaths *int assists *int addassists *int headshot *int addheadshot *int mvp *uint addmvp *int score *int addscore *int rank_new *int addrank_new *int rank_old *int addrank_old *int mk_2 *uint addmk_2 *int mk_3 *uint addmk_3 *int mk_4 *uint addmk_4 *int mk_5 *uint addmk_5 *int dmg_enemy *uint adddmg_enemy *int dmg_team *uint adddmg_team *int ud_he *uint addud_he *int ud_flames *uint addud_flames *int ud_flash *uint addud_flash *int ud_decoy *uint addud_decoy *int ud_smoke *uint addud_smoke *int crosshair *string color *matchplayer.Color kast *int addkast *int flash_duration_self *float32 addflash_duration_self *float32 flash_duration_team *float32 addflash_duration_team *float32 flash_duration_enemy *float32 addflash_duration_enemy *float32 flash_total_self *uint addflash_total_self *int flash_total_team *uint addflash_total_team *int flash_total_enemy *uint addflash_total_enemy *int flash_assists *int addflash_assists *int avg_ping *float64 addavg_ping *float64 clearedFields map[string]struct{} matches *uint64 clearedmatches bool players *uint64 clearedplayers bool weapon_stats map[int]struct{} removedweapon_stats map[int]struct{} clearedweapon_stats bool round_stats map[int]struct{} removedround_stats map[int]struct{} clearedround_stats bool spray map[int]struct{} removedspray map[int]struct{} clearedspray bool messages map[int]struct{} removedmessages map[int]struct{} clearedmessages bool done bool oldValue func(context.Context) (*MatchPlayer, error) predicates []predicate.MatchPlayer } var _ ent.Mutation = (*MatchPlayerMutation)(nil) // matchplayerOption allows management of the mutation configuration using functional options. type matchplayerOption func(*MatchPlayerMutation) // newMatchPlayerMutation creates new mutation for the MatchPlayer entity. func newMatchPlayerMutation(c config, op Op, opts ...matchplayerOption) *MatchPlayerMutation { m := &MatchPlayerMutation{ config: c, op: op, typ: TypeMatchPlayer, clearedFields: make(map[string]struct{}), } for _, opt := range opts { opt(m) } return m } // withMatchPlayerID sets the ID field of the mutation. func withMatchPlayerID(id int) matchplayerOption { return func(m *MatchPlayerMutation) { var ( err error once sync.Once value *MatchPlayer ) m.oldValue = func(ctx context.Context) (*MatchPlayer, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { value, err = m.Client().MatchPlayer.Get(ctx, id) } }) return value, err } m.id = &id } } // withMatchPlayer sets the old MatchPlayer of the mutation. func withMatchPlayer(node *MatchPlayer) matchplayerOption { return func(m *MatchPlayerMutation) { m.oldValue = func(context.Context) (*MatchPlayer, 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 MatchPlayerMutation) 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 MatchPlayerMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("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 *MatchPlayerMutation) ID() (id int, exists bool) { if m.id == nil { return } return *m.id, true } // IDs queries the database and returns the entity ids that match the mutation's predicate. // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. func (m *MatchPlayerMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { return []int{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): return m.Client().MatchPlayer.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // SetTeamID sets the "team_id" field. func (m *MatchPlayerMutation) 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 *MatchPlayerMutation) 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 MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldTeamID(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldTeamID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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 *MatchPlayerMutation) 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 *MatchPlayerMutation) 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 *MatchPlayerMutation) ResetTeamID() { m.team_id = nil m.addteam_id = nil } // SetKills sets the "kills" field. func (m *MatchPlayerMutation) SetKills(i int) { m.kills = &i m.addkills = nil } // Kills returns the value of the "kills" field in the mutation. func (m *MatchPlayerMutation) 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 MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldKills(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldKills is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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 *MatchPlayerMutation) 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 *MatchPlayerMutation) 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 *MatchPlayerMutation) ResetKills() { m.kills = nil m.addkills = nil } // SetDeaths sets the "deaths" field. func (m *MatchPlayerMutation) SetDeaths(i int) { m.deaths = &i m.adddeaths = nil } // Deaths returns the value of the "deaths" field in the mutation. func (m *MatchPlayerMutation) 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 MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldDeaths(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldDeaths is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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 *MatchPlayerMutation) 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 *MatchPlayerMutation) 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 *MatchPlayerMutation) ResetDeaths() { m.deaths = nil m.adddeaths = nil } // SetAssists sets the "assists" field. func (m *MatchPlayerMutation) SetAssists(i int) { m.assists = &i m.addassists = nil } // Assists returns the value of the "assists" field in the mutation. func (m *MatchPlayerMutation) 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 MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldAssists(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldAssists is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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 *MatchPlayerMutation) 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 *MatchPlayerMutation) 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 *MatchPlayerMutation) ResetAssists() { m.assists = nil m.addassists = nil } // SetHeadshot sets the "headshot" field. func (m *MatchPlayerMutation) SetHeadshot(i int) { m.headshot = &i m.addheadshot = nil } // Headshot returns the value of the "headshot" field in the mutation. func (m *MatchPlayerMutation) 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 MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldHeadshot(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldHeadshot is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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 *MatchPlayerMutation) 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 *MatchPlayerMutation) 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 *MatchPlayerMutation) ResetHeadshot() { m.headshot = nil m.addheadshot = nil } // SetMvp sets the "mvp" field. func (m *MatchPlayerMutation) SetMvp(u uint) { m.mvp = &u m.addmvp = nil } // Mvp returns the value of the "mvp" field in the mutation. func (m *MatchPlayerMutation) Mvp() (r uint, exists bool) { v := m.mvp if v == nil { return } return *v, true } // OldMvp returns the old "mvp" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldMvp(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldMvp is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldMvp requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldMvp: %w", err) } return oldValue.Mvp, nil } // AddMvp adds u to the "mvp" field. func (m *MatchPlayerMutation) AddMvp(u int) { if m.addmvp != nil { *m.addmvp += u } else { m.addmvp = &u } } // AddedMvp returns the value that was added to the "mvp" field in this mutation. func (m *MatchPlayerMutation) 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 *MatchPlayerMutation) ResetMvp() { m.mvp = nil m.addmvp = nil } // SetScore sets the "score" field. func (m *MatchPlayerMutation) SetScore(i int) { m.score = &i m.addscore = nil } // Score returns the value of the "score" field in the mutation. func (m *MatchPlayerMutation) 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 MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldScore(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldScore is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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 *MatchPlayerMutation) 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 *MatchPlayerMutation) 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 *MatchPlayerMutation) ResetScore() { m.score = nil m.addscore = nil } // SetRankNew sets the "rank_new" field. func (m *MatchPlayerMutation) SetRankNew(i int) { m.rank_new = &i m.addrank_new = nil } // RankNew returns the value of the "rank_new" field in the mutation. func (m *MatchPlayerMutation) RankNew() (r int, exists bool) { v := m.rank_new if v == nil { return } return *v, true } // OldRankNew returns the old "rank_new" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldRankNew(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldRankNew is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldRankNew requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldRankNew: %w", err) } return oldValue.RankNew, nil } // AddRankNew adds i to the "rank_new" field. func (m *MatchPlayerMutation) AddRankNew(i int) { if m.addrank_new != nil { *m.addrank_new += i } else { m.addrank_new = &i } } // AddedRankNew returns the value that was added to the "rank_new" field in this mutation. func (m *MatchPlayerMutation) AddedRankNew() (r int, exists bool) { v := m.addrank_new if v == nil { return } return *v, true } // ClearRankNew clears the value of the "rank_new" field. func (m *MatchPlayerMutation) ClearRankNew() { m.rank_new = nil m.addrank_new = nil m.clearedFields[matchplayer.FieldRankNew] = struct{}{} } // RankNewCleared returns if the "rank_new" field was cleared in this mutation. func (m *MatchPlayerMutation) RankNewCleared() bool { _, ok := m.clearedFields[matchplayer.FieldRankNew] return ok } // ResetRankNew resets all changes to the "rank_new" field. func (m *MatchPlayerMutation) ResetRankNew() { m.rank_new = nil m.addrank_new = nil delete(m.clearedFields, matchplayer.FieldRankNew) } // SetRankOld sets the "rank_old" field. func (m *MatchPlayerMutation) SetRankOld(i int) { m.rank_old = &i m.addrank_old = nil } // RankOld returns the value of the "rank_old" field in the mutation. func (m *MatchPlayerMutation) RankOld() (r int, exists bool) { v := m.rank_old if v == nil { return } return *v, true } // OldRankOld returns the old "rank_old" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldRankOld(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldRankOld is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldRankOld requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldRankOld: %w", err) } return oldValue.RankOld, nil } // AddRankOld adds i to the "rank_old" field. func (m *MatchPlayerMutation) AddRankOld(i int) { if m.addrank_old != nil { *m.addrank_old += i } else { m.addrank_old = &i } } // AddedRankOld returns the value that was added to the "rank_old" field in this mutation. func (m *MatchPlayerMutation) AddedRankOld() (r int, exists bool) { v := m.addrank_old if v == nil { return } return *v, true } // ClearRankOld clears the value of the "rank_old" field. func (m *MatchPlayerMutation) ClearRankOld() { m.rank_old = nil m.addrank_old = nil m.clearedFields[matchplayer.FieldRankOld] = struct{}{} } // RankOldCleared returns if the "rank_old" field was cleared in this mutation. func (m *MatchPlayerMutation) RankOldCleared() bool { _, ok := m.clearedFields[matchplayer.FieldRankOld] return ok } // ResetRankOld resets all changes to the "rank_old" field. func (m *MatchPlayerMutation) ResetRankOld() { m.rank_old = nil m.addrank_old = nil delete(m.clearedFields, matchplayer.FieldRankOld) } // SetMk2 sets the "mk_2" field. func (m *MatchPlayerMutation) SetMk2(u uint) { m.mk_2 = &u m.addmk_2 = nil } // Mk2 returns the value of the "mk_2" field in the mutation. func (m *MatchPlayerMutation) Mk2() (r uint, exists bool) { v := m.mk_2 if v == nil { return } return *v, true } // OldMk2 returns the old "mk_2" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldMk2(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldMk2 is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldMk2 requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldMk2: %w", err) } return oldValue.Mk2, nil } // AddMk2 adds u to the "mk_2" field. func (m *MatchPlayerMutation) AddMk2(u int) { if m.addmk_2 != nil { *m.addmk_2 += u } else { m.addmk_2 = &u } } // AddedMk2 returns the value that was added to the "mk_2" field in this mutation. func (m *MatchPlayerMutation) AddedMk2() (r int, exists bool) { v := m.addmk_2 if v == nil { return } return *v, true } // ClearMk2 clears the value of the "mk_2" field. func (m *MatchPlayerMutation) ClearMk2() { m.mk_2 = nil m.addmk_2 = nil m.clearedFields[matchplayer.FieldMk2] = struct{}{} } // Mk2Cleared returns if the "mk_2" field was cleared in this mutation. func (m *MatchPlayerMutation) Mk2Cleared() bool { _, ok := m.clearedFields[matchplayer.FieldMk2] return ok } // ResetMk2 resets all changes to the "mk_2" field. func (m *MatchPlayerMutation) ResetMk2() { m.mk_2 = nil m.addmk_2 = nil delete(m.clearedFields, matchplayer.FieldMk2) } // SetMk3 sets the "mk_3" field. func (m *MatchPlayerMutation) SetMk3(u uint) { m.mk_3 = &u m.addmk_3 = nil } // Mk3 returns the value of the "mk_3" field in the mutation. func (m *MatchPlayerMutation) Mk3() (r uint, exists bool) { v := m.mk_3 if v == nil { return } return *v, true } // OldMk3 returns the old "mk_3" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldMk3(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldMk3 is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldMk3 requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldMk3: %w", err) } return oldValue.Mk3, nil } // AddMk3 adds u to the "mk_3" field. func (m *MatchPlayerMutation) AddMk3(u int) { if m.addmk_3 != nil { *m.addmk_3 += u } else { m.addmk_3 = &u } } // AddedMk3 returns the value that was added to the "mk_3" field in this mutation. func (m *MatchPlayerMutation) AddedMk3() (r int, exists bool) { v := m.addmk_3 if v == nil { return } return *v, true } // ClearMk3 clears the value of the "mk_3" field. func (m *MatchPlayerMutation) ClearMk3() { m.mk_3 = nil m.addmk_3 = nil m.clearedFields[matchplayer.FieldMk3] = struct{}{} } // Mk3Cleared returns if the "mk_3" field was cleared in this mutation. func (m *MatchPlayerMutation) Mk3Cleared() bool { _, ok := m.clearedFields[matchplayer.FieldMk3] return ok } // ResetMk3 resets all changes to the "mk_3" field. func (m *MatchPlayerMutation) ResetMk3() { m.mk_3 = nil m.addmk_3 = nil delete(m.clearedFields, matchplayer.FieldMk3) } // SetMk4 sets the "mk_4" field. func (m *MatchPlayerMutation) SetMk4(u uint) { m.mk_4 = &u m.addmk_4 = nil } // Mk4 returns the value of the "mk_4" field in the mutation. func (m *MatchPlayerMutation) Mk4() (r uint, exists bool) { v := m.mk_4 if v == nil { return } return *v, true } // OldMk4 returns the old "mk_4" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldMk4(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldMk4 is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldMk4 requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldMk4: %w", err) } return oldValue.Mk4, nil } // AddMk4 adds u to the "mk_4" field. func (m *MatchPlayerMutation) AddMk4(u int) { if m.addmk_4 != nil { *m.addmk_4 += u } else { m.addmk_4 = &u } } // AddedMk4 returns the value that was added to the "mk_4" field in this mutation. func (m *MatchPlayerMutation) AddedMk4() (r int, exists bool) { v := m.addmk_4 if v == nil { return } return *v, true } // ClearMk4 clears the value of the "mk_4" field. func (m *MatchPlayerMutation) ClearMk4() { m.mk_4 = nil m.addmk_4 = nil m.clearedFields[matchplayer.FieldMk4] = struct{}{} } // Mk4Cleared returns if the "mk_4" field was cleared in this mutation. func (m *MatchPlayerMutation) Mk4Cleared() bool { _, ok := m.clearedFields[matchplayer.FieldMk4] return ok } // ResetMk4 resets all changes to the "mk_4" field. func (m *MatchPlayerMutation) ResetMk4() { m.mk_4 = nil m.addmk_4 = nil delete(m.clearedFields, matchplayer.FieldMk4) } // SetMk5 sets the "mk_5" field. func (m *MatchPlayerMutation) SetMk5(u uint) { m.mk_5 = &u m.addmk_5 = nil } // Mk5 returns the value of the "mk_5" field in the mutation. func (m *MatchPlayerMutation) Mk5() (r uint, exists bool) { v := m.mk_5 if v == nil { return } return *v, true } // OldMk5 returns the old "mk_5" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldMk5(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldMk5 is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldMk5 requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldMk5: %w", err) } return oldValue.Mk5, nil } // AddMk5 adds u to the "mk_5" field. func (m *MatchPlayerMutation) AddMk5(u int) { if m.addmk_5 != nil { *m.addmk_5 += u } else { m.addmk_5 = &u } } // AddedMk5 returns the value that was added to the "mk_5" field in this mutation. func (m *MatchPlayerMutation) AddedMk5() (r int, exists bool) { v := m.addmk_5 if v == nil { return } return *v, true } // ClearMk5 clears the value of the "mk_5" field. func (m *MatchPlayerMutation) ClearMk5() { m.mk_5 = nil m.addmk_5 = nil m.clearedFields[matchplayer.FieldMk5] = struct{}{} } // Mk5Cleared returns if the "mk_5" field was cleared in this mutation. func (m *MatchPlayerMutation) Mk5Cleared() bool { _, ok := m.clearedFields[matchplayer.FieldMk5] return ok } // ResetMk5 resets all changes to the "mk_5" field. func (m *MatchPlayerMutation) ResetMk5() { m.mk_5 = nil m.addmk_5 = nil delete(m.clearedFields, matchplayer.FieldMk5) } // SetDmgEnemy sets the "dmg_enemy" field. func (m *MatchPlayerMutation) SetDmgEnemy(u uint) { m.dmg_enemy = &u m.adddmg_enemy = nil } // DmgEnemy returns the value of the "dmg_enemy" field in the mutation. func (m *MatchPlayerMutation) DmgEnemy() (r uint, exists bool) { v := m.dmg_enemy if v == nil { return } return *v, true } // OldDmgEnemy returns the old "dmg_enemy" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldDmgEnemy(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldDmgEnemy is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldDmgEnemy requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldDmgEnemy: %w", err) } return oldValue.DmgEnemy, nil } // AddDmgEnemy adds u to the "dmg_enemy" field. func (m *MatchPlayerMutation) AddDmgEnemy(u int) { if m.adddmg_enemy != nil { *m.adddmg_enemy += u } else { m.adddmg_enemy = &u } } // AddedDmgEnemy returns the value that was added to the "dmg_enemy" field in this mutation. func (m *MatchPlayerMutation) AddedDmgEnemy() (r int, exists bool) { v := m.adddmg_enemy if v == nil { return } return *v, true } // ClearDmgEnemy clears the value of the "dmg_enemy" field. func (m *MatchPlayerMutation) ClearDmgEnemy() { m.dmg_enemy = nil m.adddmg_enemy = nil m.clearedFields[matchplayer.FieldDmgEnemy] = struct{}{} } // DmgEnemyCleared returns if the "dmg_enemy" field was cleared in this mutation. func (m *MatchPlayerMutation) DmgEnemyCleared() bool { _, ok := m.clearedFields[matchplayer.FieldDmgEnemy] return ok } // ResetDmgEnemy resets all changes to the "dmg_enemy" field. func (m *MatchPlayerMutation) ResetDmgEnemy() { m.dmg_enemy = nil m.adddmg_enemy = nil delete(m.clearedFields, matchplayer.FieldDmgEnemy) } // SetDmgTeam sets the "dmg_team" field. func (m *MatchPlayerMutation) SetDmgTeam(u uint) { m.dmg_team = &u m.adddmg_team = nil } // DmgTeam returns the value of the "dmg_team" field in the mutation. func (m *MatchPlayerMutation) DmgTeam() (r uint, exists bool) { v := m.dmg_team if v == nil { return } return *v, true } // OldDmgTeam returns the old "dmg_team" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldDmgTeam(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldDmgTeam is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldDmgTeam requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldDmgTeam: %w", err) } return oldValue.DmgTeam, nil } // AddDmgTeam adds u to the "dmg_team" field. func (m *MatchPlayerMutation) AddDmgTeam(u int) { if m.adddmg_team != nil { *m.adddmg_team += u } else { m.adddmg_team = &u } } // AddedDmgTeam returns the value that was added to the "dmg_team" field in this mutation. func (m *MatchPlayerMutation) AddedDmgTeam() (r int, exists bool) { v := m.adddmg_team if v == nil { return } return *v, true } // ClearDmgTeam clears the value of the "dmg_team" field. func (m *MatchPlayerMutation) ClearDmgTeam() { m.dmg_team = nil m.adddmg_team = nil m.clearedFields[matchplayer.FieldDmgTeam] = struct{}{} } // DmgTeamCleared returns if the "dmg_team" field was cleared in this mutation. func (m *MatchPlayerMutation) DmgTeamCleared() bool { _, ok := m.clearedFields[matchplayer.FieldDmgTeam] return ok } // ResetDmgTeam resets all changes to the "dmg_team" field. func (m *MatchPlayerMutation) ResetDmgTeam() { m.dmg_team = nil m.adddmg_team = nil delete(m.clearedFields, matchplayer.FieldDmgTeam) } // SetUdHe sets the "ud_he" field. func (m *MatchPlayerMutation) SetUdHe(u uint) { m.ud_he = &u m.addud_he = nil } // UdHe returns the value of the "ud_he" field in the mutation. func (m *MatchPlayerMutation) UdHe() (r uint, exists bool) { v := m.ud_he if v == nil { return } return *v, true } // OldUdHe returns the old "ud_he" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldUdHe(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUdHe is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldUdHe requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldUdHe: %w", err) } return oldValue.UdHe, nil } // AddUdHe adds u to the "ud_he" field. func (m *MatchPlayerMutation) AddUdHe(u int) { if m.addud_he != nil { *m.addud_he += u } else { m.addud_he = &u } } // AddedUdHe returns the value that was added to the "ud_he" field in this mutation. func (m *MatchPlayerMutation) AddedUdHe() (r int, exists bool) { v := m.addud_he if v == nil { return } return *v, true } // ClearUdHe clears the value of the "ud_he" field. func (m *MatchPlayerMutation) ClearUdHe() { m.ud_he = nil m.addud_he = nil m.clearedFields[matchplayer.FieldUdHe] = struct{}{} } // UdHeCleared returns if the "ud_he" field was cleared in this mutation. func (m *MatchPlayerMutation) UdHeCleared() bool { _, ok := m.clearedFields[matchplayer.FieldUdHe] return ok } // ResetUdHe resets all changes to the "ud_he" field. func (m *MatchPlayerMutation) ResetUdHe() { m.ud_he = nil m.addud_he = nil delete(m.clearedFields, matchplayer.FieldUdHe) } // SetUdFlames sets the "ud_flames" field. func (m *MatchPlayerMutation) SetUdFlames(u uint) { m.ud_flames = &u m.addud_flames = nil } // UdFlames returns the value of the "ud_flames" field in the mutation. func (m *MatchPlayerMutation) UdFlames() (r uint, exists bool) { v := m.ud_flames if v == nil { return } return *v, true } // OldUdFlames returns the old "ud_flames" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldUdFlames(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUdFlames is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldUdFlames requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldUdFlames: %w", err) } return oldValue.UdFlames, nil } // AddUdFlames adds u to the "ud_flames" field. func (m *MatchPlayerMutation) AddUdFlames(u int) { if m.addud_flames != nil { *m.addud_flames += u } else { m.addud_flames = &u } } // AddedUdFlames returns the value that was added to the "ud_flames" field in this mutation. func (m *MatchPlayerMutation) AddedUdFlames() (r int, exists bool) { v := m.addud_flames if v == nil { return } return *v, true } // ClearUdFlames clears the value of the "ud_flames" field. func (m *MatchPlayerMutation) ClearUdFlames() { m.ud_flames = nil m.addud_flames = nil m.clearedFields[matchplayer.FieldUdFlames] = struct{}{} } // UdFlamesCleared returns if the "ud_flames" field was cleared in this mutation. func (m *MatchPlayerMutation) UdFlamesCleared() bool { _, ok := m.clearedFields[matchplayer.FieldUdFlames] return ok } // ResetUdFlames resets all changes to the "ud_flames" field. func (m *MatchPlayerMutation) ResetUdFlames() { m.ud_flames = nil m.addud_flames = nil delete(m.clearedFields, matchplayer.FieldUdFlames) } // SetUdFlash sets the "ud_flash" field. func (m *MatchPlayerMutation) SetUdFlash(u uint) { m.ud_flash = &u m.addud_flash = nil } // UdFlash returns the value of the "ud_flash" field in the mutation. func (m *MatchPlayerMutation) UdFlash() (r uint, exists bool) { v := m.ud_flash if v == nil { return } return *v, true } // OldUdFlash returns the old "ud_flash" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldUdFlash(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUdFlash is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldUdFlash requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldUdFlash: %w", err) } return oldValue.UdFlash, nil } // AddUdFlash adds u to the "ud_flash" field. func (m *MatchPlayerMutation) AddUdFlash(u int) { if m.addud_flash != nil { *m.addud_flash += u } else { m.addud_flash = &u } } // AddedUdFlash returns the value that was added to the "ud_flash" field in this mutation. func (m *MatchPlayerMutation) AddedUdFlash() (r int, exists bool) { v := m.addud_flash if v == nil { return } return *v, true } // ClearUdFlash clears the value of the "ud_flash" field. func (m *MatchPlayerMutation) ClearUdFlash() { m.ud_flash = nil m.addud_flash = nil m.clearedFields[matchplayer.FieldUdFlash] = struct{}{} } // UdFlashCleared returns if the "ud_flash" field was cleared in this mutation. func (m *MatchPlayerMutation) UdFlashCleared() bool { _, ok := m.clearedFields[matchplayer.FieldUdFlash] return ok } // ResetUdFlash resets all changes to the "ud_flash" field. func (m *MatchPlayerMutation) ResetUdFlash() { m.ud_flash = nil m.addud_flash = nil delete(m.clearedFields, matchplayer.FieldUdFlash) } // SetUdDecoy sets the "ud_decoy" field. func (m *MatchPlayerMutation) SetUdDecoy(u uint) { m.ud_decoy = &u m.addud_decoy = nil } // UdDecoy returns the value of the "ud_decoy" field in the mutation. func (m *MatchPlayerMutation) UdDecoy() (r uint, exists bool) { v := m.ud_decoy if v == nil { return } return *v, true } // OldUdDecoy returns the old "ud_decoy" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldUdDecoy(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUdDecoy is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldUdDecoy requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldUdDecoy: %w", err) } return oldValue.UdDecoy, nil } // AddUdDecoy adds u to the "ud_decoy" field. func (m *MatchPlayerMutation) AddUdDecoy(u int) { if m.addud_decoy != nil { *m.addud_decoy += u } else { m.addud_decoy = &u } } // AddedUdDecoy returns the value that was added to the "ud_decoy" field in this mutation. func (m *MatchPlayerMutation) AddedUdDecoy() (r int, exists bool) { v := m.addud_decoy if v == nil { return } return *v, true } // ClearUdDecoy clears the value of the "ud_decoy" field. func (m *MatchPlayerMutation) ClearUdDecoy() { m.ud_decoy = nil m.addud_decoy = nil m.clearedFields[matchplayer.FieldUdDecoy] = struct{}{} } // UdDecoyCleared returns if the "ud_decoy" field was cleared in this mutation. func (m *MatchPlayerMutation) UdDecoyCleared() bool { _, ok := m.clearedFields[matchplayer.FieldUdDecoy] return ok } // ResetUdDecoy resets all changes to the "ud_decoy" field. func (m *MatchPlayerMutation) ResetUdDecoy() { m.ud_decoy = nil m.addud_decoy = nil delete(m.clearedFields, matchplayer.FieldUdDecoy) } // SetUdSmoke sets the "ud_smoke" field. func (m *MatchPlayerMutation) SetUdSmoke(u uint) { m.ud_smoke = &u m.addud_smoke = nil } // UdSmoke returns the value of the "ud_smoke" field in the mutation. func (m *MatchPlayerMutation) UdSmoke() (r uint, exists bool) { v := m.ud_smoke if v == nil { return } return *v, true } // OldUdSmoke returns the old "ud_smoke" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldUdSmoke(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUdSmoke is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldUdSmoke requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldUdSmoke: %w", err) } return oldValue.UdSmoke, nil } // AddUdSmoke adds u to the "ud_smoke" field. func (m *MatchPlayerMutation) AddUdSmoke(u int) { if m.addud_smoke != nil { *m.addud_smoke += u } else { m.addud_smoke = &u } } // AddedUdSmoke returns the value that was added to the "ud_smoke" field in this mutation. func (m *MatchPlayerMutation) AddedUdSmoke() (r int, exists bool) { v := m.addud_smoke if v == nil { return } return *v, true } // ClearUdSmoke clears the value of the "ud_smoke" field. func (m *MatchPlayerMutation) ClearUdSmoke() { m.ud_smoke = nil m.addud_smoke = nil m.clearedFields[matchplayer.FieldUdSmoke] = struct{}{} } // UdSmokeCleared returns if the "ud_smoke" field was cleared in this mutation. func (m *MatchPlayerMutation) UdSmokeCleared() bool { _, ok := m.clearedFields[matchplayer.FieldUdSmoke] return ok } // ResetUdSmoke resets all changes to the "ud_smoke" field. func (m *MatchPlayerMutation) ResetUdSmoke() { m.ud_smoke = nil m.addud_smoke = nil delete(m.clearedFields, matchplayer.FieldUdSmoke) } // SetCrosshair sets the "crosshair" field. func (m *MatchPlayerMutation) SetCrosshair(s string) { m.crosshair = &s } // Crosshair returns the value of the "crosshair" field in the mutation. func (m *MatchPlayerMutation) Crosshair() (r string, exists bool) { v := m.crosshair if v == nil { return } return *v, true } // OldCrosshair returns the old "crosshair" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldCrosshair(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCrosshair is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldCrosshair requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldCrosshair: %w", err) } return oldValue.Crosshair, nil } // ClearCrosshair clears the value of the "crosshair" field. func (m *MatchPlayerMutation) ClearCrosshair() { m.crosshair = nil m.clearedFields[matchplayer.FieldCrosshair] = struct{}{} } // CrosshairCleared returns if the "crosshair" field was cleared in this mutation. func (m *MatchPlayerMutation) CrosshairCleared() bool { _, ok := m.clearedFields[matchplayer.FieldCrosshair] return ok } // ResetCrosshair resets all changes to the "crosshair" field. func (m *MatchPlayerMutation) ResetCrosshair() { m.crosshair = nil delete(m.clearedFields, matchplayer.FieldCrosshair) } // SetColor sets the "color" field. func (m *MatchPlayerMutation) SetColor(value matchplayer.Color) { m.color = &value } // Color returns the value of the "color" field in the mutation. func (m *MatchPlayerMutation) Color() (r matchplayer.Color, exists bool) { v := m.color if v == nil { return } return *v, true } // OldColor returns the old "color" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldColor(ctx context.Context) (v matchplayer.Color, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldColor is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldColor requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldColor: %w", err) } return oldValue.Color, nil } // ClearColor clears the value of the "color" field. func (m *MatchPlayerMutation) ClearColor() { m.color = nil m.clearedFields[matchplayer.FieldColor] = struct{}{} } // ColorCleared returns if the "color" field was cleared in this mutation. func (m *MatchPlayerMutation) ColorCleared() bool { _, ok := m.clearedFields[matchplayer.FieldColor] return ok } // ResetColor resets all changes to the "color" field. func (m *MatchPlayerMutation) ResetColor() { m.color = nil delete(m.clearedFields, matchplayer.FieldColor) } // SetKast sets the "kast" field. func (m *MatchPlayerMutation) SetKast(i int) { m.kast = &i m.addkast = nil } // Kast returns the value of the "kast" field in the mutation. func (m *MatchPlayerMutation) Kast() (r int, exists bool) { v := m.kast if v == nil { return } return *v, true } // OldKast returns the old "kast" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldKast(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldKast is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldKast requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldKast: %w", err) } return oldValue.Kast, nil } // AddKast adds i to the "kast" field. func (m *MatchPlayerMutation) AddKast(i int) { if m.addkast != nil { *m.addkast += i } else { m.addkast = &i } } // AddedKast returns the value that was added to the "kast" field in this mutation. func (m *MatchPlayerMutation) AddedKast() (r int, exists bool) { v := m.addkast if v == nil { return } return *v, true } // ClearKast clears the value of the "kast" field. func (m *MatchPlayerMutation) ClearKast() { m.kast = nil m.addkast = nil m.clearedFields[matchplayer.FieldKast] = struct{}{} } // KastCleared returns if the "kast" field was cleared in this mutation. func (m *MatchPlayerMutation) KastCleared() bool { _, ok := m.clearedFields[matchplayer.FieldKast] return ok } // ResetKast resets all changes to the "kast" field. func (m *MatchPlayerMutation) ResetKast() { m.kast = nil m.addkast = nil delete(m.clearedFields, matchplayer.FieldKast) } // SetFlashDurationSelf sets the "flash_duration_self" field. func (m *MatchPlayerMutation) SetFlashDurationSelf(f float32) { m.flash_duration_self = &f m.addflash_duration_self = nil } // FlashDurationSelf returns the value of the "flash_duration_self" field in the mutation. func (m *MatchPlayerMutation) FlashDurationSelf() (r float32, exists bool) { v := m.flash_duration_self if v == nil { return } return *v, true } // OldFlashDurationSelf returns the old "flash_duration_self" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldFlashDurationSelf(ctx context.Context) (v float32, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldFlashDurationSelf is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldFlashDurationSelf requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldFlashDurationSelf: %w", err) } return oldValue.FlashDurationSelf, nil } // AddFlashDurationSelf adds f to the "flash_duration_self" field. func (m *MatchPlayerMutation) AddFlashDurationSelf(f float32) { if m.addflash_duration_self != nil { *m.addflash_duration_self += f } else { m.addflash_duration_self = &f } } // AddedFlashDurationSelf returns the value that was added to the "flash_duration_self" field in this mutation. func (m *MatchPlayerMutation) AddedFlashDurationSelf() (r float32, exists bool) { v := m.addflash_duration_self if v == nil { return } return *v, true } // ClearFlashDurationSelf clears the value of the "flash_duration_self" field. func (m *MatchPlayerMutation) ClearFlashDurationSelf() { m.flash_duration_self = nil m.addflash_duration_self = nil m.clearedFields[matchplayer.FieldFlashDurationSelf] = struct{}{} } // FlashDurationSelfCleared returns if the "flash_duration_self" field was cleared in this mutation. func (m *MatchPlayerMutation) FlashDurationSelfCleared() bool { _, ok := m.clearedFields[matchplayer.FieldFlashDurationSelf] return ok } // ResetFlashDurationSelf resets all changes to the "flash_duration_self" field. func (m *MatchPlayerMutation) ResetFlashDurationSelf() { m.flash_duration_self = nil m.addflash_duration_self = nil delete(m.clearedFields, matchplayer.FieldFlashDurationSelf) } // SetFlashDurationTeam sets the "flash_duration_team" field. func (m *MatchPlayerMutation) SetFlashDurationTeam(f float32) { m.flash_duration_team = &f m.addflash_duration_team = nil } // FlashDurationTeam returns the value of the "flash_duration_team" field in the mutation. func (m *MatchPlayerMutation) FlashDurationTeam() (r float32, exists bool) { v := m.flash_duration_team if v == nil { return } return *v, true } // OldFlashDurationTeam returns the old "flash_duration_team" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldFlashDurationTeam(ctx context.Context) (v float32, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldFlashDurationTeam is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldFlashDurationTeam requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldFlashDurationTeam: %w", err) } return oldValue.FlashDurationTeam, nil } // AddFlashDurationTeam adds f to the "flash_duration_team" field. func (m *MatchPlayerMutation) AddFlashDurationTeam(f float32) { if m.addflash_duration_team != nil { *m.addflash_duration_team += f } else { m.addflash_duration_team = &f } } // AddedFlashDurationTeam returns the value that was added to the "flash_duration_team" field in this mutation. func (m *MatchPlayerMutation) AddedFlashDurationTeam() (r float32, exists bool) { v := m.addflash_duration_team if v == nil { return } return *v, true } // ClearFlashDurationTeam clears the value of the "flash_duration_team" field. func (m *MatchPlayerMutation) ClearFlashDurationTeam() { m.flash_duration_team = nil m.addflash_duration_team = nil m.clearedFields[matchplayer.FieldFlashDurationTeam] = struct{}{} } // FlashDurationTeamCleared returns if the "flash_duration_team" field was cleared in this mutation. func (m *MatchPlayerMutation) FlashDurationTeamCleared() bool { _, ok := m.clearedFields[matchplayer.FieldFlashDurationTeam] return ok } // ResetFlashDurationTeam resets all changes to the "flash_duration_team" field. func (m *MatchPlayerMutation) ResetFlashDurationTeam() { m.flash_duration_team = nil m.addflash_duration_team = nil delete(m.clearedFields, matchplayer.FieldFlashDurationTeam) } // SetFlashDurationEnemy sets the "flash_duration_enemy" field. func (m *MatchPlayerMutation) SetFlashDurationEnemy(f float32) { m.flash_duration_enemy = &f m.addflash_duration_enemy = nil } // FlashDurationEnemy returns the value of the "flash_duration_enemy" field in the mutation. func (m *MatchPlayerMutation) FlashDurationEnemy() (r float32, exists bool) { v := m.flash_duration_enemy if v == nil { return } return *v, true } // OldFlashDurationEnemy returns the old "flash_duration_enemy" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldFlashDurationEnemy(ctx context.Context) (v float32, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldFlashDurationEnemy is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldFlashDurationEnemy requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldFlashDurationEnemy: %w", err) } return oldValue.FlashDurationEnemy, nil } // AddFlashDurationEnemy adds f to the "flash_duration_enemy" field. func (m *MatchPlayerMutation) AddFlashDurationEnemy(f float32) { if m.addflash_duration_enemy != nil { *m.addflash_duration_enemy += f } else { m.addflash_duration_enemy = &f } } // AddedFlashDurationEnemy returns the value that was added to the "flash_duration_enemy" field in this mutation. func (m *MatchPlayerMutation) AddedFlashDurationEnemy() (r float32, exists bool) { v := m.addflash_duration_enemy if v == nil { return } return *v, true } // ClearFlashDurationEnemy clears the value of the "flash_duration_enemy" field. func (m *MatchPlayerMutation) ClearFlashDurationEnemy() { m.flash_duration_enemy = nil m.addflash_duration_enemy = nil m.clearedFields[matchplayer.FieldFlashDurationEnemy] = struct{}{} } // FlashDurationEnemyCleared returns if the "flash_duration_enemy" field was cleared in this mutation. func (m *MatchPlayerMutation) FlashDurationEnemyCleared() bool { _, ok := m.clearedFields[matchplayer.FieldFlashDurationEnemy] return ok } // ResetFlashDurationEnemy resets all changes to the "flash_duration_enemy" field. func (m *MatchPlayerMutation) ResetFlashDurationEnemy() { m.flash_duration_enemy = nil m.addflash_duration_enemy = nil delete(m.clearedFields, matchplayer.FieldFlashDurationEnemy) } // SetFlashTotalSelf sets the "flash_total_self" field. func (m *MatchPlayerMutation) SetFlashTotalSelf(u uint) { m.flash_total_self = &u m.addflash_total_self = nil } // FlashTotalSelf returns the value of the "flash_total_self" field in the mutation. func (m *MatchPlayerMutation) FlashTotalSelf() (r uint, exists bool) { v := m.flash_total_self if v == nil { return } return *v, true } // OldFlashTotalSelf returns the old "flash_total_self" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldFlashTotalSelf(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldFlashTotalSelf is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldFlashTotalSelf requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldFlashTotalSelf: %w", err) } return oldValue.FlashTotalSelf, nil } // AddFlashTotalSelf adds u to the "flash_total_self" field. func (m *MatchPlayerMutation) AddFlashTotalSelf(u int) { if m.addflash_total_self != nil { *m.addflash_total_self += u } else { m.addflash_total_self = &u } } // AddedFlashTotalSelf returns the value that was added to the "flash_total_self" field in this mutation. func (m *MatchPlayerMutation) AddedFlashTotalSelf() (r int, exists bool) { v := m.addflash_total_self if v == nil { return } return *v, true } // ClearFlashTotalSelf clears the value of the "flash_total_self" field. func (m *MatchPlayerMutation) ClearFlashTotalSelf() { m.flash_total_self = nil m.addflash_total_self = nil m.clearedFields[matchplayer.FieldFlashTotalSelf] = struct{}{} } // FlashTotalSelfCleared returns if the "flash_total_self" field was cleared in this mutation. func (m *MatchPlayerMutation) FlashTotalSelfCleared() bool { _, ok := m.clearedFields[matchplayer.FieldFlashTotalSelf] return ok } // ResetFlashTotalSelf resets all changes to the "flash_total_self" field. func (m *MatchPlayerMutation) ResetFlashTotalSelf() { m.flash_total_self = nil m.addflash_total_self = nil delete(m.clearedFields, matchplayer.FieldFlashTotalSelf) } // SetFlashTotalTeam sets the "flash_total_team" field. func (m *MatchPlayerMutation) SetFlashTotalTeam(u uint) { m.flash_total_team = &u m.addflash_total_team = nil } // FlashTotalTeam returns the value of the "flash_total_team" field in the mutation. func (m *MatchPlayerMutation) FlashTotalTeam() (r uint, exists bool) { v := m.flash_total_team if v == nil { return } return *v, true } // OldFlashTotalTeam returns the old "flash_total_team" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldFlashTotalTeam(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldFlashTotalTeam is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldFlashTotalTeam requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldFlashTotalTeam: %w", err) } return oldValue.FlashTotalTeam, nil } // AddFlashTotalTeam adds u to the "flash_total_team" field. func (m *MatchPlayerMutation) AddFlashTotalTeam(u int) { if m.addflash_total_team != nil { *m.addflash_total_team += u } else { m.addflash_total_team = &u } } // AddedFlashTotalTeam returns the value that was added to the "flash_total_team" field in this mutation. func (m *MatchPlayerMutation) AddedFlashTotalTeam() (r int, exists bool) { v := m.addflash_total_team if v == nil { return } return *v, true } // ClearFlashTotalTeam clears the value of the "flash_total_team" field. func (m *MatchPlayerMutation) ClearFlashTotalTeam() { m.flash_total_team = nil m.addflash_total_team = nil m.clearedFields[matchplayer.FieldFlashTotalTeam] = struct{}{} } // FlashTotalTeamCleared returns if the "flash_total_team" field was cleared in this mutation. func (m *MatchPlayerMutation) FlashTotalTeamCleared() bool { _, ok := m.clearedFields[matchplayer.FieldFlashTotalTeam] return ok } // ResetFlashTotalTeam resets all changes to the "flash_total_team" field. func (m *MatchPlayerMutation) ResetFlashTotalTeam() { m.flash_total_team = nil m.addflash_total_team = nil delete(m.clearedFields, matchplayer.FieldFlashTotalTeam) } // SetFlashTotalEnemy sets the "flash_total_enemy" field. func (m *MatchPlayerMutation) SetFlashTotalEnemy(u uint) { m.flash_total_enemy = &u m.addflash_total_enemy = nil } // FlashTotalEnemy returns the value of the "flash_total_enemy" field in the mutation. func (m *MatchPlayerMutation) FlashTotalEnemy() (r uint, exists bool) { v := m.flash_total_enemy if v == nil { return } return *v, true } // OldFlashTotalEnemy returns the old "flash_total_enemy" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldFlashTotalEnemy(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldFlashTotalEnemy is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldFlashTotalEnemy requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldFlashTotalEnemy: %w", err) } return oldValue.FlashTotalEnemy, nil } // AddFlashTotalEnemy adds u to the "flash_total_enemy" field. func (m *MatchPlayerMutation) AddFlashTotalEnemy(u int) { if m.addflash_total_enemy != nil { *m.addflash_total_enemy += u } else { m.addflash_total_enemy = &u } } // AddedFlashTotalEnemy returns the value that was added to the "flash_total_enemy" field in this mutation. func (m *MatchPlayerMutation) AddedFlashTotalEnemy() (r int, exists bool) { v := m.addflash_total_enemy if v == nil { return } return *v, true } // ClearFlashTotalEnemy clears the value of the "flash_total_enemy" field. func (m *MatchPlayerMutation) ClearFlashTotalEnemy() { m.flash_total_enemy = nil m.addflash_total_enemy = nil m.clearedFields[matchplayer.FieldFlashTotalEnemy] = struct{}{} } // FlashTotalEnemyCleared returns if the "flash_total_enemy" field was cleared in this mutation. func (m *MatchPlayerMutation) FlashTotalEnemyCleared() bool { _, ok := m.clearedFields[matchplayer.FieldFlashTotalEnemy] return ok } // ResetFlashTotalEnemy resets all changes to the "flash_total_enemy" field. func (m *MatchPlayerMutation) ResetFlashTotalEnemy() { m.flash_total_enemy = nil m.addflash_total_enemy = nil delete(m.clearedFields, matchplayer.FieldFlashTotalEnemy) } // SetMatchStats sets the "match_stats" field. func (m *MatchPlayerMutation) SetMatchStats(u uint64) { m.matches = &u } // MatchStats returns the value of the "match_stats" field in the mutation. func (m *MatchPlayerMutation) MatchStats() (r uint64, exists bool) { v := m.matches if v == nil { return } return *v, true } // OldMatchStats returns the old "match_stats" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldMatchStats(ctx context.Context) (v uint64, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldMatchStats is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldMatchStats requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldMatchStats: %w", err) } return oldValue.MatchStats, nil } // ClearMatchStats clears the value of the "match_stats" field. func (m *MatchPlayerMutation) ClearMatchStats() { m.matches = nil m.clearedFields[matchplayer.FieldMatchStats] = struct{}{} } // MatchStatsCleared returns if the "match_stats" field was cleared in this mutation. func (m *MatchPlayerMutation) MatchStatsCleared() bool { _, ok := m.clearedFields[matchplayer.FieldMatchStats] return ok } // ResetMatchStats resets all changes to the "match_stats" field. func (m *MatchPlayerMutation) ResetMatchStats() { m.matches = nil delete(m.clearedFields, matchplayer.FieldMatchStats) } // SetPlayerStats sets the "player_stats" field. func (m *MatchPlayerMutation) SetPlayerStats(u uint64) { m.players = &u } // PlayerStats returns the value of the "player_stats" field in the mutation. func (m *MatchPlayerMutation) PlayerStats() (r uint64, exists bool) { v := m.players if v == nil { return } return *v, true } // OldPlayerStats returns the old "player_stats" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldPlayerStats(ctx context.Context) (v uint64, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldPlayerStats is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldPlayerStats requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldPlayerStats: %w", err) } return oldValue.PlayerStats, nil } // ClearPlayerStats clears the value of the "player_stats" field. func (m *MatchPlayerMutation) ClearPlayerStats() { m.players = nil m.clearedFields[matchplayer.FieldPlayerStats] = struct{}{} } // PlayerStatsCleared returns if the "player_stats" field was cleared in this mutation. func (m *MatchPlayerMutation) PlayerStatsCleared() bool { _, ok := m.clearedFields[matchplayer.FieldPlayerStats] return ok } // ResetPlayerStats resets all changes to the "player_stats" field. func (m *MatchPlayerMutation) ResetPlayerStats() { m.players = nil delete(m.clearedFields, matchplayer.FieldPlayerStats) } // SetFlashAssists sets the "flash_assists" field. func (m *MatchPlayerMutation) SetFlashAssists(i int) { m.flash_assists = &i m.addflash_assists = nil } // FlashAssists returns the value of the "flash_assists" field in the mutation. func (m *MatchPlayerMutation) FlashAssists() (r int, exists bool) { v := m.flash_assists if v == nil { return } return *v, true } // OldFlashAssists returns the old "flash_assists" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldFlashAssists(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldFlashAssists is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldFlashAssists requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldFlashAssists: %w", err) } return oldValue.FlashAssists, nil } // AddFlashAssists adds i to the "flash_assists" field. func (m *MatchPlayerMutation) AddFlashAssists(i int) { if m.addflash_assists != nil { *m.addflash_assists += i } else { m.addflash_assists = &i } } // AddedFlashAssists returns the value that was added to the "flash_assists" field in this mutation. func (m *MatchPlayerMutation) AddedFlashAssists() (r int, exists bool) { v := m.addflash_assists if v == nil { return } return *v, true } // ClearFlashAssists clears the value of the "flash_assists" field. func (m *MatchPlayerMutation) ClearFlashAssists() { m.flash_assists = nil m.addflash_assists = nil m.clearedFields[matchplayer.FieldFlashAssists] = struct{}{} } // FlashAssistsCleared returns if the "flash_assists" field was cleared in this mutation. func (m *MatchPlayerMutation) FlashAssistsCleared() bool { _, ok := m.clearedFields[matchplayer.FieldFlashAssists] return ok } // ResetFlashAssists resets all changes to the "flash_assists" field. func (m *MatchPlayerMutation) ResetFlashAssists() { m.flash_assists = nil m.addflash_assists = nil delete(m.clearedFields, matchplayer.FieldFlashAssists) } // SetAvgPing sets the "avg_ping" field. func (m *MatchPlayerMutation) SetAvgPing(f float64) { m.avg_ping = &f m.addavg_ping = nil } // AvgPing returns the value of the "avg_ping" field in the mutation. func (m *MatchPlayerMutation) AvgPing() (r float64, exists bool) { v := m.avg_ping if v == nil { return } return *v, true } // OldAvgPing returns the old "avg_ping" field's value of the MatchPlayer entity. // If the MatchPlayer 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 *MatchPlayerMutation) OldAvgPing(ctx context.Context) (v float64, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldAvgPing is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldAvgPing requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldAvgPing: %w", err) } return oldValue.AvgPing, nil } // AddAvgPing adds f to the "avg_ping" field. func (m *MatchPlayerMutation) AddAvgPing(f float64) { if m.addavg_ping != nil { *m.addavg_ping += f } else { m.addavg_ping = &f } } // AddedAvgPing returns the value that was added to the "avg_ping" field in this mutation. func (m *MatchPlayerMutation) AddedAvgPing() (r float64, exists bool) { v := m.addavg_ping if v == nil { return } return *v, true } // ClearAvgPing clears the value of the "avg_ping" field. func (m *MatchPlayerMutation) ClearAvgPing() { m.avg_ping = nil m.addavg_ping = nil m.clearedFields[matchplayer.FieldAvgPing] = struct{}{} } // AvgPingCleared returns if the "avg_ping" field was cleared in this mutation. func (m *MatchPlayerMutation) AvgPingCleared() bool { _, ok := m.clearedFields[matchplayer.FieldAvgPing] return ok } // ResetAvgPing resets all changes to the "avg_ping" field. func (m *MatchPlayerMutation) ResetAvgPing() { m.avg_ping = nil m.addavg_ping = nil delete(m.clearedFields, matchplayer.FieldAvgPing) } // SetMatchesID sets the "matches" edge to the Match entity by id. func (m *MatchPlayerMutation) SetMatchesID(id uint64) { m.matches = &id } // ClearMatches clears the "matches" edge to the Match entity. func (m *MatchPlayerMutation) ClearMatches() { m.clearedmatches = true } // MatchesCleared reports if the "matches" edge to the Match entity was cleared. func (m *MatchPlayerMutation) MatchesCleared() bool { return m.MatchStatsCleared() || m.clearedmatches } // MatchesID returns the "matches" edge ID in the mutation. func (m *MatchPlayerMutation) 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 *MatchPlayerMutation) MatchesIDs() (ids []uint64) { if id := m.matches; id != nil { ids = append(ids, *id) } return } // ResetMatches resets all changes to the "matches" edge. func (m *MatchPlayerMutation) ResetMatches() { m.matches = nil m.clearedmatches = false } // SetPlayersID sets the "players" edge to the Player entity by id. func (m *MatchPlayerMutation) SetPlayersID(id uint64) { m.players = &id } // ClearPlayers clears the "players" edge to the Player entity. func (m *MatchPlayerMutation) ClearPlayers() { m.clearedplayers = true } // PlayersCleared reports if the "players" edge to the Player entity was cleared. func (m *MatchPlayerMutation) PlayersCleared() bool { return m.PlayerStatsCleared() || m.clearedplayers } // PlayersID returns the "players" edge ID in the mutation. func (m *MatchPlayerMutation) 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 *MatchPlayerMutation) PlayersIDs() (ids []uint64) { if id := m.players; id != nil { ids = append(ids, *id) } return } // ResetPlayers resets all changes to the "players" edge. func (m *MatchPlayerMutation) ResetPlayers() { m.players = nil m.clearedplayers = false } // AddWeaponStatIDs adds the "weapon_stats" edge to the Weapon entity by ids. func (m *MatchPlayerMutation) AddWeaponStatIDs(ids ...int) { if m.weapon_stats == nil { m.weapon_stats = make(map[int]struct{}) } for i := range ids { m.weapon_stats[ids[i]] = struct{}{} } } // ClearWeaponStats clears the "weapon_stats" edge to the Weapon entity. func (m *MatchPlayerMutation) ClearWeaponStats() { m.clearedweapon_stats = true } // WeaponStatsCleared reports if the "weapon_stats" edge to the Weapon entity was cleared. func (m *MatchPlayerMutation) WeaponStatsCleared() bool { return m.clearedweapon_stats } // RemoveWeaponStatIDs removes the "weapon_stats" edge to the Weapon entity by IDs. func (m *MatchPlayerMutation) RemoveWeaponStatIDs(ids ...int) { if m.removedweapon_stats == nil { m.removedweapon_stats = make(map[int]struct{}) } for i := range ids { delete(m.weapon_stats, ids[i]) m.removedweapon_stats[ids[i]] = struct{}{} } } // RemovedWeaponStats returns the removed IDs of the "weapon_stats" edge to the Weapon entity. func (m *MatchPlayerMutation) RemovedWeaponStatsIDs() (ids []int) { for id := range m.removedweapon_stats { ids = append(ids, id) } return } // WeaponStatsIDs returns the "weapon_stats" edge IDs in the mutation. func (m *MatchPlayerMutation) WeaponStatsIDs() (ids []int) { for id := range m.weapon_stats { ids = append(ids, id) } return } // ResetWeaponStats resets all changes to the "weapon_stats" edge. func (m *MatchPlayerMutation) ResetWeaponStats() { m.weapon_stats = nil m.clearedweapon_stats = false m.removedweapon_stats = nil } // AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by ids. func (m *MatchPlayerMutation) AddRoundStatIDs(ids ...int) { if m.round_stats == nil { m.round_stats = make(map[int]struct{}) } for i := range ids { m.round_stats[ids[i]] = struct{}{} } } // ClearRoundStats clears the "round_stats" edge to the RoundStats entity. func (m *MatchPlayerMutation) ClearRoundStats() { m.clearedround_stats = true } // RoundStatsCleared reports if the "round_stats" edge to the RoundStats entity was cleared. func (m *MatchPlayerMutation) RoundStatsCleared() bool { return m.clearedround_stats } // RemoveRoundStatIDs removes the "round_stats" edge to the RoundStats entity by IDs. func (m *MatchPlayerMutation) RemoveRoundStatIDs(ids ...int) { if m.removedround_stats == nil { m.removedround_stats = make(map[int]struct{}) } for i := range ids { delete(m.round_stats, ids[i]) m.removedround_stats[ids[i]] = struct{}{} } } // RemovedRoundStats returns the removed IDs of the "round_stats" edge to the RoundStats entity. func (m *MatchPlayerMutation) RemovedRoundStatsIDs() (ids []int) { for id := range m.removedround_stats { ids = append(ids, id) } return } // RoundStatsIDs returns the "round_stats" edge IDs in the mutation. func (m *MatchPlayerMutation) RoundStatsIDs() (ids []int) { for id := range m.round_stats { ids = append(ids, id) } return } // ResetRoundStats resets all changes to the "round_stats" edge. func (m *MatchPlayerMutation) ResetRoundStats() { m.round_stats = nil m.clearedround_stats = false m.removedround_stats = nil } // AddSprayIDs adds the "spray" edge to the Spray entity by ids. func (m *MatchPlayerMutation) AddSprayIDs(ids ...int) { if m.spray == nil { m.spray = make(map[int]struct{}) } for i := range ids { m.spray[ids[i]] = struct{}{} } } // ClearSpray clears the "spray" edge to the Spray entity. func (m *MatchPlayerMutation) ClearSpray() { m.clearedspray = true } // SprayCleared reports if the "spray" edge to the Spray entity was cleared. func (m *MatchPlayerMutation) SprayCleared() bool { return m.clearedspray } // RemoveSprayIDs removes the "spray" edge to the Spray entity by IDs. func (m *MatchPlayerMutation) RemoveSprayIDs(ids ...int) { if m.removedspray == nil { m.removedspray = make(map[int]struct{}) } for i := range ids { delete(m.spray, ids[i]) m.removedspray[ids[i]] = struct{}{} } } // RemovedSpray returns the removed IDs of the "spray" edge to the Spray entity. func (m *MatchPlayerMutation) RemovedSprayIDs() (ids []int) { for id := range m.removedspray { ids = append(ids, id) } return } // SprayIDs returns the "spray" edge IDs in the mutation. func (m *MatchPlayerMutation) SprayIDs() (ids []int) { for id := range m.spray { ids = append(ids, id) } return } // ResetSpray resets all changes to the "spray" edge. func (m *MatchPlayerMutation) ResetSpray() { m.spray = nil m.clearedspray = false m.removedspray = nil } // AddMessageIDs adds the "messages" edge to the Messages entity by ids. func (m *MatchPlayerMutation) AddMessageIDs(ids ...int) { if m.messages == nil { m.messages = make(map[int]struct{}) } for i := range ids { m.messages[ids[i]] = struct{}{} } } // ClearMessages clears the "messages" edge to the Messages entity. func (m *MatchPlayerMutation) ClearMessages() { m.clearedmessages = true } // MessagesCleared reports if the "messages" edge to the Messages entity was cleared. func (m *MatchPlayerMutation) MessagesCleared() bool { return m.clearedmessages } // RemoveMessageIDs removes the "messages" edge to the Messages entity by IDs. func (m *MatchPlayerMutation) RemoveMessageIDs(ids ...int) { if m.removedmessages == nil { m.removedmessages = make(map[int]struct{}) } for i := range ids { delete(m.messages, ids[i]) m.removedmessages[ids[i]] = struct{}{} } } // RemovedMessages returns the removed IDs of the "messages" edge to the Messages entity. func (m *MatchPlayerMutation) RemovedMessagesIDs() (ids []int) { for id := range m.removedmessages { ids = append(ids, id) } return } // MessagesIDs returns the "messages" edge IDs in the mutation. func (m *MatchPlayerMutation) MessagesIDs() (ids []int) { for id := range m.messages { ids = append(ids, id) } return } // ResetMessages resets all changes to the "messages" edge. func (m *MatchPlayerMutation) ResetMessages() { m.messages = nil m.clearedmessages = false m.removedmessages = nil } // Where appends a list predicates to the MatchPlayerMutation builder. func (m *MatchPlayerMutation) Where(ps ...predicate.MatchPlayer) { m.predicates = append(m.predicates, ps...) } // WhereP appends storage-level predicates to the MatchPlayerMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. func (m *MatchPlayerMutation) WhereP(ps ...func(*sql.Selector)) { p := make([]predicate.MatchPlayer, len(ps)) for i := range ps { p[i] = ps[i] } m.Where(p...) } // Op returns the operation name. func (m *MatchPlayerMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. func (m *MatchPlayerMutation) SetOp(op Op) { m.op = op } // Type returns the node type of this mutation (MatchPlayer). func (m *MatchPlayerMutation) 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 *MatchPlayerMutation) Fields() []string { fields := make([]string, 0, 33) if m.team_id != nil { fields = append(fields, matchplayer.FieldTeamID) } if m.kills != nil { fields = append(fields, matchplayer.FieldKills) } if m.deaths != nil { fields = append(fields, matchplayer.FieldDeaths) } if m.assists != nil { fields = append(fields, matchplayer.FieldAssists) } if m.headshot != nil { fields = append(fields, matchplayer.FieldHeadshot) } if m.mvp != nil { fields = append(fields, matchplayer.FieldMvp) } if m.score != nil { fields = append(fields, matchplayer.FieldScore) } if m.rank_new != nil { fields = append(fields, matchplayer.FieldRankNew) } if m.rank_old != nil { fields = append(fields, matchplayer.FieldRankOld) } if m.mk_2 != nil { fields = append(fields, matchplayer.FieldMk2) } if m.mk_3 != nil { fields = append(fields, matchplayer.FieldMk3) } if m.mk_4 != nil { fields = append(fields, matchplayer.FieldMk4) } if m.mk_5 != nil { fields = append(fields, matchplayer.FieldMk5) } if m.dmg_enemy != nil { fields = append(fields, matchplayer.FieldDmgEnemy) } if m.dmg_team != nil { fields = append(fields, matchplayer.FieldDmgTeam) } if m.ud_he != nil { fields = append(fields, matchplayer.FieldUdHe) } if m.ud_flames != nil { fields = append(fields, matchplayer.FieldUdFlames) } if m.ud_flash != nil { fields = append(fields, matchplayer.FieldUdFlash) } if m.ud_decoy != nil { fields = append(fields, matchplayer.FieldUdDecoy) } if m.ud_smoke != nil { fields = append(fields, matchplayer.FieldUdSmoke) } if m.crosshair != nil { fields = append(fields, matchplayer.FieldCrosshair) } if m.color != nil { fields = append(fields, matchplayer.FieldColor) } if m.kast != nil { fields = append(fields, matchplayer.FieldKast) } if m.flash_duration_self != nil { fields = append(fields, matchplayer.FieldFlashDurationSelf) } if m.flash_duration_team != nil { fields = append(fields, matchplayer.FieldFlashDurationTeam) } if m.flash_duration_enemy != nil { fields = append(fields, matchplayer.FieldFlashDurationEnemy) } if m.flash_total_self != nil { fields = append(fields, matchplayer.FieldFlashTotalSelf) } if m.flash_total_team != nil { fields = append(fields, matchplayer.FieldFlashTotalTeam) } if m.flash_total_enemy != nil { fields = append(fields, matchplayer.FieldFlashTotalEnemy) } if m.matches != nil { fields = append(fields, matchplayer.FieldMatchStats) } if m.players != nil { fields = append(fields, matchplayer.FieldPlayerStats) } if m.flash_assists != nil { fields = append(fields, matchplayer.FieldFlashAssists) } if m.avg_ping != nil { fields = append(fields, matchplayer.FieldAvgPing) } 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 *MatchPlayerMutation) Field(name string) (ent.Value, bool) { switch name { case matchplayer.FieldTeamID: return m.TeamID() case matchplayer.FieldKills: return m.Kills() case matchplayer.FieldDeaths: return m.Deaths() case matchplayer.FieldAssists: return m.Assists() case matchplayer.FieldHeadshot: return m.Headshot() case matchplayer.FieldMvp: return m.Mvp() case matchplayer.FieldScore: return m.Score() case matchplayer.FieldRankNew: return m.RankNew() case matchplayer.FieldRankOld: return m.RankOld() case matchplayer.FieldMk2: return m.Mk2() case matchplayer.FieldMk3: return m.Mk3() case matchplayer.FieldMk4: return m.Mk4() case matchplayer.FieldMk5: return m.Mk5() case matchplayer.FieldDmgEnemy: return m.DmgEnemy() case matchplayer.FieldDmgTeam: return m.DmgTeam() case matchplayer.FieldUdHe: return m.UdHe() case matchplayer.FieldUdFlames: return m.UdFlames() case matchplayer.FieldUdFlash: return m.UdFlash() case matchplayer.FieldUdDecoy: return m.UdDecoy() case matchplayer.FieldUdSmoke: return m.UdSmoke() case matchplayer.FieldCrosshair: return m.Crosshair() case matchplayer.FieldColor: return m.Color() case matchplayer.FieldKast: return m.Kast() case matchplayer.FieldFlashDurationSelf: return m.FlashDurationSelf() case matchplayer.FieldFlashDurationTeam: return m.FlashDurationTeam() case matchplayer.FieldFlashDurationEnemy: return m.FlashDurationEnemy() case matchplayer.FieldFlashTotalSelf: return m.FlashTotalSelf() case matchplayer.FieldFlashTotalTeam: return m.FlashTotalTeam() case matchplayer.FieldFlashTotalEnemy: return m.FlashTotalEnemy() case matchplayer.FieldMatchStats: return m.MatchStats() case matchplayer.FieldPlayerStats: return m.PlayerStats() case matchplayer.FieldFlashAssists: return m.FlashAssists() case matchplayer.FieldAvgPing: return m.AvgPing() } 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 *MatchPlayerMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { case matchplayer.FieldTeamID: return m.OldTeamID(ctx) case matchplayer.FieldKills: return m.OldKills(ctx) case matchplayer.FieldDeaths: return m.OldDeaths(ctx) case matchplayer.FieldAssists: return m.OldAssists(ctx) case matchplayer.FieldHeadshot: return m.OldHeadshot(ctx) case matchplayer.FieldMvp: return m.OldMvp(ctx) case matchplayer.FieldScore: return m.OldScore(ctx) case matchplayer.FieldRankNew: return m.OldRankNew(ctx) case matchplayer.FieldRankOld: return m.OldRankOld(ctx) case matchplayer.FieldMk2: return m.OldMk2(ctx) case matchplayer.FieldMk3: return m.OldMk3(ctx) case matchplayer.FieldMk4: return m.OldMk4(ctx) case matchplayer.FieldMk5: return m.OldMk5(ctx) case matchplayer.FieldDmgEnemy: return m.OldDmgEnemy(ctx) case matchplayer.FieldDmgTeam: return m.OldDmgTeam(ctx) case matchplayer.FieldUdHe: return m.OldUdHe(ctx) case matchplayer.FieldUdFlames: return m.OldUdFlames(ctx) case matchplayer.FieldUdFlash: return m.OldUdFlash(ctx) case matchplayer.FieldUdDecoy: return m.OldUdDecoy(ctx) case matchplayer.FieldUdSmoke: return m.OldUdSmoke(ctx) case matchplayer.FieldCrosshair: return m.OldCrosshair(ctx) case matchplayer.FieldColor: return m.OldColor(ctx) case matchplayer.FieldKast: return m.OldKast(ctx) case matchplayer.FieldFlashDurationSelf: return m.OldFlashDurationSelf(ctx) case matchplayer.FieldFlashDurationTeam: return m.OldFlashDurationTeam(ctx) case matchplayer.FieldFlashDurationEnemy: return m.OldFlashDurationEnemy(ctx) case matchplayer.FieldFlashTotalSelf: return m.OldFlashTotalSelf(ctx) case matchplayer.FieldFlashTotalTeam: return m.OldFlashTotalTeam(ctx) case matchplayer.FieldFlashTotalEnemy: return m.OldFlashTotalEnemy(ctx) case matchplayer.FieldMatchStats: return m.OldMatchStats(ctx) case matchplayer.FieldPlayerStats: return m.OldPlayerStats(ctx) case matchplayer.FieldFlashAssists: return m.OldFlashAssists(ctx) case matchplayer.FieldAvgPing: return m.OldAvgPing(ctx) } return nil, fmt.Errorf("unknown MatchPlayer 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 *MatchPlayerMutation) SetField(name string, value ent.Value) error { switch name { case matchplayer.FieldTeamID: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetTeamID(v) return nil case matchplayer.FieldKills: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetKills(v) return nil case matchplayer.FieldDeaths: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDeaths(v) return nil case matchplayer.FieldAssists: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetAssists(v) return nil case matchplayer.FieldHeadshot: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetHeadshot(v) return nil case matchplayer.FieldMvp: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetMvp(v) return nil case matchplayer.FieldScore: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetScore(v) return nil case matchplayer.FieldRankNew: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetRankNew(v) return nil case matchplayer.FieldRankOld: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetRankOld(v) return nil case matchplayer.FieldMk2: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetMk2(v) return nil case matchplayer.FieldMk3: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetMk3(v) return nil case matchplayer.FieldMk4: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetMk4(v) return nil case matchplayer.FieldMk5: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetMk5(v) return nil case matchplayer.FieldDmgEnemy: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDmgEnemy(v) return nil case matchplayer.FieldDmgTeam: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDmgTeam(v) return nil case matchplayer.FieldUdHe: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUdHe(v) return nil case matchplayer.FieldUdFlames: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUdFlames(v) return nil case matchplayer.FieldUdFlash: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUdFlash(v) return nil case matchplayer.FieldUdDecoy: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUdDecoy(v) return nil case matchplayer.FieldUdSmoke: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUdSmoke(v) return nil case matchplayer.FieldCrosshair: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCrosshair(v) return nil case matchplayer.FieldColor: v, ok := value.(matchplayer.Color) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetColor(v) return nil case matchplayer.FieldKast: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetKast(v) return nil case matchplayer.FieldFlashDurationSelf: v, ok := value.(float32) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetFlashDurationSelf(v) return nil case matchplayer.FieldFlashDurationTeam: v, ok := value.(float32) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetFlashDurationTeam(v) return nil case matchplayer.FieldFlashDurationEnemy: v, ok := value.(float32) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetFlashDurationEnemy(v) return nil case matchplayer.FieldFlashTotalSelf: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetFlashTotalSelf(v) return nil case matchplayer.FieldFlashTotalTeam: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetFlashTotalTeam(v) return nil case matchplayer.FieldFlashTotalEnemy: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetFlashTotalEnemy(v) return nil case matchplayer.FieldMatchStats: v, ok := value.(uint64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetMatchStats(v) return nil case matchplayer.FieldPlayerStats: v, ok := value.(uint64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetPlayerStats(v) return nil case matchplayer.FieldFlashAssists: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetFlashAssists(v) return nil case matchplayer.FieldAvgPing: v, ok := value.(float64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetAvgPing(v) return nil } return fmt.Errorf("unknown MatchPlayer field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. func (m *MatchPlayerMutation) AddedFields() []string { var fields []string if m.addteam_id != nil { fields = append(fields, matchplayer.FieldTeamID) } if m.addkills != nil { fields = append(fields, matchplayer.FieldKills) } if m.adddeaths != nil { fields = append(fields, matchplayer.FieldDeaths) } if m.addassists != nil { fields = append(fields, matchplayer.FieldAssists) } if m.addheadshot != nil { fields = append(fields, matchplayer.FieldHeadshot) } if m.addmvp != nil { fields = append(fields, matchplayer.FieldMvp) } if m.addscore != nil { fields = append(fields, matchplayer.FieldScore) } if m.addrank_new != nil { fields = append(fields, matchplayer.FieldRankNew) } if m.addrank_old != nil { fields = append(fields, matchplayer.FieldRankOld) } if m.addmk_2 != nil { fields = append(fields, matchplayer.FieldMk2) } if m.addmk_3 != nil { fields = append(fields, matchplayer.FieldMk3) } if m.addmk_4 != nil { fields = append(fields, matchplayer.FieldMk4) } if m.addmk_5 != nil { fields = append(fields, matchplayer.FieldMk5) } if m.adddmg_enemy != nil { fields = append(fields, matchplayer.FieldDmgEnemy) } if m.adddmg_team != nil { fields = append(fields, matchplayer.FieldDmgTeam) } if m.addud_he != nil { fields = append(fields, matchplayer.FieldUdHe) } if m.addud_flames != nil { fields = append(fields, matchplayer.FieldUdFlames) } if m.addud_flash != nil { fields = append(fields, matchplayer.FieldUdFlash) } if m.addud_decoy != nil { fields = append(fields, matchplayer.FieldUdDecoy) } if m.addud_smoke != nil { fields = append(fields, matchplayer.FieldUdSmoke) } if m.addkast != nil { fields = append(fields, matchplayer.FieldKast) } if m.addflash_duration_self != nil { fields = append(fields, matchplayer.FieldFlashDurationSelf) } if m.addflash_duration_team != nil { fields = append(fields, matchplayer.FieldFlashDurationTeam) } if m.addflash_duration_enemy != nil { fields = append(fields, matchplayer.FieldFlashDurationEnemy) } if m.addflash_total_self != nil { fields = append(fields, matchplayer.FieldFlashTotalSelf) } if m.addflash_total_team != nil { fields = append(fields, matchplayer.FieldFlashTotalTeam) } if m.addflash_total_enemy != nil { fields = append(fields, matchplayer.FieldFlashTotalEnemy) } if m.addflash_assists != nil { fields = append(fields, matchplayer.FieldFlashAssists) } if m.addavg_ping != nil { fields = append(fields, matchplayer.FieldAvgPing) } 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 *MatchPlayerMutation) AddedField(name string) (ent.Value, bool) { switch name { case matchplayer.FieldTeamID: return m.AddedTeamID() case matchplayer.FieldKills: return m.AddedKills() case matchplayer.FieldDeaths: return m.AddedDeaths() case matchplayer.FieldAssists: return m.AddedAssists() case matchplayer.FieldHeadshot: return m.AddedHeadshot() case matchplayer.FieldMvp: return m.AddedMvp() case matchplayer.FieldScore: return m.AddedScore() case matchplayer.FieldRankNew: return m.AddedRankNew() case matchplayer.FieldRankOld: return m.AddedRankOld() case matchplayer.FieldMk2: return m.AddedMk2() case matchplayer.FieldMk3: return m.AddedMk3() case matchplayer.FieldMk4: return m.AddedMk4() case matchplayer.FieldMk5: return m.AddedMk5() case matchplayer.FieldDmgEnemy: return m.AddedDmgEnemy() case matchplayer.FieldDmgTeam: return m.AddedDmgTeam() case matchplayer.FieldUdHe: return m.AddedUdHe() case matchplayer.FieldUdFlames: return m.AddedUdFlames() case matchplayer.FieldUdFlash: return m.AddedUdFlash() case matchplayer.FieldUdDecoy: return m.AddedUdDecoy() case matchplayer.FieldUdSmoke: return m.AddedUdSmoke() case matchplayer.FieldKast: return m.AddedKast() case matchplayer.FieldFlashDurationSelf: return m.AddedFlashDurationSelf() case matchplayer.FieldFlashDurationTeam: return m.AddedFlashDurationTeam() case matchplayer.FieldFlashDurationEnemy: return m.AddedFlashDurationEnemy() case matchplayer.FieldFlashTotalSelf: return m.AddedFlashTotalSelf() case matchplayer.FieldFlashTotalTeam: return m.AddedFlashTotalTeam() case matchplayer.FieldFlashTotalEnemy: return m.AddedFlashTotalEnemy() case matchplayer.FieldFlashAssists: return m.AddedFlashAssists() case matchplayer.FieldAvgPing: return m.AddedAvgPing() } 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 *MatchPlayerMutation) AddField(name string, value ent.Value) error { switch name { case matchplayer.FieldTeamID: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddTeamID(v) return nil case matchplayer.FieldKills: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddKills(v) return nil case matchplayer.FieldDeaths: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddDeaths(v) return nil case matchplayer.FieldAssists: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddAssists(v) return nil case matchplayer.FieldHeadshot: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddHeadshot(v) return nil case matchplayer.FieldMvp: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddMvp(v) return nil case matchplayer.FieldScore: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddScore(v) return nil case matchplayer.FieldRankNew: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddRankNew(v) return nil case matchplayer.FieldRankOld: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddRankOld(v) return nil case matchplayer.FieldMk2: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddMk2(v) return nil case matchplayer.FieldMk3: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddMk3(v) return nil case matchplayer.FieldMk4: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddMk4(v) return nil case matchplayer.FieldMk5: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddMk5(v) return nil case matchplayer.FieldDmgEnemy: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddDmgEnemy(v) return nil case matchplayer.FieldDmgTeam: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddDmgTeam(v) return nil case matchplayer.FieldUdHe: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddUdHe(v) return nil case matchplayer.FieldUdFlames: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddUdFlames(v) return nil case matchplayer.FieldUdFlash: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddUdFlash(v) return nil case matchplayer.FieldUdDecoy: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddUdDecoy(v) return nil case matchplayer.FieldUdSmoke: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddUdSmoke(v) return nil case matchplayer.FieldKast: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddKast(v) return nil case matchplayer.FieldFlashDurationSelf: v, ok := value.(float32) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddFlashDurationSelf(v) return nil case matchplayer.FieldFlashDurationTeam: v, ok := value.(float32) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddFlashDurationTeam(v) return nil case matchplayer.FieldFlashDurationEnemy: v, ok := value.(float32) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddFlashDurationEnemy(v) return nil case matchplayer.FieldFlashTotalSelf: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddFlashTotalSelf(v) return nil case matchplayer.FieldFlashTotalTeam: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddFlashTotalTeam(v) return nil case matchplayer.FieldFlashTotalEnemy: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddFlashTotalEnemy(v) return nil case matchplayer.FieldFlashAssists: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddFlashAssists(v) return nil case matchplayer.FieldAvgPing: v, ok := value.(float64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddAvgPing(v) return nil } return fmt.Errorf("unknown MatchPlayer numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. func (m *MatchPlayerMutation) ClearedFields() []string { var fields []string if m.FieldCleared(matchplayer.FieldRankNew) { fields = append(fields, matchplayer.FieldRankNew) } if m.FieldCleared(matchplayer.FieldRankOld) { fields = append(fields, matchplayer.FieldRankOld) } if m.FieldCleared(matchplayer.FieldMk2) { fields = append(fields, matchplayer.FieldMk2) } if m.FieldCleared(matchplayer.FieldMk3) { fields = append(fields, matchplayer.FieldMk3) } if m.FieldCleared(matchplayer.FieldMk4) { fields = append(fields, matchplayer.FieldMk4) } if m.FieldCleared(matchplayer.FieldMk5) { fields = append(fields, matchplayer.FieldMk5) } if m.FieldCleared(matchplayer.FieldDmgEnemy) { fields = append(fields, matchplayer.FieldDmgEnemy) } if m.FieldCleared(matchplayer.FieldDmgTeam) { fields = append(fields, matchplayer.FieldDmgTeam) } if m.FieldCleared(matchplayer.FieldUdHe) { fields = append(fields, matchplayer.FieldUdHe) } if m.FieldCleared(matchplayer.FieldUdFlames) { fields = append(fields, matchplayer.FieldUdFlames) } if m.FieldCleared(matchplayer.FieldUdFlash) { fields = append(fields, matchplayer.FieldUdFlash) } if m.FieldCleared(matchplayer.FieldUdDecoy) { fields = append(fields, matchplayer.FieldUdDecoy) } if m.FieldCleared(matchplayer.FieldUdSmoke) { fields = append(fields, matchplayer.FieldUdSmoke) } if m.FieldCleared(matchplayer.FieldCrosshair) { fields = append(fields, matchplayer.FieldCrosshair) } if m.FieldCleared(matchplayer.FieldColor) { fields = append(fields, matchplayer.FieldColor) } if m.FieldCleared(matchplayer.FieldKast) { fields = append(fields, matchplayer.FieldKast) } if m.FieldCleared(matchplayer.FieldFlashDurationSelf) { fields = append(fields, matchplayer.FieldFlashDurationSelf) } if m.FieldCleared(matchplayer.FieldFlashDurationTeam) { fields = append(fields, matchplayer.FieldFlashDurationTeam) } if m.FieldCleared(matchplayer.FieldFlashDurationEnemy) { fields = append(fields, matchplayer.FieldFlashDurationEnemy) } if m.FieldCleared(matchplayer.FieldFlashTotalSelf) { fields = append(fields, matchplayer.FieldFlashTotalSelf) } if m.FieldCleared(matchplayer.FieldFlashTotalTeam) { fields = append(fields, matchplayer.FieldFlashTotalTeam) } if m.FieldCleared(matchplayer.FieldFlashTotalEnemy) { fields = append(fields, matchplayer.FieldFlashTotalEnemy) } if m.FieldCleared(matchplayer.FieldMatchStats) { fields = append(fields, matchplayer.FieldMatchStats) } if m.FieldCleared(matchplayer.FieldPlayerStats) { fields = append(fields, matchplayer.FieldPlayerStats) } if m.FieldCleared(matchplayer.FieldFlashAssists) { fields = append(fields, matchplayer.FieldFlashAssists) } if m.FieldCleared(matchplayer.FieldAvgPing) { fields = append(fields, matchplayer.FieldAvgPing) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. func (m *MatchPlayerMutation) 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 *MatchPlayerMutation) ClearField(name string) error { switch name { case matchplayer.FieldRankNew: m.ClearRankNew() return nil case matchplayer.FieldRankOld: m.ClearRankOld() return nil case matchplayer.FieldMk2: m.ClearMk2() return nil case matchplayer.FieldMk3: m.ClearMk3() return nil case matchplayer.FieldMk4: m.ClearMk4() return nil case matchplayer.FieldMk5: m.ClearMk5() return nil case matchplayer.FieldDmgEnemy: m.ClearDmgEnemy() return nil case matchplayer.FieldDmgTeam: m.ClearDmgTeam() return nil case matchplayer.FieldUdHe: m.ClearUdHe() return nil case matchplayer.FieldUdFlames: m.ClearUdFlames() return nil case matchplayer.FieldUdFlash: m.ClearUdFlash() return nil case matchplayer.FieldUdDecoy: m.ClearUdDecoy() return nil case matchplayer.FieldUdSmoke: m.ClearUdSmoke() return nil case matchplayer.FieldCrosshair: m.ClearCrosshair() return nil case matchplayer.FieldColor: m.ClearColor() return nil case matchplayer.FieldKast: m.ClearKast() return nil case matchplayer.FieldFlashDurationSelf: m.ClearFlashDurationSelf() return nil case matchplayer.FieldFlashDurationTeam: m.ClearFlashDurationTeam() return nil case matchplayer.FieldFlashDurationEnemy: m.ClearFlashDurationEnemy() return nil case matchplayer.FieldFlashTotalSelf: m.ClearFlashTotalSelf() return nil case matchplayer.FieldFlashTotalTeam: m.ClearFlashTotalTeam() return nil case matchplayer.FieldFlashTotalEnemy: m.ClearFlashTotalEnemy() return nil case matchplayer.FieldMatchStats: m.ClearMatchStats() return nil case matchplayer.FieldPlayerStats: m.ClearPlayerStats() return nil case matchplayer.FieldFlashAssists: m.ClearFlashAssists() return nil case matchplayer.FieldAvgPing: m.ClearAvgPing() return nil } return fmt.Errorf("unknown MatchPlayer 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 *MatchPlayerMutation) ResetField(name string) error { switch name { case matchplayer.FieldTeamID: m.ResetTeamID() return nil case matchplayer.FieldKills: m.ResetKills() return nil case matchplayer.FieldDeaths: m.ResetDeaths() return nil case matchplayer.FieldAssists: m.ResetAssists() return nil case matchplayer.FieldHeadshot: m.ResetHeadshot() return nil case matchplayer.FieldMvp: m.ResetMvp() return nil case matchplayer.FieldScore: m.ResetScore() return nil case matchplayer.FieldRankNew: m.ResetRankNew() return nil case matchplayer.FieldRankOld: m.ResetRankOld() return nil case matchplayer.FieldMk2: m.ResetMk2() return nil case matchplayer.FieldMk3: m.ResetMk3() return nil case matchplayer.FieldMk4: m.ResetMk4() return nil case matchplayer.FieldMk5: m.ResetMk5() return nil case matchplayer.FieldDmgEnemy: m.ResetDmgEnemy() return nil case matchplayer.FieldDmgTeam: m.ResetDmgTeam() return nil case matchplayer.FieldUdHe: m.ResetUdHe() return nil case matchplayer.FieldUdFlames: m.ResetUdFlames() return nil case matchplayer.FieldUdFlash: m.ResetUdFlash() return nil case matchplayer.FieldUdDecoy: m.ResetUdDecoy() return nil case matchplayer.FieldUdSmoke: m.ResetUdSmoke() return nil case matchplayer.FieldCrosshair: m.ResetCrosshair() return nil case matchplayer.FieldColor: m.ResetColor() return nil case matchplayer.FieldKast: m.ResetKast() return nil case matchplayer.FieldFlashDurationSelf: m.ResetFlashDurationSelf() return nil case matchplayer.FieldFlashDurationTeam: m.ResetFlashDurationTeam() return nil case matchplayer.FieldFlashDurationEnemy: m.ResetFlashDurationEnemy() return nil case matchplayer.FieldFlashTotalSelf: m.ResetFlashTotalSelf() return nil case matchplayer.FieldFlashTotalTeam: m.ResetFlashTotalTeam() return nil case matchplayer.FieldFlashTotalEnemy: m.ResetFlashTotalEnemy() return nil case matchplayer.FieldMatchStats: m.ResetMatchStats() return nil case matchplayer.FieldPlayerStats: m.ResetPlayerStats() return nil case matchplayer.FieldFlashAssists: m.ResetFlashAssists() return nil case matchplayer.FieldAvgPing: m.ResetAvgPing() return nil } return fmt.Errorf("unknown MatchPlayer field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. func (m *MatchPlayerMutation) AddedEdges() []string { edges := make([]string, 0, 6) if m.matches != nil { edges = append(edges, matchplayer.EdgeMatches) } if m.players != nil { edges = append(edges, matchplayer.EdgePlayers) } if m.weapon_stats != nil { edges = append(edges, matchplayer.EdgeWeaponStats) } if m.round_stats != nil { edges = append(edges, matchplayer.EdgeRoundStats) } if m.spray != nil { edges = append(edges, matchplayer.EdgeSpray) } if m.messages != nil { edges = append(edges, matchplayer.EdgeMessages) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. func (m *MatchPlayerMutation) AddedIDs(name string) []ent.Value { switch name { case matchplayer.EdgeMatches: if id := m.matches; id != nil { return []ent.Value{*id} } case matchplayer.EdgePlayers: if id := m.players; id != nil { return []ent.Value{*id} } case matchplayer.EdgeWeaponStats: ids := make([]ent.Value, 0, len(m.weapon_stats)) for id := range m.weapon_stats { ids = append(ids, id) } return ids case matchplayer.EdgeRoundStats: ids := make([]ent.Value, 0, len(m.round_stats)) for id := range m.round_stats { ids = append(ids, id) } return ids case matchplayer.EdgeSpray: ids := make([]ent.Value, 0, len(m.spray)) for id := range m.spray { ids = append(ids, id) } return ids case matchplayer.EdgeMessages: ids := make([]ent.Value, 0, len(m.messages)) for id := range m.messages { ids = append(ids, id) } return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *MatchPlayerMutation) RemovedEdges() []string { edges := make([]string, 0, 6) if m.removedweapon_stats != nil { edges = append(edges, matchplayer.EdgeWeaponStats) } if m.removedround_stats != nil { edges = append(edges, matchplayer.EdgeRoundStats) } if m.removedspray != nil { edges = append(edges, matchplayer.EdgeSpray) } if m.removedmessages != nil { edges = append(edges, matchplayer.EdgeMessages) } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. func (m *MatchPlayerMutation) RemovedIDs(name string) []ent.Value { switch name { case matchplayer.EdgeWeaponStats: ids := make([]ent.Value, 0, len(m.removedweapon_stats)) for id := range m.removedweapon_stats { ids = append(ids, id) } return ids case matchplayer.EdgeRoundStats: ids := make([]ent.Value, 0, len(m.removedround_stats)) for id := range m.removedround_stats { ids = append(ids, id) } return ids case matchplayer.EdgeSpray: ids := make([]ent.Value, 0, len(m.removedspray)) for id := range m.removedspray { ids = append(ids, id) } return ids case matchplayer.EdgeMessages: ids := make([]ent.Value, 0, len(m.removedmessages)) for id := range m.removedmessages { ids = append(ids, id) } return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *MatchPlayerMutation) ClearedEdges() []string { edges := make([]string, 0, 6) if m.clearedmatches { edges = append(edges, matchplayer.EdgeMatches) } if m.clearedplayers { edges = append(edges, matchplayer.EdgePlayers) } if m.clearedweapon_stats { edges = append(edges, matchplayer.EdgeWeaponStats) } if m.clearedround_stats { edges = append(edges, matchplayer.EdgeRoundStats) } if m.clearedspray { edges = append(edges, matchplayer.EdgeSpray) } if m.clearedmessages { edges = append(edges, matchplayer.EdgeMessages) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. func (m *MatchPlayerMutation) EdgeCleared(name string) bool { switch name { case matchplayer.EdgeMatches: return m.clearedmatches case matchplayer.EdgePlayers: return m.clearedplayers case matchplayer.EdgeWeaponStats: return m.clearedweapon_stats case matchplayer.EdgeRoundStats: return m.clearedround_stats case matchplayer.EdgeSpray: return m.clearedspray case matchplayer.EdgeMessages: return m.clearedmessages } 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 *MatchPlayerMutation) ClearEdge(name string) error { switch name { case matchplayer.EdgeMatches: m.ClearMatches() return nil case matchplayer.EdgePlayers: m.ClearPlayers() return nil } return fmt.Errorf("unknown MatchPlayer 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 *MatchPlayerMutation) ResetEdge(name string) error { switch name { case matchplayer.EdgeMatches: m.ResetMatches() return nil case matchplayer.EdgePlayers: m.ResetPlayers() return nil case matchplayer.EdgeWeaponStats: m.ResetWeaponStats() return nil case matchplayer.EdgeRoundStats: m.ResetRoundStats() return nil case matchplayer.EdgeSpray: m.ResetSpray() return nil case matchplayer.EdgeMessages: m.ResetMessages() return nil } return fmt.Errorf("unknown MatchPlayer edge %s", name) } // MessagesMutation represents an operation that mutates the Messages nodes in the graph. type MessagesMutation struct { config op Op typ string id *int message *string all_chat *bool tick *int addtick *int clearedFields map[string]struct{} match_player *int clearedmatch_player bool done bool oldValue func(context.Context) (*Messages, error) predicates []predicate.Messages } var _ ent.Mutation = (*MessagesMutation)(nil) // messagesOption allows management of the mutation configuration using functional options. type messagesOption func(*MessagesMutation) // newMessagesMutation creates new mutation for the Messages entity. func newMessagesMutation(c config, op Op, opts ...messagesOption) *MessagesMutation { m := &MessagesMutation{ config: c, op: op, typ: TypeMessages, clearedFields: make(map[string]struct{}), } for _, opt := range opts { opt(m) } return m } // withMessagesID sets the ID field of the mutation. func withMessagesID(id int) messagesOption { return func(m *MessagesMutation) { var ( err error once sync.Once value *Messages ) m.oldValue = func(ctx context.Context) (*Messages, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { value, err = m.Client().Messages.Get(ctx, id) } }) return value, err } m.id = &id } } // withMessages sets the old Messages of the mutation. func withMessages(node *Messages) messagesOption { return func(m *MessagesMutation) { m.oldValue = func(context.Context) (*Messages, 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 MessagesMutation) 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 MessagesMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("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 *MessagesMutation) ID() (id int, exists bool) { if m.id == nil { return } return *m.id, true } // IDs queries the database and returns the entity ids that match the mutation's predicate. // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. func (m *MessagesMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { return []int{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): return m.Client().Messages.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // SetMessage sets the "message" field. func (m *MessagesMutation) SetMessage(s string) { m.message = &s } // Message returns the value of the "message" field in the mutation. func (m *MessagesMutation) Message() (r string, exists bool) { v := m.message if v == nil { return } return *v, true } // OldMessage returns the old "message" field's value of the Messages entity. // If the Messages 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 *MessagesMutation) OldMessage(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldMessage is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldMessage requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldMessage: %w", err) } return oldValue.Message, nil } // ResetMessage resets all changes to the "message" field. func (m *MessagesMutation) ResetMessage() { m.message = nil } // SetAllChat sets the "all_chat" field. func (m *MessagesMutation) SetAllChat(b bool) { m.all_chat = &b } // AllChat returns the value of the "all_chat" field in the mutation. func (m *MessagesMutation) AllChat() (r bool, exists bool) { v := m.all_chat if v == nil { return } return *v, true } // OldAllChat returns the old "all_chat" field's value of the Messages entity. // If the Messages 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 *MessagesMutation) OldAllChat(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldAllChat is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldAllChat requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldAllChat: %w", err) } return oldValue.AllChat, nil } // ResetAllChat resets all changes to the "all_chat" field. func (m *MessagesMutation) ResetAllChat() { m.all_chat = nil } // SetTick sets the "tick" field. func (m *MessagesMutation) SetTick(i int) { m.tick = &i m.addtick = nil } // Tick returns the value of the "tick" field in the mutation. func (m *MessagesMutation) Tick() (r int, exists bool) { v := m.tick if v == nil { return } return *v, true } // OldTick returns the old "tick" field's value of the Messages entity. // If the Messages 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 *MessagesMutation) OldTick(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldTick is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldTick requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldTick: %w", err) } return oldValue.Tick, nil } // AddTick adds i to the "tick" field. func (m *MessagesMutation) AddTick(i int) { if m.addtick != nil { *m.addtick += i } else { m.addtick = &i } } // AddedTick returns the value that was added to the "tick" field in this mutation. func (m *MessagesMutation) AddedTick() (r int, exists bool) { v := m.addtick if v == nil { return } return *v, true } // ResetTick resets all changes to the "tick" field. func (m *MessagesMutation) ResetTick() { m.tick = nil m.addtick = nil } // SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by id. func (m *MessagesMutation) SetMatchPlayerID(id int) { m.match_player = &id } // ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity. func (m *MessagesMutation) ClearMatchPlayer() { m.clearedmatch_player = true } // MatchPlayerCleared reports if the "match_player" edge to the MatchPlayer entity was cleared. func (m *MessagesMutation) MatchPlayerCleared() bool { return m.clearedmatch_player } // MatchPlayerID returns the "match_player" edge ID in the mutation. func (m *MessagesMutation) MatchPlayerID() (id int, exists bool) { if m.match_player != nil { return *m.match_player, true } return } // MatchPlayerIDs returns the "match_player" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // MatchPlayerID instead. It exists only for internal usage by the builders. func (m *MessagesMutation) MatchPlayerIDs() (ids []int) { if id := m.match_player; id != nil { ids = append(ids, *id) } return } // ResetMatchPlayer resets all changes to the "match_player" edge. func (m *MessagesMutation) ResetMatchPlayer() { m.match_player = nil m.clearedmatch_player = false } // Where appends a list predicates to the MessagesMutation builder. func (m *MessagesMutation) Where(ps ...predicate.Messages) { m.predicates = append(m.predicates, ps...) } // WhereP appends storage-level predicates to the MessagesMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. func (m *MessagesMutation) WhereP(ps ...func(*sql.Selector)) { p := make([]predicate.Messages, len(ps)) for i := range ps { p[i] = ps[i] } m.Where(p...) } // Op returns the operation name. func (m *MessagesMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. func (m *MessagesMutation) SetOp(op Op) { m.op = op } // Type returns the node type of this mutation (Messages). func (m *MessagesMutation) 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 *MessagesMutation) Fields() []string { fields := make([]string, 0, 3) if m.message != nil { fields = append(fields, messages.FieldMessage) } if m.all_chat != nil { fields = append(fields, messages.FieldAllChat) } if m.tick != nil { fields = append(fields, messages.FieldTick) } 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 *MessagesMutation) Field(name string) (ent.Value, bool) { switch name { case messages.FieldMessage: return m.Message() case messages.FieldAllChat: return m.AllChat() case messages.FieldTick: return m.Tick() } 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 *MessagesMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { case messages.FieldMessage: return m.OldMessage(ctx) case messages.FieldAllChat: return m.OldAllChat(ctx) case messages.FieldTick: return m.OldTick(ctx) } return nil, fmt.Errorf("unknown Messages 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 *MessagesMutation) SetField(name string, value ent.Value) error { switch name { case messages.FieldMessage: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetMessage(v) return nil case messages.FieldAllChat: v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetAllChat(v) return nil case messages.FieldTick: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetTick(v) return nil } return fmt.Errorf("unknown Messages field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. func (m *MessagesMutation) AddedFields() []string { var fields []string if m.addtick != nil { fields = append(fields, messages.FieldTick) } 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 *MessagesMutation) AddedField(name string) (ent.Value, bool) { switch name { case messages.FieldTick: return m.AddedTick() } 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 *MessagesMutation) AddField(name string, value ent.Value) error { switch name { case messages.FieldTick: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddTick(v) return nil } return fmt.Errorf("unknown Messages numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. func (m *MessagesMutation) ClearedFields() []string { return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. func (m *MessagesMutation) 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 *MessagesMutation) ClearField(name string) error { return fmt.Errorf("unknown Messages 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 *MessagesMutation) ResetField(name string) error { switch name { case messages.FieldMessage: m.ResetMessage() return nil case messages.FieldAllChat: m.ResetAllChat() return nil case messages.FieldTick: m.ResetTick() return nil } return fmt.Errorf("unknown Messages field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. func (m *MessagesMutation) AddedEdges() []string { edges := make([]string, 0, 1) if m.match_player != nil { edges = append(edges, messages.EdgeMatchPlayer) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. func (m *MessagesMutation) AddedIDs(name string) []ent.Value { switch name { case messages.EdgeMatchPlayer: if id := m.match_player; id != nil { return []ent.Value{*id} } } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *MessagesMutation) RemovedEdges() []string { edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. func (m *MessagesMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *MessagesMutation) ClearedEdges() []string { edges := make([]string, 0, 1) if m.clearedmatch_player { edges = append(edges, messages.EdgeMatchPlayer) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. func (m *MessagesMutation) EdgeCleared(name string) bool { switch name { case messages.EdgeMatchPlayer: return m.clearedmatch_player } 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 *MessagesMutation) ClearEdge(name string) error { switch name { case messages.EdgeMatchPlayer: m.ClearMatchPlayer() return nil } return fmt.Errorf("unknown Messages 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 *MessagesMutation) ResetEdge(name string) error { switch name { case messages.EdgeMatchPlayer: m.ResetMatchPlayer() return nil } return fmt.Errorf("unknown Messages edge %s", name) } // PlayerMutation represents an operation that mutates the Player nodes in the graph. type PlayerMutation struct { config op Op typ string id *uint64 name *string avatar *string vanity_url *string vanity_url_real *string vac_date *time.Time vac_count *int addvac_count *int game_ban_date *time.Time game_ban_count *int addgame_ban_count *int steam_updated *time.Time sharecode_updated *time.Time auth_code *string profile_created *time.Time oldest_sharecode_seen *string wins *int addwins *int looses *int addlooses *int ties *int addties *int 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 = errors.New("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, errors.New("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 } // IDs queries the database and returns the entity ids that match the mutation's predicate. // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. func (m *PlayerMutation) IDs(ctx context.Context) ([]uint64, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { return []uint64{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): return m.Client().Player.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // 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, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldName: %w", err) } return oldValue.Name, nil } // ClearName clears the value of the "name" field. func (m *PlayerMutation) ClearName() { m.name = nil m.clearedFields[player.FieldName] = struct{}{} } // NameCleared returns if the "name" field was cleared in this mutation. func (m *PlayerMutation) NameCleared() bool { _, ok := m.clearedFields[player.FieldName] return ok } // ResetName resets all changes to the "name" field. func (m *PlayerMutation) ResetName() { m.name = nil delete(m.clearedFields, player.FieldName) } // SetAvatar sets the "avatar" field. func (m *PlayerMutation) SetAvatar(s string) { m.avatar = &s } // Avatar returns the value of the "avatar" field in the mutation. func (m *PlayerMutation) Avatar() (r string, exists bool) { v := m.avatar if v == nil { return } return *v, true } // OldAvatar returns the old "avatar" field's value of the Player entity. // If the Player object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *PlayerMutation) OldAvatar(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldAvatar is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldAvatar requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldAvatar: %w", err) } return oldValue.Avatar, nil } // ClearAvatar clears the value of the "avatar" field. func (m *PlayerMutation) ClearAvatar() { m.avatar = nil m.clearedFields[player.FieldAvatar] = struct{}{} } // AvatarCleared returns if the "avatar" field was cleared in this mutation. func (m *PlayerMutation) AvatarCleared() bool { _, ok := m.clearedFields[player.FieldAvatar] return ok } // ResetAvatar resets all changes to the "avatar" field. func (m *PlayerMutation) ResetAvatar() { m.avatar = nil delete(m.clearedFields, player.FieldAvatar) } // SetVanityURL sets the "vanity_url" field. func (m *PlayerMutation) SetVanityURL(s string) { m.vanity_url = &s } // VanityURL returns the value of the "vanity_url" field in the mutation. func (m *PlayerMutation) VanityURL() (r string, exists bool) { v := m.vanity_url if v == nil { return } return *v, true } // OldVanityURL returns the old "vanity_url" field's value of the Player entity. // If the Player object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *PlayerMutation) OldVanityURL(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldVanityURL is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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, errors.New("OldVanityURLReal is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldVanityURLReal requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldVanityURLReal: %w", err) } return oldValue.VanityURLReal, nil } // ClearVanityURLReal clears the value of the "vanity_url_real" field. func (m *PlayerMutation) ClearVanityURLReal() { m.vanity_url_real = nil m.clearedFields[player.FieldVanityURLReal] = struct{}{} } // VanityURLRealCleared returns if the "vanity_url_real" field was cleared in this mutation. func (m *PlayerMutation) VanityURLRealCleared() bool { _, ok := m.clearedFields[player.FieldVanityURLReal] return ok } // ResetVanityURLReal resets all changes to the "vanity_url_real" field. func (m *PlayerMutation) ResetVanityURLReal() { m.vanity_url_real = nil delete(m.clearedFields, player.FieldVanityURLReal) } // SetVacDate sets the "vac_date" field. func (m *PlayerMutation) SetVacDate(t time.Time) { m.vac_date = &t } // VacDate returns the value of the "vac_date" field in the mutation. func (m *PlayerMutation) VacDate() (r time.Time, exists bool) { v := m.vac_date if v == nil { return } return *v, true } // OldVacDate returns the old "vac_date" field's value of the Player entity. // If the Player object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *PlayerMutation) OldVacDate(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldVacDate is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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, errors.New("OldVacCount is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldVacCount requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldVacCount: %w", err) } return oldValue.VacCount, nil } // AddVacCount adds i to the "vac_count" field. func (m *PlayerMutation) AddVacCount(i int) { if m.addvac_count != nil { *m.addvac_count += i } else { m.addvac_count = &i } } // AddedVacCount returns the value that was added to the "vac_count" field in this mutation. func (m *PlayerMutation) AddedVacCount() (r int, exists bool) { v := m.addvac_count if v == nil { return } return *v, true } // ClearVacCount clears the value of the "vac_count" field. func (m *PlayerMutation) ClearVacCount() { m.vac_count = nil m.addvac_count = nil m.clearedFields[player.FieldVacCount] = struct{}{} } // VacCountCleared returns if the "vac_count" field was cleared in this mutation. func (m *PlayerMutation) VacCountCleared() bool { _, ok := m.clearedFields[player.FieldVacCount] return ok } // ResetVacCount resets all changes to the "vac_count" field. func (m *PlayerMutation) ResetVacCount() { m.vac_count = nil m.addvac_count = nil delete(m.clearedFields, player.FieldVacCount) } // SetGameBanDate sets the "game_ban_date" field. func (m *PlayerMutation) SetGameBanDate(t time.Time) { m.game_ban_date = &t } // GameBanDate returns the value of the "game_ban_date" field in the mutation. func (m *PlayerMutation) GameBanDate() (r time.Time, exists bool) { v := m.game_ban_date if v == nil { return } return *v, true } // OldGameBanDate returns the old "game_ban_date" field's value of the Player entity. // If the Player object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *PlayerMutation) OldGameBanDate(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldGameBanDate is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldGameBanDate requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldGameBanDate: %w", err) } return oldValue.GameBanDate, nil } // ClearGameBanDate clears the value of the "game_ban_date" field. func (m *PlayerMutation) ClearGameBanDate() { m.game_ban_date = nil m.clearedFields[player.FieldGameBanDate] = struct{}{} } // GameBanDateCleared returns if the "game_ban_date" field was cleared in this mutation. func (m *PlayerMutation) GameBanDateCleared() bool { _, ok := m.clearedFields[player.FieldGameBanDate] return ok } // ResetGameBanDate resets all changes to the "game_ban_date" field. func (m *PlayerMutation) ResetGameBanDate() { m.game_ban_date = nil delete(m.clearedFields, player.FieldGameBanDate) } // SetGameBanCount sets the "game_ban_count" field. func (m *PlayerMutation) SetGameBanCount(i int) { m.game_ban_count = &i m.addgame_ban_count = nil } // GameBanCount returns the value of the "game_ban_count" field in the mutation. func (m *PlayerMutation) GameBanCount() (r int, exists bool) { v := m.game_ban_count if v == nil { return } return *v, true } // OldGameBanCount returns the old "game_ban_count" field's value of the Player entity. // If the Player object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *PlayerMutation) OldGameBanCount(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldGameBanCount is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldGameBanCount requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldGameBanCount: %w", err) } return oldValue.GameBanCount, nil } // AddGameBanCount adds i to the "game_ban_count" field. func (m *PlayerMutation) AddGameBanCount(i int) { if m.addgame_ban_count != nil { *m.addgame_ban_count += i } else { m.addgame_ban_count = &i } } // AddedGameBanCount returns the value that was added to the "game_ban_count" field in this mutation. func (m *PlayerMutation) AddedGameBanCount() (r int, exists bool) { v := m.addgame_ban_count if v == nil { return } return *v, true } // ClearGameBanCount clears the value of the "game_ban_count" field. func (m *PlayerMutation) ClearGameBanCount() { m.game_ban_count = nil m.addgame_ban_count = nil m.clearedFields[player.FieldGameBanCount] = struct{}{} } // GameBanCountCleared returns if the "game_ban_count" field was cleared in this mutation. func (m *PlayerMutation) GameBanCountCleared() bool { _, ok := m.clearedFields[player.FieldGameBanCount] return ok } // ResetGameBanCount resets all changes to the "game_ban_count" field. func (m *PlayerMutation) ResetGameBanCount() { m.game_ban_count = nil m.addgame_ban_count = nil delete(m.clearedFields, player.FieldGameBanCount) } // SetSteamUpdated sets the "steam_updated" field. func (m *PlayerMutation) SetSteamUpdated(t time.Time) { m.steam_updated = &t } // SteamUpdated returns the value of the "steam_updated" field in the mutation. func (m *PlayerMutation) SteamUpdated() (r time.Time, exists bool) { v := m.steam_updated if v == nil { return } return *v, true } // OldSteamUpdated returns the old "steam_updated" field's value of the Player entity. // If the Player object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *PlayerMutation) OldSteamUpdated(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldSteamUpdated is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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, errors.New("OldSharecodeUpdated is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("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, errors.New("OldAuthCode is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldAuthCode requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldAuthCode: %w", err) } return oldValue.AuthCode, nil } // ClearAuthCode clears the value of the "auth_code" field. func (m *PlayerMutation) ClearAuthCode() { m.auth_code = nil m.clearedFields[player.FieldAuthCode] = struct{}{} } // AuthCodeCleared returns if the "auth_code" field was cleared in this mutation. func (m *PlayerMutation) AuthCodeCleared() bool { _, ok := m.clearedFields[player.FieldAuthCode] return ok } // ResetAuthCode resets all changes to the "auth_code" field. func (m *PlayerMutation) ResetAuthCode() { m.auth_code = nil delete(m.clearedFields, player.FieldAuthCode) } // SetProfileCreated sets the "profile_created" field. func (m *PlayerMutation) SetProfileCreated(t time.Time) { m.profile_created = &t } // ProfileCreated returns the value of the "profile_created" field in the mutation. func (m *PlayerMutation) ProfileCreated() (r time.Time, exists bool) { v := m.profile_created if v == nil { return } return *v, true } // OldProfileCreated returns the old "profile_created" field's value of the Player entity. // If the Player object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *PlayerMutation) OldProfileCreated(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldProfileCreated is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldProfileCreated requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldProfileCreated: %w", err) } return oldValue.ProfileCreated, nil } // ClearProfileCreated clears the value of the "profile_created" field. func (m *PlayerMutation) ClearProfileCreated() { m.profile_created = nil m.clearedFields[player.FieldProfileCreated] = struct{}{} } // ProfileCreatedCleared returns if the "profile_created" field was cleared in this mutation. func (m *PlayerMutation) ProfileCreatedCleared() bool { _, ok := m.clearedFields[player.FieldProfileCreated] return ok } // ResetProfileCreated resets all changes to the "profile_created" field. func (m *PlayerMutation) ResetProfileCreated() { m.profile_created = nil delete(m.clearedFields, player.FieldProfileCreated) } // SetOldestSharecodeSeen sets the "oldest_sharecode_seen" field. func (m *PlayerMutation) SetOldestSharecodeSeen(s string) { m.oldest_sharecode_seen = &s } // OldestSharecodeSeen returns the value of the "oldest_sharecode_seen" field in the mutation. func (m *PlayerMutation) OldestSharecodeSeen() (r string, exists bool) { v := m.oldest_sharecode_seen if v == nil { return } return *v, true } // OldOldestSharecodeSeen returns the old "oldest_sharecode_seen" field's value of the Player entity. // If the Player object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *PlayerMutation) OldOldestSharecodeSeen(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldOldestSharecodeSeen is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldOldestSharecodeSeen requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldOldestSharecodeSeen: %w", err) } return oldValue.OldestSharecodeSeen, nil } // ClearOldestSharecodeSeen clears the value of the "oldest_sharecode_seen" field. func (m *PlayerMutation) ClearOldestSharecodeSeen() { m.oldest_sharecode_seen = nil m.clearedFields[player.FieldOldestSharecodeSeen] = struct{}{} } // OldestSharecodeSeenCleared returns if the "oldest_sharecode_seen" field was cleared in this mutation. func (m *PlayerMutation) OldestSharecodeSeenCleared() bool { _, ok := m.clearedFields[player.FieldOldestSharecodeSeen] return ok } // ResetOldestSharecodeSeen resets all changes to the "oldest_sharecode_seen" field. func (m *PlayerMutation) ResetOldestSharecodeSeen() { m.oldest_sharecode_seen = nil delete(m.clearedFields, player.FieldOldestSharecodeSeen) } // SetWins sets the "wins" field. func (m *PlayerMutation) SetWins(i int) { m.wins = &i m.addwins = nil } // Wins returns the value of the "wins" field in the mutation. func (m *PlayerMutation) Wins() (r int, exists bool) { v := m.wins if v == nil { return } return *v, true } // OldWins returns the old "wins" 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) OldWins(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldWins is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldWins requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldWins: %w", err) } return oldValue.Wins, nil } // AddWins adds i to the "wins" field. func (m *PlayerMutation) AddWins(i int) { if m.addwins != nil { *m.addwins += i } else { m.addwins = &i } } // AddedWins returns the value that was added to the "wins" field in this mutation. func (m *PlayerMutation) AddedWins() (r int, exists bool) { v := m.addwins if v == nil { return } return *v, true } // ClearWins clears the value of the "wins" field. func (m *PlayerMutation) ClearWins() { m.wins = nil m.addwins = nil m.clearedFields[player.FieldWins] = struct{}{} } // WinsCleared returns if the "wins" field was cleared in this mutation. func (m *PlayerMutation) WinsCleared() bool { _, ok := m.clearedFields[player.FieldWins] return ok } // ResetWins resets all changes to the "wins" field. func (m *PlayerMutation) ResetWins() { m.wins = nil m.addwins = nil delete(m.clearedFields, player.FieldWins) } // SetLooses sets the "looses" field. func (m *PlayerMutation) SetLooses(i int) { m.looses = &i m.addlooses = nil } // Looses returns the value of the "looses" field in the mutation. func (m *PlayerMutation) Looses() (r int, exists bool) { v := m.looses if v == nil { return } return *v, true } // OldLooses returns the old "looses" 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) OldLooses(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldLooses is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldLooses requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldLooses: %w", err) } return oldValue.Looses, nil } // AddLooses adds i to the "looses" field. func (m *PlayerMutation) AddLooses(i int) { if m.addlooses != nil { *m.addlooses += i } else { m.addlooses = &i } } // AddedLooses returns the value that was added to the "looses" field in this mutation. func (m *PlayerMutation) AddedLooses() (r int, exists bool) { v := m.addlooses if v == nil { return } return *v, true } // ClearLooses clears the value of the "looses" field. func (m *PlayerMutation) ClearLooses() { m.looses = nil m.addlooses = nil m.clearedFields[player.FieldLooses] = struct{}{} } // LoosesCleared returns if the "looses" field was cleared in this mutation. func (m *PlayerMutation) LoosesCleared() bool { _, ok := m.clearedFields[player.FieldLooses] return ok } // ResetLooses resets all changes to the "looses" field. func (m *PlayerMutation) ResetLooses() { m.looses = nil m.addlooses = nil delete(m.clearedFields, player.FieldLooses) } // SetTies sets the "ties" field. func (m *PlayerMutation) SetTies(i int) { m.ties = &i m.addties = nil } // Ties returns the value of the "ties" field in the mutation. func (m *PlayerMutation) Ties() (r int, exists bool) { v := m.ties if v == nil { return } return *v, true } // OldTies returns the old "ties" 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) OldTies(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldTies is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldTies requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldTies: %w", err) } return oldValue.Ties, nil } // AddTies adds i to the "ties" field. func (m *PlayerMutation) AddTies(i int) { if m.addties != nil { *m.addties += i } else { m.addties = &i } } // AddedTies returns the value that was added to the "ties" field in this mutation. func (m *PlayerMutation) AddedTies() (r int, exists bool) { v := m.addties if v == nil { return } return *v, true } // ClearTies clears the value of the "ties" field. func (m *PlayerMutation) ClearTies() { m.ties = nil m.addties = nil m.clearedFields[player.FieldTies] = struct{}{} } // TiesCleared returns if the "ties" field was cleared in this mutation. func (m *PlayerMutation) TiesCleared() bool { _, ok := m.clearedFields[player.FieldTies] return ok } // ResetTies resets all changes to the "ties" field. func (m *PlayerMutation) ResetTies() { m.ties = nil m.addties = nil delete(m.clearedFields, player.FieldTies) } // AddStatIDs adds the "stats" edge to the MatchPlayer 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 MatchPlayer entity. func (m *PlayerMutation) ClearStats() { m.clearedstats = true } // StatsCleared reports if the "stats" edge to the MatchPlayer entity was cleared. func (m *PlayerMutation) StatsCleared() bool { return m.clearedstats } // RemoveStatIDs removes the "stats" edge to the MatchPlayer 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 MatchPlayer 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...) } // WhereP appends storage-level predicates to the PlayerMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. func (m *PlayerMutation) WhereP(ps ...func(*sql.Selector)) { p := make([]predicate.Player, len(ps)) for i := range ps { p[i] = ps[i] } m.Where(p...) } // Op returns the operation name. func (m *PlayerMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. func (m *PlayerMutation) SetOp(op Op) { m.op = 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, 16) if m.name != nil { fields = append(fields, player.FieldName) } if m.avatar != nil { fields = append(fields, player.FieldAvatar) } if m.vanity_url != nil { fields = append(fields, player.FieldVanityURL) } if m.vanity_url_real != nil { fields = append(fields, player.FieldVanityURLReal) } if m.vac_date != nil { fields = append(fields, player.FieldVacDate) } if m.vac_count != nil { fields = append(fields, player.FieldVacCount) } if m.game_ban_date != nil { fields = append(fields, player.FieldGameBanDate) } if m.game_ban_count != nil { fields = append(fields, player.FieldGameBanCount) } if m.steam_updated != nil { fields = append(fields, player.FieldSteamUpdated) } if m.sharecode_updated != nil { fields = append(fields, player.FieldSharecodeUpdated) } if m.auth_code != nil { fields = append(fields, player.FieldAuthCode) } if m.profile_created != nil { fields = append(fields, player.FieldProfileCreated) } if m.oldest_sharecode_seen != nil { fields = append(fields, player.FieldOldestSharecodeSeen) } if m.wins != nil { fields = append(fields, player.FieldWins) } if m.looses != nil { fields = append(fields, player.FieldLooses) } if m.ties != nil { fields = append(fields, player.FieldTies) } return fields } // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. func (m *PlayerMutation) Field(name string) (ent.Value, bool) { switch name { case player.FieldName: return m.Name() case player.FieldAvatar: return m.Avatar() case player.FieldVanityURL: return m.VanityURL() case player.FieldVanityURLReal: return m.VanityURLReal() case player.FieldVacDate: return m.VacDate() case player.FieldVacCount: return m.VacCount() case player.FieldGameBanDate: return m.GameBanDate() case player.FieldGameBanCount: return m.GameBanCount() case player.FieldSteamUpdated: return m.SteamUpdated() case player.FieldSharecodeUpdated: return m.SharecodeUpdated() case player.FieldAuthCode: return m.AuthCode() case player.FieldProfileCreated: return m.ProfileCreated() case player.FieldOldestSharecodeSeen: return m.OldestSharecodeSeen() case player.FieldWins: return m.Wins() case player.FieldLooses: return m.Looses() case player.FieldTies: return m.Ties() } return nil, false } // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. func (m *PlayerMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { case player.FieldName: return m.OldName(ctx) case player.FieldAvatar: return m.OldAvatar(ctx) case player.FieldVanityURL: return m.OldVanityURL(ctx) case player.FieldVanityURLReal: return m.OldVanityURLReal(ctx) case player.FieldVacDate: return m.OldVacDate(ctx) case player.FieldVacCount: return m.OldVacCount(ctx) case player.FieldGameBanDate: return m.OldGameBanDate(ctx) case player.FieldGameBanCount: return m.OldGameBanCount(ctx) case player.FieldSteamUpdated: return m.OldSteamUpdated(ctx) case player.FieldSharecodeUpdated: return m.OldSharecodeUpdated(ctx) case player.FieldAuthCode: return m.OldAuthCode(ctx) case player.FieldProfileCreated: return m.OldProfileCreated(ctx) case player.FieldOldestSharecodeSeen: return m.OldOldestSharecodeSeen(ctx) case player.FieldWins: return m.OldWins(ctx) case player.FieldLooses: return m.OldLooses(ctx) case player.FieldTies: return m.OldTies(ctx) } return nil, fmt.Errorf("unknown Player field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. func (m *PlayerMutation) SetField(name string, value ent.Value) error { switch name { case player.FieldName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetName(v) return nil case player.FieldAvatar: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetAvatar(v) return nil case player.FieldVanityURL: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetVanityURL(v) return nil case player.FieldVanityURLReal: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetVanityURLReal(v) return nil case player.FieldVacDate: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetVacDate(v) return nil case player.FieldVacCount: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetVacCount(v) return nil case player.FieldGameBanDate: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetGameBanDate(v) return nil case player.FieldGameBanCount: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetGameBanCount(v) return nil case player.FieldSteamUpdated: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetSteamUpdated(v) return nil case player.FieldSharecodeUpdated: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetSharecodeUpdated(v) return nil case player.FieldAuthCode: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetAuthCode(v) return nil case player.FieldProfileCreated: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetProfileCreated(v) return nil case player.FieldOldestSharecodeSeen: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetOldestSharecodeSeen(v) return nil case player.FieldWins: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetWins(v) return nil case player.FieldLooses: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetLooses(v) return nil case player.FieldTies: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetTies(v) return nil } return fmt.Errorf("unknown Player field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. func (m *PlayerMutation) AddedFields() []string { var fields []string if m.addvac_count != nil { fields = append(fields, player.FieldVacCount) } if m.addgame_ban_count != nil { fields = append(fields, player.FieldGameBanCount) } if m.addwins != nil { fields = append(fields, player.FieldWins) } if m.addlooses != nil { fields = append(fields, player.FieldLooses) } if m.addties != nil { fields = append(fields, player.FieldTies) } return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. func (m *PlayerMutation) AddedField(name string) (ent.Value, bool) { switch name { case player.FieldVacCount: return m.AddedVacCount() case player.FieldGameBanCount: return m.AddedGameBanCount() case player.FieldWins: return m.AddedWins() case player.FieldLooses: return m.AddedLooses() case player.FieldTies: return m.AddedTies() } return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. func (m *PlayerMutation) AddField(name string, value ent.Value) error { switch name { case player.FieldVacCount: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddVacCount(v) return nil case player.FieldGameBanCount: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddGameBanCount(v) return nil case player.FieldWins: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddWins(v) return nil case player.FieldLooses: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddLooses(v) return nil case player.FieldTies: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddTies(v) return nil } return fmt.Errorf("unknown Player numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. func (m *PlayerMutation) ClearedFields() []string { var fields []string if m.FieldCleared(player.FieldName) { fields = append(fields, player.FieldName) } if m.FieldCleared(player.FieldAvatar) { fields = append(fields, player.FieldAvatar) } if m.FieldCleared(player.FieldVanityURL) { fields = append(fields, player.FieldVanityURL) } if m.FieldCleared(player.FieldVanityURLReal) { fields = append(fields, player.FieldVanityURLReal) } if m.FieldCleared(player.FieldVacDate) { fields = append(fields, player.FieldVacDate) } if m.FieldCleared(player.FieldVacCount) { fields = append(fields, player.FieldVacCount) } if m.FieldCleared(player.FieldGameBanDate) { fields = append(fields, player.FieldGameBanDate) } if m.FieldCleared(player.FieldGameBanCount) { fields = append(fields, player.FieldGameBanCount) } if m.FieldCleared(player.FieldSharecodeUpdated) { fields = append(fields, player.FieldSharecodeUpdated) } if m.FieldCleared(player.FieldAuthCode) { fields = append(fields, player.FieldAuthCode) } if m.FieldCleared(player.FieldProfileCreated) { fields = append(fields, player.FieldProfileCreated) } if m.FieldCleared(player.FieldOldestSharecodeSeen) { fields = append(fields, player.FieldOldestSharecodeSeen) } if m.FieldCleared(player.FieldWins) { fields = append(fields, player.FieldWins) } if m.FieldCleared(player.FieldLooses) { fields = append(fields, player.FieldLooses) } if m.FieldCleared(player.FieldTies) { fields = append(fields, player.FieldTies) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. func (m *PlayerMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. func (m *PlayerMutation) ClearField(name string) error { switch name { case player.FieldName: m.ClearName() return nil case player.FieldAvatar: m.ClearAvatar() return nil case player.FieldVanityURL: m.ClearVanityURL() return nil case player.FieldVanityURLReal: m.ClearVanityURLReal() return nil case player.FieldVacDate: m.ClearVacDate() return nil case player.FieldVacCount: m.ClearVacCount() return nil case player.FieldGameBanDate: m.ClearGameBanDate() return nil case player.FieldGameBanCount: m.ClearGameBanCount() return nil case player.FieldSharecodeUpdated: m.ClearSharecodeUpdated() return nil case player.FieldAuthCode: m.ClearAuthCode() return nil case player.FieldProfileCreated: m.ClearProfileCreated() return nil case player.FieldOldestSharecodeSeen: m.ClearOldestSharecodeSeen() return nil case player.FieldWins: m.ClearWins() return nil case player.FieldLooses: m.ClearLooses() return nil case player.FieldTies: m.ClearTies() return nil } return fmt.Errorf("unknown Player nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. func (m *PlayerMutation) ResetField(name string) error { switch name { case player.FieldName: m.ResetName() return nil case player.FieldAvatar: m.ResetAvatar() return nil case player.FieldVanityURL: m.ResetVanityURL() return nil case player.FieldVanityURLReal: m.ResetVanityURLReal() return nil case player.FieldVacDate: m.ResetVacDate() return nil case player.FieldVacCount: m.ResetVacCount() return nil case player.FieldGameBanDate: m.ResetGameBanDate() return nil case player.FieldGameBanCount: m.ResetGameBanCount() return nil case player.FieldSteamUpdated: m.ResetSteamUpdated() return nil case player.FieldSharecodeUpdated: m.ResetSharecodeUpdated() return nil case player.FieldAuthCode: m.ResetAuthCode() return nil case player.FieldProfileCreated: m.ResetProfileCreated() return nil case player.FieldOldestSharecodeSeen: m.ResetOldestSharecodeSeen() return nil case player.FieldWins: m.ResetWins() return nil case player.FieldLooses: m.ResetLooses() return nil case player.FieldTies: m.ResetTies() return nil } return fmt.Errorf("unknown Player field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. func (m *PlayerMutation) AddedEdges() []string { edges := make([]string, 0, 2) if m.stats != nil { edges = append(edges, player.EdgeStats) } if m.matches != nil { edges = append(edges, player.EdgeMatches) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. func (m *PlayerMutation) AddedIDs(name string) []ent.Value { switch name { case player.EdgeStats: ids := make([]ent.Value, 0, len(m.stats)) for id := range m.stats { ids = append(ids, id) } return ids case player.EdgeMatches: ids := make([]ent.Value, 0, len(m.matches)) for id := range m.matches { ids = append(ids, id) } return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *PlayerMutation) RemovedEdges() []string { edges := make([]string, 0, 2) if m.removedstats != nil { edges = append(edges, player.EdgeStats) } if m.removedmatches != nil { edges = append(edges, player.EdgeMatches) } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. func (m *PlayerMutation) RemovedIDs(name string) []ent.Value { switch name { case player.EdgeStats: ids := make([]ent.Value, 0, len(m.removedstats)) for id := range m.removedstats { ids = append(ids, id) } return ids case player.EdgeMatches: ids := make([]ent.Value, 0, len(m.removedmatches)) for id := range m.removedmatches { ids = append(ids, id) } return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *PlayerMutation) ClearedEdges() []string { edges := make([]string, 0, 2) if m.clearedstats { edges = append(edges, player.EdgeStats) } if m.clearedmatches { edges = append(edges, player.EdgeMatches) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. func (m *PlayerMutation) EdgeCleared(name string) bool { switch name { case player.EdgeStats: return m.clearedstats case player.EdgeMatches: return m.clearedmatches } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. func (m *PlayerMutation) ClearEdge(name string) error { switch name { } return fmt.Errorf("unknown Player unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. func (m *PlayerMutation) ResetEdge(name string) error { switch name { case player.EdgeStats: m.ResetStats() return nil case player.EdgeMatches: m.ResetMatches() return nil } return fmt.Errorf("unknown Player edge %s", name) } // RoundStatsMutation represents an operation that mutates the RoundStats nodes in the graph. type RoundStatsMutation struct { config op Op typ string id *int round *uint addround *int bank *uint addbank *int equipment *uint addequipment *int spent *uint addspent *int clearedFields map[string]struct{} match_player *int clearedmatch_player bool done bool oldValue func(context.Context) (*RoundStats, error) predicates []predicate.RoundStats } var _ ent.Mutation = (*RoundStatsMutation)(nil) // roundstatsOption allows management of the mutation configuration using functional options. type roundstatsOption func(*RoundStatsMutation) // newRoundStatsMutation creates new mutation for the RoundStats entity. func newRoundStatsMutation(c config, op Op, opts ...roundstatsOption) *RoundStatsMutation { m := &RoundStatsMutation{ config: c, op: op, typ: TypeRoundStats, clearedFields: make(map[string]struct{}), } for _, opt := range opts { opt(m) } return m } // withRoundStatsID sets the ID field of the mutation. func withRoundStatsID(id int) roundstatsOption { return func(m *RoundStatsMutation) { var ( err error once sync.Once value *RoundStats ) m.oldValue = func(ctx context.Context) (*RoundStats, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { value, err = m.Client().RoundStats.Get(ctx, id) } }) return value, err } m.id = &id } } // withRoundStats sets the old RoundStats of the mutation. func withRoundStats(node *RoundStats) roundstatsOption { return func(m *RoundStatsMutation) { m.oldValue = func(context.Context) (*RoundStats, error) { return node, nil } m.id = &node.ID } } // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. func (m RoundStatsMutation) Client() *Client { client := &Client{config: m.config} client.init() return client } // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. func (m RoundStatsMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } tx := &Tx{config: m.config} tx.init() return tx, nil } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. func (m *RoundStatsMutation) ID() (id int, exists bool) { if m.id == nil { return } return *m.id, true } // IDs queries the database and returns the entity ids that match the mutation's predicate. // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. func (m *RoundStatsMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { return []int{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): return m.Client().RoundStats.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // SetRound sets the "round" field. func (m *RoundStatsMutation) SetRound(u uint) { m.round = &u m.addround = nil } // Round returns the value of the "round" field in the mutation. func (m *RoundStatsMutation) Round() (r uint, exists bool) { v := m.round if v == nil { return } return *v, true } // OldRound returns the old "round" field's value of the RoundStats entity. // If the RoundStats object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *RoundStatsMutation) OldRound(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldRound is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldRound requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldRound: %w", err) } return oldValue.Round, nil } // AddRound adds u to the "round" field. func (m *RoundStatsMutation) AddRound(u int) { if m.addround != nil { *m.addround += u } else { m.addround = &u } } // AddedRound returns the value that was added to the "round" field in this mutation. func (m *RoundStatsMutation) AddedRound() (r int, exists bool) { v := m.addround if v == nil { return } return *v, true } // ResetRound resets all changes to the "round" field. func (m *RoundStatsMutation) ResetRound() { m.round = nil m.addround = nil } // SetBank sets the "bank" field. func (m *RoundStatsMutation) SetBank(u uint) { m.bank = &u m.addbank = nil } // Bank returns the value of the "bank" field in the mutation. func (m *RoundStatsMutation) Bank() (r uint, exists bool) { v := m.bank if v == nil { return } return *v, true } // OldBank returns the old "bank" field's value of the RoundStats entity. // If the RoundStats object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *RoundStatsMutation) OldBank(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldBank is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldBank requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldBank: %w", err) } return oldValue.Bank, nil } // AddBank adds u to the "bank" field. func (m *RoundStatsMutation) AddBank(u int) { if m.addbank != nil { *m.addbank += u } else { m.addbank = &u } } // AddedBank returns the value that was added to the "bank" field in this mutation. func (m *RoundStatsMutation) AddedBank() (r int, exists bool) { v := m.addbank if v == nil { return } return *v, true } // ResetBank resets all changes to the "bank" field. func (m *RoundStatsMutation) ResetBank() { m.bank = nil m.addbank = nil } // SetEquipment sets the "equipment" field. func (m *RoundStatsMutation) SetEquipment(u uint) { m.equipment = &u m.addequipment = nil } // Equipment returns the value of the "equipment" field in the mutation. func (m *RoundStatsMutation) Equipment() (r uint, exists bool) { v := m.equipment if v == nil { return } return *v, true } // OldEquipment returns the old "equipment" field's value of the RoundStats entity. // If the RoundStats object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *RoundStatsMutation) OldEquipment(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldEquipment is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldEquipment requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldEquipment: %w", err) } return oldValue.Equipment, nil } // AddEquipment adds u to the "equipment" field. func (m *RoundStatsMutation) AddEquipment(u int) { if m.addequipment != nil { *m.addequipment += u } else { m.addequipment = &u } } // AddedEquipment returns the value that was added to the "equipment" field in this mutation. func (m *RoundStatsMutation) AddedEquipment() (r int, exists bool) { v := m.addequipment if v == nil { return } return *v, true } // ResetEquipment resets all changes to the "equipment" field. func (m *RoundStatsMutation) ResetEquipment() { m.equipment = nil m.addequipment = nil } // SetSpent sets the "spent" field. func (m *RoundStatsMutation) SetSpent(u uint) { m.spent = &u m.addspent = nil } // Spent returns the value of the "spent" field in the mutation. func (m *RoundStatsMutation) Spent() (r uint, exists bool) { v := m.spent if v == nil { return } return *v, true } // OldSpent returns the old "spent" field's value of the RoundStats entity. // If the RoundStats object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *RoundStatsMutation) OldSpent(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldSpent is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldSpent requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldSpent: %w", err) } return oldValue.Spent, nil } // AddSpent adds u to the "spent" field. func (m *RoundStatsMutation) AddSpent(u int) { if m.addspent != nil { *m.addspent += u } else { m.addspent = &u } } // AddedSpent returns the value that was added to the "spent" field in this mutation. func (m *RoundStatsMutation) AddedSpent() (r int, exists bool) { v := m.addspent if v == nil { return } return *v, true } // ResetSpent resets all changes to the "spent" field. func (m *RoundStatsMutation) ResetSpent() { m.spent = nil m.addspent = nil } // SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by id. func (m *RoundStatsMutation) SetMatchPlayerID(id int) { m.match_player = &id } // ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity. func (m *RoundStatsMutation) ClearMatchPlayer() { m.clearedmatch_player = true } // MatchPlayerCleared reports if the "match_player" edge to the MatchPlayer entity was cleared. func (m *RoundStatsMutation) MatchPlayerCleared() bool { return m.clearedmatch_player } // MatchPlayerID returns the "match_player" edge ID in the mutation. func (m *RoundStatsMutation) MatchPlayerID() (id int, exists bool) { if m.match_player != nil { return *m.match_player, true } return } // MatchPlayerIDs returns the "match_player" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // MatchPlayerID instead. It exists only for internal usage by the builders. func (m *RoundStatsMutation) MatchPlayerIDs() (ids []int) { if id := m.match_player; id != nil { ids = append(ids, *id) } return } // ResetMatchPlayer resets all changes to the "match_player" edge. func (m *RoundStatsMutation) ResetMatchPlayer() { m.match_player = nil m.clearedmatch_player = false } // Where appends a list predicates to the RoundStatsMutation builder. func (m *RoundStatsMutation) Where(ps ...predicate.RoundStats) { m.predicates = append(m.predicates, ps...) } // WhereP appends storage-level predicates to the RoundStatsMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. func (m *RoundStatsMutation) WhereP(ps ...func(*sql.Selector)) { p := make([]predicate.RoundStats, len(ps)) for i := range ps { p[i] = ps[i] } m.Where(p...) } // Op returns the operation name. func (m *RoundStatsMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. func (m *RoundStatsMutation) SetOp(op Op) { m.op = op } // Type returns the node type of this mutation (RoundStats). func (m *RoundStatsMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *RoundStatsMutation) Fields() []string { fields := make([]string, 0, 4) if m.round != nil { fields = append(fields, roundstats.FieldRound) } if m.bank != nil { fields = append(fields, roundstats.FieldBank) } if m.equipment != nil { fields = append(fields, roundstats.FieldEquipment) } if m.spent != nil { fields = append(fields, roundstats.FieldSpent) } return fields } // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. func (m *RoundStatsMutation) Field(name string) (ent.Value, bool) { switch name { case roundstats.FieldRound: return m.Round() case roundstats.FieldBank: return m.Bank() case roundstats.FieldEquipment: return m.Equipment() case roundstats.FieldSpent: return m.Spent() } return nil, false } // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. func (m *RoundStatsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { case roundstats.FieldRound: return m.OldRound(ctx) case roundstats.FieldBank: return m.OldBank(ctx) case roundstats.FieldEquipment: return m.OldEquipment(ctx) case roundstats.FieldSpent: return m.OldSpent(ctx) } return nil, fmt.Errorf("unknown RoundStats field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. func (m *RoundStatsMutation) SetField(name string, value ent.Value) error { switch name { case roundstats.FieldRound: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetRound(v) return nil case roundstats.FieldBank: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetBank(v) return nil case roundstats.FieldEquipment: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetEquipment(v) return nil case roundstats.FieldSpent: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetSpent(v) return nil } return fmt.Errorf("unknown RoundStats field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. func (m *RoundStatsMutation) AddedFields() []string { var fields []string if m.addround != nil { fields = append(fields, roundstats.FieldRound) } if m.addbank != nil { fields = append(fields, roundstats.FieldBank) } if m.addequipment != nil { fields = append(fields, roundstats.FieldEquipment) } if m.addspent != nil { fields = append(fields, roundstats.FieldSpent) } return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. func (m *RoundStatsMutation) AddedField(name string) (ent.Value, bool) { switch name { case roundstats.FieldRound: return m.AddedRound() case roundstats.FieldBank: return m.AddedBank() case roundstats.FieldEquipment: return m.AddedEquipment() case roundstats.FieldSpent: return m.AddedSpent() } return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. func (m *RoundStatsMutation) AddField(name string, value ent.Value) error { switch name { case roundstats.FieldRound: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddRound(v) return nil case roundstats.FieldBank: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddBank(v) return nil case roundstats.FieldEquipment: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddEquipment(v) return nil case roundstats.FieldSpent: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddSpent(v) return nil } return fmt.Errorf("unknown RoundStats numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. func (m *RoundStatsMutation) ClearedFields() []string { return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. func (m *RoundStatsMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. func (m *RoundStatsMutation) ClearField(name string) error { return fmt.Errorf("unknown RoundStats nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. func (m *RoundStatsMutation) ResetField(name string) error { switch name { case roundstats.FieldRound: m.ResetRound() return nil case roundstats.FieldBank: m.ResetBank() return nil case roundstats.FieldEquipment: m.ResetEquipment() return nil case roundstats.FieldSpent: m.ResetSpent() return nil } return fmt.Errorf("unknown RoundStats field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. func (m *RoundStatsMutation) AddedEdges() []string { edges := make([]string, 0, 1) if m.match_player != nil { edges = append(edges, roundstats.EdgeMatchPlayer) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. func (m *RoundStatsMutation) AddedIDs(name string) []ent.Value { switch name { case roundstats.EdgeMatchPlayer: if id := m.match_player; id != nil { return []ent.Value{*id} } } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *RoundStatsMutation) RemovedEdges() []string { edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. func (m *RoundStatsMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *RoundStatsMutation) ClearedEdges() []string { edges := make([]string, 0, 1) if m.clearedmatch_player { edges = append(edges, roundstats.EdgeMatchPlayer) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. func (m *RoundStatsMutation) EdgeCleared(name string) bool { switch name { case roundstats.EdgeMatchPlayer: return m.clearedmatch_player } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. func (m *RoundStatsMutation) ClearEdge(name string) error { switch name { case roundstats.EdgeMatchPlayer: m.ClearMatchPlayer() return nil } return fmt.Errorf("unknown RoundStats unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. func (m *RoundStatsMutation) ResetEdge(name string) error { switch name { case roundstats.EdgeMatchPlayer: m.ResetMatchPlayer() return nil } return fmt.Errorf("unknown RoundStats edge %s", name) } // SprayMutation represents an operation that mutates the Spray nodes in the graph. type SprayMutation struct { config op Op typ string id *int weapon *int addweapon *int spray *[]byte clearedFields map[string]struct{} match_players *int clearedmatch_players bool done bool oldValue func(context.Context) (*Spray, error) predicates []predicate.Spray } var _ ent.Mutation = (*SprayMutation)(nil) // sprayOption allows management of the mutation configuration using functional options. type sprayOption func(*SprayMutation) // newSprayMutation creates new mutation for the Spray entity. func newSprayMutation(c config, op Op, opts ...sprayOption) *SprayMutation { m := &SprayMutation{ config: c, op: op, typ: TypeSpray, clearedFields: make(map[string]struct{}), } for _, opt := range opts { opt(m) } return m } // withSprayID sets the ID field of the mutation. func withSprayID(id int) sprayOption { return func(m *SprayMutation) { var ( err error once sync.Once value *Spray ) m.oldValue = func(ctx context.Context) (*Spray, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { value, err = m.Client().Spray.Get(ctx, id) } }) return value, err } m.id = &id } } // withSpray sets the old Spray of the mutation. func withSpray(node *Spray) sprayOption { return func(m *SprayMutation) { m.oldValue = func(context.Context) (*Spray, 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 SprayMutation) 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 SprayMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("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 *SprayMutation) ID() (id int, exists bool) { if m.id == nil { return } return *m.id, true } // IDs queries the database and returns the entity ids that match the mutation's predicate. // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. func (m *SprayMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { return []int{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): return m.Client().Spray.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // SetWeapon sets the "weapon" field. func (m *SprayMutation) SetWeapon(i int) { m.weapon = &i m.addweapon = nil } // Weapon returns the value of the "weapon" field in the mutation. func (m *SprayMutation) Weapon() (r int, exists bool) { v := m.weapon if v == nil { return } return *v, true } // OldWeapon returns the old "weapon" field's value of the Spray entity. // If the Spray 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 *SprayMutation) OldWeapon(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldWeapon is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldWeapon requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldWeapon: %w", err) } return oldValue.Weapon, nil } // AddWeapon adds i to the "weapon" field. func (m *SprayMutation) AddWeapon(i int) { if m.addweapon != nil { *m.addweapon += i } else { m.addweapon = &i } } // AddedWeapon returns the value that was added to the "weapon" field in this mutation. func (m *SprayMutation) AddedWeapon() (r int, exists bool) { v := m.addweapon if v == nil { return } return *v, true } // ResetWeapon resets all changes to the "weapon" field. func (m *SprayMutation) ResetWeapon() { m.weapon = nil m.addweapon = nil } // SetSpray sets the "spray" field. func (m *SprayMutation) SetSpray(b []byte) { m.spray = &b } // Spray returns the value of the "spray" field in the mutation. func (m *SprayMutation) Spray() (r []byte, exists bool) { v := m.spray if v == nil { return } return *v, true } // OldSpray returns the old "spray" field's value of the Spray entity. // If the Spray 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 *SprayMutation) OldSpray(ctx context.Context) (v []byte, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldSpray is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldSpray requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldSpray: %w", err) } return oldValue.Spray, nil } // ResetSpray resets all changes to the "spray" field. func (m *SprayMutation) ResetSpray() { m.spray = nil } // SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by id. func (m *SprayMutation) SetMatchPlayersID(id int) { m.match_players = &id } // ClearMatchPlayers clears the "match_players" edge to the MatchPlayer entity. func (m *SprayMutation) ClearMatchPlayers() { m.clearedmatch_players = true } // MatchPlayersCleared reports if the "match_players" edge to the MatchPlayer entity was cleared. func (m *SprayMutation) MatchPlayersCleared() bool { return m.clearedmatch_players } // MatchPlayersID returns the "match_players" edge ID in the mutation. func (m *SprayMutation) MatchPlayersID() (id int, exists bool) { if m.match_players != nil { return *m.match_players, true } return } // MatchPlayersIDs returns the "match_players" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // MatchPlayersID instead. It exists only for internal usage by the builders. func (m *SprayMutation) MatchPlayersIDs() (ids []int) { if id := m.match_players; id != nil { ids = append(ids, *id) } return } // ResetMatchPlayers resets all changes to the "match_players" edge. func (m *SprayMutation) ResetMatchPlayers() { m.match_players = nil m.clearedmatch_players = false } // Where appends a list predicates to the SprayMutation builder. func (m *SprayMutation) Where(ps ...predicate.Spray) { m.predicates = append(m.predicates, ps...) } // WhereP appends storage-level predicates to the SprayMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. func (m *SprayMutation) WhereP(ps ...func(*sql.Selector)) { p := make([]predicate.Spray, len(ps)) for i := range ps { p[i] = ps[i] } m.Where(p...) } // Op returns the operation name. func (m *SprayMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. func (m *SprayMutation) SetOp(op Op) { m.op = op } // Type returns the node type of this mutation (Spray). func (m *SprayMutation) 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 *SprayMutation) Fields() []string { fields := make([]string, 0, 2) if m.weapon != nil { fields = append(fields, spray.FieldWeapon) } if m.spray != nil { fields = append(fields, spray.FieldSpray) } 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 *SprayMutation) Field(name string) (ent.Value, bool) { switch name { case spray.FieldWeapon: return m.Weapon() case spray.FieldSpray: return m.Spray() } 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 *SprayMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { case spray.FieldWeapon: return m.OldWeapon(ctx) case spray.FieldSpray: return m.OldSpray(ctx) } return nil, fmt.Errorf("unknown Spray 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 *SprayMutation) SetField(name string, value ent.Value) error { switch name { case spray.FieldWeapon: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetWeapon(v) return nil case spray.FieldSpray: v, ok := value.([]byte) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetSpray(v) return nil } return fmt.Errorf("unknown Spray field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. func (m *SprayMutation) AddedFields() []string { var fields []string if m.addweapon != nil { fields = append(fields, spray.FieldWeapon) } 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 *SprayMutation) AddedField(name string) (ent.Value, bool) { switch name { case spray.FieldWeapon: return m.AddedWeapon() } 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 *SprayMutation) AddField(name string, value ent.Value) error { switch name { case spray.FieldWeapon: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddWeapon(v) return nil } return fmt.Errorf("unknown Spray numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. func (m *SprayMutation) ClearedFields() []string { return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. func (m *SprayMutation) 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 *SprayMutation) ClearField(name string) error { return fmt.Errorf("unknown Spray 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 *SprayMutation) ResetField(name string) error { switch name { case spray.FieldWeapon: m.ResetWeapon() return nil case spray.FieldSpray: m.ResetSpray() return nil } return fmt.Errorf("unknown Spray field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. func (m *SprayMutation) AddedEdges() []string { edges := make([]string, 0, 1) if m.match_players != nil { edges = append(edges, spray.EdgeMatchPlayers) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. func (m *SprayMutation) AddedIDs(name string) []ent.Value { switch name { case spray.EdgeMatchPlayers: if id := m.match_players; id != nil { return []ent.Value{*id} } } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *SprayMutation) RemovedEdges() []string { edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. func (m *SprayMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *SprayMutation) ClearedEdges() []string { edges := make([]string, 0, 1) if m.clearedmatch_players { edges = append(edges, spray.EdgeMatchPlayers) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. func (m *SprayMutation) EdgeCleared(name string) bool { switch name { case spray.EdgeMatchPlayers: return m.clearedmatch_players } 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 *SprayMutation) ClearEdge(name string) error { switch name { case spray.EdgeMatchPlayers: m.ClearMatchPlayers() return nil } return fmt.Errorf("unknown Spray 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 *SprayMutation) ResetEdge(name string) error { switch name { case spray.EdgeMatchPlayers: m.ResetMatchPlayers() return nil } return fmt.Errorf("unknown Spray edge %s", name) } // WeaponMutation represents an operation that mutates the Weapon nodes in the graph. type WeaponMutation struct { config op Op typ string id *int victim *uint64 addvictim *int64 dmg *uint adddmg *int eq_type *int addeq_type *int hit_group *int addhit_group *int clearedFields map[string]struct{} stat *int clearedstat bool done bool oldValue func(context.Context) (*Weapon, error) predicates []predicate.Weapon } var _ ent.Mutation = (*WeaponMutation)(nil) // weaponOption allows management of the mutation configuration using functional options. type weaponOption func(*WeaponMutation) // newWeaponMutation creates new mutation for the Weapon entity. func newWeaponMutation(c config, op Op, opts ...weaponOption) *WeaponMutation { m := &WeaponMutation{ config: c, op: op, typ: TypeWeapon, clearedFields: make(map[string]struct{}), } for _, opt := range opts { opt(m) } return m } // withWeaponID sets the ID field of the mutation. func withWeaponID(id int) weaponOption { return func(m *WeaponMutation) { var ( err error once sync.Once value *Weapon ) m.oldValue = func(ctx context.Context) (*Weapon, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { value, err = m.Client().Weapon.Get(ctx, id) } }) return value, err } m.id = &id } } // withWeapon sets the old Weapon of the mutation. func withWeapon(node *Weapon) weaponOption { return func(m *WeaponMutation) { m.oldValue = func(context.Context) (*Weapon, 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 WeaponMutation) 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 WeaponMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("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 *WeaponMutation) ID() (id int, exists bool) { if m.id == nil { return } return *m.id, true } // IDs queries the database and returns the entity ids that match the mutation's predicate. // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. func (m *WeaponMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { return []int{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): return m.Client().Weapon.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // SetVictim sets the "victim" field. func (m *WeaponMutation) SetVictim(u uint64) { m.victim = &u m.addvictim = nil } // Victim returns the value of the "victim" field in the mutation. func (m *WeaponMutation) Victim() (r uint64, exists bool) { v := m.victim if v == nil { return } return *v, true } // OldVictim returns the old "victim" field's value of the Weapon entity. // If the Weapon 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 *WeaponMutation) OldVictim(ctx context.Context) (v uint64, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldVictim is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldVictim requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldVictim: %w", err) } return oldValue.Victim, nil } // AddVictim adds u to the "victim" field. func (m *WeaponMutation) AddVictim(u int64) { if m.addvictim != nil { *m.addvictim += u } else { m.addvictim = &u } } // AddedVictim returns the value that was added to the "victim" field in this mutation. func (m *WeaponMutation) AddedVictim() (r int64, exists bool) { v := m.addvictim if v == nil { return } return *v, true } // ResetVictim resets all changes to the "victim" field. func (m *WeaponMutation) ResetVictim() { m.victim = nil m.addvictim = nil } // SetDmg sets the "dmg" field. func (m *WeaponMutation) SetDmg(u uint) { m.dmg = &u m.adddmg = nil } // Dmg returns the value of the "dmg" field in the mutation. func (m *WeaponMutation) Dmg() (r uint, exists bool) { v := m.dmg if v == nil { return } return *v, true } // OldDmg returns the old "dmg" field's value of the Weapon entity. // If the Weapon 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 *WeaponMutation) OldDmg(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldDmg is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldDmg requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldDmg: %w", err) } return oldValue.Dmg, nil } // AddDmg adds u to the "dmg" field. func (m *WeaponMutation) AddDmg(u int) { if m.adddmg != nil { *m.adddmg += u } else { m.adddmg = &u } } // AddedDmg returns the value that was added to the "dmg" field in this mutation. func (m *WeaponMutation) AddedDmg() (r int, exists bool) { v := m.adddmg if v == nil { return } return *v, true } // ResetDmg resets all changes to the "dmg" field. func (m *WeaponMutation) ResetDmg() { m.dmg = nil m.adddmg = nil } // SetEqType sets the "eq_type" field. func (m *WeaponMutation) SetEqType(i int) { m.eq_type = &i m.addeq_type = nil } // EqType returns the value of the "eq_type" field in the mutation. func (m *WeaponMutation) EqType() (r int, exists bool) { v := m.eq_type if v == nil { return } return *v, true } // OldEqType returns the old "eq_type" field's value of the Weapon entity. // If the Weapon 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 *WeaponMutation) OldEqType(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldEqType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldEqType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldEqType: %w", err) } return oldValue.EqType, nil } // AddEqType adds i to the "eq_type" field. func (m *WeaponMutation) AddEqType(i int) { if m.addeq_type != nil { *m.addeq_type += i } else { m.addeq_type = &i } } // AddedEqType returns the value that was added to the "eq_type" field in this mutation. func (m *WeaponMutation) AddedEqType() (r int, exists bool) { v := m.addeq_type if v == nil { return } return *v, true } // ResetEqType resets all changes to the "eq_type" field. func (m *WeaponMutation) ResetEqType() { m.eq_type = nil m.addeq_type = nil } // SetHitGroup sets the "hit_group" field. func (m *WeaponMutation) SetHitGroup(i int) { m.hit_group = &i m.addhit_group = nil } // HitGroup returns the value of the "hit_group" field in the mutation. func (m *WeaponMutation) HitGroup() (r int, exists bool) { v := m.hit_group if v == nil { return } return *v, true } // OldHitGroup returns the old "hit_group" field's value of the Weapon entity. // If the Weapon 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 *WeaponMutation) OldHitGroup(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldHitGroup is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldHitGroup requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldHitGroup: %w", err) } return oldValue.HitGroup, nil } // AddHitGroup adds i to the "hit_group" field. func (m *WeaponMutation) AddHitGroup(i int) { if m.addhit_group != nil { *m.addhit_group += i } else { m.addhit_group = &i } } // AddedHitGroup returns the value that was added to the "hit_group" field in this mutation. func (m *WeaponMutation) AddedHitGroup() (r int, exists bool) { v := m.addhit_group if v == nil { return } return *v, true } // ResetHitGroup resets all changes to the "hit_group" field. func (m *WeaponMutation) ResetHitGroup() { m.hit_group = nil m.addhit_group = nil } // SetStatID sets the "stat" edge to the MatchPlayer entity by id. func (m *WeaponMutation) SetStatID(id int) { m.stat = &id } // ClearStat clears the "stat" edge to the MatchPlayer entity. func (m *WeaponMutation) ClearStat() { m.clearedstat = true } // StatCleared reports if the "stat" edge to the MatchPlayer entity was cleared. func (m *WeaponMutation) StatCleared() bool { return m.clearedstat } // StatID returns the "stat" edge ID in the mutation. func (m *WeaponMutation) StatID() (id int, exists bool) { if m.stat != nil { return *m.stat, true } return } // StatIDs returns the "stat" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // StatID instead. It exists only for internal usage by the builders. func (m *WeaponMutation) StatIDs() (ids []int) { if id := m.stat; id != nil { ids = append(ids, *id) } return } // ResetStat resets all changes to the "stat" edge. func (m *WeaponMutation) ResetStat() { m.stat = nil m.clearedstat = false } // Where appends a list predicates to the WeaponMutation builder. func (m *WeaponMutation) Where(ps ...predicate.Weapon) { m.predicates = append(m.predicates, ps...) } // WhereP appends storage-level predicates to the WeaponMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. func (m *WeaponMutation) WhereP(ps ...func(*sql.Selector)) { p := make([]predicate.Weapon, len(ps)) for i := range ps { p[i] = ps[i] } m.Where(p...) } // Op returns the operation name. func (m *WeaponMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. func (m *WeaponMutation) SetOp(op Op) { m.op = op } // Type returns the node type of this mutation (Weapon). func (m *WeaponMutation) 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 *WeaponMutation) Fields() []string { fields := make([]string, 0, 4) if m.victim != nil { fields = append(fields, weapon.FieldVictim) } if m.dmg != nil { fields = append(fields, weapon.FieldDmg) } if m.eq_type != nil { fields = append(fields, weapon.FieldEqType) } if m.hit_group != nil { fields = append(fields, weapon.FieldHitGroup) } return fields } // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. func (m *WeaponMutation) Field(name string) (ent.Value, bool) { switch name { case weapon.FieldVictim: return m.Victim() case weapon.FieldDmg: return m.Dmg() case weapon.FieldEqType: return m.EqType() case weapon.FieldHitGroup: return m.HitGroup() } return nil, false } // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. func (m *WeaponMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { case weapon.FieldVictim: return m.OldVictim(ctx) case weapon.FieldDmg: return m.OldDmg(ctx) case weapon.FieldEqType: return m.OldEqType(ctx) case weapon.FieldHitGroup: return m.OldHitGroup(ctx) } return nil, fmt.Errorf("unknown Weapon 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 *WeaponMutation) SetField(name string, value ent.Value) error { switch name { case weapon.FieldVictim: v, ok := value.(uint64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetVictim(v) return nil case weapon.FieldDmg: v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDmg(v) return nil case weapon.FieldEqType: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetEqType(v) return nil case weapon.FieldHitGroup: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetHitGroup(v) return nil } return fmt.Errorf("unknown Weapon field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. func (m *WeaponMutation) AddedFields() []string { var fields []string if m.addvictim != nil { fields = append(fields, weapon.FieldVictim) } if m.adddmg != nil { fields = append(fields, weapon.FieldDmg) } if m.addeq_type != nil { fields = append(fields, weapon.FieldEqType) } if m.addhit_group != nil { fields = append(fields, weapon.FieldHitGroup) } return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. func (m *WeaponMutation) AddedField(name string) (ent.Value, bool) { switch name { case weapon.FieldVictim: return m.AddedVictim() case weapon.FieldDmg: return m.AddedDmg() case weapon.FieldEqType: return m.AddedEqType() case weapon.FieldHitGroup: return m.AddedHitGroup() } return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. func (m *WeaponMutation) AddField(name string, value ent.Value) error { switch name { case weapon.FieldVictim: v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddVictim(v) return nil case weapon.FieldDmg: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddDmg(v) return nil case weapon.FieldEqType: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddEqType(v) return nil case weapon.FieldHitGroup: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddHitGroup(v) return nil } return fmt.Errorf("unknown Weapon numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. func (m *WeaponMutation) ClearedFields() []string { return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. func (m *WeaponMutation) 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 *WeaponMutation) ClearField(name string) error { return fmt.Errorf("unknown Weapon 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 *WeaponMutation) ResetField(name string) error { switch name { case weapon.FieldVictim: m.ResetVictim() return nil case weapon.FieldDmg: m.ResetDmg() return nil case weapon.FieldEqType: m.ResetEqType() return nil case weapon.FieldHitGroup: m.ResetHitGroup() return nil } return fmt.Errorf("unknown Weapon field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. func (m *WeaponMutation) AddedEdges() []string { edges := make([]string, 0, 1) if m.stat != nil { edges = append(edges, weapon.EdgeStat) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. func (m *WeaponMutation) AddedIDs(name string) []ent.Value { switch name { case weapon.EdgeStat: if id := m.stat; id != nil { return []ent.Value{*id} } } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *WeaponMutation) RemovedEdges() []string { edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. func (m *WeaponMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *WeaponMutation) ClearedEdges() []string { edges := make([]string, 0, 1) if m.clearedstat { edges = append(edges, weapon.EdgeStat) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. func (m *WeaponMutation) EdgeCleared(name string) bool { switch name { case weapon.EdgeStat: return m.clearedstat } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. func (m *WeaponMutation) ClearEdge(name string) error { switch name { case weapon.EdgeStat: m.ClearStat() return nil } return fmt.Errorf("unknown Weapon 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 *WeaponMutation) ResetEdge(name string) error { switch name { case weapon.EdgeStat: m.ResetStat() return nil } return fmt.Errorf("unknown Weapon edge %s", name) }