added roundstats with eco info, switched to avatar hash
This commit is contained in:
825
ent/mutation.go
825
ent/mutation.go
@@ -7,6 +7,7 @@ import (
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/predicate"
|
||||
"csgowtfd/ent/roundstats"
|
||||
"csgowtfd/ent/stats"
|
||||
"csgowtfd/ent/weaponstats"
|
||||
"fmt"
|
||||
@@ -27,6 +28,7 @@ const (
|
||||
// Node types.
|
||||
TypeMatch = "Match"
|
||||
TypePlayer = "Player"
|
||||
TypeRoundStats = "RoundStats"
|
||||
TypeStats = "Stats"
|
||||
TypeWeaponStats = "WeaponStats"
|
||||
)
|
||||
@@ -1310,7 +1312,7 @@ type PlayerMutation struct {
|
||||
typ string
|
||||
id *uint64
|
||||
name *string
|
||||
avatar_url *string
|
||||
avatar *string
|
||||
vanity_url *string
|
||||
vanity_url_real *string
|
||||
vac *bool
|
||||
@@ -1467,53 +1469,53 @@ func (m *PlayerMutation) ResetName() {
|
||||
delete(m.clearedFields, player.FieldName)
|
||||
}
|
||||
|
||||
// SetAvatarURL sets the "avatar_url" field.
|
||||
func (m *PlayerMutation) SetAvatarURL(s string) {
|
||||
m.avatar_url = &s
|
||||
// SetAvatar sets the "avatar" field.
|
||||
func (m *PlayerMutation) SetAvatar(s string) {
|
||||
m.avatar = &s
|
||||
}
|
||||
|
||||
// AvatarURL returns the value of the "avatar_url" field in the mutation.
|
||||
func (m *PlayerMutation) AvatarURL() (r string, exists bool) {
|
||||
v := m.avatar_url
|
||||
// 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
|
||||
}
|
||||
|
||||
// OldAvatarURL returns the old "avatar_url" field's value of the Player entity.
|
||||
// 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) OldAvatarURL(ctx context.Context) (v string, err error) {
|
||||
func (m *PlayerMutation) OldAvatar(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldAvatarURL is only allowed on UpdateOne operations")
|
||||
return v, fmt.Errorf("OldAvatar is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldAvatarURL requires an ID field in the mutation")
|
||||
return v, fmt.Errorf("OldAvatar requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldAvatarURL: %w", err)
|
||||
return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
|
||||
}
|
||||
return oldValue.AvatarURL, nil
|
||||
return oldValue.Avatar, nil
|
||||
}
|
||||
|
||||
// ClearAvatarURL clears the value of the "avatar_url" field.
|
||||
func (m *PlayerMutation) ClearAvatarURL() {
|
||||
m.avatar_url = nil
|
||||
m.clearedFields[player.FieldAvatarURL] = struct{}{}
|
||||
// ClearAvatar clears the value of the "avatar" field.
|
||||
func (m *PlayerMutation) ClearAvatar() {
|
||||
m.avatar = nil
|
||||
m.clearedFields[player.FieldAvatar] = struct{}{}
|
||||
}
|
||||
|
||||
// AvatarURLCleared returns if the "avatar_url" field was cleared in this mutation.
|
||||
func (m *PlayerMutation) AvatarURLCleared() bool {
|
||||
_, ok := m.clearedFields[player.FieldAvatarURL]
|
||||
// AvatarCleared returns if the "avatar" field was cleared in this mutation.
|
||||
func (m *PlayerMutation) AvatarCleared() bool {
|
||||
_, ok := m.clearedFields[player.FieldAvatar]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetAvatarURL resets all changes to the "avatar_url" field.
|
||||
func (m *PlayerMutation) ResetAvatarURL() {
|
||||
m.avatar_url = nil
|
||||
delete(m.clearedFields, player.FieldAvatarURL)
|
||||
// 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.
|
||||
@@ -2083,8 +2085,8 @@ func (m *PlayerMutation) Fields() []string {
|
||||
if m.name != nil {
|
||||
fields = append(fields, player.FieldName)
|
||||
}
|
||||
if m.avatar_url != nil {
|
||||
fields = append(fields, player.FieldAvatarURL)
|
||||
if m.avatar != nil {
|
||||
fields = append(fields, player.FieldAvatar)
|
||||
}
|
||||
if m.vanity_url != nil {
|
||||
fields = append(fields, player.FieldVanityURL)
|
||||
@@ -2123,8 +2125,8 @@ func (m *PlayerMutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case player.FieldName:
|
||||
return m.Name()
|
||||
case player.FieldAvatarURL:
|
||||
return m.AvatarURL()
|
||||
case player.FieldAvatar:
|
||||
return m.Avatar()
|
||||
case player.FieldVanityURL:
|
||||
return m.VanityURL()
|
||||
case player.FieldVanityURLReal:
|
||||
@@ -2154,8 +2156,8 @@ func (m *PlayerMutation) OldField(ctx context.Context, name string) (ent.Value,
|
||||
switch name {
|
||||
case player.FieldName:
|
||||
return m.OldName(ctx)
|
||||
case player.FieldAvatarURL:
|
||||
return m.OldAvatarURL(ctx)
|
||||
case player.FieldAvatar:
|
||||
return m.OldAvatar(ctx)
|
||||
case player.FieldVanityURL:
|
||||
return m.OldVanityURL(ctx)
|
||||
case player.FieldVanityURLReal:
|
||||
@@ -2190,12 +2192,12 @@ func (m *PlayerMutation) SetField(name string, value ent.Value) error {
|
||||
}
|
||||
m.SetName(v)
|
||||
return nil
|
||||
case player.FieldAvatarURL:
|
||||
case player.FieldAvatar:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetAvatarURL(v)
|
||||
m.SetAvatar(v)
|
||||
return nil
|
||||
case player.FieldVanityURL:
|
||||
v, ok := value.(string)
|
||||
@@ -2308,8 +2310,8 @@ func (m *PlayerMutation) ClearedFields() []string {
|
||||
if m.FieldCleared(player.FieldName) {
|
||||
fields = append(fields, player.FieldName)
|
||||
}
|
||||
if m.FieldCleared(player.FieldAvatarURL) {
|
||||
fields = append(fields, player.FieldAvatarURL)
|
||||
if m.FieldCleared(player.FieldAvatar) {
|
||||
fields = append(fields, player.FieldAvatar)
|
||||
}
|
||||
if m.FieldCleared(player.FieldVanityURL) {
|
||||
fields = append(fields, player.FieldVanityURL)
|
||||
@@ -2349,8 +2351,8 @@ func (m *PlayerMutation) ClearField(name string) error {
|
||||
case player.FieldName:
|
||||
m.ClearName()
|
||||
return nil
|
||||
case player.FieldAvatarURL:
|
||||
m.ClearAvatarURL()
|
||||
case player.FieldAvatar:
|
||||
m.ClearAvatar()
|
||||
return nil
|
||||
case player.FieldVanityURL:
|
||||
m.ClearVanityURL()
|
||||
@@ -2384,8 +2386,8 @@ func (m *PlayerMutation) ResetField(name string) error {
|
||||
case player.FieldName:
|
||||
m.ResetName()
|
||||
return nil
|
||||
case player.FieldAvatarURL:
|
||||
m.ResetAvatarURL()
|
||||
case player.FieldAvatar:
|
||||
m.ResetAvatar()
|
||||
return nil
|
||||
case player.FieldVanityURL:
|
||||
m.ResetVanityURL()
|
||||
@@ -2528,6 +2530,664 @@ func (m *PlayerMutation) ResetEdge(name string) error {
|
||||
return fmt.Errorf("unknown Player edge %s", name)
|
||||
}
|
||||
|
||||
// RoundStatsMutation represents an operation that mutates the RoundStats nodes in the graph.
|
||||
type RoundStatsMutation struct {
|
||||
config
|
||||
op Op
|
||||
typ string
|
||||
id *int
|
||||
round *uint
|
||||
addround *uint
|
||||
bank *uint
|
||||
addbank *uint
|
||||
equipment *uint
|
||||
addequipment *uint
|
||||
spent *uint
|
||||
addspent *uint
|
||||
clearedFields map[string]struct{}
|
||||
stat *int
|
||||
clearedstat bool
|
||||
done bool
|
||||
oldValue func(context.Context) (*RoundStats, error)
|
||||
predicates []predicate.RoundStats
|
||||
}
|
||||
|
||||
var _ ent.Mutation = (*RoundStatsMutation)(nil)
|
||||
|
||||
// roundstatsOption allows management of the mutation configuration using functional options.
|
||||
type roundstatsOption func(*RoundStatsMutation)
|
||||
|
||||
// newRoundStatsMutation creates new mutation for the RoundStats entity.
|
||||
func newRoundStatsMutation(c config, op Op, opts ...roundstatsOption) *RoundStatsMutation {
|
||||
m := &RoundStatsMutation{
|
||||
config: c,
|
||||
op: op,
|
||||
typ: TypeRoundStats,
|
||||
clearedFields: make(map[string]struct{}),
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(m)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
// withRoundStatsID sets the ID field of the mutation.
|
||||
func withRoundStatsID(id int) roundstatsOption {
|
||||
return func(m *RoundStatsMutation) {
|
||||
var (
|
||||
err error
|
||||
once sync.Once
|
||||
value *RoundStats
|
||||
)
|
||||
m.oldValue = func(ctx context.Context) (*RoundStats, error) {
|
||||
once.Do(func() {
|
||||
if m.done {
|
||||
err = fmt.Errorf("querying old values post mutation is not allowed")
|
||||
} else {
|
||||
value, err = m.Client().RoundStats.Get(ctx, id)
|
||||
}
|
||||
})
|
||||
return value, err
|
||||
}
|
||||
m.id = &id
|
||||
}
|
||||
}
|
||||
|
||||
// withRoundStats sets the old RoundStats of the mutation.
|
||||
func withRoundStats(node *RoundStats) roundstatsOption {
|
||||
return func(m *RoundStatsMutation) {
|
||||
m.oldValue = func(context.Context) (*RoundStats, error) {
|
||||
return node, nil
|
||||
}
|
||||
m.id = &node.ID
|
||||
}
|
||||
}
|
||||
|
||||
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
||||
// executed in a transaction (ent.Tx), a transactional client is returned.
|
||||
func (m RoundStatsMutation) Client() *Client {
|
||||
client := &Client{config: m.config}
|
||||
client.init()
|
||||
return client
|
||||
}
|
||||
|
||||
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
||||
// it returns an error otherwise.
|
||||
func (m RoundStatsMutation) Tx() (*Tx, error) {
|
||||
if _, ok := m.driver.(*txDriver); !ok {
|
||||
return nil, fmt.Errorf("ent: mutation is not running in a transaction")
|
||||
}
|
||||
tx := &Tx{config: m.config}
|
||||
tx.init()
|
||||
return tx, nil
|
||||
}
|
||||
|
||||
// ID returns the ID value in the mutation. Note that the ID is only available
|
||||
// if it was provided to the builder or after it was returned from the database.
|
||||
func (m *RoundStatsMutation) ID() (id int, exists bool) {
|
||||
if m.id == nil {
|
||||
return
|
||||
}
|
||||
return *m.id, true
|
||||
}
|
||||
|
||||
// SetRound sets the "round" field.
|
||||
func (m *RoundStatsMutation) SetRound(u uint) {
|
||||
m.round = &u
|
||||
m.addround = nil
|
||||
}
|
||||
|
||||
// Round returns the value of the "round" field in the mutation.
|
||||
func (m *RoundStatsMutation) Round() (r uint, exists bool) {
|
||||
v := m.round
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldRound returns the old "round" field's value of the RoundStats entity.
|
||||
// If the RoundStats object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *RoundStatsMutation) OldRound(ctx context.Context) (v uint, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldRound is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldRound requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldRound: %w", err)
|
||||
}
|
||||
return oldValue.Round, nil
|
||||
}
|
||||
|
||||
// AddRound adds u to the "round" field.
|
||||
func (m *RoundStatsMutation) AddRound(u uint) {
|
||||
if m.addround != nil {
|
||||
*m.addround += u
|
||||
} else {
|
||||
m.addround = &u
|
||||
}
|
||||
}
|
||||
|
||||
// AddedRound returns the value that was added to the "round" field in this mutation.
|
||||
func (m *RoundStatsMutation) AddedRound() (r uint, exists bool) {
|
||||
v := m.addround
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ResetRound resets all changes to the "round" field.
|
||||
func (m *RoundStatsMutation) ResetRound() {
|
||||
m.round = nil
|
||||
m.addround = nil
|
||||
}
|
||||
|
||||
// SetBank sets the "bank" field.
|
||||
func (m *RoundStatsMutation) SetBank(u uint) {
|
||||
m.bank = &u
|
||||
m.addbank = nil
|
||||
}
|
||||
|
||||
// Bank returns the value of the "bank" field in the mutation.
|
||||
func (m *RoundStatsMutation) Bank() (r uint, exists bool) {
|
||||
v := m.bank
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldBank returns the old "bank" field's value of the RoundStats entity.
|
||||
// If the RoundStats object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *RoundStatsMutation) OldBank(ctx context.Context) (v uint, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldBank is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldBank requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldBank: %w", err)
|
||||
}
|
||||
return oldValue.Bank, nil
|
||||
}
|
||||
|
||||
// AddBank adds u to the "bank" field.
|
||||
func (m *RoundStatsMutation) AddBank(u uint) {
|
||||
if m.addbank != nil {
|
||||
*m.addbank += u
|
||||
} else {
|
||||
m.addbank = &u
|
||||
}
|
||||
}
|
||||
|
||||
// AddedBank returns the value that was added to the "bank" field in this mutation.
|
||||
func (m *RoundStatsMutation) AddedBank() (r uint, exists bool) {
|
||||
v := m.addbank
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ResetBank resets all changes to the "bank" field.
|
||||
func (m *RoundStatsMutation) ResetBank() {
|
||||
m.bank = nil
|
||||
m.addbank = nil
|
||||
}
|
||||
|
||||
// SetEquipment sets the "equipment" field.
|
||||
func (m *RoundStatsMutation) SetEquipment(u uint) {
|
||||
m.equipment = &u
|
||||
m.addequipment = nil
|
||||
}
|
||||
|
||||
// Equipment returns the value of the "equipment" field in the mutation.
|
||||
func (m *RoundStatsMutation) Equipment() (r uint, exists bool) {
|
||||
v := m.equipment
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldEquipment returns the old "equipment" field's value of the RoundStats entity.
|
||||
// If the RoundStats object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *RoundStatsMutation) OldEquipment(ctx context.Context) (v uint, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldEquipment is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldEquipment requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldEquipment: %w", err)
|
||||
}
|
||||
return oldValue.Equipment, nil
|
||||
}
|
||||
|
||||
// AddEquipment adds u to the "equipment" field.
|
||||
func (m *RoundStatsMutation) AddEquipment(u uint) {
|
||||
if m.addequipment != nil {
|
||||
*m.addequipment += u
|
||||
} else {
|
||||
m.addequipment = &u
|
||||
}
|
||||
}
|
||||
|
||||
// AddedEquipment returns the value that was added to the "equipment" field in this mutation.
|
||||
func (m *RoundStatsMutation) AddedEquipment() (r uint, exists bool) {
|
||||
v := m.addequipment
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ResetEquipment resets all changes to the "equipment" field.
|
||||
func (m *RoundStatsMutation) ResetEquipment() {
|
||||
m.equipment = nil
|
||||
m.addequipment = nil
|
||||
}
|
||||
|
||||
// SetSpent sets the "spent" field.
|
||||
func (m *RoundStatsMutation) SetSpent(u uint) {
|
||||
m.spent = &u
|
||||
m.addspent = nil
|
||||
}
|
||||
|
||||
// Spent returns the value of the "spent" field in the mutation.
|
||||
func (m *RoundStatsMutation) Spent() (r uint, exists bool) {
|
||||
v := m.spent
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldSpent returns the old "spent" field's value of the RoundStats entity.
|
||||
// If the RoundStats object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *RoundStatsMutation) OldSpent(ctx context.Context) (v uint, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldSpent is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldSpent requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldSpent: %w", err)
|
||||
}
|
||||
return oldValue.Spent, nil
|
||||
}
|
||||
|
||||
// AddSpent adds u to the "spent" field.
|
||||
func (m *RoundStatsMutation) AddSpent(u uint) {
|
||||
if m.addspent != nil {
|
||||
*m.addspent += u
|
||||
} else {
|
||||
m.addspent = &u
|
||||
}
|
||||
}
|
||||
|
||||
// AddedSpent returns the value that was added to the "spent" field in this mutation.
|
||||
func (m *RoundStatsMutation) AddedSpent() (r uint, exists bool) {
|
||||
v := m.addspent
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ResetSpent resets all changes to the "spent" field.
|
||||
func (m *RoundStatsMutation) ResetSpent() {
|
||||
m.spent = nil
|
||||
m.addspent = nil
|
||||
}
|
||||
|
||||
// SetStatID sets the "stat" edge to the Stats entity by id.
|
||||
func (m *RoundStatsMutation) SetStatID(id int) {
|
||||
m.stat = &id
|
||||
}
|
||||
|
||||
// ClearStat clears the "stat" edge to the Stats entity.
|
||||
func (m *RoundStatsMutation) ClearStat() {
|
||||
m.clearedstat = true
|
||||
}
|
||||
|
||||
// StatCleared reports if the "stat" edge to the Stats entity was cleared.
|
||||
func (m *RoundStatsMutation) StatCleared() bool {
|
||||
return m.clearedstat
|
||||
}
|
||||
|
||||
// StatID returns the "stat" edge ID in the mutation.
|
||||
func (m *RoundStatsMutation) StatID() (id int, exists bool) {
|
||||
if m.stat != nil {
|
||||
return *m.stat, true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// StatIDs returns the "stat" edge IDs in the mutation.
|
||||
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
||||
// StatID instead. It exists only for internal usage by the builders.
|
||||
func (m *RoundStatsMutation) StatIDs() (ids []int) {
|
||||
if id := m.stat; id != nil {
|
||||
ids = append(ids, *id)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ResetStat resets all changes to the "stat" edge.
|
||||
func (m *RoundStatsMutation) ResetStat() {
|
||||
m.stat = nil
|
||||
m.clearedstat = false
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the RoundStatsMutation builder.
|
||||
func (m *RoundStatsMutation) Where(ps ...predicate.RoundStats) {
|
||||
m.predicates = append(m.predicates, ps...)
|
||||
}
|
||||
|
||||
// Op returns the operation name.
|
||||
func (m *RoundStatsMutation) Op() Op {
|
||||
return m.op
|
||||
}
|
||||
|
||||
// Type returns the node type of this mutation (RoundStats).
|
||||
func (m *RoundStatsMutation) Type() string {
|
||||
return m.typ
|
||||
}
|
||||
|
||||
// Fields returns all fields that were changed during this mutation. Note that in
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *RoundStatsMutation) Fields() []string {
|
||||
fields := make([]string, 0, 4)
|
||||
if m.round != nil {
|
||||
fields = append(fields, roundstats.FieldRound)
|
||||
}
|
||||
if m.bank != nil {
|
||||
fields = append(fields, roundstats.FieldBank)
|
||||
}
|
||||
if m.equipment != nil {
|
||||
fields = append(fields, roundstats.FieldEquipment)
|
||||
}
|
||||
if m.spent != nil {
|
||||
fields = append(fields, roundstats.FieldSpent)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
// Field returns the value of a field with the given name. The second boolean
|
||||
// return value indicates that this field was not set, or was not defined in the
|
||||
// schema.
|
||||
func (m *RoundStatsMutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case roundstats.FieldRound:
|
||||
return m.Round()
|
||||
case roundstats.FieldBank:
|
||||
return m.Bank()
|
||||
case roundstats.FieldEquipment:
|
||||
return m.Equipment()
|
||||
case roundstats.FieldSpent:
|
||||
return m.Spent()
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// OldField returns the old value of the field from the database. An error is
|
||||
// returned if the mutation operation is not UpdateOne, or the query to the
|
||||
// database failed.
|
||||
func (m *RoundStatsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||
switch name {
|
||||
case roundstats.FieldRound:
|
||||
return m.OldRound(ctx)
|
||||
case roundstats.FieldBank:
|
||||
return m.OldBank(ctx)
|
||||
case roundstats.FieldEquipment:
|
||||
return m.OldEquipment(ctx)
|
||||
case roundstats.FieldSpent:
|
||||
return m.OldSpent(ctx)
|
||||
}
|
||||
return nil, fmt.Errorf("unknown RoundStats field %s", name)
|
||||
}
|
||||
|
||||
// SetField sets the value of a field with the given name. It returns an error if
|
||||
// the field is not defined in the schema, or if the type mismatched the field
|
||||
// type.
|
||||
func (m *RoundStatsMutation) SetField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case roundstats.FieldRound:
|
||||
v, ok := value.(uint)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetRound(v)
|
||||
return nil
|
||||
case roundstats.FieldBank:
|
||||
v, ok := value.(uint)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetBank(v)
|
||||
return nil
|
||||
case roundstats.FieldEquipment:
|
||||
v, ok := value.(uint)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetEquipment(v)
|
||||
return nil
|
||||
case roundstats.FieldSpent:
|
||||
v, ok := value.(uint)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetSpent(v)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown RoundStats field %s", name)
|
||||
}
|
||||
|
||||
// AddedFields returns all numeric fields that were incremented/decremented during
|
||||
// this mutation.
|
||||
func (m *RoundStatsMutation) AddedFields() []string {
|
||||
var fields []string
|
||||
if m.addround != nil {
|
||||
fields = append(fields, roundstats.FieldRound)
|
||||
}
|
||||
if m.addbank != nil {
|
||||
fields = append(fields, roundstats.FieldBank)
|
||||
}
|
||||
if m.addequipment != nil {
|
||||
fields = append(fields, roundstats.FieldEquipment)
|
||||
}
|
||||
if m.addspent != nil {
|
||||
fields = append(fields, roundstats.FieldSpent)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
// AddedField returns the numeric value that was incremented/decremented on a field
|
||||
// with the given name. The second boolean return value indicates that this field
|
||||
// was not set, or was not defined in the schema.
|
||||
func (m *RoundStatsMutation) AddedField(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case roundstats.FieldRound:
|
||||
return m.AddedRound()
|
||||
case roundstats.FieldBank:
|
||||
return m.AddedBank()
|
||||
case roundstats.FieldEquipment:
|
||||
return m.AddedEquipment()
|
||||
case roundstats.FieldSpent:
|
||||
return m.AddedSpent()
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// AddField adds the value to the field with the given name. It returns an error if
|
||||
// the field is not defined in the schema, or if the type mismatched the field
|
||||
// type.
|
||||
func (m *RoundStatsMutation) AddField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case roundstats.FieldRound:
|
||||
v, ok := value.(uint)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.AddRound(v)
|
||||
return nil
|
||||
case roundstats.FieldBank:
|
||||
v, ok := value.(uint)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.AddBank(v)
|
||||
return nil
|
||||
case roundstats.FieldEquipment:
|
||||
v, ok := value.(uint)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.AddEquipment(v)
|
||||
return nil
|
||||
case roundstats.FieldSpent:
|
||||
v, ok := value.(uint)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.AddSpent(v)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown RoundStats numeric field %s", name)
|
||||
}
|
||||
|
||||
// ClearedFields returns all nullable fields that were cleared during this
|
||||
// mutation.
|
||||
func (m *RoundStatsMutation) ClearedFields() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
// FieldCleared returns a boolean indicating if a field with the given name was
|
||||
// cleared in this mutation.
|
||||
func (m *RoundStatsMutation) FieldCleared(name string) bool {
|
||||
_, ok := m.clearedFields[name]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ClearField clears the value of the field with the given name. It returns an
|
||||
// error if the field is not defined in the schema.
|
||||
func (m *RoundStatsMutation) ClearField(name string) error {
|
||||
return fmt.Errorf("unknown RoundStats nullable field %s", name)
|
||||
}
|
||||
|
||||
// ResetField resets all changes in the mutation for the field with the given name.
|
||||
// It returns an error if the field is not defined in the schema.
|
||||
func (m *RoundStatsMutation) ResetField(name string) error {
|
||||
switch name {
|
||||
case roundstats.FieldRound:
|
||||
m.ResetRound()
|
||||
return nil
|
||||
case roundstats.FieldBank:
|
||||
m.ResetBank()
|
||||
return nil
|
||||
case roundstats.FieldEquipment:
|
||||
m.ResetEquipment()
|
||||
return nil
|
||||
case roundstats.FieldSpent:
|
||||
m.ResetSpent()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown RoundStats field %s", name)
|
||||
}
|
||||
|
||||
// AddedEdges returns all edge names that were set/added in this mutation.
|
||||
func (m *RoundStatsMutation) AddedEdges() []string {
|
||||
edges := make([]string, 0, 1)
|
||||
if m.stat != nil {
|
||||
edges = append(edges, roundstats.EdgeStat)
|
||||
}
|
||||
return edges
|
||||
}
|
||||
|
||||
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
||||
// name in this mutation.
|
||||
func (m *RoundStatsMutation) AddedIDs(name string) []ent.Value {
|
||||
switch name {
|
||||
case roundstats.EdgeStat:
|
||||
if id := m.stat; id != nil {
|
||||
return []ent.Value{*id}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemovedEdges returns all edge names that were removed in this mutation.
|
||||
func (m *RoundStatsMutation) RemovedEdges() []string {
|
||||
edges := make([]string, 0, 1)
|
||||
return edges
|
||||
}
|
||||
|
||||
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
||||
// the given name in this mutation.
|
||||
func (m *RoundStatsMutation) RemovedIDs(name string) []ent.Value {
|
||||
switch name {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ClearedEdges returns all edge names that were cleared in this mutation.
|
||||
func (m *RoundStatsMutation) ClearedEdges() []string {
|
||||
edges := make([]string, 0, 1)
|
||||
if m.clearedstat {
|
||||
edges = append(edges, roundstats.EdgeStat)
|
||||
}
|
||||
return edges
|
||||
}
|
||||
|
||||
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
||||
// was cleared in this mutation.
|
||||
func (m *RoundStatsMutation) EdgeCleared(name string) bool {
|
||||
switch name {
|
||||
case roundstats.EdgeStat:
|
||||
return m.clearedstat
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ClearEdge clears the value of the edge with the given name. It returns an error
|
||||
// if that edge is not defined in the schema.
|
||||
func (m *RoundStatsMutation) ClearEdge(name string) error {
|
||||
switch name {
|
||||
case roundstats.EdgeStat:
|
||||
m.ClearStat()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown RoundStats unique edge %s", name)
|
||||
}
|
||||
|
||||
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
||||
// It returns an error if the edge is not defined in the schema.
|
||||
func (m *RoundStatsMutation) ResetEdge(name string) error {
|
||||
switch name {
|
||||
case roundstats.EdgeStat:
|
||||
m.ResetStat()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown RoundStats edge %s", name)
|
||||
}
|
||||
|
||||
// StatsMutation represents an operation that mutates the Stats nodes in the graph.
|
||||
type StatsMutation struct {
|
||||
config
|
||||
@@ -2614,6 +3274,9 @@ type StatsMutation struct {
|
||||
weapon_stats map[int]struct{}
|
||||
removedweapon_stats map[int]struct{}
|
||||
clearedweapon_stats bool
|
||||
round_stats map[int]struct{}
|
||||
removedround_stats map[int]struct{}
|
||||
clearedround_stats bool
|
||||
done bool
|
||||
oldValue func(context.Context) (*Stats, error)
|
||||
predicates []predicate.Stats
|
||||
@@ -5378,6 +6041,60 @@ func (m *StatsMutation) ResetWeaponStats() {
|
||||
m.removedweapon_stats = nil
|
||||
}
|
||||
|
||||
// AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by ids.
|
||||
func (m *StatsMutation) AddRoundStatIDs(ids ...int) {
|
||||
if m.round_stats == nil {
|
||||
m.round_stats = make(map[int]struct{})
|
||||
}
|
||||
for i := range ids {
|
||||
m.round_stats[ids[i]] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
// ClearRoundStats clears the "round_stats" edge to the RoundStats entity.
|
||||
func (m *StatsMutation) ClearRoundStats() {
|
||||
m.clearedround_stats = true
|
||||
}
|
||||
|
||||
// RoundStatsCleared reports if the "round_stats" edge to the RoundStats entity was cleared.
|
||||
func (m *StatsMutation) RoundStatsCleared() bool {
|
||||
return m.clearedround_stats
|
||||
}
|
||||
|
||||
// RemoveRoundStatIDs removes the "round_stats" edge to the RoundStats entity by IDs.
|
||||
func (m *StatsMutation) RemoveRoundStatIDs(ids ...int) {
|
||||
if m.removedround_stats == nil {
|
||||
m.removedround_stats = make(map[int]struct{})
|
||||
}
|
||||
for i := range ids {
|
||||
delete(m.round_stats, ids[i])
|
||||
m.removedround_stats[ids[i]] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
// RemovedRoundStats returns the removed IDs of the "round_stats" edge to the RoundStats entity.
|
||||
func (m *StatsMutation) RemovedRoundStatsIDs() (ids []int) {
|
||||
for id := range m.removedround_stats {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// RoundStatsIDs returns the "round_stats" edge IDs in the mutation.
|
||||
func (m *StatsMutation) RoundStatsIDs() (ids []int) {
|
||||
for id := range m.round_stats {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ResetRoundStats resets all changes to the "round_stats" edge.
|
||||
func (m *StatsMutation) ResetRoundStats() {
|
||||
m.round_stats = nil
|
||||
m.clearedround_stats = false
|
||||
m.removedround_stats = nil
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the StatsMutation builder.
|
||||
func (m *StatsMutation) Where(ps ...predicate.Stats) {
|
||||
m.predicates = append(m.predicates, ps...)
|
||||
@@ -6760,7 +7477,7 @@ func (m *StatsMutation) ResetField(name string) error {
|
||||
|
||||
// AddedEdges returns all edge names that were set/added in this mutation.
|
||||
func (m *StatsMutation) AddedEdges() []string {
|
||||
edges := make([]string, 0, 3)
|
||||
edges := make([]string, 0, 4)
|
||||
if m.matches != nil {
|
||||
edges = append(edges, stats.EdgeMatches)
|
||||
}
|
||||
@@ -6770,6 +7487,9 @@ func (m *StatsMutation) AddedEdges() []string {
|
||||
if m.weapon_stats != nil {
|
||||
edges = append(edges, stats.EdgeWeaponStats)
|
||||
}
|
||||
if m.round_stats != nil {
|
||||
edges = append(edges, stats.EdgeRoundStats)
|
||||
}
|
||||
return edges
|
||||
}
|
||||
|
||||
@@ -6791,16 +7511,25 @@ func (m *StatsMutation) AddedIDs(name string) []ent.Value {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return ids
|
||||
case stats.EdgeRoundStats:
|
||||
ids := make([]ent.Value, 0, len(m.round_stats))
|
||||
for id := range m.round_stats {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemovedEdges returns all edge names that were removed in this mutation.
|
||||
func (m *StatsMutation) RemovedEdges() []string {
|
||||
edges := make([]string, 0, 3)
|
||||
edges := make([]string, 0, 4)
|
||||
if m.removedweapon_stats != nil {
|
||||
edges = append(edges, stats.EdgeWeaponStats)
|
||||
}
|
||||
if m.removedround_stats != nil {
|
||||
edges = append(edges, stats.EdgeRoundStats)
|
||||
}
|
||||
return edges
|
||||
}
|
||||
|
||||
@@ -6814,13 +7543,19 @@ func (m *StatsMutation) RemovedIDs(name string) []ent.Value {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return ids
|
||||
case stats.EdgeRoundStats:
|
||||
ids := make([]ent.Value, 0, len(m.removedround_stats))
|
||||
for id := range m.removedround_stats {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ClearedEdges returns all edge names that were cleared in this mutation.
|
||||
func (m *StatsMutation) ClearedEdges() []string {
|
||||
edges := make([]string, 0, 3)
|
||||
edges := make([]string, 0, 4)
|
||||
if m.clearedmatches {
|
||||
edges = append(edges, stats.EdgeMatches)
|
||||
}
|
||||
@@ -6830,6 +7565,9 @@ func (m *StatsMutation) ClearedEdges() []string {
|
||||
if m.clearedweapon_stats {
|
||||
edges = append(edges, stats.EdgeWeaponStats)
|
||||
}
|
||||
if m.clearedround_stats {
|
||||
edges = append(edges, stats.EdgeRoundStats)
|
||||
}
|
||||
return edges
|
||||
}
|
||||
|
||||
@@ -6843,6 +7581,8 @@ func (m *StatsMutation) EdgeCleared(name string) bool {
|
||||
return m.clearedplayers
|
||||
case stats.EdgeWeaponStats:
|
||||
return m.clearedweapon_stats
|
||||
case stats.EdgeRoundStats:
|
||||
return m.clearedround_stats
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -6874,6 +7614,9 @@ func (m *StatsMutation) ResetEdge(name string) error {
|
||||
case stats.EdgeWeaponStats:
|
||||
m.ResetWeaponStats()
|
||||
return nil
|
||||
case stats.EdgeRoundStats:
|
||||
m.ResetRoundStats()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Stats edge %s", name)
|
||||
}
|
||||
|
Reference in New Issue
Block a user