929 lines
27 KiB
Go
929 lines
27 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"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/roundstats"
|
|
"somegit.dev/csgowtf/csgowtfd/ent/spray"
|
|
"somegit.dev/csgowtf/csgowtfd/ent/weapon"
|
|
)
|
|
|
|
// MatchPlayerCreate is the builder for creating a MatchPlayer entity.
|
|
type MatchPlayerCreate struct {
|
|
config
|
|
mutation *MatchPlayerMutation
|
|
hooks []Hook
|
|
}
|
|
|
|
// SetTeamID sets the "team_id" field.
|
|
func (_c *MatchPlayerCreate) SetTeamID(v int) *MatchPlayerCreate {
|
|
_c.mutation.SetTeamID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetKills sets the "kills" field.
|
|
func (_c *MatchPlayerCreate) SetKills(v int) *MatchPlayerCreate {
|
|
_c.mutation.SetKills(v)
|
|
return _c
|
|
}
|
|
|
|
// SetDeaths sets the "deaths" field.
|
|
func (_c *MatchPlayerCreate) SetDeaths(v int) *MatchPlayerCreate {
|
|
_c.mutation.SetDeaths(v)
|
|
return _c
|
|
}
|
|
|
|
// SetAssists sets the "assists" field.
|
|
func (_c *MatchPlayerCreate) SetAssists(v int) *MatchPlayerCreate {
|
|
_c.mutation.SetAssists(v)
|
|
return _c
|
|
}
|
|
|
|
// SetHeadshot sets the "headshot" field.
|
|
func (_c *MatchPlayerCreate) SetHeadshot(v int) *MatchPlayerCreate {
|
|
_c.mutation.SetHeadshot(v)
|
|
return _c
|
|
}
|
|
|
|
// SetMvp sets the "mvp" field.
|
|
func (_c *MatchPlayerCreate) SetMvp(v uint) *MatchPlayerCreate {
|
|
_c.mutation.SetMvp(v)
|
|
return _c
|
|
}
|
|
|
|
// SetScore sets the "score" field.
|
|
func (_c *MatchPlayerCreate) SetScore(v int) *MatchPlayerCreate {
|
|
_c.mutation.SetScore(v)
|
|
return _c
|
|
}
|
|
|
|
// SetRankNew sets the "rank_new" field.
|
|
func (_c *MatchPlayerCreate) SetRankNew(v int) *MatchPlayerCreate {
|
|
_c.mutation.SetRankNew(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableRankNew sets the "rank_new" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableRankNew(v *int) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetRankNew(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetRankOld sets the "rank_old" field.
|
|
func (_c *MatchPlayerCreate) SetRankOld(v int) *MatchPlayerCreate {
|
|
_c.mutation.SetRankOld(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableRankOld sets the "rank_old" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableRankOld(v *int) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetRankOld(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetMk2 sets the "mk_2" field.
|
|
func (_c *MatchPlayerCreate) SetMk2(v uint) *MatchPlayerCreate {
|
|
_c.mutation.SetMk2(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableMk2 sets the "mk_2" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableMk2(v *uint) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetMk2(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetMk3 sets the "mk_3" field.
|
|
func (_c *MatchPlayerCreate) SetMk3(v uint) *MatchPlayerCreate {
|
|
_c.mutation.SetMk3(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableMk3 sets the "mk_3" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableMk3(v *uint) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetMk3(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetMk4 sets the "mk_4" field.
|
|
func (_c *MatchPlayerCreate) SetMk4(v uint) *MatchPlayerCreate {
|
|
_c.mutation.SetMk4(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableMk4 sets the "mk_4" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableMk4(v *uint) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetMk4(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetMk5 sets the "mk_5" field.
|
|
func (_c *MatchPlayerCreate) SetMk5(v uint) *MatchPlayerCreate {
|
|
_c.mutation.SetMk5(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableMk5 sets the "mk_5" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableMk5(v *uint) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetMk5(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetDmgEnemy sets the "dmg_enemy" field.
|
|
func (_c *MatchPlayerCreate) SetDmgEnemy(v uint) *MatchPlayerCreate {
|
|
_c.mutation.SetDmgEnemy(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDmgEnemy sets the "dmg_enemy" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableDmgEnemy(v *uint) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetDmgEnemy(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetDmgTeam sets the "dmg_team" field.
|
|
func (_c *MatchPlayerCreate) SetDmgTeam(v uint) *MatchPlayerCreate {
|
|
_c.mutation.SetDmgTeam(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDmgTeam sets the "dmg_team" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableDmgTeam(v *uint) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetDmgTeam(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUdHe sets the "ud_he" field.
|
|
func (_c *MatchPlayerCreate) SetUdHe(v uint) *MatchPlayerCreate {
|
|
_c.mutation.SetUdHe(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUdHe sets the "ud_he" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableUdHe(v *uint) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetUdHe(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUdFlames sets the "ud_flames" field.
|
|
func (_c *MatchPlayerCreate) SetUdFlames(v uint) *MatchPlayerCreate {
|
|
_c.mutation.SetUdFlames(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUdFlames sets the "ud_flames" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableUdFlames(v *uint) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetUdFlames(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUdFlash sets the "ud_flash" field.
|
|
func (_c *MatchPlayerCreate) SetUdFlash(v uint) *MatchPlayerCreate {
|
|
_c.mutation.SetUdFlash(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUdFlash sets the "ud_flash" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableUdFlash(v *uint) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetUdFlash(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUdDecoy sets the "ud_decoy" field.
|
|
func (_c *MatchPlayerCreate) SetUdDecoy(v uint) *MatchPlayerCreate {
|
|
_c.mutation.SetUdDecoy(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUdDecoy sets the "ud_decoy" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableUdDecoy(v *uint) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetUdDecoy(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUdSmoke sets the "ud_smoke" field.
|
|
func (_c *MatchPlayerCreate) SetUdSmoke(v uint) *MatchPlayerCreate {
|
|
_c.mutation.SetUdSmoke(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUdSmoke sets the "ud_smoke" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableUdSmoke(v *uint) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetUdSmoke(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCrosshair sets the "crosshair" field.
|
|
func (_c *MatchPlayerCreate) SetCrosshair(v string) *MatchPlayerCreate {
|
|
_c.mutation.SetCrosshair(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCrosshair sets the "crosshair" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableCrosshair(v *string) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetCrosshair(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetColor sets the "color" field.
|
|
func (_c *MatchPlayerCreate) SetColor(v matchplayer.Color) *MatchPlayerCreate {
|
|
_c.mutation.SetColor(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableColor sets the "color" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableColor(v *matchplayer.Color) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetColor(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetKast sets the "kast" field.
|
|
func (_c *MatchPlayerCreate) SetKast(v int) *MatchPlayerCreate {
|
|
_c.mutation.SetKast(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableKast sets the "kast" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableKast(v *int) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetKast(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetFlashDurationSelf sets the "flash_duration_self" field.
|
|
func (_c *MatchPlayerCreate) SetFlashDurationSelf(v float32) *MatchPlayerCreate {
|
|
_c.mutation.SetFlashDurationSelf(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableFlashDurationSelf sets the "flash_duration_self" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableFlashDurationSelf(v *float32) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetFlashDurationSelf(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetFlashDurationTeam sets the "flash_duration_team" field.
|
|
func (_c *MatchPlayerCreate) SetFlashDurationTeam(v float32) *MatchPlayerCreate {
|
|
_c.mutation.SetFlashDurationTeam(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableFlashDurationTeam sets the "flash_duration_team" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableFlashDurationTeam(v *float32) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetFlashDurationTeam(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetFlashDurationEnemy sets the "flash_duration_enemy" field.
|
|
func (_c *MatchPlayerCreate) SetFlashDurationEnemy(v float32) *MatchPlayerCreate {
|
|
_c.mutation.SetFlashDurationEnemy(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableFlashDurationEnemy sets the "flash_duration_enemy" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableFlashDurationEnemy(v *float32) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetFlashDurationEnemy(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetFlashTotalSelf sets the "flash_total_self" field.
|
|
func (_c *MatchPlayerCreate) SetFlashTotalSelf(v uint) *MatchPlayerCreate {
|
|
_c.mutation.SetFlashTotalSelf(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableFlashTotalSelf sets the "flash_total_self" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableFlashTotalSelf(v *uint) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetFlashTotalSelf(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetFlashTotalTeam sets the "flash_total_team" field.
|
|
func (_c *MatchPlayerCreate) SetFlashTotalTeam(v uint) *MatchPlayerCreate {
|
|
_c.mutation.SetFlashTotalTeam(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableFlashTotalTeam sets the "flash_total_team" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableFlashTotalTeam(v *uint) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetFlashTotalTeam(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetFlashTotalEnemy sets the "flash_total_enemy" field.
|
|
func (_c *MatchPlayerCreate) SetFlashTotalEnemy(v uint) *MatchPlayerCreate {
|
|
_c.mutation.SetFlashTotalEnemy(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableFlashTotalEnemy sets the "flash_total_enemy" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableFlashTotalEnemy(v *uint) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetFlashTotalEnemy(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetMatchStats sets the "match_stats" field.
|
|
func (_c *MatchPlayerCreate) SetMatchStats(v uint64) *MatchPlayerCreate {
|
|
_c.mutation.SetMatchStats(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableMatchStats sets the "match_stats" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableMatchStats(v *uint64) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetMatchStats(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetPlayerStats sets the "player_stats" field.
|
|
func (_c *MatchPlayerCreate) SetPlayerStats(v uint64) *MatchPlayerCreate {
|
|
_c.mutation.SetPlayerStats(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillablePlayerStats sets the "player_stats" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillablePlayerStats(v *uint64) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetPlayerStats(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetFlashAssists sets the "flash_assists" field.
|
|
func (_c *MatchPlayerCreate) SetFlashAssists(v int) *MatchPlayerCreate {
|
|
_c.mutation.SetFlashAssists(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableFlashAssists sets the "flash_assists" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableFlashAssists(v *int) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetFlashAssists(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetAvgPing sets the "avg_ping" field.
|
|
func (_c *MatchPlayerCreate) SetAvgPing(v float64) *MatchPlayerCreate {
|
|
_c.mutation.SetAvgPing(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableAvgPing sets the "avg_ping" field if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableAvgPing(v *float64) *MatchPlayerCreate {
|
|
if v != nil {
|
|
_c.SetAvgPing(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetMatchesID sets the "matches" edge to the Match entity by ID.
|
|
func (_c *MatchPlayerCreate) SetMatchesID(id uint64) *MatchPlayerCreate {
|
|
_c.mutation.SetMatchesID(id)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableMatchesID sets the "matches" edge to the Match entity by ID if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillableMatchesID(id *uint64) *MatchPlayerCreate {
|
|
if id != nil {
|
|
_c = _c.SetMatchesID(*id)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetMatches sets the "matches" edge to the Match entity.
|
|
func (_c *MatchPlayerCreate) SetMatches(v *Match) *MatchPlayerCreate {
|
|
return _c.SetMatchesID(v.ID)
|
|
}
|
|
|
|
// SetPlayersID sets the "players" edge to the Player entity by ID.
|
|
func (_c *MatchPlayerCreate) SetPlayersID(id uint64) *MatchPlayerCreate {
|
|
_c.mutation.SetPlayersID(id)
|
|
return _c
|
|
}
|
|
|
|
// SetNillablePlayersID sets the "players" edge to the Player entity by ID if the given value is not nil.
|
|
func (_c *MatchPlayerCreate) SetNillablePlayersID(id *uint64) *MatchPlayerCreate {
|
|
if id != nil {
|
|
_c = _c.SetPlayersID(*id)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetPlayers sets the "players" edge to the Player entity.
|
|
func (_c *MatchPlayerCreate) SetPlayers(v *Player) *MatchPlayerCreate {
|
|
return _c.SetPlayersID(v.ID)
|
|
}
|
|
|
|
// AddWeaponStatIDs adds the "weapon_stats" edge to the Weapon entity by IDs.
|
|
func (_c *MatchPlayerCreate) AddWeaponStatIDs(ids ...int) *MatchPlayerCreate {
|
|
_c.mutation.AddWeaponStatIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddWeaponStats adds the "weapon_stats" edges to the Weapon entity.
|
|
func (_c *MatchPlayerCreate) AddWeaponStats(v ...*Weapon) *MatchPlayerCreate {
|
|
ids := make([]int, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddWeaponStatIDs(ids...)
|
|
}
|
|
|
|
// AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by IDs.
|
|
func (_c *MatchPlayerCreate) AddRoundStatIDs(ids ...int) *MatchPlayerCreate {
|
|
_c.mutation.AddRoundStatIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddRoundStats adds the "round_stats" edges to the RoundStats entity.
|
|
func (_c *MatchPlayerCreate) AddRoundStats(v ...*RoundStats) *MatchPlayerCreate {
|
|
ids := make([]int, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddRoundStatIDs(ids...)
|
|
}
|
|
|
|
// AddSprayIDs adds the "spray" edge to the Spray entity by IDs.
|
|
func (_c *MatchPlayerCreate) AddSprayIDs(ids ...int) *MatchPlayerCreate {
|
|
_c.mutation.AddSprayIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddSpray adds the "spray" edges to the Spray entity.
|
|
func (_c *MatchPlayerCreate) AddSpray(v ...*Spray) *MatchPlayerCreate {
|
|
ids := make([]int, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddSprayIDs(ids...)
|
|
}
|
|
|
|
// AddMessageIDs adds the "messages" edge to the Messages entity by IDs.
|
|
func (_c *MatchPlayerCreate) AddMessageIDs(ids ...int) *MatchPlayerCreate {
|
|
_c.mutation.AddMessageIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddMessages adds the "messages" edges to the Messages entity.
|
|
func (_c *MatchPlayerCreate) AddMessages(v ...*Messages) *MatchPlayerCreate {
|
|
ids := make([]int, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddMessageIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the MatchPlayerMutation object of the builder.
|
|
func (_c *MatchPlayerCreate) Mutation() *MatchPlayerMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the MatchPlayer in the database.
|
|
func (_c *MatchPlayerCreate) Save(ctx context.Context) (*MatchPlayer, error) {
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *MatchPlayerCreate) SaveX(ctx context.Context) *MatchPlayer {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *MatchPlayerCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *MatchPlayerCreate) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *MatchPlayerCreate) check() error {
|
|
if _, ok := _c.mutation.TeamID(); !ok {
|
|
return &ValidationError{Name: "team_id", err: errors.New(`ent: missing required field "MatchPlayer.team_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.Kills(); !ok {
|
|
return &ValidationError{Name: "kills", err: errors.New(`ent: missing required field "MatchPlayer.kills"`)}
|
|
}
|
|
if _, ok := _c.mutation.Deaths(); !ok {
|
|
return &ValidationError{Name: "deaths", err: errors.New(`ent: missing required field "MatchPlayer.deaths"`)}
|
|
}
|
|
if _, ok := _c.mutation.Assists(); !ok {
|
|
return &ValidationError{Name: "assists", err: errors.New(`ent: missing required field "MatchPlayer.assists"`)}
|
|
}
|
|
if _, ok := _c.mutation.Headshot(); !ok {
|
|
return &ValidationError{Name: "headshot", err: errors.New(`ent: missing required field "MatchPlayer.headshot"`)}
|
|
}
|
|
if _, ok := _c.mutation.Mvp(); !ok {
|
|
return &ValidationError{Name: "mvp", err: errors.New(`ent: missing required field "MatchPlayer.mvp"`)}
|
|
}
|
|
if _, ok := _c.mutation.Score(); !ok {
|
|
return &ValidationError{Name: "score", err: errors.New(`ent: missing required field "MatchPlayer.score"`)}
|
|
}
|
|
if v, ok := _c.mutation.Color(); ok {
|
|
if err := matchplayer.ColorValidator(v); err != nil {
|
|
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "MatchPlayer.color": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *MatchPlayerCreate) sqlSave(ctx context.Context) (*MatchPlayer, error) {
|
|
if err := _c.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
_node, _spec := _c.createSpec()
|
|
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
id := _spec.ID.Value.(int64)
|
|
_node.ID = int(id)
|
|
_c.mutation.id = &_node.ID
|
|
_c.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (_c *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &MatchPlayer{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(matchplayer.Table, sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt))
|
|
)
|
|
if value, ok := _c.mutation.TeamID(); ok {
|
|
_spec.SetField(matchplayer.FieldTeamID, field.TypeInt, value)
|
|
_node.TeamID = value
|
|
}
|
|
if value, ok := _c.mutation.Kills(); ok {
|
|
_spec.SetField(matchplayer.FieldKills, field.TypeInt, value)
|
|
_node.Kills = value
|
|
}
|
|
if value, ok := _c.mutation.Deaths(); ok {
|
|
_spec.SetField(matchplayer.FieldDeaths, field.TypeInt, value)
|
|
_node.Deaths = value
|
|
}
|
|
if value, ok := _c.mutation.Assists(); ok {
|
|
_spec.SetField(matchplayer.FieldAssists, field.TypeInt, value)
|
|
_node.Assists = value
|
|
}
|
|
if value, ok := _c.mutation.Headshot(); ok {
|
|
_spec.SetField(matchplayer.FieldHeadshot, field.TypeInt, value)
|
|
_node.Headshot = value
|
|
}
|
|
if value, ok := _c.mutation.Mvp(); ok {
|
|
_spec.SetField(matchplayer.FieldMvp, field.TypeUint, value)
|
|
_node.Mvp = value
|
|
}
|
|
if value, ok := _c.mutation.Score(); ok {
|
|
_spec.SetField(matchplayer.FieldScore, field.TypeInt, value)
|
|
_node.Score = value
|
|
}
|
|
if value, ok := _c.mutation.RankNew(); ok {
|
|
_spec.SetField(matchplayer.FieldRankNew, field.TypeInt, value)
|
|
_node.RankNew = value
|
|
}
|
|
if value, ok := _c.mutation.RankOld(); ok {
|
|
_spec.SetField(matchplayer.FieldRankOld, field.TypeInt, value)
|
|
_node.RankOld = value
|
|
}
|
|
if value, ok := _c.mutation.Mk2(); ok {
|
|
_spec.SetField(matchplayer.FieldMk2, field.TypeUint, value)
|
|
_node.Mk2 = value
|
|
}
|
|
if value, ok := _c.mutation.Mk3(); ok {
|
|
_spec.SetField(matchplayer.FieldMk3, field.TypeUint, value)
|
|
_node.Mk3 = value
|
|
}
|
|
if value, ok := _c.mutation.Mk4(); ok {
|
|
_spec.SetField(matchplayer.FieldMk4, field.TypeUint, value)
|
|
_node.Mk4 = value
|
|
}
|
|
if value, ok := _c.mutation.Mk5(); ok {
|
|
_spec.SetField(matchplayer.FieldMk5, field.TypeUint, value)
|
|
_node.Mk5 = value
|
|
}
|
|
if value, ok := _c.mutation.DmgEnemy(); ok {
|
|
_spec.SetField(matchplayer.FieldDmgEnemy, field.TypeUint, value)
|
|
_node.DmgEnemy = value
|
|
}
|
|
if value, ok := _c.mutation.DmgTeam(); ok {
|
|
_spec.SetField(matchplayer.FieldDmgTeam, field.TypeUint, value)
|
|
_node.DmgTeam = value
|
|
}
|
|
if value, ok := _c.mutation.UdHe(); ok {
|
|
_spec.SetField(matchplayer.FieldUdHe, field.TypeUint, value)
|
|
_node.UdHe = value
|
|
}
|
|
if value, ok := _c.mutation.UdFlames(); ok {
|
|
_spec.SetField(matchplayer.FieldUdFlames, field.TypeUint, value)
|
|
_node.UdFlames = value
|
|
}
|
|
if value, ok := _c.mutation.UdFlash(); ok {
|
|
_spec.SetField(matchplayer.FieldUdFlash, field.TypeUint, value)
|
|
_node.UdFlash = value
|
|
}
|
|
if value, ok := _c.mutation.UdDecoy(); ok {
|
|
_spec.SetField(matchplayer.FieldUdDecoy, field.TypeUint, value)
|
|
_node.UdDecoy = value
|
|
}
|
|
if value, ok := _c.mutation.UdSmoke(); ok {
|
|
_spec.SetField(matchplayer.FieldUdSmoke, field.TypeUint, value)
|
|
_node.UdSmoke = value
|
|
}
|
|
if value, ok := _c.mutation.Crosshair(); ok {
|
|
_spec.SetField(matchplayer.FieldCrosshair, field.TypeString, value)
|
|
_node.Crosshair = value
|
|
}
|
|
if value, ok := _c.mutation.Color(); ok {
|
|
_spec.SetField(matchplayer.FieldColor, field.TypeEnum, value)
|
|
_node.Color = value
|
|
}
|
|
if value, ok := _c.mutation.Kast(); ok {
|
|
_spec.SetField(matchplayer.FieldKast, field.TypeInt, value)
|
|
_node.Kast = value
|
|
}
|
|
if value, ok := _c.mutation.FlashDurationSelf(); ok {
|
|
_spec.SetField(matchplayer.FieldFlashDurationSelf, field.TypeFloat32, value)
|
|
_node.FlashDurationSelf = value
|
|
}
|
|
if value, ok := _c.mutation.FlashDurationTeam(); ok {
|
|
_spec.SetField(matchplayer.FieldFlashDurationTeam, field.TypeFloat32, value)
|
|
_node.FlashDurationTeam = value
|
|
}
|
|
if value, ok := _c.mutation.FlashDurationEnemy(); ok {
|
|
_spec.SetField(matchplayer.FieldFlashDurationEnemy, field.TypeFloat32, value)
|
|
_node.FlashDurationEnemy = value
|
|
}
|
|
if value, ok := _c.mutation.FlashTotalSelf(); ok {
|
|
_spec.SetField(matchplayer.FieldFlashTotalSelf, field.TypeUint, value)
|
|
_node.FlashTotalSelf = value
|
|
}
|
|
if value, ok := _c.mutation.FlashTotalTeam(); ok {
|
|
_spec.SetField(matchplayer.FieldFlashTotalTeam, field.TypeUint, value)
|
|
_node.FlashTotalTeam = value
|
|
}
|
|
if value, ok := _c.mutation.FlashTotalEnemy(); ok {
|
|
_spec.SetField(matchplayer.FieldFlashTotalEnemy, field.TypeUint, value)
|
|
_node.FlashTotalEnemy = value
|
|
}
|
|
if value, ok := _c.mutation.FlashAssists(); ok {
|
|
_spec.SetField(matchplayer.FieldFlashAssists, field.TypeInt, value)
|
|
_node.FlashAssists = value
|
|
}
|
|
if value, ok := _c.mutation.AvgPing(); ok {
|
|
_spec.SetField(matchplayer.FieldAvgPing, field.TypeFloat64, value)
|
|
_node.AvgPing = value
|
|
}
|
|
if nodes := _c.mutation.MatchesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: matchplayer.MatchesTable,
|
|
Columns: []string{matchplayer.MatchesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.MatchStats = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.PlayersIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: matchplayer.PlayersTable,
|
|
Columns: []string{matchplayer.PlayersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.PlayerStats = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.WeaponStatsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: matchplayer.WeaponStatsTable,
|
|
Columns: []string{matchplayer.WeaponStatsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.RoundStatsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: matchplayer.RoundStatsTable,
|
|
Columns: []string{matchplayer.RoundStatsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.SprayIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: matchplayer.SprayTable,
|
|
Columns: []string{matchplayer.SprayColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.MessagesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: matchplayer.MessagesTable,
|
|
Columns: []string{matchplayer.MessagesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// MatchPlayerCreateBulk is the builder for creating many MatchPlayer entities in bulk.
|
|
type MatchPlayerCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*MatchPlayerCreate
|
|
}
|
|
|
|
// Save creates the MatchPlayer entities in the database.
|
|
func (_c *MatchPlayerCreateBulk) Save(ctx context.Context) ([]*MatchPlayer, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*MatchPlayer, len(_c.builders))
|
|
mutators := make([]Mutator, len(_c.builders))
|
|
for i := range _c.builders {
|
|
func(i int, root context.Context) {
|
|
builder := _c.builders[i]
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*MatchPlayerMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
if err := builder.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
builder.mutation = mutation
|
|
var err error
|
|
nodes[i], specs[i] = builder.createSpec()
|
|
if i < len(mutators)-1 {
|
|
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
|
} else {
|
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
// Invoke the actual operation on the latest mutation in the chain.
|
|
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
}
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
mutation.id = &nodes[i].ID
|
|
if specs[i].ID.Value != nil {
|
|
id := specs[i].ID.Value.(int64)
|
|
nodes[i].ID = int(id)
|
|
}
|
|
mutation.done = true
|
|
return nodes[i], nil
|
|
})
|
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
|
mut = builder.hooks[i](mut)
|
|
}
|
|
mutators[i] = mut
|
|
}(i, ctx)
|
|
}
|
|
if len(mutators) > 0 {
|
|
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_c *MatchPlayerCreateBulk) SaveX(ctx context.Context) []*MatchPlayer {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *MatchPlayerCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *MatchPlayerCreateBulk) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|