12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760 |
- // 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
- }
- // 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)
- }
- 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 v, ok := ec.mutation.Avatar(); ok {
- if err := employee.AvatarValidator(v); err != nil {
- return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "Employee.avatar": %w`, err)}
- }
- }
- if _, ok := ec.mutation.Tags(); !ok {
- return &ValidationError{Name: "tags", err: errors.New(`ent: missing required field "Employee.tags"`)}
- }
- if v, ok := ec.mutation.Tags(); ok {
- if err := employee.TagsValidator(v); err != nil {
- return &ValidationError{Name: "tags", err: fmt.Errorf(`ent: validator failed for field "Employee.tags": %w`, err)}
- }
- }
- 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 v, ok := ec.mutation.Intro(); ok {
- if err := employee.IntroValidator(v); err != nil {
- return &ValidationError{Name: "intro", err: fmt.Errorf(`ent: validator failed for field "Employee.intro": %w`, err)}
- }
- }
- if _, ok := ec.mutation.Estimate(); !ok {
- return &ValidationError{Name: "estimate", err: errors.New(`ent: missing required field "Employee.estimate"`)}
- }
- if v, ok := ec.mutation.Estimate(); ok {
- if err := employee.EstimateValidator(v); err != nil {
- return &ValidationError{Name: "estimate", err: fmt.Errorf(`ent: validator failed for field "Employee.estimate": %w`, err)}
- }
- }
- if _, ok := ec.mutation.Skill(); !ok {
- return &ValidationError{Name: "skill", err: errors.New(`ent: missing required field "Employee.skill"`)}
- }
- if v, ok := ec.mutation.Skill(); ok {
- if err := employee.SkillValidator(v); err != nil {
- return &ValidationError{Name: "skill", err: fmt.Errorf(`ent: validator failed for field "Employee.skill": %w`, err)}
- }
- }
- 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 v, ok := ec.mutation.VideoURL(); ok {
- if err := employee.VideoURLValidator(v); err != nil {
- return &ValidationError{Name: "video_url", err: fmt.Errorf(`ent: validator failed for field "Employee.video_url": %w`, err)}
- }
- }
- 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)}
- }
- }
- 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 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
- }
- // 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()
- })
- }
- // 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()
- })
- }
- // 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)
- }
- }
|