regenerate ent
This commit is contained in:
@@ -21,49 +21,49 @@ type SprayCreate struct {
|
||||
}
|
||||
|
||||
// SetWeapon sets the "weapon" field.
|
||||
func (sc *SprayCreate) SetWeapon(i int) *SprayCreate {
|
||||
sc.mutation.SetWeapon(i)
|
||||
return sc
|
||||
func (_c *SprayCreate) SetWeapon(v int) *SprayCreate {
|
||||
_c.mutation.SetWeapon(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetSpray sets the "spray" field.
|
||||
func (sc *SprayCreate) SetSpray(b []byte) *SprayCreate {
|
||||
sc.mutation.SetSpray(b)
|
||||
return sc
|
||||
func (_c *SprayCreate) SetSpray(v []byte) *SprayCreate {
|
||||
_c.mutation.SetSpray(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID.
|
||||
func (sc *SprayCreate) SetMatchPlayersID(id int) *SprayCreate {
|
||||
sc.mutation.SetMatchPlayersID(id)
|
||||
return sc
|
||||
func (_c *SprayCreate) SetMatchPlayersID(id int) *SprayCreate {
|
||||
_c.mutation.SetMatchPlayersID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID if the given value is not nil.
|
||||
func (sc *SprayCreate) SetNillableMatchPlayersID(id *int) *SprayCreate {
|
||||
func (_c *SprayCreate) SetNillableMatchPlayersID(id *int) *SprayCreate {
|
||||
if id != nil {
|
||||
sc = sc.SetMatchPlayersID(*id)
|
||||
_c = _c.SetMatchPlayersID(*id)
|
||||
}
|
||||
return sc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMatchPlayers sets the "match_players" edge to the MatchPlayer entity.
|
||||
func (sc *SprayCreate) SetMatchPlayers(m *MatchPlayer) *SprayCreate {
|
||||
return sc.SetMatchPlayersID(m.ID)
|
||||
func (_c *SprayCreate) SetMatchPlayers(v *MatchPlayer) *SprayCreate {
|
||||
return _c.SetMatchPlayersID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the SprayMutation object of the builder.
|
||||
func (sc *SprayCreate) Mutation() *SprayMutation {
|
||||
return sc.mutation
|
||||
func (_c *SprayCreate) Mutation() *SprayMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the Spray in the database.
|
||||
func (sc *SprayCreate) Save(ctx context.Context) (*Spray, error) {
|
||||
return withHooks(ctx, sc.sqlSave, sc.mutation, sc.hooks)
|
||||
func (_c *SprayCreate) Save(ctx context.Context) (*Spray, error) {
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (sc *SprayCreate) SaveX(ctx context.Context) *Spray {
|
||||
v, err := sc.Save(ctx)
|
||||
func (_c *SprayCreate) SaveX(ctx context.Context) *Spray {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -71,35 +71,35 @@ func (sc *SprayCreate) SaveX(ctx context.Context) *Spray {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (sc *SprayCreate) Exec(ctx context.Context) error {
|
||||
_, err := sc.Save(ctx)
|
||||
func (_c *SprayCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (sc *SprayCreate) ExecX(ctx context.Context) {
|
||||
if err := sc.Exec(ctx); err != nil {
|
||||
func (_c *SprayCreate) 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 (sc *SprayCreate) check() error {
|
||||
if _, ok := sc.mutation.Weapon(); !ok {
|
||||
func (_c *SprayCreate) check() error {
|
||||
if _, ok := _c.mutation.Weapon(); !ok {
|
||||
return &ValidationError{Name: "weapon", err: errors.New(`ent: missing required field "Spray.weapon"`)}
|
||||
}
|
||||
if _, ok := sc.mutation.Spray(); !ok {
|
||||
if _, ok := _c.mutation.Spray(); !ok {
|
||||
return &ValidationError{Name: "spray", err: errors.New(`ent: missing required field "Spray.spray"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sc *SprayCreate) sqlSave(ctx context.Context) (*Spray, error) {
|
||||
if err := sc.check(); err != nil {
|
||||
func (_c *SprayCreate) sqlSave(ctx context.Context) (*Spray, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := sc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, sc.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}
|
||||
}
|
||||
@@ -107,25 +107,25 @@ func (sc *SprayCreate) sqlSave(ctx context.Context) (*Spray, error) {
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
sc.mutation.id = &_node.ID
|
||||
sc.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (sc *SprayCreate) createSpec() (*Spray, *sqlgraph.CreateSpec) {
|
||||
func (_c *SprayCreate) createSpec() (*Spray, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Spray{config: sc.config}
|
||||
_node = &Spray{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(spray.Table, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := sc.mutation.Weapon(); ok {
|
||||
if value, ok := _c.mutation.Weapon(); ok {
|
||||
_spec.SetField(spray.FieldWeapon, field.TypeInt, value)
|
||||
_node.Weapon = value
|
||||
}
|
||||
if value, ok := sc.mutation.Spray(); ok {
|
||||
if value, ok := _c.mutation.Spray(); ok {
|
||||
_spec.SetField(spray.FieldSpray, field.TypeBytes, value)
|
||||
_node.Spray = value
|
||||
}
|
||||
if nodes := sc.mutation.MatchPlayersIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.MatchPlayersIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -148,17 +148,21 @@ func (sc *SprayCreate) createSpec() (*Spray, *sqlgraph.CreateSpec) {
|
||||
// SprayCreateBulk is the builder for creating many Spray entities in bulk.
|
||||
type SprayCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*SprayCreate
|
||||
}
|
||||
|
||||
// Save creates the Spray entities in the database.
|
||||
func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(scb.builders))
|
||||
nodes := make([]*Spray, len(scb.builders))
|
||||
mutators := make([]Mutator, len(scb.builders))
|
||||
for i := range scb.builders {
|
||||
func (_c *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*Spray, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := scb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*SprayMutation)
|
||||
if !ok {
|
||||
@@ -171,11 +175,11 @@ func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, scb.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, scb.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}
|
||||
}
|
||||
@@ -199,7 +203,7 @@ func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, scb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -207,8 +211,8 @@ func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (scb *SprayCreateBulk) SaveX(ctx context.Context) []*Spray {
|
||||
v, err := scb.Save(ctx)
|
||||
func (_c *SprayCreateBulk) SaveX(ctx context.Context) []*Spray {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -216,14 +220,14 @@ func (scb *SprayCreateBulk) SaveX(ctx context.Context) []*Spray {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (scb *SprayCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := scb.Save(ctx)
|
||||
func (_c *SprayCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (scb *SprayCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := scb.Exec(ctx); err != nil {
|
||||
func (_c *SprayCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user