// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "time" "wechat-api/ent/employee" "wechat-api/ent/tutorial" "wechat-api/ent/workexperience" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // EmployeeCreate is the builder for creating a Employee entity. type EmployeeCreate struct { config mutation *EmployeeMutation hooks []Hook conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. func (ec *EmployeeCreate) SetCreatedAt(t time.Time) *EmployeeCreate { ec.mutation.SetCreatedAt(t) return ec } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (ec *EmployeeCreate) SetNillableCreatedAt(t *time.Time) *EmployeeCreate { if t != nil { ec.SetCreatedAt(*t) } return ec } // SetUpdatedAt sets the "updated_at" field. func (ec *EmployeeCreate) SetUpdatedAt(t time.Time) *EmployeeCreate { ec.mutation.SetUpdatedAt(t) return ec } // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. func (ec *EmployeeCreate) SetNillableUpdatedAt(t *time.Time) *EmployeeCreate { if t != nil { ec.SetUpdatedAt(*t) } return ec } // SetDeletedAt sets the "deleted_at" field. func (ec *EmployeeCreate) SetDeletedAt(t time.Time) *EmployeeCreate { ec.mutation.SetDeletedAt(t) return ec } // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. func (ec *EmployeeCreate) SetNillableDeletedAt(t *time.Time) *EmployeeCreate { if t != nil { ec.SetDeletedAt(*t) } return ec } // SetTitle sets the "title" field. func (ec *EmployeeCreate) SetTitle(s string) *EmployeeCreate { ec.mutation.SetTitle(s) return ec } // SetAvatar sets the "avatar" field. func (ec *EmployeeCreate) SetAvatar(s string) *EmployeeCreate { ec.mutation.SetAvatar(s) return ec } // SetTags sets the "tags" field. func (ec *EmployeeCreate) SetTags(s string) *EmployeeCreate { ec.mutation.SetTags(s) return ec } // SetHireCount sets the "hire_count" field. func (ec *EmployeeCreate) SetHireCount(i int) *EmployeeCreate { ec.mutation.SetHireCount(i) return ec } // SetNillableHireCount sets the "hire_count" field if the given value is not nil. func (ec *EmployeeCreate) SetNillableHireCount(i *int) *EmployeeCreate { if i != nil { ec.SetHireCount(*i) } return ec } // SetServiceCount sets the "service_count" field. func (ec *EmployeeCreate) SetServiceCount(i int) *EmployeeCreate { ec.mutation.SetServiceCount(i) return ec } // SetNillableServiceCount sets the "service_count" field if the given value is not nil. func (ec *EmployeeCreate) SetNillableServiceCount(i *int) *EmployeeCreate { if i != nil { ec.SetServiceCount(*i) } return ec } // SetAchievementCount sets the "achievement_count" field. func (ec *EmployeeCreate) SetAchievementCount(i int) *EmployeeCreate { ec.mutation.SetAchievementCount(i) return ec } // SetNillableAchievementCount sets the "achievement_count" field if the given value is not nil. func (ec *EmployeeCreate) SetNillableAchievementCount(i *int) *EmployeeCreate { if i != nil { ec.SetAchievementCount(*i) } return ec } // SetIntro sets the "intro" field. func (ec *EmployeeCreate) SetIntro(s string) *EmployeeCreate { ec.mutation.SetIntro(s) return ec } // SetNillableIntro sets the "intro" field if the given value is not nil. func (ec *EmployeeCreate) SetNillableIntro(s *string) *EmployeeCreate { if s != nil { ec.SetIntro(*s) } return ec } // SetEstimate sets the "estimate" field. func (ec *EmployeeCreate) SetEstimate(s string) *EmployeeCreate { ec.mutation.SetEstimate(s) return ec } // SetNillableEstimate sets the "estimate" field if the given value is not nil. func (ec *EmployeeCreate) SetNillableEstimate(s *string) *EmployeeCreate { if s != nil { ec.SetEstimate(*s) } return ec } // SetSkill sets the "skill" field. func (ec *EmployeeCreate) SetSkill(s string) *EmployeeCreate { ec.mutation.SetSkill(s) return ec } // SetNillableSkill sets the "skill" field if the given value is not nil. func (ec *EmployeeCreate) SetNillableSkill(s *string) *EmployeeCreate { if s != nil { ec.SetSkill(*s) } return ec } // SetAbilityType sets the "ability_type" field. func (ec *EmployeeCreate) SetAbilityType(s string) *EmployeeCreate { ec.mutation.SetAbilityType(s) return ec } // SetNillableAbilityType sets the "ability_type" field if the given value is not nil. func (ec *EmployeeCreate) SetNillableAbilityType(s *string) *EmployeeCreate { if s != nil { ec.SetAbilityType(*s) } return ec } // SetScene sets the "scene" field. func (ec *EmployeeCreate) SetScene(s string) *EmployeeCreate { ec.mutation.SetScene(s) return ec } // SetNillableScene sets the "scene" field if the given value is not nil. func (ec *EmployeeCreate) SetNillableScene(s *string) *EmployeeCreate { if s != nil { ec.SetScene(*s) } return ec } // SetSwitchIn sets the "switch_in" field. func (ec *EmployeeCreate) SetSwitchIn(s string) *EmployeeCreate { ec.mutation.SetSwitchIn(s) return ec } // SetNillableSwitchIn sets the "switch_in" field if the given value is not nil. func (ec *EmployeeCreate) SetNillableSwitchIn(s *string) *EmployeeCreate { if s != nil { ec.SetSwitchIn(*s) } return ec } // SetVideoURL sets the "video_url" field. func (ec *EmployeeCreate) SetVideoURL(s string) *EmployeeCreate { ec.mutation.SetVideoURL(s) return ec } // SetNillableVideoURL sets the "video_url" field if the given value is not nil. func (ec *EmployeeCreate) SetNillableVideoURL(s *string) *EmployeeCreate { if s != nil { ec.SetVideoURL(*s) } return ec } // SetOrganizationID sets the "organization_id" field. func (ec *EmployeeCreate) SetOrganizationID(u uint64) *EmployeeCreate { ec.mutation.SetOrganizationID(u) return ec } // SetCategoryID sets the "category_id" field. func (ec *EmployeeCreate) SetCategoryID(u uint64) *EmployeeCreate { ec.mutation.SetCategoryID(u) return ec } // SetAPIBase sets the "api_base" field. func (ec *EmployeeCreate) SetAPIBase(s string) *EmployeeCreate { ec.mutation.SetAPIBase(s) return ec } // SetNillableAPIBase sets the "api_base" field if the given value is not nil. func (ec *EmployeeCreate) SetNillableAPIBase(s *string) *EmployeeCreate { if s != nil { ec.SetAPIBase(*s) } return ec } // SetAPIKey sets the "api_key" field. func (ec *EmployeeCreate) SetAPIKey(s string) *EmployeeCreate { ec.mutation.SetAPIKey(s) return ec } // SetNillableAPIKey sets the "api_key" field if the given value is not nil. func (ec *EmployeeCreate) SetNillableAPIKey(s *string) *EmployeeCreate { if s != nil { ec.SetAPIKey(*s) } return ec } // SetAiInfo sets the "ai_info" field. func (ec *EmployeeCreate) SetAiInfo(s string) *EmployeeCreate { ec.mutation.SetAiInfo(s) return ec } // SetNillableAiInfo sets the "ai_info" field if the given value is not nil. func (ec *EmployeeCreate) SetNillableAiInfo(s *string) *EmployeeCreate { if s != nil { ec.SetAiInfo(*s) } return ec } // SetIsVip sets the "is_vip" field. func (ec *EmployeeCreate) SetIsVip(i int) *EmployeeCreate { ec.mutation.SetIsVip(i) return ec } // SetNillableIsVip sets the "is_vip" field if the given value is not nil. func (ec *EmployeeCreate) SetNillableIsVip(i *int) *EmployeeCreate { if i != nil { ec.SetIsVip(*i) } return ec } // SetChatURL sets the "chat_url" field. func (ec *EmployeeCreate) SetChatURL(s string) *EmployeeCreate { ec.mutation.SetChatURL(s) return ec } // SetID sets the "id" field. func (ec *EmployeeCreate) SetID(u uint64) *EmployeeCreate { ec.mutation.SetID(u) return ec } // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by IDs. func (ec *EmployeeCreate) AddEmWorkExperienceIDs(ids ...uint64) *EmployeeCreate { ec.mutation.AddEmWorkExperienceIDs(ids...) return ec } // AddEmWorkExperiences adds the "em_work_experiences" edges to the WorkExperience entity. func (ec *EmployeeCreate) AddEmWorkExperiences(w ...*WorkExperience) *EmployeeCreate { ids := make([]uint64, len(w)) for i := range w { ids[i] = w[i].ID } return ec.AddEmWorkExperienceIDs(ids...) } // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by IDs. func (ec *EmployeeCreate) AddEmTutorialIDs(ids ...uint64) *EmployeeCreate { ec.mutation.AddEmTutorialIDs(ids...) return ec } // AddEmTutorial adds the "em_tutorial" edges to the Tutorial entity. func (ec *EmployeeCreate) AddEmTutorial(t ...*Tutorial) *EmployeeCreate { ids := make([]uint64, len(t)) for i := range t { ids[i] = t[i].ID } return ec.AddEmTutorialIDs(ids...) } // Mutation returns the EmployeeMutation object of the builder. func (ec *EmployeeCreate) Mutation() *EmployeeMutation { return ec.mutation } // Save creates the Employee in the database. func (ec *EmployeeCreate) Save(ctx context.Context) (*Employee, error) { if err := ec.defaults(); err != nil { return nil, err } return withHooks(ctx, ec.sqlSave, ec.mutation, ec.hooks) } // SaveX calls Save and panics if Save returns an error. func (ec *EmployeeCreate) SaveX(ctx context.Context) *Employee { v, err := ec.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (ec *EmployeeCreate) Exec(ctx context.Context) error { _, err := ec.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (ec *EmployeeCreate) ExecX(ctx context.Context) { if err := ec.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. func (ec *EmployeeCreate) defaults() error { if _, ok := ec.mutation.CreatedAt(); !ok { if employee.DefaultCreatedAt == nil { return fmt.Errorf("ent: uninitialized employee.DefaultCreatedAt (forgotten import ent/runtime?)") } v := employee.DefaultCreatedAt() ec.mutation.SetCreatedAt(v) } if _, ok := ec.mutation.UpdatedAt(); !ok { if employee.DefaultUpdatedAt == nil { return fmt.Errorf("ent: uninitialized employee.DefaultUpdatedAt (forgotten import ent/runtime?)") } v := employee.DefaultUpdatedAt() ec.mutation.SetUpdatedAt(v) } if _, ok := ec.mutation.HireCount(); !ok { v := employee.DefaultHireCount ec.mutation.SetHireCount(v) } if _, ok := ec.mutation.ServiceCount(); !ok { v := employee.DefaultServiceCount ec.mutation.SetServiceCount(v) } if _, ok := ec.mutation.AchievementCount(); !ok { v := employee.DefaultAchievementCount ec.mutation.SetAchievementCount(v) } if _, ok := ec.mutation.Intro(); !ok { v := employee.DefaultIntro ec.mutation.SetIntro(v) } if _, ok := ec.mutation.Estimate(); !ok { v := employee.DefaultEstimate ec.mutation.SetEstimate(v) } if _, ok := ec.mutation.Skill(); !ok { v := employee.DefaultSkill ec.mutation.SetSkill(v) } if _, ok := ec.mutation.AbilityType(); !ok { v := employee.DefaultAbilityType ec.mutation.SetAbilityType(v) } if _, ok := ec.mutation.Scene(); !ok { v := employee.DefaultScene ec.mutation.SetScene(v) } if _, ok := ec.mutation.SwitchIn(); !ok { v := employee.DefaultSwitchIn ec.mutation.SetSwitchIn(v) } if _, ok := ec.mutation.VideoURL(); !ok { v := employee.DefaultVideoURL ec.mutation.SetVideoURL(v) } if _, ok := ec.mutation.APIBase(); !ok { v := employee.DefaultAPIBase ec.mutation.SetAPIBase(v) } if _, ok := ec.mutation.APIKey(); !ok { v := employee.DefaultAPIKey ec.mutation.SetAPIKey(v) } if _, ok := ec.mutation.IsVip(); !ok { v := employee.DefaultIsVip ec.mutation.SetIsVip(v) } return nil } // check runs all checks and user-defined validators on the builder. func (ec *EmployeeCreate) check() error { if _, ok := ec.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Employee.created_at"`)} } if _, ok := ec.mutation.UpdatedAt(); !ok { return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Employee.updated_at"`)} } if _, ok := ec.mutation.Title(); !ok { return &ValidationError{Name: "title", err: errors.New(`ent: missing required field "Employee.title"`)} } if v, ok := ec.mutation.Title(); ok { if err := employee.TitleValidator(v); err != nil { return &ValidationError{Name: "title", err: fmt.Errorf(`ent: validator failed for field "Employee.title": %w`, err)} } } if _, ok := ec.mutation.Avatar(); !ok { return &ValidationError{Name: "avatar", err: errors.New(`ent: missing required field "Employee.avatar"`)} } if _, ok := ec.mutation.Tags(); !ok { return &ValidationError{Name: "tags", err: errors.New(`ent: missing required field "Employee.tags"`)} } if _, ok := ec.mutation.HireCount(); !ok { return &ValidationError{Name: "hire_count", err: errors.New(`ent: missing required field "Employee.hire_count"`)} } if v, ok := ec.mutation.HireCount(); ok { if err := employee.HireCountValidator(v); err != nil { return &ValidationError{Name: "hire_count", err: fmt.Errorf(`ent: validator failed for field "Employee.hire_count": %w`, err)} } } if _, ok := ec.mutation.ServiceCount(); !ok { return &ValidationError{Name: "service_count", err: errors.New(`ent: missing required field "Employee.service_count"`)} } if v, ok := ec.mutation.ServiceCount(); ok { if err := employee.ServiceCountValidator(v); err != nil { return &ValidationError{Name: "service_count", err: fmt.Errorf(`ent: validator failed for field "Employee.service_count": %w`, err)} } } if _, ok := ec.mutation.AchievementCount(); !ok { return &ValidationError{Name: "achievement_count", err: errors.New(`ent: missing required field "Employee.achievement_count"`)} } if v, ok := ec.mutation.AchievementCount(); ok { if err := employee.AchievementCountValidator(v); err != nil { return &ValidationError{Name: "achievement_count", err: fmt.Errorf(`ent: validator failed for field "Employee.achievement_count": %w`, err)} } } if _, ok := ec.mutation.Intro(); !ok { return &ValidationError{Name: "intro", err: errors.New(`ent: missing required field "Employee.intro"`)} } if _, ok := ec.mutation.Estimate(); !ok { return &ValidationError{Name: "estimate", err: errors.New(`ent: missing required field "Employee.estimate"`)} } if _, ok := ec.mutation.Skill(); !ok { return &ValidationError{Name: "skill", err: errors.New(`ent: missing required field "Employee.skill"`)} } if _, ok := ec.mutation.AbilityType(); !ok { return &ValidationError{Name: "ability_type", err: errors.New(`ent: missing required field "Employee.ability_type"`)} } if _, ok := ec.mutation.Scene(); !ok { return &ValidationError{Name: "scene", err: errors.New(`ent: missing required field "Employee.scene"`)} } if _, ok := ec.mutation.SwitchIn(); !ok { return &ValidationError{Name: "switch_in", err: errors.New(`ent: missing required field "Employee.switch_in"`)} } if _, ok := ec.mutation.VideoURL(); !ok { return &ValidationError{Name: "video_url", err: errors.New(`ent: missing required field "Employee.video_url"`)} } if _, ok := ec.mutation.OrganizationID(); !ok { return &ValidationError{Name: "organization_id", err: errors.New(`ent: missing required field "Employee.organization_id"`)} } if v, ok := ec.mutation.OrganizationID(); ok { if err := employee.OrganizationIDValidator(v); err != nil { return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "Employee.organization_id": %w`, err)} } } if _, ok := ec.mutation.CategoryID(); !ok { return &ValidationError{Name: "category_id", err: errors.New(`ent: missing required field "Employee.category_id"`)} } if v, ok := ec.mutation.CategoryID(); ok { if err := employee.CategoryIDValidator(v); err != nil { return &ValidationError{Name: "category_id", err: fmt.Errorf(`ent: validator failed for field "Employee.category_id": %w`, err)} } } if _, ok := ec.mutation.APIBase(); !ok { return &ValidationError{Name: "api_base", err: errors.New(`ent: missing required field "Employee.api_base"`)} } if _, ok := ec.mutation.APIKey(); !ok { return &ValidationError{Name: "api_key", err: errors.New(`ent: missing required field "Employee.api_key"`)} } if _, ok := ec.mutation.IsVip(); !ok { return &ValidationError{Name: "is_vip", err: errors.New(`ent: missing required field "Employee.is_vip"`)} } if _, ok := ec.mutation.ChatURL(); !ok { return &ValidationError{Name: "chat_url", err: errors.New(`ent: missing required field "Employee.chat_url"`)} } return nil } func (ec *EmployeeCreate) sqlSave(ctx context.Context) (*Employee, error) { if err := ec.check(); err != nil { return nil, err } _node, _spec := ec.createSpec() if err := sqlgraph.CreateNode(ctx, ec.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) } ec.mutation.id = &_node.ID ec.mutation.done = true return _node, nil } func (ec *EmployeeCreate) createSpec() (*Employee, *sqlgraph.CreateSpec) { var ( _node = &Employee{config: ec.config} _spec = sqlgraph.NewCreateSpec(employee.Table, sqlgraph.NewFieldSpec(employee.FieldID, field.TypeUint64)) ) _spec.OnConflict = ec.conflict if id, ok := ec.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id } if value, ok := ec.mutation.CreatedAt(); ok { _spec.SetField(employee.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value } if value, ok := ec.mutation.UpdatedAt(); ok { _spec.SetField(employee.FieldUpdatedAt, field.TypeTime, value) _node.UpdatedAt = value } if value, ok := ec.mutation.DeletedAt(); ok { _spec.SetField(employee.FieldDeletedAt, field.TypeTime, value) _node.DeletedAt = value } if value, ok := ec.mutation.Title(); ok { _spec.SetField(employee.FieldTitle, field.TypeString, value) _node.Title = value } if value, ok := ec.mutation.Avatar(); ok { _spec.SetField(employee.FieldAvatar, field.TypeString, value) _node.Avatar = value } if value, ok := ec.mutation.Tags(); ok { _spec.SetField(employee.FieldTags, field.TypeString, value) _node.Tags = value } if value, ok := ec.mutation.HireCount(); ok { _spec.SetField(employee.FieldHireCount, field.TypeInt, value) _node.HireCount = value } if value, ok := ec.mutation.ServiceCount(); ok { _spec.SetField(employee.FieldServiceCount, field.TypeInt, value) _node.ServiceCount = value } if value, ok := ec.mutation.AchievementCount(); ok { _spec.SetField(employee.FieldAchievementCount, field.TypeInt, value) _node.AchievementCount = value } if value, ok := ec.mutation.Intro(); ok { _spec.SetField(employee.FieldIntro, field.TypeString, value) _node.Intro = value } if value, ok := ec.mutation.Estimate(); ok { _spec.SetField(employee.FieldEstimate, field.TypeString, value) _node.Estimate = value } if value, ok := ec.mutation.Skill(); ok { _spec.SetField(employee.FieldSkill, field.TypeString, value) _node.Skill = value } if value, ok := ec.mutation.AbilityType(); ok { _spec.SetField(employee.FieldAbilityType, field.TypeString, value) _node.AbilityType = value } if value, ok := ec.mutation.Scene(); ok { _spec.SetField(employee.FieldScene, field.TypeString, value) _node.Scene = value } if value, ok := ec.mutation.SwitchIn(); ok { _spec.SetField(employee.FieldSwitchIn, field.TypeString, value) _node.SwitchIn = value } if value, ok := ec.mutation.VideoURL(); ok { _spec.SetField(employee.FieldVideoURL, field.TypeString, value) _node.VideoURL = value } if value, ok := ec.mutation.OrganizationID(); ok { _spec.SetField(employee.FieldOrganizationID, field.TypeUint64, value) _node.OrganizationID = value } if value, ok := ec.mutation.CategoryID(); ok { _spec.SetField(employee.FieldCategoryID, field.TypeUint64, value) _node.CategoryID = value } if value, ok := ec.mutation.APIBase(); ok { _spec.SetField(employee.FieldAPIBase, field.TypeString, value) _node.APIBase = value } if value, ok := ec.mutation.APIKey(); ok { _spec.SetField(employee.FieldAPIKey, field.TypeString, value) _node.APIKey = value } if value, ok := ec.mutation.AiInfo(); ok { _spec.SetField(employee.FieldAiInfo, field.TypeString, value) _node.AiInfo = value } if value, ok := ec.mutation.IsVip(); ok { _spec.SetField(employee.FieldIsVip, field.TypeInt, value) _node.IsVip = value } if value, ok := ec.mutation.ChatURL(); ok { _spec.SetField(employee.FieldChatURL, field.TypeString, value) _node.ChatURL = value } if nodes := ec.mutation.EmWorkExperiencesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: employee.EmWorkExperiencesTable, Columns: []string{employee.EmWorkExperiencesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(workexperience.FieldID, field.TypeUint64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges = append(_spec.Edges, edge) } if nodes := ec.mutation.EmTutorialIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: employee.EmTutorialTable, Columns: []string{employee.EmTutorialColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(tutorial.FieldID, field.TypeUint64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _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.Employee.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.EmployeeUpsert) { // SetCreatedAt(v+v). // }). // Exec(ctx) func (ec *EmployeeCreate) OnConflict(opts ...sql.ConflictOption) *EmployeeUpsertOne { ec.conflict = opts return &EmployeeUpsertOne{ create: ec, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.Employee.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (ec *EmployeeCreate) OnConflictColumns(columns ...string) *EmployeeUpsertOne { ec.conflict = append(ec.conflict, sql.ConflictColumns(columns...)) return &EmployeeUpsertOne{ create: ec, } } type ( // EmployeeUpsertOne is the builder for "upsert"-ing // one Employee node. EmployeeUpsertOne struct { create *EmployeeCreate } // EmployeeUpsert is the "OnConflict" setter. EmployeeUpsert struct { *sql.UpdateSet } ) // SetUpdatedAt sets the "updated_at" field. func (u *EmployeeUpsert) SetUpdatedAt(v time.Time) *EmployeeUpsert { u.Set(employee.FieldUpdatedAt, v) return u } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateUpdatedAt() *EmployeeUpsert { u.SetExcluded(employee.FieldUpdatedAt) return u } // SetDeletedAt sets the "deleted_at" field. func (u *EmployeeUpsert) SetDeletedAt(v time.Time) *EmployeeUpsert { u.Set(employee.FieldDeletedAt, v) return u } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateDeletedAt() *EmployeeUpsert { u.SetExcluded(employee.FieldDeletedAt) return u } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *EmployeeUpsert) ClearDeletedAt() *EmployeeUpsert { u.SetNull(employee.FieldDeletedAt) return u } // SetTitle sets the "title" field. func (u *EmployeeUpsert) SetTitle(v string) *EmployeeUpsert { u.Set(employee.FieldTitle, v) return u } // UpdateTitle sets the "title" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateTitle() *EmployeeUpsert { u.SetExcluded(employee.FieldTitle) return u } // SetAvatar sets the "avatar" field. func (u *EmployeeUpsert) SetAvatar(v string) *EmployeeUpsert { u.Set(employee.FieldAvatar, v) return u } // UpdateAvatar sets the "avatar" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateAvatar() *EmployeeUpsert { u.SetExcluded(employee.FieldAvatar) return u } // SetTags sets the "tags" field. func (u *EmployeeUpsert) SetTags(v string) *EmployeeUpsert { u.Set(employee.FieldTags, v) return u } // UpdateTags sets the "tags" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateTags() *EmployeeUpsert { u.SetExcluded(employee.FieldTags) return u } // SetHireCount sets the "hire_count" field. func (u *EmployeeUpsert) SetHireCount(v int) *EmployeeUpsert { u.Set(employee.FieldHireCount, v) return u } // UpdateHireCount sets the "hire_count" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateHireCount() *EmployeeUpsert { u.SetExcluded(employee.FieldHireCount) return u } // AddHireCount adds v to the "hire_count" field. func (u *EmployeeUpsert) AddHireCount(v int) *EmployeeUpsert { u.Add(employee.FieldHireCount, v) return u } // SetServiceCount sets the "service_count" field. func (u *EmployeeUpsert) SetServiceCount(v int) *EmployeeUpsert { u.Set(employee.FieldServiceCount, v) return u } // UpdateServiceCount sets the "service_count" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateServiceCount() *EmployeeUpsert { u.SetExcluded(employee.FieldServiceCount) return u } // AddServiceCount adds v to the "service_count" field. func (u *EmployeeUpsert) AddServiceCount(v int) *EmployeeUpsert { u.Add(employee.FieldServiceCount, v) return u } // SetAchievementCount sets the "achievement_count" field. func (u *EmployeeUpsert) SetAchievementCount(v int) *EmployeeUpsert { u.Set(employee.FieldAchievementCount, v) return u } // UpdateAchievementCount sets the "achievement_count" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateAchievementCount() *EmployeeUpsert { u.SetExcluded(employee.FieldAchievementCount) return u } // AddAchievementCount adds v to the "achievement_count" field. func (u *EmployeeUpsert) AddAchievementCount(v int) *EmployeeUpsert { u.Add(employee.FieldAchievementCount, v) return u } // SetIntro sets the "intro" field. func (u *EmployeeUpsert) SetIntro(v string) *EmployeeUpsert { u.Set(employee.FieldIntro, v) return u } // UpdateIntro sets the "intro" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateIntro() *EmployeeUpsert { u.SetExcluded(employee.FieldIntro) return u } // SetEstimate sets the "estimate" field. func (u *EmployeeUpsert) SetEstimate(v string) *EmployeeUpsert { u.Set(employee.FieldEstimate, v) return u } // UpdateEstimate sets the "estimate" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateEstimate() *EmployeeUpsert { u.SetExcluded(employee.FieldEstimate) return u } // SetSkill sets the "skill" field. func (u *EmployeeUpsert) SetSkill(v string) *EmployeeUpsert { u.Set(employee.FieldSkill, v) return u } // UpdateSkill sets the "skill" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateSkill() *EmployeeUpsert { u.SetExcluded(employee.FieldSkill) return u } // SetAbilityType sets the "ability_type" field. func (u *EmployeeUpsert) SetAbilityType(v string) *EmployeeUpsert { u.Set(employee.FieldAbilityType, v) return u } // UpdateAbilityType sets the "ability_type" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateAbilityType() *EmployeeUpsert { u.SetExcluded(employee.FieldAbilityType) return u } // SetScene sets the "scene" field. func (u *EmployeeUpsert) SetScene(v string) *EmployeeUpsert { u.Set(employee.FieldScene, v) return u } // UpdateScene sets the "scene" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateScene() *EmployeeUpsert { u.SetExcluded(employee.FieldScene) return u } // SetSwitchIn sets the "switch_in" field. func (u *EmployeeUpsert) SetSwitchIn(v string) *EmployeeUpsert { u.Set(employee.FieldSwitchIn, v) return u } // UpdateSwitchIn sets the "switch_in" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateSwitchIn() *EmployeeUpsert { u.SetExcluded(employee.FieldSwitchIn) return u } // SetVideoURL sets the "video_url" field. func (u *EmployeeUpsert) SetVideoURL(v string) *EmployeeUpsert { u.Set(employee.FieldVideoURL, v) return u } // UpdateVideoURL sets the "video_url" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateVideoURL() *EmployeeUpsert { u.SetExcluded(employee.FieldVideoURL) return u } // SetOrganizationID sets the "organization_id" field. func (u *EmployeeUpsert) SetOrganizationID(v uint64) *EmployeeUpsert { u.Set(employee.FieldOrganizationID, v) return u } // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateOrganizationID() *EmployeeUpsert { u.SetExcluded(employee.FieldOrganizationID) return u } // AddOrganizationID adds v to the "organization_id" field. func (u *EmployeeUpsert) AddOrganizationID(v uint64) *EmployeeUpsert { u.Add(employee.FieldOrganizationID, v) return u } // SetCategoryID sets the "category_id" field. func (u *EmployeeUpsert) SetCategoryID(v uint64) *EmployeeUpsert { u.Set(employee.FieldCategoryID, v) return u } // UpdateCategoryID sets the "category_id" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateCategoryID() *EmployeeUpsert { u.SetExcluded(employee.FieldCategoryID) return u } // AddCategoryID adds v to the "category_id" field. func (u *EmployeeUpsert) AddCategoryID(v uint64) *EmployeeUpsert { u.Add(employee.FieldCategoryID, v) return u } // SetAPIBase sets the "api_base" field. func (u *EmployeeUpsert) SetAPIBase(v string) *EmployeeUpsert { u.Set(employee.FieldAPIBase, v) return u } // UpdateAPIBase sets the "api_base" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateAPIBase() *EmployeeUpsert { u.SetExcluded(employee.FieldAPIBase) return u } // SetAPIKey sets the "api_key" field. func (u *EmployeeUpsert) SetAPIKey(v string) *EmployeeUpsert { u.Set(employee.FieldAPIKey, v) return u } // UpdateAPIKey sets the "api_key" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateAPIKey() *EmployeeUpsert { u.SetExcluded(employee.FieldAPIKey) return u } // SetAiInfo sets the "ai_info" field. func (u *EmployeeUpsert) SetAiInfo(v string) *EmployeeUpsert { u.Set(employee.FieldAiInfo, v) return u } // UpdateAiInfo sets the "ai_info" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateAiInfo() *EmployeeUpsert { u.SetExcluded(employee.FieldAiInfo) return u } // ClearAiInfo clears the value of the "ai_info" field. func (u *EmployeeUpsert) ClearAiInfo() *EmployeeUpsert { u.SetNull(employee.FieldAiInfo) return u } // SetIsVip sets the "is_vip" field. func (u *EmployeeUpsert) SetIsVip(v int) *EmployeeUpsert { u.Set(employee.FieldIsVip, v) return u } // UpdateIsVip sets the "is_vip" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateIsVip() *EmployeeUpsert { u.SetExcluded(employee.FieldIsVip) return u } // AddIsVip adds v to the "is_vip" field. func (u *EmployeeUpsert) AddIsVip(v int) *EmployeeUpsert { u.Add(employee.FieldIsVip, v) return u } // SetChatURL sets the "chat_url" field. func (u *EmployeeUpsert) SetChatURL(v string) *EmployeeUpsert { u.Set(employee.FieldChatURL, v) return u } // UpdateChatURL sets the "chat_url" field to the value that was provided on create. func (u *EmployeeUpsert) UpdateChatURL() *EmployeeUpsert { u.SetExcluded(employee.FieldChatURL) 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.Employee.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(employee.FieldID) // }), // ). // Exec(ctx) func (u *EmployeeUpsertOne) UpdateNewValues() *EmployeeUpsertOne { 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(employee.FieldID) } if _, exists := u.create.mutation.CreatedAt(); exists { s.SetIgnore(employee.FieldCreatedAt) } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.Employee.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *EmployeeUpsertOne) Ignore() *EmployeeUpsertOne { 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 *EmployeeUpsertOne) DoNothing() *EmployeeUpsertOne { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the EmployeeCreate.OnConflict // documentation for more info. func (u *EmployeeUpsertOne) Update(set func(*EmployeeUpsert)) *EmployeeUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&EmployeeUpsert{UpdateSet: update}) })) return u } // SetUpdatedAt sets the "updated_at" field. func (u *EmployeeUpsertOne) SetUpdatedAt(v time.Time) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetUpdatedAt(v) }) } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateUpdatedAt() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateUpdatedAt() }) } // SetDeletedAt sets the "deleted_at" field. func (u *EmployeeUpsertOne) SetDeletedAt(v time.Time) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetDeletedAt(v) }) } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateDeletedAt() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateDeletedAt() }) } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *EmployeeUpsertOne) ClearDeletedAt() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.ClearDeletedAt() }) } // SetTitle sets the "title" field. func (u *EmployeeUpsertOne) SetTitle(v string) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetTitle(v) }) } // UpdateTitle sets the "title" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateTitle() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateTitle() }) } // SetAvatar sets the "avatar" field. func (u *EmployeeUpsertOne) SetAvatar(v string) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetAvatar(v) }) } // UpdateAvatar sets the "avatar" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateAvatar() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateAvatar() }) } // SetTags sets the "tags" field. func (u *EmployeeUpsertOne) SetTags(v string) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetTags(v) }) } // UpdateTags sets the "tags" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateTags() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateTags() }) } // SetHireCount sets the "hire_count" field. func (u *EmployeeUpsertOne) SetHireCount(v int) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetHireCount(v) }) } // AddHireCount adds v to the "hire_count" field. func (u *EmployeeUpsertOne) AddHireCount(v int) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.AddHireCount(v) }) } // UpdateHireCount sets the "hire_count" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateHireCount() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateHireCount() }) } // SetServiceCount sets the "service_count" field. func (u *EmployeeUpsertOne) SetServiceCount(v int) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetServiceCount(v) }) } // AddServiceCount adds v to the "service_count" field. func (u *EmployeeUpsertOne) AddServiceCount(v int) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.AddServiceCount(v) }) } // UpdateServiceCount sets the "service_count" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateServiceCount() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateServiceCount() }) } // SetAchievementCount sets the "achievement_count" field. func (u *EmployeeUpsertOne) SetAchievementCount(v int) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetAchievementCount(v) }) } // AddAchievementCount adds v to the "achievement_count" field. func (u *EmployeeUpsertOne) AddAchievementCount(v int) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.AddAchievementCount(v) }) } // UpdateAchievementCount sets the "achievement_count" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateAchievementCount() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateAchievementCount() }) } // SetIntro sets the "intro" field. func (u *EmployeeUpsertOne) SetIntro(v string) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetIntro(v) }) } // UpdateIntro sets the "intro" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateIntro() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateIntro() }) } // SetEstimate sets the "estimate" field. func (u *EmployeeUpsertOne) SetEstimate(v string) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetEstimate(v) }) } // UpdateEstimate sets the "estimate" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateEstimate() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateEstimate() }) } // SetSkill sets the "skill" field. func (u *EmployeeUpsertOne) SetSkill(v string) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetSkill(v) }) } // UpdateSkill sets the "skill" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateSkill() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateSkill() }) } // SetAbilityType sets the "ability_type" field. func (u *EmployeeUpsertOne) SetAbilityType(v string) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetAbilityType(v) }) } // UpdateAbilityType sets the "ability_type" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateAbilityType() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateAbilityType() }) } // SetScene sets the "scene" field. func (u *EmployeeUpsertOne) SetScene(v string) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetScene(v) }) } // UpdateScene sets the "scene" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateScene() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateScene() }) } // SetSwitchIn sets the "switch_in" field. func (u *EmployeeUpsertOne) SetSwitchIn(v string) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetSwitchIn(v) }) } // UpdateSwitchIn sets the "switch_in" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateSwitchIn() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateSwitchIn() }) } // SetVideoURL sets the "video_url" field. func (u *EmployeeUpsertOne) SetVideoURL(v string) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetVideoURL(v) }) } // UpdateVideoURL sets the "video_url" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateVideoURL() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateVideoURL() }) } // SetOrganizationID sets the "organization_id" field. func (u *EmployeeUpsertOne) SetOrganizationID(v uint64) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetOrganizationID(v) }) } // AddOrganizationID adds v to the "organization_id" field. func (u *EmployeeUpsertOne) AddOrganizationID(v uint64) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.AddOrganizationID(v) }) } // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateOrganizationID() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateOrganizationID() }) } // SetCategoryID sets the "category_id" field. func (u *EmployeeUpsertOne) SetCategoryID(v uint64) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetCategoryID(v) }) } // AddCategoryID adds v to the "category_id" field. func (u *EmployeeUpsertOne) AddCategoryID(v uint64) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.AddCategoryID(v) }) } // UpdateCategoryID sets the "category_id" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateCategoryID() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateCategoryID() }) } // SetAPIBase sets the "api_base" field. func (u *EmployeeUpsertOne) SetAPIBase(v string) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetAPIBase(v) }) } // UpdateAPIBase sets the "api_base" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateAPIBase() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateAPIBase() }) } // SetAPIKey sets the "api_key" field. func (u *EmployeeUpsertOne) SetAPIKey(v string) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetAPIKey(v) }) } // UpdateAPIKey sets the "api_key" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateAPIKey() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateAPIKey() }) } // SetAiInfo sets the "ai_info" field. func (u *EmployeeUpsertOne) SetAiInfo(v string) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetAiInfo(v) }) } // UpdateAiInfo sets the "ai_info" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateAiInfo() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateAiInfo() }) } // ClearAiInfo clears the value of the "ai_info" field. func (u *EmployeeUpsertOne) ClearAiInfo() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.ClearAiInfo() }) } // SetIsVip sets the "is_vip" field. func (u *EmployeeUpsertOne) SetIsVip(v int) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetIsVip(v) }) } // AddIsVip adds v to the "is_vip" field. func (u *EmployeeUpsertOne) AddIsVip(v int) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.AddIsVip(v) }) } // UpdateIsVip sets the "is_vip" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateIsVip() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateIsVip() }) } // SetChatURL sets the "chat_url" field. func (u *EmployeeUpsertOne) SetChatURL(v string) *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.SetChatURL(v) }) } // UpdateChatURL sets the "chat_url" field to the value that was provided on create. func (u *EmployeeUpsertOne) UpdateChatURL() *EmployeeUpsertOne { return u.Update(func(s *EmployeeUpsert) { s.UpdateChatURL() }) } // Exec executes the query. func (u *EmployeeUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { return errors.New("ent: missing options for EmployeeCreate.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *EmployeeUpsertOne) 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 *EmployeeUpsertOne) 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 *EmployeeUpsertOne) IDX(ctx context.Context) uint64 { id, err := u.ID(ctx) if err != nil { panic(err) } return id } // EmployeeCreateBulk is the builder for creating many Employee entities in bulk. type EmployeeCreateBulk struct { config err error builders []*EmployeeCreate conflict []sql.ConflictOption } // Save creates the Employee entities in the database. func (ecb *EmployeeCreateBulk) Save(ctx context.Context) ([]*Employee, error) { if ecb.err != nil { return nil, ecb.err } specs := make([]*sqlgraph.CreateSpec, len(ecb.builders)) nodes := make([]*Employee, len(ecb.builders)) mutators := make([]Mutator, len(ecb.builders)) for i := range ecb.builders { func(i int, root context.Context) { builder := ecb.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*EmployeeMutation) 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, ecb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} spec.OnConflict = ecb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ecb.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, ecb.builders[0].mutation); err != nil { return nil, err } } return nodes, nil } // SaveX is like Save, but panics if an error occurs. func (ecb *EmployeeCreateBulk) SaveX(ctx context.Context) []*Employee { v, err := ecb.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (ecb *EmployeeCreateBulk) Exec(ctx context.Context) error { _, err := ecb.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (ecb *EmployeeCreateBulk) ExecX(ctx context.Context) { if err := ecb.Exec(ctx); err != nil { panic(err) } } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.Employee.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.EmployeeUpsert) { // SetCreatedAt(v+v). // }). // Exec(ctx) func (ecb *EmployeeCreateBulk) OnConflict(opts ...sql.ConflictOption) *EmployeeUpsertBulk { ecb.conflict = opts return &EmployeeUpsertBulk{ create: ecb, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.Employee.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (ecb *EmployeeCreateBulk) OnConflictColumns(columns ...string) *EmployeeUpsertBulk { ecb.conflict = append(ecb.conflict, sql.ConflictColumns(columns...)) return &EmployeeUpsertBulk{ create: ecb, } } // EmployeeUpsertBulk is the builder for "upsert"-ing // a bulk of Employee nodes. type EmployeeUpsertBulk struct { create *EmployeeCreateBulk } // UpdateNewValues updates the mutable fields using the new values that // were set on create. Using this option is equivalent to using: // // client.Employee.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(employee.FieldID) // }), // ). // Exec(ctx) func (u *EmployeeUpsertBulk) UpdateNewValues() *EmployeeUpsertBulk { 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(employee.FieldID) } if _, exists := b.mutation.CreatedAt(); exists { s.SetIgnore(employee.FieldCreatedAt) } } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.Employee.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *EmployeeUpsertBulk) Ignore() *EmployeeUpsertBulk { 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 *EmployeeUpsertBulk) DoNothing() *EmployeeUpsertBulk { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the EmployeeCreateBulk.OnConflict // documentation for more info. func (u *EmployeeUpsertBulk) Update(set func(*EmployeeUpsert)) *EmployeeUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&EmployeeUpsert{UpdateSet: update}) })) return u } // SetUpdatedAt sets the "updated_at" field. func (u *EmployeeUpsertBulk) SetUpdatedAt(v time.Time) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetUpdatedAt(v) }) } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateUpdatedAt() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateUpdatedAt() }) } // SetDeletedAt sets the "deleted_at" field. func (u *EmployeeUpsertBulk) SetDeletedAt(v time.Time) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetDeletedAt(v) }) } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateDeletedAt() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateDeletedAt() }) } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *EmployeeUpsertBulk) ClearDeletedAt() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.ClearDeletedAt() }) } // SetTitle sets the "title" field. func (u *EmployeeUpsertBulk) SetTitle(v string) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetTitle(v) }) } // UpdateTitle sets the "title" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateTitle() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateTitle() }) } // SetAvatar sets the "avatar" field. func (u *EmployeeUpsertBulk) SetAvatar(v string) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetAvatar(v) }) } // UpdateAvatar sets the "avatar" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateAvatar() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateAvatar() }) } // SetTags sets the "tags" field. func (u *EmployeeUpsertBulk) SetTags(v string) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetTags(v) }) } // UpdateTags sets the "tags" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateTags() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateTags() }) } // SetHireCount sets the "hire_count" field. func (u *EmployeeUpsertBulk) SetHireCount(v int) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetHireCount(v) }) } // AddHireCount adds v to the "hire_count" field. func (u *EmployeeUpsertBulk) AddHireCount(v int) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.AddHireCount(v) }) } // UpdateHireCount sets the "hire_count" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateHireCount() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateHireCount() }) } // SetServiceCount sets the "service_count" field. func (u *EmployeeUpsertBulk) SetServiceCount(v int) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetServiceCount(v) }) } // AddServiceCount adds v to the "service_count" field. func (u *EmployeeUpsertBulk) AddServiceCount(v int) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.AddServiceCount(v) }) } // UpdateServiceCount sets the "service_count" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateServiceCount() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateServiceCount() }) } // SetAchievementCount sets the "achievement_count" field. func (u *EmployeeUpsertBulk) SetAchievementCount(v int) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetAchievementCount(v) }) } // AddAchievementCount adds v to the "achievement_count" field. func (u *EmployeeUpsertBulk) AddAchievementCount(v int) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.AddAchievementCount(v) }) } // UpdateAchievementCount sets the "achievement_count" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateAchievementCount() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateAchievementCount() }) } // SetIntro sets the "intro" field. func (u *EmployeeUpsertBulk) SetIntro(v string) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetIntro(v) }) } // UpdateIntro sets the "intro" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateIntro() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateIntro() }) } // SetEstimate sets the "estimate" field. func (u *EmployeeUpsertBulk) SetEstimate(v string) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetEstimate(v) }) } // UpdateEstimate sets the "estimate" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateEstimate() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateEstimate() }) } // SetSkill sets the "skill" field. func (u *EmployeeUpsertBulk) SetSkill(v string) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetSkill(v) }) } // UpdateSkill sets the "skill" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateSkill() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateSkill() }) } // SetAbilityType sets the "ability_type" field. func (u *EmployeeUpsertBulk) SetAbilityType(v string) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetAbilityType(v) }) } // UpdateAbilityType sets the "ability_type" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateAbilityType() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateAbilityType() }) } // SetScene sets the "scene" field. func (u *EmployeeUpsertBulk) SetScene(v string) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetScene(v) }) } // UpdateScene sets the "scene" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateScene() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateScene() }) } // SetSwitchIn sets the "switch_in" field. func (u *EmployeeUpsertBulk) SetSwitchIn(v string) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetSwitchIn(v) }) } // UpdateSwitchIn sets the "switch_in" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateSwitchIn() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateSwitchIn() }) } // SetVideoURL sets the "video_url" field. func (u *EmployeeUpsertBulk) SetVideoURL(v string) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetVideoURL(v) }) } // UpdateVideoURL sets the "video_url" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateVideoURL() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateVideoURL() }) } // SetOrganizationID sets the "organization_id" field. func (u *EmployeeUpsertBulk) SetOrganizationID(v uint64) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetOrganizationID(v) }) } // AddOrganizationID adds v to the "organization_id" field. func (u *EmployeeUpsertBulk) AddOrganizationID(v uint64) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.AddOrganizationID(v) }) } // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateOrganizationID() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateOrganizationID() }) } // SetCategoryID sets the "category_id" field. func (u *EmployeeUpsertBulk) SetCategoryID(v uint64) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetCategoryID(v) }) } // AddCategoryID adds v to the "category_id" field. func (u *EmployeeUpsertBulk) AddCategoryID(v uint64) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.AddCategoryID(v) }) } // UpdateCategoryID sets the "category_id" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateCategoryID() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateCategoryID() }) } // SetAPIBase sets the "api_base" field. func (u *EmployeeUpsertBulk) SetAPIBase(v string) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetAPIBase(v) }) } // UpdateAPIBase sets the "api_base" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateAPIBase() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateAPIBase() }) } // SetAPIKey sets the "api_key" field. func (u *EmployeeUpsertBulk) SetAPIKey(v string) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetAPIKey(v) }) } // UpdateAPIKey sets the "api_key" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateAPIKey() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateAPIKey() }) } // SetAiInfo sets the "ai_info" field. func (u *EmployeeUpsertBulk) SetAiInfo(v string) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetAiInfo(v) }) } // UpdateAiInfo sets the "ai_info" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateAiInfo() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateAiInfo() }) } // ClearAiInfo clears the value of the "ai_info" field. func (u *EmployeeUpsertBulk) ClearAiInfo() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.ClearAiInfo() }) } // SetIsVip sets the "is_vip" field. func (u *EmployeeUpsertBulk) SetIsVip(v int) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetIsVip(v) }) } // AddIsVip adds v to the "is_vip" field. func (u *EmployeeUpsertBulk) AddIsVip(v int) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.AddIsVip(v) }) } // UpdateIsVip sets the "is_vip" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateIsVip() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateIsVip() }) } // SetChatURL sets the "chat_url" field. func (u *EmployeeUpsertBulk) SetChatURL(v string) *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.SetChatURL(v) }) } // UpdateChatURL sets the "chat_url" field to the value that was provided on create. func (u *EmployeeUpsertBulk) UpdateChatURL() *EmployeeUpsertBulk { return u.Update(func(s *EmployeeUpsert) { s.UpdateChatURL() }) } // Exec executes the query. func (u *EmployeeUpsertBulk) 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 EmployeeCreateBulk instead", i) } } if len(u.create.conflict) == 0 { return errors.New("ent: missing options for EmployeeCreateBulk.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *EmployeeUpsertBulk) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } }