1539 lines
43 KiB
Go
1539 lines
43 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
|
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
|
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
|
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
|
)
|
|
|
|
// PlayerUpdate is the builder for updating Player entities.
|
|
type PlayerUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *PlayerMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// Where appends a list predicates to the PlayerUpdate builder.
|
|
func (pu *PlayerUpdate) Where(ps ...predicate.Player) *PlayerUpdate {
|
|
pu.mutation.Where(ps...)
|
|
return pu
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (pu *PlayerUpdate) SetName(s string) *PlayerUpdate {
|
|
pu.mutation.SetName(s)
|
|
return pu
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (pu *PlayerUpdate) SetNillableName(s *string) *PlayerUpdate {
|
|
if s != nil {
|
|
pu.SetName(*s)
|
|
}
|
|
return pu
|
|
}
|
|
|
|
// ClearName clears the value of the "name" field.
|
|
func (pu *PlayerUpdate) ClearName() *PlayerUpdate {
|
|
pu.mutation.ClearName()
|
|
return pu
|
|
}
|
|
|
|
// SetAvatar sets the "avatar" field.
|
|
func (pu *PlayerUpdate) SetAvatar(s string) *PlayerUpdate {
|
|
pu.mutation.SetAvatar(s)
|
|
return pu
|
|
}
|
|
|
|
// SetNillableAvatar sets the "avatar" field if the given value is not nil.
|
|
func (pu *PlayerUpdate) SetNillableAvatar(s *string) *PlayerUpdate {
|
|
if s != nil {
|
|
pu.SetAvatar(*s)
|
|
}
|
|
return pu
|
|
}
|
|
|
|
// ClearAvatar clears the value of the "avatar" field.
|
|
func (pu *PlayerUpdate) ClearAvatar() *PlayerUpdate {
|
|
pu.mutation.ClearAvatar()
|
|
return pu
|
|
}
|
|
|
|
// SetVanityURL sets the "vanity_url" field.
|
|
func (pu *PlayerUpdate) SetVanityURL(s string) *PlayerUpdate {
|
|
pu.mutation.SetVanityURL(s)
|
|
return pu
|
|
}
|
|
|
|
// SetNillableVanityURL sets the "vanity_url" field if the given value is not nil.
|
|
func (pu *PlayerUpdate) SetNillableVanityURL(s *string) *PlayerUpdate {
|
|
if s != nil {
|
|
pu.SetVanityURL(*s)
|
|
}
|
|
return pu
|
|
}
|
|
|
|
// ClearVanityURL clears the value of the "vanity_url" field.
|
|
func (pu *PlayerUpdate) ClearVanityURL() *PlayerUpdate {
|
|
pu.mutation.ClearVanityURL()
|
|
return pu
|
|
}
|
|
|
|
// SetVanityURLReal sets the "vanity_url_real" field.
|
|
func (pu *PlayerUpdate) SetVanityURLReal(s string) *PlayerUpdate {
|
|
pu.mutation.SetVanityURLReal(s)
|
|
return pu
|
|
}
|
|
|
|
// SetNillableVanityURLReal sets the "vanity_url_real" field if the given value is not nil.
|
|
func (pu *PlayerUpdate) SetNillableVanityURLReal(s *string) *PlayerUpdate {
|
|
if s != nil {
|
|
pu.SetVanityURLReal(*s)
|
|
}
|
|
return pu
|
|
}
|
|
|
|
// ClearVanityURLReal clears the value of the "vanity_url_real" field.
|
|
func (pu *PlayerUpdate) ClearVanityURLReal() *PlayerUpdate {
|
|
pu.mutation.ClearVanityURLReal()
|
|
return pu
|
|
}
|
|
|
|
// SetVacDate sets the "vac_date" field.
|
|
func (pu *PlayerUpdate) SetVacDate(t time.Time) *PlayerUpdate {
|
|
pu.mutation.SetVacDate(t)
|
|
return pu
|
|
}
|
|
|
|
// SetNillableVacDate sets the "vac_date" field if the given value is not nil.
|
|
func (pu *PlayerUpdate) SetNillableVacDate(t *time.Time) *PlayerUpdate {
|
|
if t != nil {
|
|
pu.SetVacDate(*t)
|
|
}
|
|
return pu
|
|
}
|
|
|
|
// ClearVacDate clears the value of the "vac_date" field.
|
|
func (pu *PlayerUpdate) ClearVacDate() *PlayerUpdate {
|
|
pu.mutation.ClearVacDate()
|
|
return pu
|
|
}
|
|
|
|
// SetVacCount sets the "vac_count" field.
|
|
func (pu *PlayerUpdate) SetVacCount(i int) *PlayerUpdate {
|
|
pu.mutation.ResetVacCount()
|
|
pu.mutation.SetVacCount(i)
|
|
return pu
|
|
}
|
|
|
|
// SetNillableVacCount sets the "vac_count" field if the given value is not nil.
|
|
func (pu *PlayerUpdate) SetNillableVacCount(i *int) *PlayerUpdate {
|
|
if i != nil {
|
|
pu.SetVacCount(*i)
|
|
}
|
|
return pu
|
|
}
|
|
|
|
// AddVacCount adds i to the "vac_count" field.
|
|
func (pu *PlayerUpdate) AddVacCount(i int) *PlayerUpdate {
|
|
pu.mutation.AddVacCount(i)
|
|
return pu
|
|
}
|
|
|
|
// ClearVacCount clears the value of the "vac_count" field.
|
|
func (pu *PlayerUpdate) ClearVacCount() *PlayerUpdate {
|
|
pu.mutation.ClearVacCount()
|
|
return pu
|
|
}
|
|
|
|
// SetGameBanDate sets the "game_ban_date" field.
|
|
func (pu *PlayerUpdate) SetGameBanDate(t time.Time) *PlayerUpdate {
|
|
pu.mutation.SetGameBanDate(t)
|
|
return pu
|
|
}
|
|
|
|
// SetNillableGameBanDate sets the "game_ban_date" field if the given value is not nil.
|
|
func (pu *PlayerUpdate) SetNillableGameBanDate(t *time.Time) *PlayerUpdate {
|
|
if t != nil {
|
|
pu.SetGameBanDate(*t)
|
|
}
|
|
return pu
|
|
}
|
|
|
|
// ClearGameBanDate clears the value of the "game_ban_date" field.
|
|
func (pu *PlayerUpdate) ClearGameBanDate() *PlayerUpdate {
|
|
pu.mutation.ClearGameBanDate()
|
|
return pu
|
|
}
|
|
|
|
// SetGameBanCount sets the "game_ban_count" field.
|
|
func (pu *PlayerUpdate) SetGameBanCount(i int) *PlayerUpdate {
|
|
pu.mutation.ResetGameBanCount()
|
|
pu.mutation.SetGameBanCount(i)
|
|
return pu
|
|
}
|
|
|
|
// SetNillableGameBanCount sets the "game_ban_count" field if the given value is not nil.
|
|
func (pu *PlayerUpdate) SetNillableGameBanCount(i *int) *PlayerUpdate {
|
|
if i != nil {
|
|
pu.SetGameBanCount(*i)
|
|
}
|
|
return pu
|
|
}
|
|
|
|
// AddGameBanCount adds i to the "game_ban_count" field.
|
|
func (pu *PlayerUpdate) AddGameBanCount(i int) *PlayerUpdate {
|
|
pu.mutation.AddGameBanCount(i)
|
|
return pu
|
|
}
|
|
|
|
// ClearGameBanCount clears the value of the "game_ban_count" field.
|
|
func (pu *PlayerUpdate) ClearGameBanCount() *PlayerUpdate {
|
|
pu.mutation.ClearGameBanCount()
|
|
return pu
|
|
}
|
|
|
|
// SetSteamUpdated sets the "steam_updated" field.
|
|
func (pu *PlayerUpdate) SetSteamUpdated(t time.Time) *PlayerUpdate {
|
|
pu.mutation.SetSteamUpdated(t)
|
|
return pu
|
|
}
|
|
|
|
// SetNillableSteamUpdated sets the "steam_updated" field if the given value is not nil.
|
|
func (pu *PlayerUpdate) SetNillableSteamUpdated(t *time.Time) *PlayerUpdate {
|
|
if t != nil {
|
|
pu.SetSteamUpdated(*t)
|
|
}
|
|
return pu
|
|
}
|
|
|
|
// SetSharecodeUpdated sets the "sharecode_updated" field.
|
|
func (pu *PlayerUpdate) SetSharecodeUpdated(t time.Time) *PlayerUpdate {
|
|
pu.mutation.SetSharecodeUpdated(t)
|
|
return pu
|
|
}
|
|
|
|
// SetNillableSharecodeUpdated sets the "sharecode_updated" field if the given value is not nil.
|
|
func (pu *PlayerUpdate) SetNillableSharecodeUpdated(t *time.Time) *PlayerUpdate {
|
|
if t != nil {
|
|
pu.SetSharecodeUpdated(*t)
|
|
}
|
|
return pu
|
|
}
|
|
|
|
// ClearSharecodeUpdated clears the value of the "sharecode_updated" field.
|
|
func (pu *PlayerUpdate) ClearSharecodeUpdated() *PlayerUpdate {
|
|
pu.mutation.ClearSharecodeUpdated()
|
|
return pu
|
|
}
|
|
|
|
// SetAuthCode sets the "auth_code" field.
|
|
func (pu *PlayerUpdate) SetAuthCode(s string) *PlayerUpdate {
|
|
pu.mutation.SetAuthCode(s)
|
|
return pu
|
|
}
|
|
|
|
// SetNillableAuthCode sets the "auth_code" field if the given value is not nil.
|
|
func (pu *PlayerUpdate) SetNillableAuthCode(s *string) *PlayerUpdate {
|
|
if s != nil {
|
|
pu.SetAuthCode(*s)
|
|
}
|
|
return pu
|
|
}
|
|
|
|
// ClearAuthCode clears the value of the "auth_code" field.
|
|
func (pu *PlayerUpdate) ClearAuthCode() *PlayerUpdate {
|
|
pu.mutation.ClearAuthCode()
|
|
return pu
|
|
}
|
|
|
|
// SetProfileCreated sets the "profile_created" field.
|
|
func (pu *PlayerUpdate) SetProfileCreated(t time.Time) *PlayerUpdate {
|
|
pu.mutation.SetProfileCreated(t)
|
|
return pu
|
|
}
|
|
|
|
// SetNillableProfileCreated sets the "profile_created" field if the given value is not nil.
|
|
func (pu *PlayerUpdate) SetNillableProfileCreated(t *time.Time) *PlayerUpdate {
|
|
if t != nil {
|
|
pu.SetProfileCreated(*t)
|
|
}
|
|
return pu
|
|
}
|
|
|
|
// ClearProfileCreated clears the value of the "profile_created" field.
|
|
func (pu *PlayerUpdate) ClearProfileCreated() *PlayerUpdate {
|
|
pu.mutation.ClearProfileCreated()
|
|
return pu
|
|
}
|
|
|
|
// SetOldestSharecodeSeen sets the "oldest_sharecode_seen" field.
|
|
func (pu *PlayerUpdate) SetOldestSharecodeSeen(s string) *PlayerUpdate {
|
|
pu.mutation.SetOldestSharecodeSeen(s)
|
|
return pu
|
|
}
|
|
|
|
// SetNillableOldestSharecodeSeen sets the "oldest_sharecode_seen" field if the given value is not nil.
|
|
func (pu *PlayerUpdate) SetNillableOldestSharecodeSeen(s *string) *PlayerUpdate {
|
|
if s != nil {
|
|
pu.SetOldestSharecodeSeen(*s)
|
|
}
|
|
return pu
|
|
}
|
|
|
|
// ClearOldestSharecodeSeen clears the value of the "oldest_sharecode_seen" field.
|
|
func (pu *PlayerUpdate) ClearOldestSharecodeSeen() *PlayerUpdate {
|
|
pu.mutation.ClearOldestSharecodeSeen()
|
|
return pu
|
|
}
|
|
|
|
// SetWins sets the "wins" field.
|
|
func (pu *PlayerUpdate) SetWins(i int) *PlayerUpdate {
|
|
pu.mutation.ResetWins()
|
|
pu.mutation.SetWins(i)
|
|
return pu
|
|
}
|
|
|
|
// SetNillableWins sets the "wins" field if the given value is not nil.
|
|
func (pu *PlayerUpdate) SetNillableWins(i *int) *PlayerUpdate {
|
|
if i != nil {
|
|
pu.SetWins(*i)
|
|
}
|
|
return pu
|
|
}
|
|
|
|
// AddWins adds i to the "wins" field.
|
|
func (pu *PlayerUpdate) AddWins(i int) *PlayerUpdate {
|
|
pu.mutation.AddWins(i)
|
|
return pu
|
|
}
|
|
|
|
// ClearWins clears the value of the "wins" field.
|
|
func (pu *PlayerUpdate) ClearWins() *PlayerUpdate {
|
|
pu.mutation.ClearWins()
|
|
return pu
|
|
}
|
|
|
|
// SetLooses sets the "looses" field.
|
|
func (pu *PlayerUpdate) SetLooses(i int) *PlayerUpdate {
|
|
pu.mutation.ResetLooses()
|
|
pu.mutation.SetLooses(i)
|
|
return pu
|
|
}
|
|
|
|
// SetNillableLooses sets the "looses" field if the given value is not nil.
|
|
func (pu *PlayerUpdate) SetNillableLooses(i *int) *PlayerUpdate {
|
|
if i != nil {
|
|
pu.SetLooses(*i)
|
|
}
|
|
return pu
|
|
}
|
|
|
|
// AddLooses adds i to the "looses" field.
|
|
func (pu *PlayerUpdate) AddLooses(i int) *PlayerUpdate {
|
|
pu.mutation.AddLooses(i)
|
|
return pu
|
|
}
|
|
|
|
// ClearLooses clears the value of the "looses" field.
|
|
func (pu *PlayerUpdate) ClearLooses() *PlayerUpdate {
|
|
pu.mutation.ClearLooses()
|
|
return pu
|
|
}
|
|
|
|
// SetTies sets the "ties" field.
|
|
func (pu *PlayerUpdate) SetTies(i int) *PlayerUpdate {
|
|
pu.mutation.ResetTies()
|
|
pu.mutation.SetTies(i)
|
|
return pu
|
|
}
|
|
|
|
// SetNillableTies sets the "ties" field if the given value is not nil.
|
|
func (pu *PlayerUpdate) SetNillableTies(i *int) *PlayerUpdate {
|
|
if i != nil {
|
|
pu.SetTies(*i)
|
|
}
|
|
return pu
|
|
}
|
|
|
|
// AddTies adds i to the "ties" field.
|
|
func (pu *PlayerUpdate) AddTies(i int) *PlayerUpdate {
|
|
pu.mutation.AddTies(i)
|
|
return pu
|
|
}
|
|
|
|
// ClearTies clears the value of the "ties" field.
|
|
func (pu *PlayerUpdate) ClearTies() *PlayerUpdate {
|
|
pu.mutation.ClearTies()
|
|
return pu
|
|
}
|
|
|
|
// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs.
|
|
func (pu *PlayerUpdate) AddStatIDs(ids ...int) *PlayerUpdate {
|
|
pu.mutation.AddStatIDs(ids...)
|
|
return pu
|
|
}
|
|
|
|
// AddStats adds the "stats" edges to the MatchPlayer entity.
|
|
func (pu *PlayerUpdate) AddStats(m ...*MatchPlayer) *PlayerUpdate {
|
|
ids := make([]int, len(m))
|
|
for i := range m {
|
|
ids[i] = m[i].ID
|
|
}
|
|
return pu.AddStatIDs(ids...)
|
|
}
|
|
|
|
// AddMatchIDs adds the "matches" edge to the Match entity by IDs.
|
|
func (pu *PlayerUpdate) AddMatchIDs(ids ...uint64) *PlayerUpdate {
|
|
pu.mutation.AddMatchIDs(ids...)
|
|
return pu
|
|
}
|
|
|
|
// AddMatches adds the "matches" edges to the Match entity.
|
|
func (pu *PlayerUpdate) AddMatches(m ...*Match) *PlayerUpdate {
|
|
ids := make([]uint64, len(m))
|
|
for i := range m {
|
|
ids[i] = m[i].ID
|
|
}
|
|
return pu.AddMatchIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the PlayerMutation object of the builder.
|
|
func (pu *PlayerUpdate) Mutation() *PlayerMutation {
|
|
return pu.mutation
|
|
}
|
|
|
|
// ClearStats clears all "stats" edges to the MatchPlayer entity.
|
|
func (pu *PlayerUpdate) ClearStats() *PlayerUpdate {
|
|
pu.mutation.ClearStats()
|
|
return pu
|
|
}
|
|
|
|
// RemoveStatIDs removes the "stats" edge to MatchPlayer entities by IDs.
|
|
func (pu *PlayerUpdate) RemoveStatIDs(ids ...int) *PlayerUpdate {
|
|
pu.mutation.RemoveStatIDs(ids...)
|
|
return pu
|
|
}
|
|
|
|
// RemoveStats removes "stats" edges to MatchPlayer entities.
|
|
func (pu *PlayerUpdate) RemoveStats(m ...*MatchPlayer) *PlayerUpdate {
|
|
ids := make([]int, len(m))
|
|
for i := range m {
|
|
ids[i] = m[i].ID
|
|
}
|
|
return pu.RemoveStatIDs(ids...)
|
|
}
|
|
|
|
// ClearMatches clears all "matches" edges to the Match entity.
|
|
func (pu *PlayerUpdate) ClearMatches() *PlayerUpdate {
|
|
pu.mutation.ClearMatches()
|
|
return pu
|
|
}
|
|
|
|
// RemoveMatchIDs removes the "matches" edge to Match entities by IDs.
|
|
func (pu *PlayerUpdate) RemoveMatchIDs(ids ...uint64) *PlayerUpdate {
|
|
pu.mutation.RemoveMatchIDs(ids...)
|
|
return pu
|
|
}
|
|
|
|
// RemoveMatches removes "matches" edges to Match entities.
|
|
func (pu *PlayerUpdate) RemoveMatches(m ...*Match) *PlayerUpdate {
|
|
ids := make([]uint64, len(m))
|
|
for i := range m {
|
|
ids[i] = m[i].ID
|
|
}
|
|
return pu.RemoveMatchIDs(ids...)
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (pu *PlayerUpdate) Save(ctx context.Context) (int, error) {
|
|
var (
|
|
err error
|
|
affected int
|
|
)
|
|
if len(pu.hooks) == 0 {
|
|
affected, err = pu.sqlSave(ctx)
|
|
} else {
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*PlayerMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
pu.mutation = mutation
|
|
affected, err = pu.sqlSave(ctx)
|
|
mutation.done = true
|
|
return affected, err
|
|
})
|
|
for i := len(pu.hooks) - 1; i >= 0; i-- {
|
|
if pu.hooks[i] == nil {
|
|
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
|
}
|
|
mut = pu.hooks[i](mut)
|
|
}
|
|
if _, err := mut.Mutate(ctx, pu.mutation); err != nil {
|
|
return 0, err
|
|
}
|
|
}
|
|
return affected, err
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (pu *PlayerUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := pu.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (pu *PlayerUpdate) Exec(ctx context.Context) error {
|
|
_, err := pu.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (pu *PlayerUpdate) ExecX(ctx context.Context) {
|
|
if err := pu.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (pu *PlayerUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PlayerUpdate {
|
|
pu.modifiers = append(pu.modifiers, modifiers...)
|
|
return pu
|
|
}
|
|
|
|
func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|
_spec := &sqlgraph.UpdateSpec{
|
|
Node: &sqlgraph.NodeSpec{
|
|
Table: player.Table,
|
|
Columns: player.Columns,
|
|
ID: &sqlgraph.FieldSpec{
|
|
Type: field.TypeUint64,
|
|
Column: player.FieldID,
|
|
},
|
|
},
|
|
}
|
|
if ps := pu.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := pu.mutation.Name(); ok {
|
|
_spec.SetField(player.FieldName, field.TypeString, value)
|
|
}
|
|
if pu.mutation.NameCleared() {
|
|
_spec.ClearField(player.FieldName, field.TypeString)
|
|
}
|
|
if value, ok := pu.mutation.Avatar(); ok {
|
|
_spec.SetField(player.FieldAvatar, field.TypeString, value)
|
|
}
|
|
if pu.mutation.AvatarCleared() {
|
|
_spec.ClearField(player.FieldAvatar, field.TypeString)
|
|
}
|
|
if value, ok := pu.mutation.VanityURL(); ok {
|
|
_spec.SetField(player.FieldVanityURL, field.TypeString, value)
|
|
}
|
|
if pu.mutation.VanityURLCleared() {
|
|
_spec.ClearField(player.FieldVanityURL, field.TypeString)
|
|
}
|
|
if value, ok := pu.mutation.VanityURLReal(); ok {
|
|
_spec.SetField(player.FieldVanityURLReal, field.TypeString, value)
|
|
}
|
|
if pu.mutation.VanityURLRealCleared() {
|
|
_spec.ClearField(player.FieldVanityURLReal, field.TypeString)
|
|
}
|
|
if value, ok := pu.mutation.VacDate(); ok {
|
|
_spec.SetField(player.FieldVacDate, field.TypeTime, value)
|
|
}
|
|
if pu.mutation.VacDateCleared() {
|
|
_spec.ClearField(player.FieldVacDate, field.TypeTime)
|
|
}
|
|
if value, ok := pu.mutation.VacCount(); ok {
|
|
_spec.SetField(player.FieldVacCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := pu.mutation.AddedVacCount(); ok {
|
|
_spec.AddField(player.FieldVacCount, field.TypeInt, value)
|
|
}
|
|
if pu.mutation.VacCountCleared() {
|
|
_spec.ClearField(player.FieldVacCount, field.TypeInt)
|
|
}
|
|
if value, ok := pu.mutation.GameBanDate(); ok {
|
|
_spec.SetField(player.FieldGameBanDate, field.TypeTime, value)
|
|
}
|
|
if pu.mutation.GameBanDateCleared() {
|
|
_spec.ClearField(player.FieldGameBanDate, field.TypeTime)
|
|
}
|
|
if value, ok := pu.mutation.GameBanCount(); ok {
|
|
_spec.SetField(player.FieldGameBanCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := pu.mutation.AddedGameBanCount(); ok {
|
|
_spec.AddField(player.FieldGameBanCount, field.TypeInt, value)
|
|
}
|
|
if pu.mutation.GameBanCountCleared() {
|
|
_spec.ClearField(player.FieldGameBanCount, field.TypeInt)
|
|
}
|
|
if value, ok := pu.mutation.SteamUpdated(); ok {
|
|
_spec.SetField(player.FieldSteamUpdated, field.TypeTime, value)
|
|
}
|
|
if value, ok := pu.mutation.SharecodeUpdated(); ok {
|
|
_spec.SetField(player.FieldSharecodeUpdated, field.TypeTime, value)
|
|
}
|
|
if pu.mutation.SharecodeUpdatedCleared() {
|
|
_spec.ClearField(player.FieldSharecodeUpdated, field.TypeTime)
|
|
}
|
|
if value, ok := pu.mutation.AuthCode(); ok {
|
|
_spec.SetField(player.FieldAuthCode, field.TypeString, value)
|
|
}
|
|
if pu.mutation.AuthCodeCleared() {
|
|
_spec.ClearField(player.FieldAuthCode, field.TypeString)
|
|
}
|
|
if value, ok := pu.mutation.ProfileCreated(); ok {
|
|
_spec.SetField(player.FieldProfileCreated, field.TypeTime, value)
|
|
}
|
|
if pu.mutation.ProfileCreatedCleared() {
|
|
_spec.ClearField(player.FieldProfileCreated, field.TypeTime)
|
|
}
|
|
if value, ok := pu.mutation.OldestSharecodeSeen(); ok {
|
|
_spec.SetField(player.FieldOldestSharecodeSeen, field.TypeString, value)
|
|
}
|
|
if pu.mutation.OldestSharecodeSeenCleared() {
|
|
_spec.ClearField(player.FieldOldestSharecodeSeen, field.TypeString)
|
|
}
|
|
if value, ok := pu.mutation.Wins(); ok {
|
|
_spec.SetField(player.FieldWins, field.TypeInt, value)
|
|
}
|
|
if value, ok := pu.mutation.AddedWins(); ok {
|
|
_spec.AddField(player.FieldWins, field.TypeInt, value)
|
|
}
|
|
if pu.mutation.WinsCleared() {
|
|
_spec.ClearField(player.FieldWins, field.TypeInt)
|
|
}
|
|
if value, ok := pu.mutation.Looses(); ok {
|
|
_spec.SetField(player.FieldLooses, field.TypeInt, value)
|
|
}
|
|
if value, ok := pu.mutation.AddedLooses(); ok {
|
|
_spec.AddField(player.FieldLooses, field.TypeInt, value)
|
|
}
|
|
if pu.mutation.LoosesCleared() {
|
|
_spec.ClearField(player.FieldLooses, field.TypeInt)
|
|
}
|
|
if value, ok := pu.mutation.Ties(); ok {
|
|
_spec.SetField(player.FieldTies, field.TypeInt, value)
|
|
}
|
|
if value, ok := pu.mutation.AddedTies(); ok {
|
|
_spec.AddField(player.FieldTies, field.TypeInt, value)
|
|
}
|
|
if pu.mutation.TiesCleared() {
|
|
_spec.ClearField(player.FieldTies, field.TypeInt)
|
|
}
|
|
if pu.mutation.StatsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: player.StatsTable,
|
|
Columns: []string{player.StatsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: matchplayer.FieldID,
|
|
},
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := pu.mutation.RemovedStatsIDs(); len(nodes) > 0 && !pu.mutation.StatsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: player.StatsTable,
|
|
Columns: []string{player.StatsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: matchplayer.FieldID,
|
|
},
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := pu.mutation.StatsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: player.StatsTable,
|
|
Columns: []string{player.StatsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: matchplayer.FieldID,
|
|
},
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if pu.mutation.MatchesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: false,
|
|
Table: player.MatchesTable,
|
|
Columns: player.MatchesPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeUint64,
|
|
Column: match.FieldID,
|
|
},
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := pu.mutation.RemovedMatchesIDs(); len(nodes) > 0 && !pu.mutation.MatchesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: false,
|
|
Table: player.MatchesTable,
|
|
Columns: player.MatchesPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeUint64,
|
|
Column: match.FieldID,
|
|
},
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := pu.mutation.MatchesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: false,
|
|
Table: player.MatchesTable,
|
|
Columns: player.MatchesPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeUint64,
|
|
Column: match.FieldID,
|
|
},
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_spec.AddModifiers(pu.modifiers...)
|
|
if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{player.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
return n, nil
|
|
}
|
|
|
|
// PlayerUpdateOne is the builder for updating a single Player entity.
|
|
type PlayerUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *PlayerMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (puo *PlayerUpdateOne) SetName(s string) *PlayerUpdateOne {
|
|
puo.mutation.SetName(s)
|
|
return puo
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (puo *PlayerUpdateOne) SetNillableName(s *string) *PlayerUpdateOne {
|
|
if s != nil {
|
|
puo.SetName(*s)
|
|
}
|
|
return puo
|
|
}
|
|
|
|
// ClearName clears the value of the "name" field.
|
|
func (puo *PlayerUpdateOne) ClearName() *PlayerUpdateOne {
|
|
puo.mutation.ClearName()
|
|
return puo
|
|
}
|
|
|
|
// SetAvatar sets the "avatar" field.
|
|
func (puo *PlayerUpdateOne) SetAvatar(s string) *PlayerUpdateOne {
|
|
puo.mutation.SetAvatar(s)
|
|
return puo
|
|
}
|
|
|
|
// SetNillableAvatar sets the "avatar" field if the given value is not nil.
|
|
func (puo *PlayerUpdateOne) SetNillableAvatar(s *string) *PlayerUpdateOne {
|
|
if s != nil {
|
|
puo.SetAvatar(*s)
|
|
}
|
|
return puo
|
|
}
|
|
|
|
// ClearAvatar clears the value of the "avatar" field.
|
|
func (puo *PlayerUpdateOne) ClearAvatar() *PlayerUpdateOne {
|
|
puo.mutation.ClearAvatar()
|
|
return puo
|
|
}
|
|
|
|
// SetVanityURL sets the "vanity_url" field.
|
|
func (puo *PlayerUpdateOne) SetVanityURL(s string) *PlayerUpdateOne {
|
|
puo.mutation.SetVanityURL(s)
|
|
return puo
|
|
}
|
|
|
|
// SetNillableVanityURL sets the "vanity_url" field if the given value is not nil.
|
|
func (puo *PlayerUpdateOne) SetNillableVanityURL(s *string) *PlayerUpdateOne {
|
|
if s != nil {
|
|
puo.SetVanityURL(*s)
|
|
}
|
|
return puo
|
|
}
|
|
|
|
// ClearVanityURL clears the value of the "vanity_url" field.
|
|
func (puo *PlayerUpdateOne) ClearVanityURL() *PlayerUpdateOne {
|
|
puo.mutation.ClearVanityURL()
|
|
return puo
|
|
}
|
|
|
|
// SetVanityURLReal sets the "vanity_url_real" field.
|
|
func (puo *PlayerUpdateOne) SetVanityURLReal(s string) *PlayerUpdateOne {
|
|
puo.mutation.SetVanityURLReal(s)
|
|
return puo
|
|
}
|
|
|
|
// SetNillableVanityURLReal sets the "vanity_url_real" field if the given value is not nil.
|
|
func (puo *PlayerUpdateOne) SetNillableVanityURLReal(s *string) *PlayerUpdateOne {
|
|
if s != nil {
|
|
puo.SetVanityURLReal(*s)
|
|
}
|
|
return puo
|
|
}
|
|
|
|
// ClearVanityURLReal clears the value of the "vanity_url_real" field.
|
|
func (puo *PlayerUpdateOne) ClearVanityURLReal() *PlayerUpdateOne {
|
|
puo.mutation.ClearVanityURLReal()
|
|
return puo
|
|
}
|
|
|
|
// SetVacDate sets the "vac_date" field.
|
|
func (puo *PlayerUpdateOne) SetVacDate(t time.Time) *PlayerUpdateOne {
|
|
puo.mutation.SetVacDate(t)
|
|
return puo
|
|
}
|
|
|
|
// SetNillableVacDate sets the "vac_date" field if the given value is not nil.
|
|
func (puo *PlayerUpdateOne) SetNillableVacDate(t *time.Time) *PlayerUpdateOne {
|
|
if t != nil {
|
|
puo.SetVacDate(*t)
|
|
}
|
|
return puo
|
|
}
|
|
|
|
// ClearVacDate clears the value of the "vac_date" field.
|
|
func (puo *PlayerUpdateOne) ClearVacDate() *PlayerUpdateOne {
|
|
puo.mutation.ClearVacDate()
|
|
return puo
|
|
}
|
|
|
|
// SetVacCount sets the "vac_count" field.
|
|
func (puo *PlayerUpdateOne) SetVacCount(i int) *PlayerUpdateOne {
|
|
puo.mutation.ResetVacCount()
|
|
puo.mutation.SetVacCount(i)
|
|
return puo
|
|
}
|
|
|
|
// SetNillableVacCount sets the "vac_count" field if the given value is not nil.
|
|
func (puo *PlayerUpdateOne) SetNillableVacCount(i *int) *PlayerUpdateOne {
|
|
if i != nil {
|
|
puo.SetVacCount(*i)
|
|
}
|
|
return puo
|
|
}
|
|
|
|
// AddVacCount adds i to the "vac_count" field.
|
|
func (puo *PlayerUpdateOne) AddVacCount(i int) *PlayerUpdateOne {
|
|
puo.mutation.AddVacCount(i)
|
|
return puo
|
|
}
|
|
|
|
// ClearVacCount clears the value of the "vac_count" field.
|
|
func (puo *PlayerUpdateOne) ClearVacCount() *PlayerUpdateOne {
|
|
puo.mutation.ClearVacCount()
|
|
return puo
|
|
}
|
|
|
|
// SetGameBanDate sets the "game_ban_date" field.
|
|
func (puo *PlayerUpdateOne) SetGameBanDate(t time.Time) *PlayerUpdateOne {
|
|
puo.mutation.SetGameBanDate(t)
|
|
return puo
|
|
}
|
|
|
|
// SetNillableGameBanDate sets the "game_ban_date" field if the given value is not nil.
|
|
func (puo *PlayerUpdateOne) SetNillableGameBanDate(t *time.Time) *PlayerUpdateOne {
|
|
if t != nil {
|
|
puo.SetGameBanDate(*t)
|
|
}
|
|
return puo
|
|
}
|
|
|
|
// ClearGameBanDate clears the value of the "game_ban_date" field.
|
|
func (puo *PlayerUpdateOne) ClearGameBanDate() *PlayerUpdateOne {
|
|
puo.mutation.ClearGameBanDate()
|
|
return puo
|
|
}
|
|
|
|
// SetGameBanCount sets the "game_ban_count" field.
|
|
func (puo *PlayerUpdateOne) SetGameBanCount(i int) *PlayerUpdateOne {
|
|
puo.mutation.ResetGameBanCount()
|
|
puo.mutation.SetGameBanCount(i)
|
|
return puo
|
|
}
|
|
|
|
// SetNillableGameBanCount sets the "game_ban_count" field if the given value is not nil.
|
|
func (puo *PlayerUpdateOne) SetNillableGameBanCount(i *int) *PlayerUpdateOne {
|
|
if i != nil {
|
|
puo.SetGameBanCount(*i)
|
|
}
|
|
return puo
|
|
}
|
|
|
|
// AddGameBanCount adds i to the "game_ban_count" field.
|
|
func (puo *PlayerUpdateOne) AddGameBanCount(i int) *PlayerUpdateOne {
|
|
puo.mutation.AddGameBanCount(i)
|
|
return puo
|
|
}
|
|
|
|
// ClearGameBanCount clears the value of the "game_ban_count" field.
|
|
func (puo *PlayerUpdateOne) ClearGameBanCount() *PlayerUpdateOne {
|
|
puo.mutation.ClearGameBanCount()
|
|
return puo
|
|
}
|
|
|
|
// SetSteamUpdated sets the "steam_updated" field.
|
|
func (puo *PlayerUpdateOne) SetSteamUpdated(t time.Time) *PlayerUpdateOne {
|
|
puo.mutation.SetSteamUpdated(t)
|
|
return puo
|
|
}
|
|
|
|
// SetNillableSteamUpdated sets the "steam_updated" field if the given value is not nil.
|
|
func (puo *PlayerUpdateOne) SetNillableSteamUpdated(t *time.Time) *PlayerUpdateOne {
|
|
if t != nil {
|
|
puo.SetSteamUpdated(*t)
|
|
}
|
|
return puo
|
|
}
|
|
|
|
// SetSharecodeUpdated sets the "sharecode_updated" field.
|
|
func (puo *PlayerUpdateOne) SetSharecodeUpdated(t time.Time) *PlayerUpdateOne {
|
|
puo.mutation.SetSharecodeUpdated(t)
|
|
return puo
|
|
}
|
|
|
|
// SetNillableSharecodeUpdated sets the "sharecode_updated" field if the given value is not nil.
|
|
func (puo *PlayerUpdateOne) SetNillableSharecodeUpdated(t *time.Time) *PlayerUpdateOne {
|
|
if t != nil {
|
|
puo.SetSharecodeUpdated(*t)
|
|
}
|
|
return puo
|
|
}
|
|
|
|
// ClearSharecodeUpdated clears the value of the "sharecode_updated" field.
|
|
func (puo *PlayerUpdateOne) ClearSharecodeUpdated() *PlayerUpdateOne {
|
|
puo.mutation.ClearSharecodeUpdated()
|
|
return puo
|
|
}
|
|
|
|
// SetAuthCode sets the "auth_code" field.
|
|
func (puo *PlayerUpdateOne) SetAuthCode(s string) *PlayerUpdateOne {
|
|
puo.mutation.SetAuthCode(s)
|
|
return puo
|
|
}
|
|
|
|
// SetNillableAuthCode sets the "auth_code" field if the given value is not nil.
|
|
func (puo *PlayerUpdateOne) SetNillableAuthCode(s *string) *PlayerUpdateOne {
|
|
if s != nil {
|
|
puo.SetAuthCode(*s)
|
|
}
|
|
return puo
|
|
}
|
|
|
|
// ClearAuthCode clears the value of the "auth_code" field.
|
|
func (puo *PlayerUpdateOne) ClearAuthCode() *PlayerUpdateOne {
|
|
puo.mutation.ClearAuthCode()
|
|
return puo
|
|
}
|
|
|
|
// SetProfileCreated sets the "profile_created" field.
|
|
func (puo *PlayerUpdateOne) SetProfileCreated(t time.Time) *PlayerUpdateOne {
|
|
puo.mutation.SetProfileCreated(t)
|
|
return puo
|
|
}
|
|
|
|
// SetNillableProfileCreated sets the "profile_created" field if the given value is not nil.
|
|
func (puo *PlayerUpdateOne) SetNillableProfileCreated(t *time.Time) *PlayerUpdateOne {
|
|
if t != nil {
|
|
puo.SetProfileCreated(*t)
|
|
}
|
|
return puo
|
|
}
|
|
|
|
// ClearProfileCreated clears the value of the "profile_created" field.
|
|
func (puo *PlayerUpdateOne) ClearProfileCreated() *PlayerUpdateOne {
|
|
puo.mutation.ClearProfileCreated()
|
|
return puo
|
|
}
|
|
|
|
// SetOldestSharecodeSeen sets the "oldest_sharecode_seen" field.
|
|
func (puo *PlayerUpdateOne) SetOldestSharecodeSeen(s string) *PlayerUpdateOne {
|
|
puo.mutation.SetOldestSharecodeSeen(s)
|
|
return puo
|
|
}
|
|
|
|
// SetNillableOldestSharecodeSeen sets the "oldest_sharecode_seen" field if the given value is not nil.
|
|
func (puo *PlayerUpdateOne) SetNillableOldestSharecodeSeen(s *string) *PlayerUpdateOne {
|
|
if s != nil {
|
|
puo.SetOldestSharecodeSeen(*s)
|
|
}
|
|
return puo
|
|
}
|
|
|
|
// ClearOldestSharecodeSeen clears the value of the "oldest_sharecode_seen" field.
|
|
func (puo *PlayerUpdateOne) ClearOldestSharecodeSeen() *PlayerUpdateOne {
|
|
puo.mutation.ClearOldestSharecodeSeen()
|
|
return puo
|
|
}
|
|
|
|
// SetWins sets the "wins" field.
|
|
func (puo *PlayerUpdateOne) SetWins(i int) *PlayerUpdateOne {
|
|
puo.mutation.ResetWins()
|
|
puo.mutation.SetWins(i)
|
|
return puo
|
|
}
|
|
|
|
// SetNillableWins sets the "wins" field if the given value is not nil.
|
|
func (puo *PlayerUpdateOne) SetNillableWins(i *int) *PlayerUpdateOne {
|
|
if i != nil {
|
|
puo.SetWins(*i)
|
|
}
|
|
return puo
|
|
}
|
|
|
|
// AddWins adds i to the "wins" field.
|
|
func (puo *PlayerUpdateOne) AddWins(i int) *PlayerUpdateOne {
|
|
puo.mutation.AddWins(i)
|
|
return puo
|
|
}
|
|
|
|
// ClearWins clears the value of the "wins" field.
|
|
func (puo *PlayerUpdateOne) ClearWins() *PlayerUpdateOne {
|
|
puo.mutation.ClearWins()
|
|
return puo
|
|
}
|
|
|
|
// SetLooses sets the "looses" field.
|
|
func (puo *PlayerUpdateOne) SetLooses(i int) *PlayerUpdateOne {
|
|
puo.mutation.ResetLooses()
|
|
puo.mutation.SetLooses(i)
|
|
return puo
|
|
}
|
|
|
|
// SetNillableLooses sets the "looses" field if the given value is not nil.
|
|
func (puo *PlayerUpdateOne) SetNillableLooses(i *int) *PlayerUpdateOne {
|
|
if i != nil {
|
|
puo.SetLooses(*i)
|
|
}
|
|
return puo
|
|
}
|
|
|
|
// AddLooses adds i to the "looses" field.
|
|
func (puo *PlayerUpdateOne) AddLooses(i int) *PlayerUpdateOne {
|
|
puo.mutation.AddLooses(i)
|
|
return puo
|
|
}
|
|
|
|
// ClearLooses clears the value of the "looses" field.
|
|
func (puo *PlayerUpdateOne) ClearLooses() *PlayerUpdateOne {
|
|
puo.mutation.ClearLooses()
|
|
return puo
|
|
}
|
|
|
|
// SetTies sets the "ties" field.
|
|
func (puo *PlayerUpdateOne) SetTies(i int) *PlayerUpdateOne {
|
|
puo.mutation.ResetTies()
|
|
puo.mutation.SetTies(i)
|
|
return puo
|
|
}
|
|
|
|
// SetNillableTies sets the "ties" field if the given value is not nil.
|
|
func (puo *PlayerUpdateOne) SetNillableTies(i *int) *PlayerUpdateOne {
|
|
if i != nil {
|
|
puo.SetTies(*i)
|
|
}
|
|
return puo
|
|
}
|
|
|
|
// AddTies adds i to the "ties" field.
|
|
func (puo *PlayerUpdateOne) AddTies(i int) *PlayerUpdateOne {
|
|
puo.mutation.AddTies(i)
|
|
return puo
|
|
}
|
|
|
|
// ClearTies clears the value of the "ties" field.
|
|
func (puo *PlayerUpdateOne) ClearTies() *PlayerUpdateOne {
|
|
puo.mutation.ClearTies()
|
|
return puo
|
|
}
|
|
|
|
// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs.
|
|
func (puo *PlayerUpdateOne) AddStatIDs(ids ...int) *PlayerUpdateOne {
|
|
puo.mutation.AddStatIDs(ids...)
|
|
return puo
|
|
}
|
|
|
|
// AddStats adds the "stats" edges to the MatchPlayer entity.
|
|
func (puo *PlayerUpdateOne) AddStats(m ...*MatchPlayer) *PlayerUpdateOne {
|
|
ids := make([]int, len(m))
|
|
for i := range m {
|
|
ids[i] = m[i].ID
|
|
}
|
|
return puo.AddStatIDs(ids...)
|
|
}
|
|
|
|
// AddMatchIDs adds the "matches" edge to the Match entity by IDs.
|
|
func (puo *PlayerUpdateOne) AddMatchIDs(ids ...uint64) *PlayerUpdateOne {
|
|
puo.mutation.AddMatchIDs(ids...)
|
|
return puo
|
|
}
|
|
|
|
// AddMatches adds the "matches" edges to the Match entity.
|
|
func (puo *PlayerUpdateOne) AddMatches(m ...*Match) *PlayerUpdateOne {
|
|
ids := make([]uint64, len(m))
|
|
for i := range m {
|
|
ids[i] = m[i].ID
|
|
}
|
|
return puo.AddMatchIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the PlayerMutation object of the builder.
|
|
func (puo *PlayerUpdateOne) Mutation() *PlayerMutation {
|
|
return puo.mutation
|
|
}
|
|
|
|
// ClearStats clears all "stats" edges to the MatchPlayer entity.
|
|
func (puo *PlayerUpdateOne) ClearStats() *PlayerUpdateOne {
|
|
puo.mutation.ClearStats()
|
|
return puo
|
|
}
|
|
|
|
// RemoveStatIDs removes the "stats" edge to MatchPlayer entities by IDs.
|
|
func (puo *PlayerUpdateOne) RemoveStatIDs(ids ...int) *PlayerUpdateOne {
|
|
puo.mutation.RemoveStatIDs(ids...)
|
|
return puo
|
|
}
|
|
|
|
// RemoveStats removes "stats" edges to MatchPlayer entities.
|
|
func (puo *PlayerUpdateOne) RemoveStats(m ...*MatchPlayer) *PlayerUpdateOne {
|
|
ids := make([]int, len(m))
|
|
for i := range m {
|
|
ids[i] = m[i].ID
|
|
}
|
|
return puo.RemoveStatIDs(ids...)
|
|
}
|
|
|
|
// ClearMatches clears all "matches" edges to the Match entity.
|
|
func (puo *PlayerUpdateOne) ClearMatches() *PlayerUpdateOne {
|
|
puo.mutation.ClearMatches()
|
|
return puo
|
|
}
|
|
|
|
// RemoveMatchIDs removes the "matches" edge to Match entities by IDs.
|
|
func (puo *PlayerUpdateOne) RemoveMatchIDs(ids ...uint64) *PlayerUpdateOne {
|
|
puo.mutation.RemoveMatchIDs(ids...)
|
|
return puo
|
|
}
|
|
|
|
// RemoveMatches removes "matches" edges to Match entities.
|
|
func (puo *PlayerUpdateOne) RemoveMatches(m ...*Match) *PlayerUpdateOne {
|
|
ids := make([]uint64, len(m))
|
|
for i := range m {
|
|
ids[i] = m[i].ID
|
|
}
|
|
return puo.RemoveMatchIDs(ids...)
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (puo *PlayerUpdateOne) Select(field string, fields ...string) *PlayerUpdateOne {
|
|
puo.fields = append([]string{field}, fields...)
|
|
return puo
|
|
}
|
|
|
|
// Save executes the query and returns the updated Player entity.
|
|
func (puo *PlayerUpdateOne) Save(ctx context.Context) (*Player, error) {
|
|
var (
|
|
err error
|
|
node *Player
|
|
)
|
|
if len(puo.hooks) == 0 {
|
|
node, err = puo.sqlSave(ctx)
|
|
} else {
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*PlayerMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
puo.mutation = mutation
|
|
node, err = puo.sqlSave(ctx)
|
|
mutation.done = true
|
|
return node, err
|
|
})
|
|
for i := len(puo.hooks) - 1; i >= 0; i-- {
|
|
if puo.hooks[i] == nil {
|
|
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
|
}
|
|
mut = puo.hooks[i](mut)
|
|
}
|
|
v, err := mut.Mutate(ctx, puo.mutation)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
nv, ok := v.(*Player)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected node type %T returned from PlayerMutation", v)
|
|
}
|
|
node = nv
|
|
}
|
|
return node, err
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (puo *PlayerUpdateOne) SaveX(ctx context.Context) *Player {
|
|
node, err := puo.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (puo *PlayerUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := puo.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (puo *PlayerUpdateOne) ExecX(ctx context.Context) {
|
|
if err := puo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (puo *PlayerUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PlayerUpdateOne {
|
|
puo.modifiers = append(puo.modifiers, modifiers...)
|
|
return puo
|
|
}
|
|
|
|
func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err error) {
|
|
_spec := &sqlgraph.UpdateSpec{
|
|
Node: &sqlgraph.NodeSpec{
|
|
Table: player.Table,
|
|
Columns: player.Columns,
|
|
ID: &sqlgraph.FieldSpec{
|
|
Type: field.TypeUint64,
|
|
Column: player.FieldID,
|
|
},
|
|
},
|
|
}
|
|
id, ok := puo.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Player.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := puo.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, player.FieldID)
|
|
for _, f := range fields {
|
|
if !player.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != player.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := puo.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := puo.mutation.Name(); ok {
|
|
_spec.SetField(player.FieldName, field.TypeString, value)
|
|
}
|
|
if puo.mutation.NameCleared() {
|
|
_spec.ClearField(player.FieldName, field.TypeString)
|
|
}
|
|
if value, ok := puo.mutation.Avatar(); ok {
|
|
_spec.SetField(player.FieldAvatar, field.TypeString, value)
|
|
}
|
|
if puo.mutation.AvatarCleared() {
|
|
_spec.ClearField(player.FieldAvatar, field.TypeString)
|
|
}
|
|
if value, ok := puo.mutation.VanityURL(); ok {
|
|
_spec.SetField(player.FieldVanityURL, field.TypeString, value)
|
|
}
|
|
if puo.mutation.VanityURLCleared() {
|
|
_spec.ClearField(player.FieldVanityURL, field.TypeString)
|
|
}
|
|
if value, ok := puo.mutation.VanityURLReal(); ok {
|
|
_spec.SetField(player.FieldVanityURLReal, field.TypeString, value)
|
|
}
|
|
if puo.mutation.VanityURLRealCleared() {
|
|
_spec.ClearField(player.FieldVanityURLReal, field.TypeString)
|
|
}
|
|
if value, ok := puo.mutation.VacDate(); ok {
|
|
_spec.SetField(player.FieldVacDate, field.TypeTime, value)
|
|
}
|
|
if puo.mutation.VacDateCleared() {
|
|
_spec.ClearField(player.FieldVacDate, field.TypeTime)
|
|
}
|
|
if value, ok := puo.mutation.VacCount(); ok {
|
|
_spec.SetField(player.FieldVacCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := puo.mutation.AddedVacCount(); ok {
|
|
_spec.AddField(player.FieldVacCount, field.TypeInt, value)
|
|
}
|
|
if puo.mutation.VacCountCleared() {
|
|
_spec.ClearField(player.FieldVacCount, field.TypeInt)
|
|
}
|
|
if value, ok := puo.mutation.GameBanDate(); ok {
|
|
_spec.SetField(player.FieldGameBanDate, field.TypeTime, value)
|
|
}
|
|
if puo.mutation.GameBanDateCleared() {
|
|
_spec.ClearField(player.FieldGameBanDate, field.TypeTime)
|
|
}
|
|
if value, ok := puo.mutation.GameBanCount(); ok {
|
|
_spec.SetField(player.FieldGameBanCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := puo.mutation.AddedGameBanCount(); ok {
|
|
_spec.AddField(player.FieldGameBanCount, field.TypeInt, value)
|
|
}
|
|
if puo.mutation.GameBanCountCleared() {
|
|
_spec.ClearField(player.FieldGameBanCount, field.TypeInt)
|
|
}
|
|
if value, ok := puo.mutation.SteamUpdated(); ok {
|
|
_spec.SetField(player.FieldSteamUpdated, field.TypeTime, value)
|
|
}
|
|
if value, ok := puo.mutation.SharecodeUpdated(); ok {
|
|
_spec.SetField(player.FieldSharecodeUpdated, field.TypeTime, value)
|
|
}
|
|
if puo.mutation.SharecodeUpdatedCleared() {
|
|
_spec.ClearField(player.FieldSharecodeUpdated, field.TypeTime)
|
|
}
|
|
if value, ok := puo.mutation.AuthCode(); ok {
|
|
_spec.SetField(player.FieldAuthCode, field.TypeString, value)
|
|
}
|
|
if puo.mutation.AuthCodeCleared() {
|
|
_spec.ClearField(player.FieldAuthCode, field.TypeString)
|
|
}
|
|
if value, ok := puo.mutation.ProfileCreated(); ok {
|
|
_spec.SetField(player.FieldProfileCreated, field.TypeTime, value)
|
|
}
|
|
if puo.mutation.ProfileCreatedCleared() {
|
|
_spec.ClearField(player.FieldProfileCreated, field.TypeTime)
|
|
}
|
|
if value, ok := puo.mutation.OldestSharecodeSeen(); ok {
|
|
_spec.SetField(player.FieldOldestSharecodeSeen, field.TypeString, value)
|
|
}
|
|
if puo.mutation.OldestSharecodeSeenCleared() {
|
|
_spec.ClearField(player.FieldOldestSharecodeSeen, field.TypeString)
|
|
}
|
|
if value, ok := puo.mutation.Wins(); ok {
|
|
_spec.SetField(player.FieldWins, field.TypeInt, value)
|
|
}
|
|
if value, ok := puo.mutation.AddedWins(); ok {
|
|
_spec.AddField(player.FieldWins, field.TypeInt, value)
|
|
}
|
|
if puo.mutation.WinsCleared() {
|
|
_spec.ClearField(player.FieldWins, field.TypeInt)
|
|
}
|
|
if value, ok := puo.mutation.Looses(); ok {
|
|
_spec.SetField(player.FieldLooses, field.TypeInt, value)
|
|
}
|
|
if value, ok := puo.mutation.AddedLooses(); ok {
|
|
_spec.AddField(player.FieldLooses, field.TypeInt, value)
|
|
}
|
|
if puo.mutation.LoosesCleared() {
|
|
_spec.ClearField(player.FieldLooses, field.TypeInt)
|
|
}
|
|
if value, ok := puo.mutation.Ties(); ok {
|
|
_spec.SetField(player.FieldTies, field.TypeInt, value)
|
|
}
|
|
if value, ok := puo.mutation.AddedTies(); ok {
|
|
_spec.AddField(player.FieldTies, field.TypeInt, value)
|
|
}
|
|
if puo.mutation.TiesCleared() {
|
|
_spec.ClearField(player.FieldTies, field.TypeInt)
|
|
}
|
|
if puo.mutation.StatsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: player.StatsTable,
|
|
Columns: []string{player.StatsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: matchplayer.FieldID,
|
|
},
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := puo.mutation.RemovedStatsIDs(); len(nodes) > 0 && !puo.mutation.StatsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: player.StatsTable,
|
|
Columns: []string{player.StatsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: matchplayer.FieldID,
|
|
},
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := puo.mutation.StatsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: player.StatsTable,
|
|
Columns: []string{player.StatsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: matchplayer.FieldID,
|
|
},
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if puo.mutation.MatchesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: false,
|
|
Table: player.MatchesTable,
|
|
Columns: player.MatchesPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeUint64,
|
|
Column: match.FieldID,
|
|
},
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := puo.mutation.RemovedMatchesIDs(); len(nodes) > 0 && !puo.mutation.MatchesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: false,
|
|
Table: player.MatchesTable,
|
|
Columns: player.MatchesPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeUint64,
|
|
Column: match.FieldID,
|
|
},
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := puo.mutation.MatchesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: false,
|
|
Table: player.MatchesTable,
|
|
Columns: player.MatchesPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: &sqlgraph.FieldSpec{
|
|
Type: field.TypeUint64,
|
|
Column: match.FieldID,
|
|
},
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_spec.AddModifiers(puo.modifiers...)
|
|
_node = &Player{config: puo.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{player.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
return _node, nil
|
|
}
|