// Code generated by ent, DO NOT EDIT. package ent import ( "bj_power_wms/ent/produciblesnapshot" "context" "errors" "fmt" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // ProducibleSnapshotCreate is the builder for creating a ProducibleSnapshot entity. type ProducibleSnapshotCreate struct { config mutation *ProducibleSnapshotMutation hooks []Hook conflict []sql.ConflictOption } // SetProductCode sets the "product_code" field. func (_c *ProducibleSnapshotCreate) SetProductCode(v string) *ProducibleSnapshotCreate { _c.mutation.SetProductCode(v) return _c } // SetProductName sets the "product_name" field. func (_c *ProducibleSnapshotCreate) SetProductName(v string) *ProducibleSnapshotCreate { _c.mutation.SetProductName(v) return _c } // SetNillableProductName sets the "product_name" field if the given value is not nil. func (_c *ProducibleSnapshotCreate) SetNillableProductName(v *string) *ProducibleSnapshotCreate { if v != nil { _c.SetProductName(*v) } return _c } // SetProducibleQty sets the "producible_qty" field. func (_c *ProducibleSnapshotCreate) SetProducibleQty(v int) *ProducibleSnapshotCreate { _c.mutation.SetProducibleQty(v) return _c } // SetNillableProducibleQty sets the "producible_qty" field if the given value is not nil. func (_c *ProducibleSnapshotCreate) SetNillableProducibleQty(v *int) *ProducibleSnapshotCreate { if v != nil { _c.SetProducibleQty(*v) } return _c } // SetShortText sets the "short_text" field. func (_c *ProducibleSnapshotCreate) SetShortText(v string) *ProducibleSnapshotCreate { _c.mutation.SetShortText(v) return _c } // SetNillableShortText sets the "short_text" field if the given value is not nil. func (_c *ProducibleSnapshotCreate) SetNillableShortText(v *string) *ProducibleSnapshotCreate { if v != nil { _c.SetShortText(*v) } return _c } // SetComputedAt sets the "computed_at" field. func (_c *ProducibleSnapshotCreate) SetComputedAt(v int64) *ProducibleSnapshotCreate { _c.mutation.SetComputedAt(v) return _c } // SetNillableComputedAt sets the "computed_at" field if the given value is not nil. func (_c *ProducibleSnapshotCreate) SetNillableComputedAt(v *int64) *ProducibleSnapshotCreate { if v != nil { _c.SetComputedAt(*v) } return _c } // SetSyncedAt sets the "synced_at" field. func (_c *ProducibleSnapshotCreate) SetSyncedAt(v int64) *ProducibleSnapshotCreate { _c.mutation.SetSyncedAt(v) return _c } // SetNillableSyncedAt sets the "synced_at" field if the given value is not nil. func (_c *ProducibleSnapshotCreate) SetNillableSyncedAt(v *int64) *ProducibleSnapshotCreate { if v != nil { _c.SetSyncedAt(*v) } return _c } // Mutation returns the ProducibleSnapshotMutation object of the builder. func (_c *ProducibleSnapshotCreate) Mutation() *ProducibleSnapshotMutation { return _c.mutation } // Save creates the ProducibleSnapshot in the database. func (_c *ProducibleSnapshotCreate) Save(ctx context.Context) (*ProducibleSnapshot, error) { _c.defaults() return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. func (_c *ProducibleSnapshotCreate) SaveX(ctx context.Context) *ProducibleSnapshot { v, err := _c.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (_c *ProducibleSnapshotCreate) Exec(ctx context.Context) error { _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_c *ProducibleSnapshotCreate) ExecX(ctx context.Context) { if err := _c.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. func (_c *ProducibleSnapshotCreate) defaults() { if _, ok := _c.mutation.ProducibleQty(); !ok { v := produciblesnapshot.DefaultProducibleQty _c.mutation.SetProducibleQty(v) } if _, ok := _c.mutation.ComputedAt(); !ok { v := produciblesnapshot.DefaultComputedAt _c.mutation.SetComputedAt(v) } if _, ok := _c.mutation.SyncedAt(); !ok { v := produciblesnapshot.DefaultSyncedAt() _c.mutation.SetSyncedAt(v) } } // check runs all checks and user-defined validators on the builder. func (_c *ProducibleSnapshotCreate) check() error { if _, ok := _c.mutation.ProductCode(); !ok { return &ValidationError{Name: "product_code", err: errors.New(`ent: missing required field "ProducibleSnapshot.product_code"`)} } if _, ok := _c.mutation.ProducibleQty(); !ok { return &ValidationError{Name: "producible_qty", err: errors.New(`ent: missing required field "ProducibleSnapshot.producible_qty"`)} } if _, ok := _c.mutation.ComputedAt(); !ok { return &ValidationError{Name: "computed_at", err: errors.New(`ent: missing required field "ProducibleSnapshot.computed_at"`)} } if _, ok := _c.mutation.SyncedAt(); !ok { return &ValidationError{Name: "synced_at", err: errors.New(`ent: missing required field "ProducibleSnapshot.synced_at"`)} } return nil } func (_c *ProducibleSnapshotCreate) sqlSave(ctx context.Context) (*ProducibleSnapshot, 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 *ProducibleSnapshotCreate) createSpec() (*ProducibleSnapshot, *sqlgraph.CreateSpec) { var ( _node = &ProducibleSnapshot{config: _c.config} _spec = sqlgraph.NewCreateSpec(produciblesnapshot.Table, sqlgraph.NewFieldSpec(produciblesnapshot.FieldID, field.TypeInt)) ) _spec.OnConflict = _c.conflict if value, ok := _c.mutation.ProductCode(); ok { _spec.SetField(produciblesnapshot.FieldProductCode, field.TypeString, value) _node.ProductCode = value } if value, ok := _c.mutation.ProductName(); ok { _spec.SetField(produciblesnapshot.FieldProductName, field.TypeString, value) _node.ProductName = value } if value, ok := _c.mutation.ProducibleQty(); ok { _spec.SetField(produciblesnapshot.FieldProducibleQty, field.TypeInt, value) _node.ProducibleQty = value } if value, ok := _c.mutation.ShortText(); ok { _spec.SetField(produciblesnapshot.FieldShortText, field.TypeString, value) _node.ShortText = value } if value, ok := _c.mutation.ComputedAt(); ok { _spec.SetField(produciblesnapshot.FieldComputedAt, field.TypeInt64, value) _node.ComputedAt = value } if value, ok := _c.mutation.SyncedAt(); ok { _spec.SetField(produciblesnapshot.FieldSyncedAt, field.TypeInt64, value) _node.SyncedAt = value } return _node, _spec } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.ProducibleSnapshot.Create(). // SetProductCode(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. // sql.ResolveWithNewValues(), // ). // // Override some of the fields with custom // // update values. // Update(func(u *ent.ProducibleSnapshotUpsert) { // SetProductCode(v+v). // }). // Exec(ctx) func (_c *ProducibleSnapshotCreate) OnConflict(opts ...sql.ConflictOption) *ProducibleSnapshotUpsertOne { _c.conflict = opts return &ProducibleSnapshotUpsertOne{ create: _c, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.ProducibleSnapshot.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (_c *ProducibleSnapshotCreate) OnConflictColumns(columns ...string) *ProducibleSnapshotUpsertOne { _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) return &ProducibleSnapshotUpsertOne{ create: _c, } } type ( // ProducibleSnapshotUpsertOne is the builder for "upsert"-ing // one ProducibleSnapshot node. ProducibleSnapshotUpsertOne struct { create *ProducibleSnapshotCreate } // ProducibleSnapshotUpsert is the "OnConflict" setter. ProducibleSnapshotUpsert struct { *sql.UpdateSet } ) // SetProductCode sets the "product_code" field. func (u *ProducibleSnapshotUpsert) SetProductCode(v string) *ProducibleSnapshotUpsert { u.Set(produciblesnapshot.FieldProductCode, v) return u } // UpdateProductCode sets the "product_code" field to the value that was provided on create. func (u *ProducibleSnapshotUpsert) UpdateProductCode() *ProducibleSnapshotUpsert { u.SetExcluded(produciblesnapshot.FieldProductCode) return u } // SetProductName sets the "product_name" field. func (u *ProducibleSnapshotUpsert) SetProductName(v string) *ProducibleSnapshotUpsert { u.Set(produciblesnapshot.FieldProductName, v) return u } // UpdateProductName sets the "product_name" field to the value that was provided on create. func (u *ProducibleSnapshotUpsert) UpdateProductName() *ProducibleSnapshotUpsert { u.SetExcluded(produciblesnapshot.FieldProductName) return u } // ClearProductName clears the value of the "product_name" field. func (u *ProducibleSnapshotUpsert) ClearProductName() *ProducibleSnapshotUpsert { u.SetNull(produciblesnapshot.FieldProductName) return u } // SetProducibleQty sets the "producible_qty" field. func (u *ProducibleSnapshotUpsert) SetProducibleQty(v int) *ProducibleSnapshotUpsert { u.Set(produciblesnapshot.FieldProducibleQty, v) return u } // UpdateProducibleQty sets the "producible_qty" field to the value that was provided on create. func (u *ProducibleSnapshotUpsert) UpdateProducibleQty() *ProducibleSnapshotUpsert { u.SetExcluded(produciblesnapshot.FieldProducibleQty) return u } // AddProducibleQty adds v to the "producible_qty" field. func (u *ProducibleSnapshotUpsert) AddProducibleQty(v int) *ProducibleSnapshotUpsert { u.Add(produciblesnapshot.FieldProducibleQty, v) return u } // SetShortText sets the "short_text" field. func (u *ProducibleSnapshotUpsert) SetShortText(v string) *ProducibleSnapshotUpsert { u.Set(produciblesnapshot.FieldShortText, v) return u } // UpdateShortText sets the "short_text" field to the value that was provided on create. func (u *ProducibleSnapshotUpsert) UpdateShortText() *ProducibleSnapshotUpsert { u.SetExcluded(produciblesnapshot.FieldShortText) return u } // ClearShortText clears the value of the "short_text" field. func (u *ProducibleSnapshotUpsert) ClearShortText() *ProducibleSnapshotUpsert { u.SetNull(produciblesnapshot.FieldShortText) return u } // SetComputedAt sets the "computed_at" field. func (u *ProducibleSnapshotUpsert) SetComputedAt(v int64) *ProducibleSnapshotUpsert { u.Set(produciblesnapshot.FieldComputedAt, v) return u } // UpdateComputedAt sets the "computed_at" field to the value that was provided on create. func (u *ProducibleSnapshotUpsert) UpdateComputedAt() *ProducibleSnapshotUpsert { u.SetExcluded(produciblesnapshot.FieldComputedAt) return u } // AddComputedAt adds v to the "computed_at" field. func (u *ProducibleSnapshotUpsert) AddComputedAt(v int64) *ProducibleSnapshotUpsert { u.Add(produciblesnapshot.FieldComputedAt, v) return u } // SetSyncedAt sets the "synced_at" field. func (u *ProducibleSnapshotUpsert) SetSyncedAt(v int64) *ProducibleSnapshotUpsert { u.Set(produciblesnapshot.FieldSyncedAt, v) return u } // UpdateSyncedAt sets the "synced_at" field to the value that was provided on create. func (u *ProducibleSnapshotUpsert) UpdateSyncedAt() *ProducibleSnapshotUpsert { u.SetExcluded(produciblesnapshot.FieldSyncedAt) return u } // AddSyncedAt adds v to the "synced_at" field. func (u *ProducibleSnapshotUpsert) AddSyncedAt(v int64) *ProducibleSnapshotUpsert { u.Add(produciblesnapshot.FieldSyncedAt, v) return u } // UpdateNewValues updates the mutable fields using the new values that were set on create. // Using this option is equivalent to using: // // client.ProducibleSnapshot.Create(). // OnConflict( // sql.ResolveWithNewValues(), // ). // Exec(ctx) func (u *ProducibleSnapshotUpsertOne) UpdateNewValues() *ProducibleSnapshotUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.ProducibleSnapshot.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *ProducibleSnapshotUpsertOne) Ignore() *ProducibleSnapshotUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) return u } // DoNothing configures the conflict_action to `DO NOTHING`. // Supported only by SQLite and PostgreSQL. func (u *ProducibleSnapshotUpsertOne) DoNothing() *ProducibleSnapshotUpsertOne { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the ProducibleSnapshotCreate.OnConflict // documentation for more info. func (u *ProducibleSnapshotUpsertOne) Update(set func(*ProducibleSnapshotUpsert)) *ProducibleSnapshotUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&ProducibleSnapshotUpsert{UpdateSet: update}) })) return u } // SetProductCode sets the "product_code" field. func (u *ProducibleSnapshotUpsertOne) SetProductCode(v string) *ProducibleSnapshotUpsertOne { return u.Update(func(s *ProducibleSnapshotUpsert) { s.SetProductCode(v) }) } // UpdateProductCode sets the "product_code" field to the value that was provided on create. func (u *ProducibleSnapshotUpsertOne) UpdateProductCode() *ProducibleSnapshotUpsertOne { return u.Update(func(s *ProducibleSnapshotUpsert) { s.UpdateProductCode() }) } // SetProductName sets the "product_name" field. func (u *ProducibleSnapshotUpsertOne) SetProductName(v string) *ProducibleSnapshotUpsertOne { return u.Update(func(s *ProducibleSnapshotUpsert) { s.SetProductName(v) }) } // UpdateProductName sets the "product_name" field to the value that was provided on create. func (u *ProducibleSnapshotUpsertOne) UpdateProductName() *ProducibleSnapshotUpsertOne { return u.Update(func(s *ProducibleSnapshotUpsert) { s.UpdateProductName() }) } // ClearProductName clears the value of the "product_name" field. func (u *ProducibleSnapshotUpsertOne) ClearProductName() *ProducibleSnapshotUpsertOne { return u.Update(func(s *ProducibleSnapshotUpsert) { s.ClearProductName() }) } // SetProducibleQty sets the "producible_qty" field. func (u *ProducibleSnapshotUpsertOne) SetProducibleQty(v int) *ProducibleSnapshotUpsertOne { return u.Update(func(s *ProducibleSnapshotUpsert) { s.SetProducibleQty(v) }) } // AddProducibleQty adds v to the "producible_qty" field. func (u *ProducibleSnapshotUpsertOne) AddProducibleQty(v int) *ProducibleSnapshotUpsertOne { return u.Update(func(s *ProducibleSnapshotUpsert) { s.AddProducibleQty(v) }) } // UpdateProducibleQty sets the "producible_qty" field to the value that was provided on create. func (u *ProducibleSnapshotUpsertOne) UpdateProducibleQty() *ProducibleSnapshotUpsertOne { return u.Update(func(s *ProducibleSnapshotUpsert) { s.UpdateProducibleQty() }) } // SetShortText sets the "short_text" field. func (u *ProducibleSnapshotUpsertOne) SetShortText(v string) *ProducibleSnapshotUpsertOne { return u.Update(func(s *ProducibleSnapshotUpsert) { s.SetShortText(v) }) } // UpdateShortText sets the "short_text" field to the value that was provided on create. func (u *ProducibleSnapshotUpsertOne) UpdateShortText() *ProducibleSnapshotUpsertOne { return u.Update(func(s *ProducibleSnapshotUpsert) { s.UpdateShortText() }) } // ClearShortText clears the value of the "short_text" field. func (u *ProducibleSnapshotUpsertOne) ClearShortText() *ProducibleSnapshotUpsertOne { return u.Update(func(s *ProducibleSnapshotUpsert) { s.ClearShortText() }) } // SetComputedAt sets the "computed_at" field. func (u *ProducibleSnapshotUpsertOne) SetComputedAt(v int64) *ProducibleSnapshotUpsertOne { return u.Update(func(s *ProducibleSnapshotUpsert) { s.SetComputedAt(v) }) } // AddComputedAt adds v to the "computed_at" field. func (u *ProducibleSnapshotUpsertOne) AddComputedAt(v int64) *ProducibleSnapshotUpsertOne { return u.Update(func(s *ProducibleSnapshotUpsert) { s.AddComputedAt(v) }) } // UpdateComputedAt sets the "computed_at" field to the value that was provided on create. func (u *ProducibleSnapshotUpsertOne) UpdateComputedAt() *ProducibleSnapshotUpsertOne { return u.Update(func(s *ProducibleSnapshotUpsert) { s.UpdateComputedAt() }) } // SetSyncedAt sets the "synced_at" field. func (u *ProducibleSnapshotUpsertOne) SetSyncedAt(v int64) *ProducibleSnapshotUpsertOne { return u.Update(func(s *ProducibleSnapshotUpsert) { s.SetSyncedAt(v) }) } // AddSyncedAt adds v to the "synced_at" field. func (u *ProducibleSnapshotUpsertOne) AddSyncedAt(v int64) *ProducibleSnapshotUpsertOne { return u.Update(func(s *ProducibleSnapshotUpsert) { s.AddSyncedAt(v) }) } // UpdateSyncedAt sets the "synced_at" field to the value that was provided on create. func (u *ProducibleSnapshotUpsertOne) UpdateSyncedAt() *ProducibleSnapshotUpsertOne { return u.Update(func(s *ProducibleSnapshotUpsert) { s.UpdateSyncedAt() }) } // Exec executes the query. func (u *ProducibleSnapshotUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { return errors.New("ent: missing options for ProducibleSnapshotCreate.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *ProducibleSnapshotUpsertOne) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } } // Exec executes the UPSERT query and returns the inserted/updated ID. func (u *ProducibleSnapshotUpsertOne) ID(ctx context.Context) (id int, err error) { node, err := u.create.Save(ctx) if err != nil { return id, err } return node.ID, nil } // IDX is like ID, but panics if an error occurs. func (u *ProducibleSnapshotUpsertOne) IDX(ctx context.Context) int { id, err := u.ID(ctx) if err != nil { panic(err) } return id } // ProducibleSnapshotCreateBulk is the builder for creating many ProducibleSnapshot entities in bulk. type ProducibleSnapshotCreateBulk struct { config err error builders []*ProducibleSnapshotCreate conflict []sql.ConflictOption } // Save creates the ProducibleSnapshot entities in the database. func (_c *ProducibleSnapshotCreateBulk) Save(ctx context.Context) ([]*ProducibleSnapshot, error) { if _c.err != nil { return nil, _c.err } specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) nodes := make([]*ProducibleSnapshot, len(_c.builders)) mutators := make([]Mutator, len(_c.builders)) for i := range _c.builders { func(i int, root context.Context) { builder := _c.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*ProducibleSnapshotMutation) 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} spec.OnConflict = _c.conflict // 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 *ProducibleSnapshotCreateBulk) SaveX(ctx context.Context) []*ProducibleSnapshot { v, err := _c.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (_c *ProducibleSnapshotCreateBulk) Exec(ctx context.Context) error { _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_c *ProducibleSnapshotCreateBulk) ExecX(ctx context.Context) { if err := _c.Exec(ctx); err != nil { panic(err) } } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.ProducibleSnapshot.CreateBulk(builders...). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. // sql.ResolveWithNewValues(), // ). // // Override some of the fields with custom // // update values. // Update(func(u *ent.ProducibleSnapshotUpsert) { // SetProductCode(v+v). // }). // Exec(ctx) func (_c *ProducibleSnapshotCreateBulk) OnConflict(opts ...sql.ConflictOption) *ProducibleSnapshotUpsertBulk { _c.conflict = opts return &ProducibleSnapshotUpsertBulk{ create: _c, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.ProducibleSnapshot.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (_c *ProducibleSnapshotCreateBulk) OnConflictColumns(columns ...string) *ProducibleSnapshotUpsertBulk { _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) return &ProducibleSnapshotUpsertBulk{ create: _c, } } // ProducibleSnapshotUpsertBulk is the builder for "upsert"-ing // a bulk of ProducibleSnapshot nodes. type ProducibleSnapshotUpsertBulk struct { create *ProducibleSnapshotCreateBulk } // UpdateNewValues updates the mutable fields using the new values that // were set on create. Using this option is equivalent to using: // // client.ProducibleSnapshot.Create(). // OnConflict( // sql.ResolveWithNewValues(), // ). // Exec(ctx) func (u *ProducibleSnapshotUpsertBulk) UpdateNewValues() *ProducibleSnapshotUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.ProducibleSnapshot.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *ProducibleSnapshotUpsertBulk) Ignore() *ProducibleSnapshotUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) return u } // DoNothing configures the conflict_action to `DO NOTHING`. // Supported only by SQLite and PostgreSQL. func (u *ProducibleSnapshotUpsertBulk) DoNothing() *ProducibleSnapshotUpsertBulk { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the ProducibleSnapshotCreateBulk.OnConflict // documentation for more info. func (u *ProducibleSnapshotUpsertBulk) Update(set func(*ProducibleSnapshotUpsert)) *ProducibleSnapshotUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&ProducibleSnapshotUpsert{UpdateSet: update}) })) return u } // SetProductCode sets the "product_code" field. func (u *ProducibleSnapshotUpsertBulk) SetProductCode(v string) *ProducibleSnapshotUpsertBulk { return u.Update(func(s *ProducibleSnapshotUpsert) { s.SetProductCode(v) }) } // UpdateProductCode sets the "product_code" field to the value that was provided on create. func (u *ProducibleSnapshotUpsertBulk) UpdateProductCode() *ProducibleSnapshotUpsertBulk { return u.Update(func(s *ProducibleSnapshotUpsert) { s.UpdateProductCode() }) } // SetProductName sets the "product_name" field. func (u *ProducibleSnapshotUpsertBulk) SetProductName(v string) *ProducibleSnapshotUpsertBulk { return u.Update(func(s *ProducibleSnapshotUpsert) { s.SetProductName(v) }) } // UpdateProductName sets the "product_name" field to the value that was provided on create. func (u *ProducibleSnapshotUpsertBulk) UpdateProductName() *ProducibleSnapshotUpsertBulk { return u.Update(func(s *ProducibleSnapshotUpsert) { s.UpdateProductName() }) } // ClearProductName clears the value of the "product_name" field. func (u *ProducibleSnapshotUpsertBulk) ClearProductName() *ProducibleSnapshotUpsertBulk { return u.Update(func(s *ProducibleSnapshotUpsert) { s.ClearProductName() }) } // SetProducibleQty sets the "producible_qty" field. func (u *ProducibleSnapshotUpsertBulk) SetProducibleQty(v int) *ProducibleSnapshotUpsertBulk { return u.Update(func(s *ProducibleSnapshotUpsert) { s.SetProducibleQty(v) }) } // AddProducibleQty adds v to the "producible_qty" field. func (u *ProducibleSnapshotUpsertBulk) AddProducibleQty(v int) *ProducibleSnapshotUpsertBulk { return u.Update(func(s *ProducibleSnapshotUpsert) { s.AddProducibleQty(v) }) } // UpdateProducibleQty sets the "producible_qty" field to the value that was provided on create. func (u *ProducibleSnapshotUpsertBulk) UpdateProducibleQty() *ProducibleSnapshotUpsertBulk { return u.Update(func(s *ProducibleSnapshotUpsert) { s.UpdateProducibleQty() }) } // SetShortText sets the "short_text" field. func (u *ProducibleSnapshotUpsertBulk) SetShortText(v string) *ProducibleSnapshotUpsertBulk { return u.Update(func(s *ProducibleSnapshotUpsert) { s.SetShortText(v) }) } // UpdateShortText sets the "short_text" field to the value that was provided on create. func (u *ProducibleSnapshotUpsertBulk) UpdateShortText() *ProducibleSnapshotUpsertBulk { return u.Update(func(s *ProducibleSnapshotUpsert) { s.UpdateShortText() }) } // ClearShortText clears the value of the "short_text" field. func (u *ProducibleSnapshotUpsertBulk) ClearShortText() *ProducibleSnapshotUpsertBulk { return u.Update(func(s *ProducibleSnapshotUpsert) { s.ClearShortText() }) } // SetComputedAt sets the "computed_at" field. func (u *ProducibleSnapshotUpsertBulk) SetComputedAt(v int64) *ProducibleSnapshotUpsertBulk { return u.Update(func(s *ProducibleSnapshotUpsert) { s.SetComputedAt(v) }) } // AddComputedAt adds v to the "computed_at" field. func (u *ProducibleSnapshotUpsertBulk) AddComputedAt(v int64) *ProducibleSnapshotUpsertBulk { return u.Update(func(s *ProducibleSnapshotUpsert) { s.AddComputedAt(v) }) } // UpdateComputedAt sets the "computed_at" field to the value that was provided on create. func (u *ProducibleSnapshotUpsertBulk) UpdateComputedAt() *ProducibleSnapshotUpsertBulk { return u.Update(func(s *ProducibleSnapshotUpsert) { s.UpdateComputedAt() }) } // SetSyncedAt sets the "synced_at" field. func (u *ProducibleSnapshotUpsertBulk) SetSyncedAt(v int64) *ProducibleSnapshotUpsertBulk { return u.Update(func(s *ProducibleSnapshotUpsert) { s.SetSyncedAt(v) }) } // AddSyncedAt adds v to the "synced_at" field. func (u *ProducibleSnapshotUpsertBulk) AddSyncedAt(v int64) *ProducibleSnapshotUpsertBulk { return u.Update(func(s *ProducibleSnapshotUpsert) { s.AddSyncedAt(v) }) } // UpdateSyncedAt sets the "synced_at" field to the value that was provided on create. func (u *ProducibleSnapshotUpsertBulk) UpdateSyncedAt() *ProducibleSnapshotUpsertBulk { return u.Update(func(s *ProducibleSnapshotUpsert) { s.UpdateSyncedAt() }) } // Exec executes the query. func (u *ProducibleSnapshotUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { return u.create.err } for i, b := range u.create.builders { if len(b.conflict) != 0 { return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ProducibleSnapshotCreateBulk instead", i) } } if len(u.create.conflict) == 0 { return errors.New("ent: missing options for ProducibleSnapshotCreateBulk.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *ProducibleSnapshotUpsertBulk) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } }