regenerate ent
This commit is contained in:
@@ -23,187 +23,187 @@ type MatchCreate struct {
|
||||
}
|
||||
|
||||
// SetShareCode sets the "share_code" field.
|
||||
func (mc *MatchCreate) SetShareCode(s string) *MatchCreate {
|
||||
mc.mutation.SetShareCode(s)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetShareCode(v string) *MatchCreate {
|
||||
_c.mutation.SetShareCode(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMap sets the "map" field.
|
||||
func (mc *MatchCreate) SetMap(s string) *MatchCreate {
|
||||
mc.mutation.SetMap(s)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetMap(v string) *MatchCreate {
|
||||
_c.mutation.SetMap(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableMap sets the "map" field if the given value is not nil.
|
||||
func (mc *MatchCreate) SetNillableMap(s *string) *MatchCreate {
|
||||
if s != nil {
|
||||
mc.SetMap(*s)
|
||||
func (_c *MatchCreate) SetNillableMap(v *string) *MatchCreate {
|
||||
if v != nil {
|
||||
_c.SetMap(*v)
|
||||
}
|
||||
return mc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDate sets the "date" field.
|
||||
func (mc *MatchCreate) SetDate(t time.Time) *MatchCreate {
|
||||
mc.mutation.SetDate(t)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetDate(v time.Time) *MatchCreate {
|
||||
_c.mutation.SetDate(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetScoreTeamA sets the "score_team_a" field.
|
||||
func (mc *MatchCreate) SetScoreTeamA(i int) *MatchCreate {
|
||||
mc.mutation.SetScoreTeamA(i)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetScoreTeamA(v int) *MatchCreate {
|
||||
_c.mutation.SetScoreTeamA(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetScoreTeamB sets the "score_team_b" field.
|
||||
func (mc *MatchCreate) SetScoreTeamB(i int) *MatchCreate {
|
||||
mc.mutation.SetScoreTeamB(i)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetScoreTeamB(v int) *MatchCreate {
|
||||
_c.mutation.SetScoreTeamB(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetReplayURL sets the "replay_url" field.
|
||||
func (mc *MatchCreate) SetReplayURL(s string) *MatchCreate {
|
||||
mc.mutation.SetReplayURL(s)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetReplayURL(v string) *MatchCreate {
|
||||
_c.mutation.SetReplayURL(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableReplayURL sets the "replay_url" field if the given value is not nil.
|
||||
func (mc *MatchCreate) SetNillableReplayURL(s *string) *MatchCreate {
|
||||
if s != nil {
|
||||
mc.SetReplayURL(*s)
|
||||
func (_c *MatchCreate) SetNillableReplayURL(v *string) *MatchCreate {
|
||||
if v != nil {
|
||||
_c.SetReplayURL(*v)
|
||||
}
|
||||
return mc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDuration sets the "duration" field.
|
||||
func (mc *MatchCreate) SetDuration(i int) *MatchCreate {
|
||||
mc.mutation.SetDuration(i)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetDuration(v int) *MatchCreate {
|
||||
_c.mutation.SetDuration(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMatchResult sets the "match_result" field.
|
||||
func (mc *MatchCreate) SetMatchResult(i int) *MatchCreate {
|
||||
mc.mutation.SetMatchResult(i)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetMatchResult(v int) *MatchCreate {
|
||||
_c.mutation.SetMatchResult(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMaxRounds sets the "max_rounds" field.
|
||||
func (mc *MatchCreate) SetMaxRounds(i int) *MatchCreate {
|
||||
mc.mutation.SetMaxRounds(i)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetMaxRounds(v int) *MatchCreate {
|
||||
_c.mutation.SetMaxRounds(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDemoParsed sets the "demo_parsed" field.
|
||||
func (mc *MatchCreate) SetDemoParsed(b bool) *MatchCreate {
|
||||
mc.mutation.SetDemoParsed(b)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetDemoParsed(v bool) *MatchCreate {
|
||||
_c.mutation.SetDemoParsed(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDemoParsed sets the "demo_parsed" field if the given value is not nil.
|
||||
func (mc *MatchCreate) SetNillableDemoParsed(b *bool) *MatchCreate {
|
||||
if b != nil {
|
||||
mc.SetDemoParsed(*b)
|
||||
func (_c *MatchCreate) SetNillableDemoParsed(v *bool) *MatchCreate {
|
||||
if v != nil {
|
||||
_c.SetDemoParsed(*v)
|
||||
}
|
||||
return mc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetVacPresent sets the "vac_present" field.
|
||||
func (mc *MatchCreate) SetVacPresent(b bool) *MatchCreate {
|
||||
mc.mutation.SetVacPresent(b)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetVacPresent(v bool) *MatchCreate {
|
||||
_c.mutation.SetVacPresent(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableVacPresent sets the "vac_present" field if the given value is not nil.
|
||||
func (mc *MatchCreate) SetNillableVacPresent(b *bool) *MatchCreate {
|
||||
if b != nil {
|
||||
mc.SetVacPresent(*b)
|
||||
func (_c *MatchCreate) SetNillableVacPresent(v *bool) *MatchCreate {
|
||||
if v != nil {
|
||||
_c.SetVacPresent(*v)
|
||||
}
|
||||
return mc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGamebanPresent sets the "gameban_present" field.
|
||||
func (mc *MatchCreate) SetGamebanPresent(b bool) *MatchCreate {
|
||||
mc.mutation.SetGamebanPresent(b)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetGamebanPresent(v bool) *MatchCreate {
|
||||
_c.mutation.SetGamebanPresent(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableGamebanPresent sets the "gameban_present" field if the given value is not nil.
|
||||
func (mc *MatchCreate) SetNillableGamebanPresent(b *bool) *MatchCreate {
|
||||
if b != nil {
|
||||
mc.SetGamebanPresent(*b)
|
||||
func (_c *MatchCreate) SetNillableGamebanPresent(v *bool) *MatchCreate {
|
||||
if v != nil {
|
||||
_c.SetGamebanPresent(*v)
|
||||
}
|
||||
return mc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDecryptionKey sets the "decryption_key" field.
|
||||
func (mc *MatchCreate) SetDecryptionKey(b []byte) *MatchCreate {
|
||||
mc.mutation.SetDecryptionKey(b)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetDecryptionKey(v []byte) *MatchCreate {
|
||||
_c.mutation.SetDecryptionKey(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetTickRate sets the "tick_rate" field.
|
||||
func (mc *MatchCreate) SetTickRate(f float64) *MatchCreate {
|
||||
mc.mutation.SetTickRate(f)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetTickRate(v float64) *MatchCreate {
|
||||
_c.mutation.SetTickRate(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableTickRate sets the "tick_rate" field if the given value is not nil.
|
||||
func (mc *MatchCreate) SetNillableTickRate(f *float64) *MatchCreate {
|
||||
if f != nil {
|
||||
mc.SetTickRate(*f)
|
||||
func (_c *MatchCreate) SetNillableTickRate(v *float64) *MatchCreate {
|
||||
if v != nil {
|
||||
_c.SetTickRate(*v)
|
||||
}
|
||||
return mc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (mc *MatchCreate) SetID(u uint64) *MatchCreate {
|
||||
mc.mutation.SetID(u)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetID(v uint64) *MatchCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs.
|
||||
func (mc *MatchCreate) AddStatIDs(ids ...int) *MatchCreate {
|
||||
mc.mutation.AddStatIDs(ids...)
|
||||
return mc
|
||||
func (_c *MatchCreate) AddStatIDs(ids ...int) *MatchCreate {
|
||||
_c.mutation.AddStatIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddStats adds the "stats" edges to the MatchPlayer entity.
|
||||
func (mc *MatchCreate) AddStats(m ...*MatchPlayer) *MatchCreate {
|
||||
ids := make([]int, len(m))
|
||||
for i := range m {
|
||||
ids[i] = m[i].ID
|
||||
func (_c *MatchCreate) AddStats(v ...*MatchPlayer) *MatchCreate {
|
||||
ids := make([]int, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return mc.AddStatIDs(ids...)
|
||||
return _c.AddStatIDs(ids...)
|
||||
}
|
||||
|
||||
// AddPlayerIDs adds the "players" edge to the Player entity by IDs.
|
||||
func (mc *MatchCreate) AddPlayerIDs(ids ...uint64) *MatchCreate {
|
||||
mc.mutation.AddPlayerIDs(ids...)
|
||||
return mc
|
||||
func (_c *MatchCreate) AddPlayerIDs(ids ...uint64) *MatchCreate {
|
||||
_c.mutation.AddPlayerIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddPlayers adds the "players" edges to the Player entity.
|
||||
func (mc *MatchCreate) AddPlayers(p ...*Player) *MatchCreate {
|
||||
ids := make([]uint64, len(p))
|
||||
for i := range p {
|
||||
ids[i] = p[i].ID
|
||||
func (_c *MatchCreate) AddPlayers(v ...*Player) *MatchCreate {
|
||||
ids := make([]uint64, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return mc.AddPlayerIDs(ids...)
|
||||
return _c.AddPlayerIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the MatchMutation object of the builder.
|
||||
func (mc *MatchCreate) Mutation() *MatchMutation {
|
||||
return mc.mutation
|
||||
func (_c *MatchCreate) Mutation() *MatchMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the Match in the database.
|
||||
func (mc *MatchCreate) Save(ctx context.Context) (*Match, error) {
|
||||
mc.defaults()
|
||||
return withHooks(ctx, mc.sqlSave, mc.mutation, mc.hooks)
|
||||
func (_c *MatchCreate) Save(ctx context.Context) (*Match, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (mc *MatchCreate) SaveX(ctx context.Context) *Match {
|
||||
v, err := mc.Save(ctx)
|
||||
func (_c *MatchCreate) SaveX(ctx context.Context) *Match {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -211,75 +211,75 @@ func (mc *MatchCreate) SaveX(ctx context.Context) *Match {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (mc *MatchCreate) Exec(ctx context.Context) error {
|
||||
_, err := mc.Save(ctx)
|
||||
func (_c *MatchCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (mc *MatchCreate) ExecX(ctx context.Context) {
|
||||
if err := mc.Exec(ctx); err != nil {
|
||||
func (_c *MatchCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (mc *MatchCreate) defaults() {
|
||||
if _, ok := mc.mutation.DemoParsed(); !ok {
|
||||
func (_c *MatchCreate) defaults() {
|
||||
if _, ok := _c.mutation.DemoParsed(); !ok {
|
||||
v := match.DefaultDemoParsed
|
||||
mc.mutation.SetDemoParsed(v)
|
||||
_c.mutation.SetDemoParsed(v)
|
||||
}
|
||||
if _, ok := mc.mutation.VacPresent(); !ok {
|
||||
if _, ok := _c.mutation.VacPresent(); !ok {
|
||||
v := match.DefaultVacPresent
|
||||
mc.mutation.SetVacPresent(v)
|
||||
_c.mutation.SetVacPresent(v)
|
||||
}
|
||||
if _, ok := mc.mutation.GamebanPresent(); !ok {
|
||||
if _, ok := _c.mutation.GamebanPresent(); !ok {
|
||||
v := match.DefaultGamebanPresent
|
||||
mc.mutation.SetGamebanPresent(v)
|
||||
_c.mutation.SetGamebanPresent(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (mc *MatchCreate) check() error {
|
||||
if _, ok := mc.mutation.ShareCode(); !ok {
|
||||
func (_c *MatchCreate) check() error {
|
||||
if _, ok := _c.mutation.ShareCode(); !ok {
|
||||
return &ValidationError{Name: "share_code", err: errors.New(`ent: missing required field "Match.share_code"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.Date(); !ok {
|
||||
if _, ok := _c.mutation.Date(); !ok {
|
||||
return &ValidationError{Name: "date", err: errors.New(`ent: missing required field "Match.date"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.ScoreTeamA(); !ok {
|
||||
if _, ok := _c.mutation.ScoreTeamA(); !ok {
|
||||
return &ValidationError{Name: "score_team_a", err: errors.New(`ent: missing required field "Match.score_team_a"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.ScoreTeamB(); !ok {
|
||||
if _, ok := _c.mutation.ScoreTeamB(); !ok {
|
||||
return &ValidationError{Name: "score_team_b", err: errors.New(`ent: missing required field "Match.score_team_b"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.Duration(); !ok {
|
||||
if _, ok := _c.mutation.Duration(); !ok {
|
||||
return &ValidationError{Name: "duration", err: errors.New(`ent: missing required field "Match.duration"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.MatchResult(); !ok {
|
||||
if _, ok := _c.mutation.MatchResult(); !ok {
|
||||
return &ValidationError{Name: "match_result", err: errors.New(`ent: missing required field "Match.match_result"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.MaxRounds(); !ok {
|
||||
if _, ok := _c.mutation.MaxRounds(); !ok {
|
||||
return &ValidationError{Name: "max_rounds", err: errors.New(`ent: missing required field "Match.max_rounds"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.DemoParsed(); !ok {
|
||||
if _, ok := _c.mutation.DemoParsed(); !ok {
|
||||
return &ValidationError{Name: "demo_parsed", err: errors.New(`ent: missing required field "Match.demo_parsed"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.VacPresent(); !ok {
|
||||
if _, ok := _c.mutation.VacPresent(); !ok {
|
||||
return &ValidationError{Name: "vac_present", err: errors.New(`ent: missing required field "Match.vac_present"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.GamebanPresent(); !ok {
|
||||
if _, ok := _c.mutation.GamebanPresent(); !ok {
|
||||
return &ValidationError{Name: "gameban_present", err: errors.New(`ent: missing required field "Match.gameban_present"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mc *MatchCreate) sqlSave(ctx context.Context) (*Match, error) {
|
||||
if err := mc.check(); err != nil {
|
||||
func (_c *MatchCreate) sqlSave(ctx context.Context) (*Match, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := mc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil {
|
||||
_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}
|
||||
}
|
||||
@@ -289,77 +289,77 @@ func (mc *MatchCreate) sqlSave(ctx context.Context) (*Match, error) {
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = uint64(id)
|
||||
}
|
||||
mc.mutation.id = &_node.ID
|
||||
mc.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
|
||||
func (_c *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Match{config: mc.config}
|
||||
_node = &Match{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(match.Table, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64))
|
||||
)
|
||||
if id, ok := mc.mutation.ID(); ok {
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = id
|
||||
}
|
||||
if value, ok := mc.mutation.ShareCode(); ok {
|
||||
if value, ok := _c.mutation.ShareCode(); ok {
|
||||
_spec.SetField(match.FieldShareCode, field.TypeString, value)
|
||||
_node.ShareCode = value
|
||||
}
|
||||
if value, ok := mc.mutation.Map(); ok {
|
||||
if value, ok := _c.mutation.Map(); ok {
|
||||
_spec.SetField(match.FieldMap, field.TypeString, value)
|
||||
_node.Map = value
|
||||
}
|
||||
if value, ok := mc.mutation.Date(); ok {
|
||||
if value, ok := _c.mutation.Date(); ok {
|
||||
_spec.SetField(match.FieldDate, field.TypeTime, value)
|
||||
_node.Date = value
|
||||
}
|
||||
if value, ok := mc.mutation.ScoreTeamA(); ok {
|
||||
if value, ok := _c.mutation.ScoreTeamA(); ok {
|
||||
_spec.SetField(match.FieldScoreTeamA, field.TypeInt, value)
|
||||
_node.ScoreTeamA = value
|
||||
}
|
||||
if value, ok := mc.mutation.ScoreTeamB(); ok {
|
||||
if value, ok := _c.mutation.ScoreTeamB(); ok {
|
||||
_spec.SetField(match.FieldScoreTeamB, field.TypeInt, value)
|
||||
_node.ScoreTeamB = value
|
||||
}
|
||||
if value, ok := mc.mutation.ReplayURL(); ok {
|
||||
if value, ok := _c.mutation.ReplayURL(); ok {
|
||||
_spec.SetField(match.FieldReplayURL, field.TypeString, value)
|
||||
_node.ReplayURL = value
|
||||
}
|
||||
if value, ok := mc.mutation.Duration(); ok {
|
||||
if value, ok := _c.mutation.Duration(); ok {
|
||||
_spec.SetField(match.FieldDuration, field.TypeInt, value)
|
||||
_node.Duration = value
|
||||
}
|
||||
if value, ok := mc.mutation.MatchResult(); ok {
|
||||
if value, ok := _c.mutation.MatchResult(); ok {
|
||||
_spec.SetField(match.FieldMatchResult, field.TypeInt, value)
|
||||
_node.MatchResult = value
|
||||
}
|
||||
if value, ok := mc.mutation.MaxRounds(); ok {
|
||||
if value, ok := _c.mutation.MaxRounds(); ok {
|
||||
_spec.SetField(match.FieldMaxRounds, field.TypeInt, value)
|
||||
_node.MaxRounds = value
|
||||
}
|
||||
if value, ok := mc.mutation.DemoParsed(); ok {
|
||||
if value, ok := _c.mutation.DemoParsed(); ok {
|
||||
_spec.SetField(match.FieldDemoParsed, field.TypeBool, value)
|
||||
_node.DemoParsed = value
|
||||
}
|
||||
if value, ok := mc.mutation.VacPresent(); ok {
|
||||
if value, ok := _c.mutation.VacPresent(); ok {
|
||||
_spec.SetField(match.FieldVacPresent, field.TypeBool, value)
|
||||
_node.VacPresent = value
|
||||
}
|
||||
if value, ok := mc.mutation.GamebanPresent(); ok {
|
||||
if value, ok := _c.mutation.GamebanPresent(); ok {
|
||||
_spec.SetField(match.FieldGamebanPresent, field.TypeBool, value)
|
||||
_node.GamebanPresent = value
|
||||
}
|
||||
if value, ok := mc.mutation.DecryptionKey(); ok {
|
||||
if value, ok := _c.mutation.DecryptionKey(); ok {
|
||||
_spec.SetField(match.FieldDecryptionKey, field.TypeBytes, value)
|
||||
_node.DecryptionKey = value
|
||||
}
|
||||
if value, ok := mc.mutation.TickRate(); ok {
|
||||
if value, ok := _c.mutation.TickRate(); ok {
|
||||
_spec.SetField(match.FieldTickRate, field.TypeFloat64, value)
|
||||
_node.TickRate = value
|
||||
}
|
||||
if nodes := mc.mutation.StatsIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.StatsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -375,7 +375,7 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := mc.mutation.PlayersIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.PlayersIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
@@ -397,17 +397,21 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
|
||||
// MatchCreateBulk is the builder for creating many Match entities in bulk.
|
||||
type MatchCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*MatchCreate
|
||||
}
|
||||
|
||||
// Save creates the Match entities in the database.
|
||||
func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(mcb.builders))
|
||||
nodes := make([]*Match, len(mcb.builders))
|
||||
mutators := make([]Mutator, len(mcb.builders))
|
||||
for i := range mcb.builders {
|
||||
func (_c *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*Match, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := mcb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*MatchMutation)
|
||||
@@ -421,11 +425,11 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, mcb.builders[i+1].mutation)
|
||||
_, 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, mcb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -449,7 +453,7 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, mcb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -457,8 +461,8 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (mcb *MatchCreateBulk) SaveX(ctx context.Context) []*Match {
|
||||
v, err := mcb.Save(ctx)
|
||||
func (_c *MatchCreateBulk) SaveX(ctx context.Context) []*Match {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -466,14 +470,14 @@ func (mcb *MatchCreateBulk) SaveX(ctx context.Context) []*Match {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (mcb *MatchCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := mcb.Save(ctx)
|
||||
func (_c *MatchCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (mcb *MatchCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := mcb.Exec(ctx); err != nil {
|
||||
func (_c *MatchCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user