regenerate ent
This commit is contained in:
@@ -24,68 +24,76 @@ type SprayUpdate struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SprayUpdate builder.
|
||||
func (su *SprayUpdate) Where(ps ...predicate.Spray) *SprayUpdate {
|
||||
su.mutation.Where(ps...)
|
||||
return su
|
||||
func (_u *SprayUpdate) Where(ps ...predicate.Spray) *SprayUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetWeapon sets the "weapon" field.
|
||||
func (su *SprayUpdate) SetWeapon(i int) *SprayUpdate {
|
||||
su.mutation.ResetWeapon()
|
||||
su.mutation.SetWeapon(i)
|
||||
return su
|
||||
func (_u *SprayUpdate) SetWeapon(v int) *SprayUpdate {
|
||||
_u.mutation.ResetWeapon()
|
||||
_u.mutation.SetWeapon(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddWeapon adds i to the "weapon" field.
|
||||
func (su *SprayUpdate) AddWeapon(i int) *SprayUpdate {
|
||||
su.mutation.AddWeapon(i)
|
||||
return su
|
||||
// SetNillableWeapon sets the "weapon" field if the given value is not nil.
|
||||
func (_u *SprayUpdate) SetNillableWeapon(v *int) *SprayUpdate {
|
||||
if v != nil {
|
||||
_u.SetWeapon(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddWeapon adds value to the "weapon" field.
|
||||
func (_u *SprayUpdate) AddWeapon(v int) *SprayUpdate {
|
||||
_u.mutation.AddWeapon(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSpray sets the "spray" field.
|
||||
func (su *SprayUpdate) SetSpray(b []byte) *SprayUpdate {
|
||||
su.mutation.SetSpray(b)
|
||||
return su
|
||||
func (_u *SprayUpdate) SetSpray(v []byte) *SprayUpdate {
|
||||
_u.mutation.SetSpray(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID.
|
||||
func (su *SprayUpdate) SetMatchPlayersID(id int) *SprayUpdate {
|
||||
su.mutation.SetMatchPlayersID(id)
|
||||
return su
|
||||
func (_u *SprayUpdate) SetMatchPlayersID(id int) *SprayUpdate {
|
||||
_u.mutation.SetMatchPlayersID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID if the given value is not nil.
|
||||
func (su *SprayUpdate) SetNillableMatchPlayersID(id *int) *SprayUpdate {
|
||||
func (_u *SprayUpdate) SetNillableMatchPlayersID(id *int) *SprayUpdate {
|
||||
if id != nil {
|
||||
su = su.SetMatchPlayersID(*id)
|
||||
_u = _u.SetMatchPlayersID(*id)
|
||||
}
|
||||
return su
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMatchPlayers sets the "match_players" edge to the MatchPlayer entity.
|
||||
func (su *SprayUpdate) SetMatchPlayers(m *MatchPlayer) *SprayUpdate {
|
||||
return su.SetMatchPlayersID(m.ID)
|
||||
func (_u *SprayUpdate) SetMatchPlayers(v *MatchPlayer) *SprayUpdate {
|
||||
return _u.SetMatchPlayersID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the SprayMutation object of the builder.
|
||||
func (su *SprayUpdate) Mutation() *SprayMutation {
|
||||
return su.mutation
|
||||
func (_u *SprayUpdate) Mutation() *SprayMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearMatchPlayers clears the "match_players" edge to the MatchPlayer entity.
|
||||
func (su *SprayUpdate) ClearMatchPlayers() *SprayUpdate {
|
||||
su.mutation.ClearMatchPlayers()
|
||||
return su
|
||||
func (_u *SprayUpdate) ClearMatchPlayers() *SprayUpdate {
|
||||
_u.mutation.ClearMatchPlayers()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (su *SprayUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, su.sqlSave, su.mutation, su.hooks)
|
||||
func (_u *SprayUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (su *SprayUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := su.Save(ctx)
|
||||
func (_u *SprayUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -93,43 +101,43 @@ func (su *SprayUpdate) SaveX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (su *SprayUpdate) Exec(ctx context.Context) error {
|
||||
_, err := su.Save(ctx)
|
||||
func (_u *SprayUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (su *SprayUpdate) ExecX(ctx context.Context) {
|
||||
if err := su.Exec(ctx); err != nil {
|
||||
func (_u *SprayUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (su *SprayUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdate {
|
||||
su.modifiers = append(su.modifiers, modifiers...)
|
||||
return su
|
||||
func (_u *SprayUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdate {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
func (_u *SprayUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(spray.Table, spray.Columns, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt))
|
||||
if ps := su.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := su.mutation.Weapon(); ok {
|
||||
if value, ok := _u.mutation.Weapon(); ok {
|
||||
_spec.SetField(spray.FieldWeapon, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := su.mutation.AddedWeapon(); ok {
|
||||
if value, ok := _u.mutation.AddedWeapon(); ok {
|
||||
_spec.AddField(spray.FieldWeapon, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := su.mutation.Spray(); ok {
|
||||
if value, ok := _u.mutation.Spray(); ok {
|
||||
_spec.SetField(spray.FieldSpray, field.TypeBytes, value)
|
||||
}
|
||||
if su.mutation.MatchPlayersCleared() {
|
||||
if _u.mutation.MatchPlayersCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -142,7 +150,7 @@ func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := su.mutation.MatchPlayersIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.MatchPlayersIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -158,8 +166,8 @@ func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_spec.AddModifiers(su.modifiers...)
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil {
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{spray.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -167,8 +175,8 @@ func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
su.mutation.done = true
|
||||
return n, nil
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// SprayUpdateOne is the builder for updating a single Spray entity.
|
||||
@@ -181,75 +189,83 @@ type SprayUpdateOne struct {
|
||||
}
|
||||
|
||||
// SetWeapon sets the "weapon" field.
|
||||
func (suo *SprayUpdateOne) SetWeapon(i int) *SprayUpdateOne {
|
||||
suo.mutation.ResetWeapon()
|
||||
suo.mutation.SetWeapon(i)
|
||||
return suo
|
||||
func (_u *SprayUpdateOne) SetWeapon(v int) *SprayUpdateOne {
|
||||
_u.mutation.ResetWeapon()
|
||||
_u.mutation.SetWeapon(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddWeapon adds i to the "weapon" field.
|
||||
func (suo *SprayUpdateOne) AddWeapon(i int) *SprayUpdateOne {
|
||||
suo.mutation.AddWeapon(i)
|
||||
return suo
|
||||
// SetNillableWeapon sets the "weapon" field if the given value is not nil.
|
||||
func (_u *SprayUpdateOne) SetNillableWeapon(v *int) *SprayUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetWeapon(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddWeapon adds value to the "weapon" field.
|
||||
func (_u *SprayUpdateOne) AddWeapon(v int) *SprayUpdateOne {
|
||||
_u.mutation.AddWeapon(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSpray sets the "spray" field.
|
||||
func (suo *SprayUpdateOne) SetSpray(b []byte) *SprayUpdateOne {
|
||||
suo.mutation.SetSpray(b)
|
||||
return suo
|
||||
func (_u *SprayUpdateOne) SetSpray(v []byte) *SprayUpdateOne {
|
||||
_u.mutation.SetSpray(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID.
|
||||
func (suo *SprayUpdateOne) SetMatchPlayersID(id int) *SprayUpdateOne {
|
||||
suo.mutation.SetMatchPlayersID(id)
|
||||
return suo
|
||||
func (_u *SprayUpdateOne) SetMatchPlayersID(id int) *SprayUpdateOne {
|
||||
_u.mutation.SetMatchPlayersID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID if the given value is not nil.
|
||||
func (suo *SprayUpdateOne) SetNillableMatchPlayersID(id *int) *SprayUpdateOne {
|
||||
func (_u *SprayUpdateOne) SetNillableMatchPlayersID(id *int) *SprayUpdateOne {
|
||||
if id != nil {
|
||||
suo = suo.SetMatchPlayersID(*id)
|
||||
_u = _u.SetMatchPlayersID(*id)
|
||||
}
|
||||
return suo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMatchPlayers sets the "match_players" edge to the MatchPlayer entity.
|
||||
func (suo *SprayUpdateOne) SetMatchPlayers(m *MatchPlayer) *SprayUpdateOne {
|
||||
return suo.SetMatchPlayersID(m.ID)
|
||||
func (_u *SprayUpdateOne) SetMatchPlayers(v *MatchPlayer) *SprayUpdateOne {
|
||||
return _u.SetMatchPlayersID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the SprayMutation object of the builder.
|
||||
func (suo *SprayUpdateOne) Mutation() *SprayMutation {
|
||||
return suo.mutation
|
||||
func (_u *SprayUpdateOne) Mutation() *SprayMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearMatchPlayers clears the "match_players" edge to the MatchPlayer entity.
|
||||
func (suo *SprayUpdateOne) ClearMatchPlayers() *SprayUpdateOne {
|
||||
suo.mutation.ClearMatchPlayers()
|
||||
return suo
|
||||
func (_u *SprayUpdateOne) ClearMatchPlayers() *SprayUpdateOne {
|
||||
_u.mutation.ClearMatchPlayers()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SprayUpdate builder.
|
||||
func (suo *SprayUpdateOne) Where(ps ...predicate.Spray) *SprayUpdateOne {
|
||||
suo.mutation.Where(ps...)
|
||||
return suo
|
||||
func (_u *SprayUpdateOne) Where(ps ...predicate.Spray) *SprayUpdateOne {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (suo *SprayUpdateOne) Select(field string, fields ...string) *SprayUpdateOne {
|
||||
suo.fields = append([]string{field}, fields...)
|
||||
return suo
|
||||
func (_u *SprayUpdateOne) Select(field string, fields ...string) *SprayUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated Spray entity.
|
||||
func (suo *SprayUpdateOne) Save(ctx context.Context) (*Spray, error) {
|
||||
return withHooks(ctx, suo.sqlSave, suo.mutation, suo.hooks)
|
||||
func (_u *SprayUpdateOne) Save(ctx context.Context) (*Spray, error) {
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (suo *SprayUpdateOne) SaveX(ctx context.Context) *Spray {
|
||||
node, err := suo.Save(ctx)
|
||||
func (_u *SprayUpdateOne) SaveX(ctx context.Context) *Spray {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -257,32 +273,32 @@ func (suo *SprayUpdateOne) SaveX(ctx context.Context) *Spray {
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (suo *SprayUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := suo.Save(ctx)
|
||||
func (_u *SprayUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (suo *SprayUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := suo.Exec(ctx); err != nil {
|
||||
func (_u *SprayUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (suo *SprayUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdateOne {
|
||||
suo.modifiers = append(suo.modifiers, modifiers...)
|
||||
return suo
|
||||
func (_u *SprayUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdateOne {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error) {
|
||||
func (_u *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(spray.Table, spray.Columns, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt))
|
||||
id, ok := suo.mutation.ID()
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Spray.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := suo.fields; len(fields) > 0 {
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, spray.FieldID)
|
||||
for _, f := range fields {
|
||||
@@ -294,23 +310,23 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := suo.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := suo.mutation.Weapon(); ok {
|
||||
if value, ok := _u.mutation.Weapon(); ok {
|
||||
_spec.SetField(spray.FieldWeapon, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := suo.mutation.AddedWeapon(); ok {
|
||||
if value, ok := _u.mutation.AddedWeapon(); ok {
|
||||
_spec.AddField(spray.FieldWeapon, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := suo.mutation.Spray(); ok {
|
||||
if value, ok := _u.mutation.Spray(); ok {
|
||||
_spec.SetField(spray.FieldSpray, field.TypeBytes, value)
|
||||
}
|
||||
if suo.mutation.MatchPlayersCleared() {
|
||||
if _u.mutation.MatchPlayersCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -323,7 +339,7 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := suo.mutation.MatchPlayersIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.MatchPlayersIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -339,11 +355,11 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_spec.AddModifiers(suo.modifiers...)
|
||||
_node = &Spray{config: suo.config}
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
_node = &Spray{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil {
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{spray.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -351,6 +367,6 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
suo.mutation.done = true
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user