added roundstats with eco info, switched to avatar hash
This commit is contained in:
575
ent/roundstats_update.go
Normal file
575
ent/roundstats_update.go
Normal file
@@ -0,0 +1,575 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/predicate"
|
||||
"csgowtfd/ent/roundstats"
|
||||
"csgowtfd/ent/stats"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// RoundStatsUpdate is the builder for updating RoundStats entities.
|
||||
type RoundStatsUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *RoundStatsMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the RoundStatsUpdate builder.
|
||||
func (rsu *RoundStatsUpdate) Where(ps ...predicate.RoundStats) *RoundStatsUpdate {
|
||||
rsu.mutation.Where(ps...)
|
||||
return rsu
|
||||
}
|
||||
|
||||
// SetRound sets the "round" field.
|
||||
func (rsu *RoundStatsUpdate) SetRound(u uint) *RoundStatsUpdate {
|
||||
rsu.mutation.ResetRound()
|
||||
rsu.mutation.SetRound(u)
|
||||
return rsu
|
||||
}
|
||||
|
||||
// AddRound adds u to the "round" field.
|
||||
func (rsu *RoundStatsUpdate) AddRound(u uint) *RoundStatsUpdate {
|
||||
rsu.mutation.AddRound(u)
|
||||
return rsu
|
||||
}
|
||||
|
||||
// SetBank sets the "bank" field.
|
||||
func (rsu *RoundStatsUpdate) SetBank(u uint) *RoundStatsUpdate {
|
||||
rsu.mutation.ResetBank()
|
||||
rsu.mutation.SetBank(u)
|
||||
return rsu
|
||||
}
|
||||
|
||||
// AddBank adds u to the "bank" field.
|
||||
func (rsu *RoundStatsUpdate) AddBank(u uint) *RoundStatsUpdate {
|
||||
rsu.mutation.AddBank(u)
|
||||
return rsu
|
||||
}
|
||||
|
||||
// SetEquipment sets the "equipment" field.
|
||||
func (rsu *RoundStatsUpdate) SetEquipment(u uint) *RoundStatsUpdate {
|
||||
rsu.mutation.ResetEquipment()
|
||||
rsu.mutation.SetEquipment(u)
|
||||
return rsu
|
||||
}
|
||||
|
||||
// AddEquipment adds u to the "equipment" field.
|
||||
func (rsu *RoundStatsUpdate) AddEquipment(u uint) *RoundStatsUpdate {
|
||||
rsu.mutation.AddEquipment(u)
|
||||
return rsu
|
||||
}
|
||||
|
||||
// SetSpent sets the "spent" field.
|
||||
func (rsu *RoundStatsUpdate) SetSpent(u uint) *RoundStatsUpdate {
|
||||
rsu.mutation.ResetSpent()
|
||||
rsu.mutation.SetSpent(u)
|
||||
return rsu
|
||||
}
|
||||
|
||||
// AddSpent adds u to the "spent" field.
|
||||
func (rsu *RoundStatsUpdate) AddSpent(u uint) *RoundStatsUpdate {
|
||||
rsu.mutation.AddSpent(u)
|
||||
return rsu
|
||||
}
|
||||
|
||||
// SetStatID sets the "stat" edge to the Stats entity by ID.
|
||||
func (rsu *RoundStatsUpdate) SetStatID(id int) *RoundStatsUpdate {
|
||||
rsu.mutation.SetStatID(id)
|
||||
return rsu
|
||||
}
|
||||
|
||||
// SetNillableStatID sets the "stat" edge to the Stats entity by ID if the given value is not nil.
|
||||
func (rsu *RoundStatsUpdate) SetNillableStatID(id *int) *RoundStatsUpdate {
|
||||
if id != nil {
|
||||
rsu = rsu.SetStatID(*id)
|
||||
}
|
||||
return rsu
|
||||
}
|
||||
|
||||
// SetStat sets the "stat" edge to the Stats entity.
|
||||
func (rsu *RoundStatsUpdate) SetStat(s *Stats) *RoundStatsUpdate {
|
||||
return rsu.SetStatID(s.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the RoundStatsMutation object of the builder.
|
||||
func (rsu *RoundStatsUpdate) Mutation() *RoundStatsMutation {
|
||||
return rsu.mutation
|
||||
}
|
||||
|
||||
// ClearStat clears the "stat" edge to the Stats entity.
|
||||
func (rsu *RoundStatsUpdate) ClearStat() *RoundStatsUpdate {
|
||||
rsu.mutation.ClearStat()
|
||||
return rsu
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (rsu *RoundStatsUpdate) Save(ctx context.Context) (int, error) {
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(rsu.hooks) == 0 {
|
||||
affected, err = rsu.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*RoundStatsMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
rsu.mutation = mutation
|
||||
affected, err = rsu.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(rsu.hooks) - 1; i >= 0; i-- {
|
||||
if rsu.hooks[i] == nil {
|
||||
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||
}
|
||||
mut = rsu.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, rsu.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (rsu *RoundStatsUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := rsu.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (rsu *RoundStatsUpdate) Exec(ctx context.Context) error {
|
||||
_, err := rsu.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (rsu *RoundStatsUpdate) ExecX(ctx context.Context) {
|
||||
if err := rsu.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: roundstats.Table,
|
||||
Columns: roundstats.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: roundstats.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := rsu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := rsu.mutation.Round(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: roundstats.FieldRound,
|
||||
})
|
||||
}
|
||||
if value, ok := rsu.mutation.AddedRound(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: roundstats.FieldRound,
|
||||
})
|
||||
}
|
||||
if value, ok := rsu.mutation.Bank(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: roundstats.FieldBank,
|
||||
})
|
||||
}
|
||||
if value, ok := rsu.mutation.AddedBank(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: roundstats.FieldBank,
|
||||
})
|
||||
}
|
||||
if value, ok := rsu.mutation.Equipment(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: roundstats.FieldEquipment,
|
||||
})
|
||||
}
|
||||
if value, ok := rsu.mutation.AddedEquipment(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: roundstats.FieldEquipment,
|
||||
})
|
||||
}
|
||||
if value, ok := rsu.mutation.Spent(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: roundstats.FieldSpent,
|
||||
})
|
||||
}
|
||||
if value, ok := rsu.mutation.AddedSpent(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: roundstats.FieldSpent,
|
||||
})
|
||||
}
|
||||
if rsu.mutation.StatCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: roundstats.StatTable,
|
||||
Columns: []string{roundstats.StatColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: stats.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := rsu.mutation.StatIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: roundstats.StatTable,
|
||||
Columns: []string{roundstats.StatColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: stats.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, rsu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{roundstats.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// RoundStatsUpdateOne is the builder for updating a single RoundStats entity.
|
||||
type RoundStatsUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *RoundStatsMutation
|
||||
}
|
||||
|
||||
// SetRound sets the "round" field.
|
||||
func (rsuo *RoundStatsUpdateOne) SetRound(u uint) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.ResetRound()
|
||||
rsuo.mutation.SetRound(u)
|
||||
return rsuo
|
||||
}
|
||||
|
||||
// AddRound adds u to the "round" field.
|
||||
func (rsuo *RoundStatsUpdateOne) AddRound(u uint) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.AddRound(u)
|
||||
return rsuo
|
||||
}
|
||||
|
||||
// SetBank sets the "bank" field.
|
||||
func (rsuo *RoundStatsUpdateOne) SetBank(u uint) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.ResetBank()
|
||||
rsuo.mutation.SetBank(u)
|
||||
return rsuo
|
||||
}
|
||||
|
||||
// AddBank adds u to the "bank" field.
|
||||
func (rsuo *RoundStatsUpdateOne) AddBank(u uint) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.AddBank(u)
|
||||
return rsuo
|
||||
}
|
||||
|
||||
// SetEquipment sets the "equipment" field.
|
||||
func (rsuo *RoundStatsUpdateOne) SetEquipment(u uint) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.ResetEquipment()
|
||||
rsuo.mutation.SetEquipment(u)
|
||||
return rsuo
|
||||
}
|
||||
|
||||
// AddEquipment adds u to the "equipment" field.
|
||||
func (rsuo *RoundStatsUpdateOne) AddEquipment(u uint) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.AddEquipment(u)
|
||||
return rsuo
|
||||
}
|
||||
|
||||
// SetSpent sets the "spent" field.
|
||||
func (rsuo *RoundStatsUpdateOne) SetSpent(u uint) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.ResetSpent()
|
||||
rsuo.mutation.SetSpent(u)
|
||||
return rsuo
|
||||
}
|
||||
|
||||
// AddSpent adds u to the "spent" field.
|
||||
func (rsuo *RoundStatsUpdateOne) AddSpent(u uint) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.AddSpent(u)
|
||||
return rsuo
|
||||
}
|
||||
|
||||
// SetStatID sets the "stat" edge to the Stats entity by ID.
|
||||
func (rsuo *RoundStatsUpdateOne) SetStatID(id int) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.SetStatID(id)
|
||||
return rsuo
|
||||
}
|
||||
|
||||
// SetNillableStatID sets the "stat" edge to the Stats entity by ID if the given value is not nil.
|
||||
func (rsuo *RoundStatsUpdateOne) SetNillableStatID(id *int) *RoundStatsUpdateOne {
|
||||
if id != nil {
|
||||
rsuo = rsuo.SetStatID(*id)
|
||||
}
|
||||
return rsuo
|
||||
}
|
||||
|
||||
// SetStat sets the "stat" edge to the Stats entity.
|
||||
func (rsuo *RoundStatsUpdateOne) SetStat(s *Stats) *RoundStatsUpdateOne {
|
||||
return rsuo.SetStatID(s.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the RoundStatsMutation object of the builder.
|
||||
func (rsuo *RoundStatsUpdateOne) Mutation() *RoundStatsMutation {
|
||||
return rsuo.mutation
|
||||
}
|
||||
|
||||
// ClearStat clears the "stat" edge to the Stats entity.
|
||||
func (rsuo *RoundStatsUpdateOne) ClearStat() *RoundStatsUpdateOne {
|
||||
rsuo.mutation.ClearStat()
|
||||
return rsuo
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (rsuo *RoundStatsUpdateOne) Select(field string, fields ...string) *RoundStatsUpdateOne {
|
||||
rsuo.fields = append([]string{field}, fields...)
|
||||
return rsuo
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated RoundStats entity.
|
||||
func (rsuo *RoundStatsUpdateOne) Save(ctx context.Context) (*RoundStats, error) {
|
||||
var (
|
||||
err error
|
||||
node *RoundStats
|
||||
)
|
||||
if len(rsuo.hooks) == 0 {
|
||||
node, err = rsuo.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*RoundStatsMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
rsuo.mutation = mutation
|
||||
node, err = rsuo.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(rsuo.hooks) - 1; i >= 0; i-- {
|
||||
if rsuo.hooks[i] == nil {
|
||||
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||
}
|
||||
mut = rsuo.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, rsuo.mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return node, err
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (rsuo *RoundStatsUpdateOne) SaveX(ctx context.Context) *RoundStats {
|
||||
node, err := rsuo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (rsuo *RoundStatsUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := rsuo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (rsuo *RoundStatsUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := rsuo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: roundstats.Table,
|
||||
Columns: roundstats.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: roundstats.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
id, ok := rsuo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing RoundStats.ID for update")}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := rsuo.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, roundstats.FieldID)
|
||||
for _, f := range fields {
|
||||
if !roundstats.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != roundstats.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := rsuo.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := rsuo.mutation.Round(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: roundstats.FieldRound,
|
||||
})
|
||||
}
|
||||
if value, ok := rsuo.mutation.AddedRound(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: roundstats.FieldRound,
|
||||
})
|
||||
}
|
||||
if value, ok := rsuo.mutation.Bank(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: roundstats.FieldBank,
|
||||
})
|
||||
}
|
||||
if value, ok := rsuo.mutation.AddedBank(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: roundstats.FieldBank,
|
||||
})
|
||||
}
|
||||
if value, ok := rsuo.mutation.Equipment(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: roundstats.FieldEquipment,
|
||||
})
|
||||
}
|
||||
if value, ok := rsuo.mutation.AddedEquipment(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: roundstats.FieldEquipment,
|
||||
})
|
||||
}
|
||||
if value, ok := rsuo.mutation.Spent(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: roundstats.FieldSpent,
|
||||
})
|
||||
}
|
||||
if value, ok := rsuo.mutation.AddedSpent(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint,
|
||||
Value: value,
|
||||
Column: roundstats.FieldSpent,
|
||||
})
|
||||
}
|
||||
if rsuo.mutation.StatCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: roundstats.StatTable,
|
||||
Columns: []string{roundstats.StatColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: stats.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := rsuo.mutation.StatIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: roundstats.StatTable,
|
||||
Columns: []string{roundstats.StatColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: stats.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &RoundStats{config: rsuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, rsuo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{roundstats.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return _node, nil
|
||||
}
|
Reference in New Issue
Block a user