// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "time" "wechat-api/ent/contact" "wechat-api/ent/contactfield" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // ContactFieldCreate is the builder for creating a ContactField entity. type ContactFieldCreate struct { config mutation *ContactFieldMutation hooks []Hook conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. func (cfc *ContactFieldCreate) SetCreatedAt(t time.Time) *ContactFieldCreate { cfc.mutation.SetCreatedAt(t) return cfc } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (cfc *ContactFieldCreate) SetNillableCreatedAt(t *time.Time) *ContactFieldCreate { if t != nil { cfc.SetCreatedAt(*t) } return cfc } // SetUpdatedAt sets the "updated_at" field. func (cfc *ContactFieldCreate) SetUpdatedAt(t time.Time) *ContactFieldCreate { cfc.mutation.SetUpdatedAt(t) return cfc } // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. func (cfc *ContactFieldCreate) SetNillableUpdatedAt(t *time.Time) *ContactFieldCreate { if t != nil { cfc.SetUpdatedAt(*t) } return cfc } // SetStatus sets the "status" field. func (cfc *ContactFieldCreate) SetStatus(u uint8) *ContactFieldCreate { cfc.mutation.SetStatus(u) return cfc } // SetNillableStatus sets the "status" field if the given value is not nil. func (cfc *ContactFieldCreate) SetNillableStatus(u *uint8) *ContactFieldCreate { if u != nil { cfc.SetStatus(*u) } return cfc } // SetDeletedAt sets the "deleted_at" field. func (cfc *ContactFieldCreate) SetDeletedAt(t time.Time) *ContactFieldCreate { cfc.mutation.SetDeletedAt(t) return cfc } // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. func (cfc *ContactFieldCreate) SetNillableDeletedAt(t *time.Time) *ContactFieldCreate { if t != nil { cfc.SetDeletedAt(*t) } return cfc } // SetContactID sets the "contact_id" field. func (cfc *ContactFieldCreate) SetContactID(u uint64) *ContactFieldCreate { cfc.mutation.SetContactID(u) return cfc } // SetNillableContactID sets the "contact_id" field if the given value is not nil. func (cfc *ContactFieldCreate) SetNillableContactID(u *uint64) *ContactFieldCreate { if u != nil { cfc.SetContactID(*u) } return cfc } // SetFormID sets the "form_id" field. func (cfc *ContactFieldCreate) SetFormID(s string) *ContactFieldCreate { cfc.mutation.SetFormID(s) return cfc } // SetValue sets the "value" field. func (cfc *ContactFieldCreate) SetValue(s []string) *ContactFieldCreate { cfc.mutation.SetValue(s) return cfc } // SetID sets the "id" field. func (cfc *ContactFieldCreate) SetID(u uint64) *ContactFieldCreate { cfc.mutation.SetID(u) return cfc } // SetFieldContactID sets the "field_contact" edge to the Contact entity by ID. func (cfc *ContactFieldCreate) SetFieldContactID(id uint64) *ContactFieldCreate { cfc.mutation.SetFieldContactID(id) return cfc } // SetFieldContact sets the "field_contact" edge to the Contact entity. func (cfc *ContactFieldCreate) SetFieldContact(c *Contact) *ContactFieldCreate { return cfc.SetFieldContactID(c.ID) } // Mutation returns the ContactFieldMutation object of the builder. func (cfc *ContactFieldCreate) Mutation() *ContactFieldMutation { return cfc.mutation } // Save creates the ContactField in the database. func (cfc *ContactFieldCreate) Save(ctx context.Context) (*ContactField, error) { if err := cfc.defaults(); err != nil { return nil, err } return withHooks(ctx, cfc.sqlSave, cfc.mutation, cfc.hooks) } // SaveX calls Save and panics if Save returns an error. func (cfc *ContactFieldCreate) SaveX(ctx context.Context) *ContactField { v, err := cfc.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (cfc *ContactFieldCreate) Exec(ctx context.Context) error { _, err := cfc.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (cfc *ContactFieldCreate) ExecX(ctx context.Context) { if err := cfc.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. func (cfc *ContactFieldCreate) defaults() error { if _, ok := cfc.mutation.CreatedAt(); !ok { if contactfield.DefaultCreatedAt == nil { return fmt.Errorf("ent: uninitialized contactfield.DefaultCreatedAt (forgotten import ent/runtime?)") } v := contactfield.DefaultCreatedAt() cfc.mutation.SetCreatedAt(v) } if _, ok := cfc.mutation.UpdatedAt(); !ok { if contactfield.DefaultUpdatedAt == nil { return fmt.Errorf("ent: uninitialized contactfield.DefaultUpdatedAt (forgotten import ent/runtime?)") } v := contactfield.DefaultUpdatedAt() cfc.mutation.SetUpdatedAt(v) } if _, ok := cfc.mutation.Status(); !ok { v := contactfield.DefaultStatus cfc.mutation.SetStatus(v) } if _, ok := cfc.mutation.ContactID(); !ok { v := contactfield.DefaultContactID cfc.mutation.SetContactID(v) } return nil } // check runs all checks and user-defined validators on the builder. func (cfc *ContactFieldCreate) check() error { if _, ok := cfc.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ContactField.created_at"`)} } if _, ok := cfc.mutation.UpdatedAt(); !ok { return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ContactField.updated_at"`)} } if _, ok := cfc.mutation.ContactID(); !ok { return &ValidationError{Name: "contact_id", err: errors.New(`ent: missing required field "ContactField.contact_id"`)} } if _, ok := cfc.mutation.FormID(); !ok { return &ValidationError{Name: "form_id", err: errors.New(`ent: missing required field "ContactField.form_id"`)} } if _, ok := cfc.mutation.Value(); !ok { return &ValidationError{Name: "value", err: errors.New(`ent: missing required field "ContactField.value"`)} } if _, ok := cfc.mutation.FieldContactID(); !ok { return &ValidationError{Name: "field_contact", err: errors.New(`ent: missing required edge "ContactField.field_contact"`)} } return nil } func (cfc *ContactFieldCreate) sqlSave(ctx context.Context) (*ContactField, error) { if err := cfc.check(); err != nil { return nil, err } _node, _spec := cfc.createSpec() if err := sqlgraph.CreateNode(ctx, cfc.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } if _spec.ID.Value != _node.ID { id := _spec.ID.Value.(int64) _node.ID = uint64(id) } cfc.mutation.id = &_node.ID cfc.mutation.done = true return _node, nil } func (cfc *ContactFieldCreate) createSpec() (*ContactField, *sqlgraph.CreateSpec) { var ( _node = &ContactField{config: cfc.config} _spec = sqlgraph.NewCreateSpec(contactfield.Table, sqlgraph.NewFieldSpec(contactfield.FieldID, field.TypeUint64)) ) _spec.OnConflict = cfc.conflict if id, ok := cfc.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id } if value, ok := cfc.mutation.CreatedAt(); ok { _spec.SetField(contactfield.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value } if value, ok := cfc.mutation.UpdatedAt(); ok { _spec.SetField(contactfield.FieldUpdatedAt, field.TypeTime, value) _node.UpdatedAt = value } if value, ok := cfc.mutation.Status(); ok { _spec.SetField(contactfield.FieldStatus, field.TypeUint8, value) _node.Status = value } if value, ok := cfc.mutation.DeletedAt(); ok { _spec.SetField(contactfield.FieldDeletedAt, field.TypeTime, value) _node.DeletedAt = value } if value, ok := cfc.mutation.FormID(); ok { _spec.SetField(contactfield.FieldFormID, field.TypeString, value) _node.FormID = value } if value, ok := cfc.mutation.Value(); ok { _spec.SetField(contactfield.FieldValue, field.TypeJSON, value) _node.Value = value } if nodes := cfc.mutation.FieldContactIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: contactfield.FieldContactTable, Columns: []string{contactfield.FieldContactColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _node.ContactID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } return _node, _spec } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.ContactField.Create(). // SetCreatedAt(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.ContactFieldUpsert) { // SetCreatedAt(v+v). // }). // Exec(ctx) func (cfc *ContactFieldCreate) OnConflict(opts ...sql.ConflictOption) *ContactFieldUpsertOne { cfc.conflict = opts return &ContactFieldUpsertOne{ create: cfc, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.ContactField.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (cfc *ContactFieldCreate) OnConflictColumns(columns ...string) *ContactFieldUpsertOne { cfc.conflict = append(cfc.conflict, sql.ConflictColumns(columns...)) return &ContactFieldUpsertOne{ create: cfc, } } type ( // ContactFieldUpsertOne is the builder for "upsert"-ing // one ContactField node. ContactFieldUpsertOne struct { create *ContactFieldCreate } // ContactFieldUpsert is the "OnConflict" setter. ContactFieldUpsert struct { *sql.UpdateSet } ) // SetUpdatedAt sets the "updated_at" field. func (u *ContactFieldUpsert) SetUpdatedAt(v time.Time) *ContactFieldUpsert { u.Set(contactfield.FieldUpdatedAt, v) return u } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *ContactFieldUpsert) UpdateUpdatedAt() *ContactFieldUpsert { u.SetExcluded(contactfield.FieldUpdatedAt) return u } // SetStatus sets the "status" field. func (u *ContactFieldUpsert) SetStatus(v uint8) *ContactFieldUpsert { u.Set(contactfield.FieldStatus, v) return u } // UpdateStatus sets the "status" field to the value that was provided on create. func (u *ContactFieldUpsert) UpdateStatus() *ContactFieldUpsert { u.SetExcluded(contactfield.FieldStatus) return u } // AddStatus adds v to the "status" field. func (u *ContactFieldUpsert) AddStatus(v uint8) *ContactFieldUpsert { u.Add(contactfield.FieldStatus, v) return u } // ClearStatus clears the value of the "status" field. func (u *ContactFieldUpsert) ClearStatus() *ContactFieldUpsert { u.SetNull(contactfield.FieldStatus) return u } // SetDeletedAt sets the "deleted_at" field. func (u *ContactFieldUpsert) SetDeletedAt(v time.Time) *ContactFieldUpsert { u.Set(contactfield.FieldDeletedAt, v) return u } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *ContactFieldUpsert) UpdateDeletedAt() *ContactFieldUpsert { u.SetExcluded(contactfield.FieldDeletedAt) return u } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *ContactFieldUpsert) ClearDeletedAt() *ContactFieldUpsert { u.SetNull(contactfield.FieldDeletedAt) return u } // SetContactID sets the "contact_id" field. func (u *ContactFieldUpsert) SetContactID(v uint64) *ContactFieldUpsert { u.Set(contactfield.FieldContactID, v) return u } // UpdateContactID sets the "contact_id" field to the value that was provided on create. func (u *ContactFieldUpsert) UpdateContactID() *ContactFieldUpsert { u.SetExcluded(contactfield.FieldContactID) return u } // SetFormID sets the "form_id" field. func (u *ContactFieldUpsert) SetFormID(v string) *ContactFieldUpsert { u.Set(contactfield.FieldFormID, v) return u } // UpdateFormID sets the "form_id" field to the value that was provided on create. func (u *ContactFieldUpsert) UpdateFormID() *ContactFieldUpsert { u.SetExcluded(contactfield.FieldFormID) return u } // SetValue sets the "value" field. func (u *ContactFieldUpsert) SetValue(v []string) *ContactFieldUpsert { u.Set(contactfield.FieldValue, v) return u } // UpdateValue sets the "value" field to the value that was provided on create. func (u *ContactFieldUpsert) UpdateValue() *ContactFieldUpsert { u.SetExcluded(contactfield.FieldValue) return u } // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. // Using this option is equivalent to using: // // client.ContactField.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(contactfield.FieldID) // }), // ). // Exec(ctx) func (u *ContactFieldUpsertOne) UpdateNewValues() *ContactFieldUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { if _, exists := u.create.mutation.ID(); exists { s.SetIgnore(contactfield.FieldID) } if _, exists := u.create.mutation.CreatedAt(); exists { s.SetIgnore(contactfield.FieldCreatedAt) } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.ContactField.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *ContactFieldUpsertOne) Ignore() *ContactFieldUpsertOne { 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 *ContactFieldUpsertOne) DoNothing() *ContactFieldUpsertOne { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the ContactFieldCreate.OnConflict // documentation for more info. func (u *ContactFieldUpsertOne) Update(set func(*ContactFieldUpsert)) *ContactFieldUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&ContactFieldUpsert{UpdateSet: update}) })) return u } // SetUpdatedAt sets the "updated_at" field. func (u *ContactFieldUpsertOne) SetUpdatedAt(v time.Time) *ContactFieldUpsertOne { return u.Update(func(s *ContactFieldUpsert) { s.SetUpdatedAt(v) }) } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *ContactFieldUpsertOne) UpdateUpdatedAt() *ContactFieldUpsertOne { return u.Update(func(s *ContactFieldUpsert) { s.UpdateUpdatedAt() }) } // SetStatus sets the "status" field. func (u *ContactFieldUpsertOne) SetStatus(v uint8) *ContactFieldUpsertOne { return u.Update(func(s *ContactFieldUpsert) { s.SetStatus(v) }) } // AddStatus adds v to the "status" field. func (u *ContactFieldUpsertOne) AddStatus(v uint8) *ContactFieldUpsertOne { return u.Update(func(s *ContactFieldUpsert) { s.AddStatus(v) }) } // UpdateStatus sets the "status" field to the value that was provided on create. func (u *ContactFieldUpsertOne) UpdateStatus() *ContactFieldUpsertOne { return u.Update(func(s *ContactFieldUpsert) { s.UpdateStatus() }) } // ClearStatus clears the value of the "status" field. func (u *ContactFieldUpsertOne) ClearStatus() *ContactFieldUpsertOne { return u.Update(func(s *ContactFieldUpsert) { s.ClearStatus() }) } // SetDeletedAt sets the "deleted_at" field. func (u *ContactFieldUpsertOne) SetDeletedAt(v time.Time) *ContactFieldUpsertOne { return u.Update(func(s *ContactFieldUpsert) { s.SetDeletedAt(v) }) } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *ContactFieldUpsertOne) UpdateDeletedAt() *ContactFieldUpsertOne { return u.Update(func(s *ContactFieldUpsert) { s.UpdateDeletedAt() }) } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *ContactFieldUpsertOne) ClearDeletedAt() *ContactFieldUpsertOne { return u.Update(func(s *ContactFieldUpsert) { s.ClearDeletedAt() }) } // SetContactID sets the "contact_id" field. func (u *ContactFieldUpsertOne) SetContactID(v uint64) *ContactFieldUpsertOne { return u.Update(func(s *ContactFieldUpsert) { s.SetContactID(v) }) } // UpdateContactID sets the "contact_id" field to the value that was provided on create. func (u *ContactFieldUpsertOne) UpdateContactID() *ContactFieldUpsertOne { return u.Update(func(s *ContactFieldUpsert) { s.UpdateContactID() }) } // SetFormID sets the "form_id" field. func (u *ContactFieldUpsertOne) SetFormID(v string) *ContactFieldUpsertOne { return u.Update(func(s *ContactFieldUpsert) { s.SetFormID(v) }) } // UpdateFormID sets the "form_id" field to the value that was provided on create. func (u *ContactFieldUpsertOne) UpdateFormID() *ContactFieldUpsertOne { return u.Update(func(s *ContactFieldUpsert) { s.UpdateFormID() }) } // SetValue sets the "value" field. func (u *ContactFieldUpsertOne) SetValue(v []string) *ContactFieldUpsertOne { return u.Update(func(s *ContactFieldUpsert) { s.SetValue(v) }) } // UpdateValue sets the "value" field to the value that was provided on create. func (u *ContactFieldUpsertOne) UpdateValue() *ContactFieldUpsertOne { return u.Update(func(s *ContactFieldUpsert) { s.UpdateValue() }) } // Exec executes the query. func (u *ContactFieldUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { return errors.New("ent: missing options for ContactFieldCreate.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *ContactFieldUpsertOne) 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 *ContactFieldUpsertOne) ID(ctx context.Context) (id uint64, 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 *ContactFieldUpsertOne) IDX(ctx context.Context) uint64 { id, err := u.ID(ctx) if err != nil { panic(err) } return id } // ContactFieldCreateBulk is the builder for creating many ContactField entities in bulk. type ContactFieldCreateBulk struct { config err error builders []*ContactFieldCreate conflict []sql.ConflictOption } // Save creates the ContactField entities in the database. func (cfcb *ContactFieldCreateBulk) Save(ctx context.Context) ([]*ContactField, error) { if cfcb.err != nil { return nil, cfcb.err } specs := make([]*sqlgraph.CreateSpec, len(cfcb.builders)) nodes := make([]*ContactField, len(cfcb.builders)) mutators := make([]Mutator, len(cfcb.builders)) for i := range cfcb.builders { func(i int, root context.Context) { builder := cfcb.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*ContactFieldMutation) 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, cfcb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} spec.OnConflict = cfcb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, cfcb.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 && nodes[i].ID == 0 { id := specs[i].ID.Value.(int64) nodes[i].ID = uint64(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, cfcb.builders[0].mutation); err != nil { return nil, err } } return nodes, nil } // SaveX is like Save, but panics if an error occurs. func (cfcb *ContactFieldCreateBulk) SaveX(ctx context.Context) []*ContactField { v, err := cfcb.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (cfcb *ContactFieldCreateBulk) Exec(ctx context.Context) error { _, err := cfcb.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (cfcb *ContactFieldCreateBulk) ExecX(ctx context.Context) { if err := cfcb.Exec(ctx); err != nil { panic(err) } } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.ContactField.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.ContactFieldUpsert) { // SetCreatedAt(v+v). // }). // Exec(ctx) func (cfcb *ContactFieldCreateBulk) OnConflict(opts ...sql.ConflictOption) *ContactFieldUpsertBulk { cfcb.conflict = opts return &ContactFieldUpsertBulk{ create: cfcb, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.ContactField.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (cfcb *ContactFieldCreateBulk) OnConflictColumns(columns ...string) *ContactFieldUpsertBulk { cfcb.conflict = append(cfcb.conflict, sql.ConflictColumns(columns...)) return &ContactFieldUpsertBulk{ create: cfcb, } } // ContactFieldUpsertBulk is the builder for "upsert"-ing // a bulk of ContactField nodes. type ContactFieldUpsertBulk struct { create *ContactFieldCreateBulk } // UpdateNewValues updates the mutable fields using the new values that // were set on create. Using this option is equivalent to using: // // client.ContactField.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(contactfield.FieldID) // }), // ). // Exec(ctx) func (u *ContactFieldUpsertBulk) UpdateNewValues() *ContactFieldUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { for _, b := range u.create.builders { if _, exists := b.mutation.ID(); exists { s.SetIgnore(contactfield.FieldID) } if _, exists := b.mutation.CreatedAt(); exists { s.SetIgnore(contactfield.FieldCreatedAt) } } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.ContactField.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *ContactFieldUpsertBulk) Ignore() *ContactFieldUpsertBulk { 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 *ContactFieldUpsertBulk) DoNothing() *ContactFieldUpsertBulk { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the ContactFieldCreateBulk.OnConflict // documentation for more info. func (u *ContactFieldUpsertBulk) Update(set func(*ContactFieldUpsert)) *ContactFieldUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&ContactFieldUpsert{UpdateSet: update}) })) return u } // SetUpdatedAt sets the "updated_at" field. func (u *ContactFieldUpsertBulk) SetUpdatedAt(v time.Time) *ContactFieldUpsertBulk { return u.Update(func(s *ContactFieldUpsert) { s.SetUpdatedAt(v) }) } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *ContactFieldUpsertBulk) UpdateUpdatedAt() *ContactFieldUpsertBulk { return u.Update(func(s *ContactFieldUpsert) { s.UpdateUpdatedAt() }) } // SetStatus sets the "status" field. func (u *ContactFieldUpsertBulk) SetStatus(v uint8) *ContactFieldUpsertBulk { return u.Update(func(s *ContactFieldUpsert) { s.SetStatus(v) }) } // AddStatus adds v to the "status" field. func (u *ContactFieldUpsertBulk) AddStatus(v uint8) *ContactFieldUpsertBulk { return u.Update(func(s *ContactFieldUpsert) { s.AddStatus(v) }) } // UpdateStatus sets the "status" field to the value that was provided on create. func (u *ContactFieldUpsertBulk) UpdateStatus() *ContactFieldUpsertBulk { return u.Update(func(s *ContactFieldUpsert) { s.UpdateStatus() }) } // ClearStatus clears the value of the "status" field. func (u *ContactFieldUpsertBulk) ClearStatus() *ContactFieldUpsertBulk { return u.Update(func(s *ContactFieldUpsert) { s.ClearStatus() }) } // SetDeletedAt sets the "deleted_at" field. func (u *ContactFieldUpsertBulk) SetDeletedAt(v time.Time) *ContactFieldUpsertBulk { return u.Update(func(s *ContactFieldUpsert) { s.SetDeletedAt(v) }) } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *ContactFieldUpsertBulk) UpdateDeletedAt() *ContactFieldUpsertBulk { return u.Update(func(s *ContactFieldUpsert) { s.UpdateDeletedAt() }) } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *ContactFieldUpsertBulk) ClearDeletedAt() *ContactFieldUpsertBulk { return u.Update(func(s *ContactFieldUpsert) { s.ClearDeletedAt() }) } // SetContactID sets the "contact_id" field. func (u *ContactFieldUpsertBulk) SetContactID(v uint64) *ContactFieldUpsertBulk { return u.Update(func(s *ContactFieldUpsert) { s.SetContactID(v) }) } // UpdateContactID sets the "contact_id" field to the value that was provided on create. func (u *ContactFieldUpsertBulk) UpdateContactID() *ContactFieldUpsertBulk { return u.Update(func(s *ContactFieldUpsert) { s.UpdateContactID() }) } // SetFormID sets the "form_id" field. func (u *ContactFieldUpsertBulk) SetFormID(v string) *ContactFieldUpsertBulk { return u.Update(func(s *ContactFieldUpsert) { s.SetFormID(v) }) } // UpdateFormID sets the "form_id" field to the value that was provided on create. func (u *ContactFieldUpsertBulk) UpdateFormID() *ContactFieldUpsertBulk { return u.Update(func(s *ContactFieldUpsert) { s.UpdateFormID() }) } // SetValue sets the "value" field. func (u *ContactFieldUpsertBulk) SetValue(v []string) *ContactFieldUpsertBulk { return u.Update(func(s *ContactFieldUpsert) { s.SetValue(v) }) } // UpdateValue sets the "value" field to the value that was provided on create. func (u *ContactFieldUpsertBulk) UpdateValue() *ContactFieldUpsertBulk { return u.Update(func(s *ContactFieldUpsert) { s.UpdateValue() }) } // Exec executes the query. func (u *ContactFieldUpsertBulk) 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 ContactFieldCreateBulk instead", i) } } if len(u.create.conflict) == 0 { return errors.New("ent: missing options for ContactFieldCreateBulk.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *ContactFieldUpsertBulk) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } }