// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/department" "git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/loginrecord" "git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/predicate" "git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/role" "git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/token" "git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/user" "git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/usermeta" "git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/usersocial" "git.noahlan.cn/noahlan/ntool-biz/core/orm/nent/types" ) // UserUpdate is the builder for updating User entities. type UserUpdate struct { config hooks []Hook mutation *UserMutation modifiers []func(*sql.UpdateBuilder) } // Where appends a list predicates to the UserUpdate builder. func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate { uu.mutation.Where(ps...) return uu } // SetStatus sets the "status" field. func (uu *UserUpdate) SetStatus(t types.Status) *UserUpdate { uu.mutation.SetStatus(t) return uu } // SetNillableStatus sets the "status" field if the given value is not nil. func (uu *UserUpdate) SetNillableStatus(t *types.Status) *UserUpdate { if t != nil { uu.SetStatus(*t) } return uu } // SetUpdatedAt sets the "updated_at" field. func (uu *UserUpdate) SetUpdatedAt(t time.Time) *UserUpdate { uu.mutation.SetUpdatedAt(t) return uu } // SetVersion sets the "version" field. func (uu *UserUpdate) SetVersion(i int64) *UserUpdate { uu.mutation.ResetVersion() uu.mutation.SetVersion(i) return uu } // SetNillableVersion sets the "version" field if the given value is not nil. func (uu *UserUpdate) SetNillableVersion(i *int64) *UserUpdate { if i != nil { uu.SetVersion(*i) } return uu } // AddVersion adds i to the "version" field. func (uu *UserUpdate) AddVersion(i int64) *UserUpdate { uu.mutation.AddVersion(i) return uu } // SetUsername sets the "username" field. func (uu *UserUpdate) SetUsername(s string) *UserUpdate { uu.mutation.SetUsername(s) return uu } // SetPhoneNumber sets the "phone_number" field. func (uu *UserUpdate) SetPhoneNumber(s string) *UserUpdate { uu.mutation.SetPhoneNumber(s) return uu } // SetNillablePhoneNumber sets the "phone_number" field if the given value is not nil. func (uu *UserUpdate) SetNillablePhoneNumber(s *string) *UserUpdate { if s != nil { uu.SetPhoneNumber(*s) } return uu } // ClearPhoneNumber clears the value of the "phone_number" field. func (uu *UserUpdate) ClearPhoneNumber() *UserUpdate { uu.mutation.ClearPhoneNumber() return uu } // SetEmail sets the "email" field. func (uu *UserUpdate) SetEmail(s string) *UserUpdate { uu.mutation.SetEmail(s) return uu } // SetNillableEmail sets the "email" field if the given value is not nil. func (uu *UserUpdate) SetNillableEmail(s *string) *UserUpdate { if s != nil { uu.SetEmail(*s) } return uu } // ClearEmail clears the value of the "email" field. func (uu *UserUpdate) ClearEmail() *UserUpdate { uu.mutation.ClearEmail() return uu } // SetPassword sets the "password" field. func (uu *UserUpdate) SetPassword(s string) *UserUpdate { uu.mutation.SetPassword(s) return uu } // SetNickname sets the "nickname" field. func (uu *UserUpdate) SetNickname(s string) *UserUpdate { uu.mutation.SetNickname(s) return uu } // SetNillableNickname sets the "nickname" field if the given value is not nil. func (uu *UserUpdate) SetNillableNickname(s *string) *UserUpdate { if s != nil { uu.SetNickname(*s) } return uu } // ClearNickname clears the value of the "nickname" field. func (uu *UserUpdate) ClearNickname() *UserUpdate { uu.mutation.ClearNickname() return uu } // AddMetaIDs adds the "metas" edge to the UserMeta entity by IDs. func (uu *UserUpdate) AddMetaIDs(ids ...int64) *UserUpdate { uu.mutation.AddMetaIDs(ids...) return uu } // AddMetas adds the "metas" edges to the UserMeta entity. func (uu *UserUpdate) AddMetas(u ...*UserMeta) *UserUpdate { ids := make([]int64, len(u)) for i := range u { ids[i] = u[i].ID } return uu.AddMetaIDs(ids...) } // AddRoleIDs adds the "roles" edge to the Role entity by IDs. func (uu *UserUpdate) AddRoleIDs(ids ...int64) *UserUpdate { uu.mutation.AddRoleIDs(ids...) return uu } // AddRoles adds the "roles" edges to the Role entity. func (uu *UserUpdate) AddRoles(r ...*Role) *UserUpdate { ids := make([]int64, len(r)) for i := range r { ids[i] = r[i].ID } return uu.AddRoleIDs(ids...) } // AddSocialIDs adds the "socials" edge to the UserSocial entity by IDs. func (uu *UserUpdate) AddSocialIDs(ids ...int64) *UserUpdate { uu.mutation.AddSocialIDs(ids...) return uu } // AddSocials adds the "socials" edges to the UserSocial entity. func (uu *UserUpdate) AddSocials(u ...*UserSocial) *UserUpdate { ids := make([]int64, len(u)) for i := range u { ids[i] = u[i].ID } return uu.AddSocialIDs(ids...) } // AddDepartmentIDs adds the "departments" edge to the Department entity by IDs. func (uu *UserUpdate) AddDepartmentIDs(ids ...int64) *UserUpdate { uu.mutation.AddDepartmentIDs(ids...) return uu } // AddDepartments adds the "departments" edges to the Department entity. func (uu *UserUpdate) AddDepartments(d ...*Department) *UserUpdate { ids := make([]int64, len(d)) for i := range d { ids[i] = d[i].ID } return uu.AddDepartmentIDs(ids...) } // AddTokenIDs adds the "token" edge to the Token entity by IDs. func (uu *UserUpdate) AddTokenIDs(ids ...int64) *UserUpdate { uu.mutation.AddTokenIDs(ids...) return uu } // AddToken adds the "token" edges to the Token entity. func (uu *UserUpdate) AddToken(t ...*Token) *UserUpdate { ids := make([]int64, len(t)) for i := range t { ids[i] = t[i].ID } return uu.AddTokenIDs(ids...) } // SetLoginRecordID sets the "loginRecord" edge to the LoginRecord entity by ID. func (uu *UserUpdate) SetLoginRecordID(id int64) *UserUpdate { uu.mutation.SetLoginRecordID(id) return uu } // SetNillableLoginRecordID sets the "loginRecord" edge to the LoginRecord entity by ID if the given value is not nil. func (uu *UserUpdate) SetNillableLoginRecordID(id *int64) *UserUpdate { if id != nil { uu = uu.SetLoginRecordID(*id) } return uu } // SetLoginRecord sets the "loginRecord" edge to the LoginRecord entity. func (uu *UserUpdate) SetLoginRecord(l *LoginRecord) *UserUpdate { return uu.SetLoginRecordID(l.ID) } // Mutation returns the UserMutation object of the builder. func (uu *UserUpdate) Mutation() *UserMutation { return uu.mutation } // ClearMetas clears all "metas" edges to the UserMeta entity. func (uu *UserUpdate) ClearMetas() *UserUpdate { uu.mutation.ClearMetas() return uu } // RemoveMetaIDs removes the "metas" edge to UserMeta entities by IDs. func (uu *UserUpdate) RemoveMetaIDs(ids ...int64) *UserUpdate { uu.mutation.RemoveMetaIDs(ids...) return uu } // RemoveMetas removes "metas" edges to UserMeta entities. func (uu *UserUpdate) RemoveMetas(u ...*UserMeta) *UserUpdate { ids := make([]int64, len(u)) for i := range u { ids[i] = u[i].ID } return uu.RemoveMetaIDs(ids...) } // ClearRoles clears all "roles" edges to the Role entity. func (uu *UserUpdate) ClearRoles() *UserUpdate { uu.mutation.ClearRoles() return uu } // RemoveRoleIDs removes the "roles" edge to Role entities by IDs. func (uu *UserUpdate) RemoveRoleIDs(ids ...int64) *UserUpdate { uu.mutation.RemoveRoleIDs(ids...) return uu } // RemoveRoles removes "roles" edges to Role entities. func (uu *UserUpdate) RemoveRoles(r ...*Role) *UserUpdate { ids := make([]int64, len(r)) for i := range r { ids[i] = r[i].ID } return uu.RemoveRoleIDs(ids...) } // ClearSocials clears all "socials" edges to the UserSocial entity. func (uu *UserUpdate) ClearSocials() *UserUpdate { uu.mutation.ClearSocials() return uu } // RemoveSocialIDs removes the "socials" edge to UserSocial entities by IDs. func (uu *UserUpdate) RemoveSocialIDs(ids ...int64) *UserUpdate { uu.mutation.RemoveSocialIDs(ids...) return uu } // RemoveSocials removes "socials" edges to UserSocial entities. func (uu *UserUpdate) RemoveSocials(u ...*UserSocial) *UserUpdate { ids := make([]int64, len(u)) for i := range u { ids[i] = u[i].ID } return uu.RemoveSocialIDs(ids...) } // ClearDepartments clears all "departments" edges to the Department entity. func (uu *UserUpdate) ClearDepartments() *UserUpdate { uu.mutation.ClearDepartments() return uu } // RemoveDepartmentIDs removes the "departments" edge to Department entities by IDs. func (uu *UserUpdate) RemoveDepartmentIDs(ids ...int64) *UserUpdate { uu.mutation.RemoveDepartmentIDs(ids...) return uu } // RemoveDepartments removes "departments" edges to Department entities. func (uu *UserUpdate) RemoveDepartments(d ...*Department) *UserUpdate { ids := make([]int64, len(d)) for i := range d { ids[i] = d[i].ID } return uu.RemoveDepartmentIDs(ids...) } // ClearToken clears all "token" edges to the Token entity. func (uu *UserUpdate) ClearToken() *UserUpdate { uu.mutation.ClearToken() return uu } // RemoveTokenIDs removes the "token" edge to Token entities by IDs. func (uu *UserUpdate) RemoveTokenIDs(ids ...int64) *UserUpdate { uu.mutation.RemoveTokenIDs(ids...) return uu } // RemoveToken removes "token" edges to Token entities. func (uu *UserUpdate) RemoveToken(t ...*Token) *UserUpdate { ids := make([]int64, len(t)) for i := range t { ids[i] = t[i].ID } return uu.RemoveTokenIDs(ids...) } // ClearLoginRecord clears the "loginRecord" edge to the LoginRecord entity. func (uu *UserUpdate) ClearLoginRecord() *UserUpdate { uu.mutation.ClearLoginRecord() return uu } // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { if err := uu.defaults(); err != nil { return 0, err } return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) } // SaveX is like Save, but panics if an error occurs. func (uu *UserUpdate) SaveX(ctx context.Context) int { affected, err := uu.Save(ctx) if err != nil { panic(err) } return affected } // Exec executes the query. func (uu *UserUpdate) Exec(ctx context.Context) error { _, err := uu.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (uu *UserUpdate) ExecX(ctx context.Context) { if err := uu.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. func (uu *UserUpdate) defaults() error { if _, ok := uu.mutation.UpdatedAt(); !ok { if user.UpdateDefaultUpdatedAt == nil { return fmt.Errorf("ent: uninitialized user.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") } v := user.UpdateDefaultUpdatedAt() uu.mutation.SetUpdatedAt(v) } return nil } // check runs all checks and user-defined validators on the builder. func (uu *UserUpdate) check() error { if v, ok := uu.mutation.Status(); ok { if err := user.StatusValidator(v); err != nil { return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "User.status": %w`, err)} } } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. func (uu *UserUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserUpdate { uu.modifiers = append(uu.modifiers, modifiers...) return uu } func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if err := uu.check(); err != nil { return n, err } _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64)) if ps := uu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := uu.mutation.Status(); ok { _spec.SetField(user.FieldStatus, field.TypeEnum, value) } if value, ok := uu.mutation.UpdatedAt(); ok { _spec.SetField(user.FieldUpdatedAt, field.TypeTime, value) } if value, ok := uu.mutation.Version(); ok { _spec.SetField(user.FieldVersion, field.TypeInt64, value) } if value, ok := uu.mutation.AddedVersion(); ok { _spec.AddField(user.FieldVersion, field.TypeInt64, value) } if value, ok := uu.mutation.Username(); ok { _spec.SetField(user.FieldUsername, field.TypeString, value) } if value, ok := uu.mutation.PhoneNumber(); ok { _spec.SetField(user.FieldPhoneNumber, field.TypeString, value) } if uu.mutation.PhoneNumberCleared() { _spec.ClearField(user.FieldPhoneNumber, field.TypeString) } if value, ok := uu.mutation.Email(); ok { _spec.SetField(user.FieldEmail, field.TypeString, value) } if uu.mutation.EmailCleared() { _spec.ClearField(user.FieldEmail, field.TypeString) } if value, ok := uu.mutation.Password(); ok { _spec.SetField(user.FieldPassword, field.TypeString, value) } if value, ok := uu.mutation.Nickname(); ok { _spec.SetField(user.FieldNickname, field.TypeString, value) } if uu.mutation.NicknameCleared() { _spec.ClearField(user.FieldNickname, field.TypeString) } if uu.mutation.MetasCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.MetasTable, Columns: []string{user.MetasColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(usermeta.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uu.mutation.RemovedMetasIDs(); len(nodes) > 0 && !uu.mutation.MetasCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.MetasTable, Columns: []string{user.MetasColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(usermeta.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uu.mutation.MetasIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.MetasTable, Columns: []string{user.MetasColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(usermeta.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if uu.mutation.RolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: user.RolesTable, Columns: user.RolesPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uu.mutation.RemovedRolesIDs(); len(nodes) > 0 && !uu.mutation.RolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: user.RolesTable, Columns: user.RolesPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uu.mutation.RolesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: user.RolesTable, Columns: user.RolesPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if uu.mutation.SocialsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.SocialsTable, Columns: []string{user.SocialsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(usersocial.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uu.mutation.RemovedSocialsIDs(); len(nodes) > 0 && !uu.mutation.SocialsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.SocialsTable, Columns: []string{user.SocialsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(usersocial.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uu.mutation.SocialsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.SocialsTable, Columns: []string{user.SocialsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(usersocial.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if uu.mutation.DepartmentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: user.DepartmentsTable, Columns: user.DepartmentsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(department.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uu.mutation.RemovedDepartmentsIDs(); len(nodes) > 0 && !uu.mutation.DepartmentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: user.DepartmentsTable, Columns: user.DepartmentsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(department.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uu.mutation.DepartmentsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: user.DepartmentsTable, Columns: user.DepartmentsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(department.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if uu.mutation.TokenCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.TokenTable, Columns: []string{user.TokenColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(token.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uu.mutation.RemovedTokenIDs(); len(nodes) > 0 && !uu.mutation.TokenCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.TokenTable, Columns: []string{user.TokenColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(token.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uu.mutation.TokenIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.TokenTable, Columns: []string{user.TokenColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(token.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if uu.mutation.LoginRecordCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2O, Inverse: false, Table: user.LoginRecordTable, Columns: []string{user.LoginRecordColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(loginrecord.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uu.mutation.LoginRecordIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2O, Inverse: false, Table: user.LoginRecordTable, Columns: []string{user.LoginRecordColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(loginrecord.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } _spec.AddModifiers(uu.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return 0, err } uu.mutation.done = true return n, nil } // UserUpdateOne is the builder for updating a single User entity. type UserUpdateOne struct { config fields []string hooks []Hook mutation *UserMutation modifiers []func(*sql.UpdateBuilder) } // SetStatus sets the "status" field. func (uuo *UserUpdateOne) SetStatus(t types.Status) *UserUpdateOne { uuo.mutation.SetStatus(t) return uuo } // SetNillableStatus sets the "status" field if the given value is not nil. func (uuo *UserUpdateOne) SetNillableStatus(t *types.Status) *UserUpdateOne { if t != nil { uuo.SetStatus(*t) } return uuo } // SetUpdatedAt sets the "updated_at" field. func (uuo *UserUpdateOne) SetUpdatedAt(t time.Time) *UserUpdateOne { uuo.mutation.SetUpdatedAt(t) return uuo } // SetVersion sets the "version" field. func (uuo *UserUpdateOne) SetVersion(i int64) *UserUpdateOne { uuo.mutation.ResetVersion() uuo.mutation.SetVersion(i) return uuo } // SetNillableVersion sets the "version" field if the given value is not nil. func (uuo *UserUpdateOne) SetNillableVersion(i *int64) *UserUpdateOne { if i != nil { uuo.SetVersion(*i) } return uuo } // AddVersion adds i to the "version" field. func (uuo *UserUpdateOne) AddVersion(i int64) *UserUpdateOne { uuo.mutation.AddVersion(i) return uuo } // SetUsername sets the "username" field. func (uuo *UserUpdateOne) SetUsername(s string) *UserUpdateOne { uuo.mutation.SetUsername(s) return uuo } // SetPhoneNumber sets the "phone_number" field. func (uuo *UserUpdateOne) SetPhoneNumber(s string) *UserUpdateOne { uuo.mutation.SetPhoneNumber(s) return uuo } // SetNillablePhoneNumber sets the "phone_number" field if the given value is not nil. func (uuo *UserUpdateOne) SetNillablePhoneNumber(s *string) *UserUpdateOne { if s != nil { uuo.SetPhoneNumber(*s) } return uuo } // ClearPhoneNumber clears the value of the "phone_number" field. func (uuo *UserUpdateOne) ClearPhoneNumber() *UserUpdateOne { uuo.mutation.ClearPhoneNumber() return uuo } // SetEmail sets the "email" field. func (uuo *UserUpdateOne) SetEmail(s string) *UserUpdateOne { uuo.mutation.SetEmail(s) return uuo } // SetNillableEmail sets the "email" field if the given value is not nil. func (uuo *UserUpdateOne) SetNillableEmail(s *string) *UserUpdateOne { if s != nil { uuo.SetEmail(*s) } return uuo } // ClearEmail clears the value of the "email" field. func (uuo *UserUpdateOne) ClearEmail() *UserUpdateOne { uuo.mutation.ClearEmail() return uuo } // SetPassword sets the "password" field. func (uuo *UserUpdateOne) SetPassword(s string) *UserUpdateOne { uuo.mutation.SetPassword(s) return uuo } // SetNickname sets the "nickname" field. func (uuo *UserUpdateOne) SetNickname(s string) *UserUpdateOne { uuo.mutation.SetNickname(s) return uuo } // SetNillableNickname sets the "nickname" field if the given value is not nil. func (uuo *UserUpdateOne) SetNillableNickname(s *string) *UserUpdateOne { if s != nil { uuo.SetNickname(*s) } return uuo } // ClearNickname clears the value of the "nickname" field. func (uuo *UserUpdateOne) ClearNickname() *UserUpdateOne { uuo.mutation.ClearNickname() return uuo } // AddMetaIDs adds the "metas" edge to the UserMeta entity by IDs. func (uuo *UserUpdateOne) AddMetaIDs(ids ...int64) *UserUpdateOne { uuo.mutation.AddMetaIDs(ids...) return uuo } // AddMetas adds the "metas" edges to the UserMeta entity. func (uuo *UserUpdateOne) AddMetas(u ...*UserMeta) *UserUpdateOne { ids := make([]int64, len(u)) for i := range u { ids[i] = u[i].ID } return uuo.AddMetaIDs(ids...) } // AddRoleIDs adds the "roles" edge to the Role entity by IDs. func (uuo *UserUpdateOne) AddRoleIDs(ids ...int64) *UserUpdateOne { uuo.mutation.AddRoleIDs(ids...) return uuo } // AddRoles adds the "roles" edges to the Role entity. func (uuo *UserUpdateOne) AddRoles(r ...*Role) *UserUpdateOne { ids := make([]int64, len(r)) for i := range r { ids[i] = r[i].ID } return uuo.AddRoleIDs(ids...) } // AddSocialIDs adds the "socials" edge to the UserSocial entity by IDs. func (uuo *UserUpdateOne) AddSocialIDs(ids ...int64) *UserUpdateOne { uuo.mutation.AddSocialIDs(ids...) return uuo } // AddSocials adds the "socials" edges to the UserSocial entity. func (uuo *UserUpdateOne) AddSocials(u ...*UserSocial) *UserUpdateOne { ids := make([]int64, len(u)) for i := range u { ids[i] = u[i].ID } return uuo.AddSocialIDs(ids...) } // AddDepartmentIDs adds the "departments" edge to the Department entity by IDs. func (uuo *UserUpdateOne) AddDepartmentIDs(ids ...int64) *UserUpdateOne { uuo.mutation.AddDepartmentIDs(ids...) return uuo } // AddDepartments adds the "departments" edges to the Department entity. func (uuo *UserUpdateOne) AddDepartments(d ...*Department) *UserUpdateOne { ids := make([]int64, len(d)) for i := range d { ids[i] = d[i].ID } return uuo.AddDepartmentIDs(ids...) } // AddTokenIDs adds the "token" edge to the Token entity by IDs. func (uuo *UserUpdateOne) AddTokenIDs(ids ...int64) *UserUpdateOne { uuo.mutation.AddTokenIDs(ids...) return uuo } // AddToken adds the "token" edges to the Token entity. func (uuo *UserUpdateOne) AddToken(t ...*Token) *UserUpdateOne { ids := make([]int64, len(t)) for i := range t { ids[i] = t[i].ID } return uuo.AddTokenIDs(ids...) } // SetLoginRecordID sets the "loginRecord" edge to the LoginRecord entity by ID. func (uuo *UserUpdateOne) SetLoginRecordID(id int64) *UserUpdateOne { uuo.mutation.SetLoginRecordID(id) return uuo } // SetNillableLoginRecordID sets the "loginRecord" edge to the LoginRecord entity by ID if the given value is not nil. func (uuo *UserUpdateOne) SetNillableLoginRecordID(id *int64) *UserUpdateOne { if id != nil { uuo = uuo.SetLoginRecordID(*id) } return uuo } // SetLoginRecord sets the "loginRecord" edge to the LoginRecord entity. func (uuo *UserUpdateOne) SetLoginRecord(l *LoginRecord) *UserUpdateOne { return uuo.SetLoginRecordID(l.ID) } // Mutation returns the UserMutation object of the builder. func (uuo *UserUpdateOne) Mutation() *UserMutation { return uuo.mutation } // ClearMetas clears all "metas" edges to the UserMeta entity. func (uuo *UserUpdateOne) ClearMetas() *UserUpdateOne { uuo.mutation.ClearMetas() return uuo } // RemoveMetaIDs removes the "metas" edge to UserMeta entities by IDs. func (uuo *UserUpdateOne) RemoveMetaIDs(ids ...int64) *UserUpdateOne { uuo.mutation.RemoveMetaIDs(ids...) return uuo } // RemoveMetas removes "metas" edges to UserMeta entities. func (uuo *UserUpdateOne) RemoveMetas(u ...*UserMeta) *UserUpdateOne { ids := make([]int64, len(u)) for i := range u { ids[i] = u[i].ID } return uuo.RemoveMetaIDs(ids...) } // ClearRoles clears all "roles" edges to the Role entity. func (uuo *UserUpdateOne) ClearRoles() *UserUpdateOne { uuo.mutation.ClearRoles() return uuo } // RemoveRoleIDs removes the "roles" edge to Role entities by IDs. func (uuo *UserUpdateOne) RemoveRoleIDs(ids ...int64) *UserUpdateOne { uuo.mutation.RemoveRoleIDs(ids...) return uuo } // RemoveRoles removes "roles" edges to Role entities. func (uuo *UserUpdateOne) RemoveRoles(r ...*Role) *UserUpdateOne { ids := make([]int64, len(r)) for i := range r { ids[i] = r[i].ID } return uuo.RemoveRoleIDs(ids...) } // ClearSocials clears all "socials" edges to the UserSocial entity. func (uuo *UserUpdateOne) ClearSocials() *UserUpdateOne { uuo.mutation.ClearSocials() return uuo } // RemoveSocialIDs removes the "socials" edge to UserSocial entities by IDs. func (uuo *UserUpdateOne) RemoveSocialIDs(ids ...int64) *UserUpdateOne { uuo.mutation.RemoveSocialIDs(ids...) return uuo } // RemoveSocials removes "socials" edges to UserSocial entities. func (uuo *UserUpdateOne) RemoveSocials(u ...*UserSocial) *UserUpdateOne { ids := make([]int64, len(u)) for i := range u { ids[i] = u[i].ID } return uuo.RemoveSocialIDs(ids...) } // ClearDepartments clears all "departments" edges to the Department entity. func (uuo *UserUpdateOne) ClearDepartments() *UserUpdateOne { uuo.mutation.ClearDepartments() return uuo } // RemoveDepartmentIDs removes the "departments" edge to Department entities by IDs. func (uuo *UserUpdateOne) RemoveDepartmentIDs(ids ...int64) *UserUpdateOne { uuo.mutation.RemoveDepartmentIDs(ids...) return uuo } // RemoveDepartments removes "departments" edges to Department entities. func (uuo *UserUpdateOne) RemoveDepartments(d ...*Department) *UserUpdateOne { ids := make([]int64, len(d)) for i := range d { ids[i] = d[i].ID } return uuo.RemoveDepartmentIDs(ids...) } // ClearToken clears all "token" edges to the Token entity. func (uuo *UserUpdateOne) ClearToken() *UserUpdateOne { uuo.mutation.ClearToken() return uuo } // RemoveTokenIDs removes the "token" edge to Token entities by IDs. func (uuo *UserUpdateOne) RemoveTokenIDs(ids ...int64) *UserUpdateOne { uuo.mutation.RemoveTokenIDs(ids...) return uuo } // RemoveToken removes "token" edges to Token entities. func (uuo *UserUpdateOne) RemoveToken(t ...*Token) *UserUpdateOne { ids := make([]int64, len(t)) for i := range t { ids[i] = t[i].ID } return uuo.RemoveTokenIDs(ids...) } // ClearLoginRecord clears the "loginRecord" edge to the LoginRecord entity. func (uuo *UserUpdateOne) ClearLoginRecord() *UserUpdateOne { uuo.mutation.ClearLoginRecord() return uuo } // Where appends a list predicates to the UserUpdate builder. func (uuo *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne { uuo.mutation.Where(ps...) return uuo } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne { uuo.fields = append([]string{field}, fields...) return uuo } // Save executes the query and returns the updated User entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { if err := uuo.defaults(); err != nil { return nil, err } return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) } // SaveX is like Save, but panics if an error occurs. func (uuo *UserUpdateOne) SaveX(ctx context.Context) *User { node, err := uuo.Save(ctx) if err != nil { panic(err) } return node } // Exec executes the query on the entity. func (uuo *UserUpdateOne) Exec(ctx context.Context) error { _, err := uuo.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (uuo *UserUpdateOne) ExecX(ctx context.Context) { if err := uuo.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. func (uuo *UserUpdateOne) defaults() error { if _, ok := uuo.mutation.UpdatedAt(); !ok { if user.UpdateDefaultUpdatedAt == nil { return fmt.Errorf("ent: uninitialized user.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") } v := user.UpdateDefaultUpdatedAt() uuo.mutation.SetUpdatedAt(v) } return nil } // check runs all checks and user-defined validators on the builder. func (uuo *UserUpdateOne) check() error { if v, ok := uuo.mutation.Status(); ok { if err := user.StatusValidator(v); err != nil { return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "User.status": %w`, err)} } } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. func (uuo *UserUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserUpdateOne { uuo.modifiers = append(uuo.modifiers, modifiers...) return uuo } func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { if err := uuo.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64)) id, ok := uuo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "User.id" for update`)} } _spec.Node.ID.Value = id if fields := uuo.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) for _, f := range fields { if !user.ValidColumn(f) { return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } if f != user.FieldID { _spec.Node.Columns = append(_spec.Node.Columns, f) } } } if ps := uuo.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := uuo.mutation.Status(); ok { _spec.SetField(user.FieldStatus, field.TypeEnum, value) } if value, ok := uuo.mutation.UpdatedAt(); ok { _spec.SetField(user.FieldUpdatedAt, field.TypeTime, value) } if value, ok := uuo.mutation.Version(); ok { _spec.SetField(user.FieldVersion, field.TypeInt64, value) } if value, ok := uuo.mutation.AddedVersion(); ok { _spec.AddField(user.FieldVersion, field.TypeInt64, value) } if value, ok := uuo.mutation.Username(); ok { _spec.SetField(user.FieldUsername, field.TypeString, value) } if value, ok := uuo.mutation.PhoneNumber(); ok { _spec.SetField(user.FieldPhoneNumber, field.TypeString, value) } if uuo.mutation.PhoneNumberCleared() { _spec.ClearField(user.FieldPhoneNumber, field.TypeString) } if value, ok := uuo.mutation.Email(); ok { _spec.SetField(user.FieldEmail, field.TypeString, value) } if uuo.mutation.EmailCleared() { _spec.ClearField(user.FieldEmail, field.TypeString) } if value, ok := uuo.mutation.Password(); ok { _spec.SetField(user.FieldPassword, field.TypeString, value) } if value, ok := uuo.mutation.Nickname(); ok { _spec.SetField(user.FieldNickname, field.TypeString, value) } if uuo.mutation.NicknameCleared() { _spec.ClearField(user.FieldNickname, field.TypeString) } if uuo.mutation.MetasCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.MetasTable, Columns: []string{user.MetasColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(usermeta.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uuo.mutation.RemovedMetasIDs(); len(nodes) > 0 && !uuo.mutation.MetasCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.MetasTable, Columns: []string{user.MetasColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(usermeta.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uuo.mutation.MetasIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.MetasTable, Columns: []string{user.MetasColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(usermeta.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if uuo.mutation.RolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: user.RolesTable, Columns: user.RolesPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uuo.mutation.RemovedRolesIDs(); len(nodes) > 0 && !uuo.mutation.RolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: user.RolesTable, Columns: user.RolesPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uuo.mutation.RolesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: user.RolesTable, Columns: user.RolesPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if uuo.mutation.SocialsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.SocialsTable, Columns: []string{user.SocialsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(usersocial.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uuo.mutation.RemovedSocialsIDs(); len(nodes) > 0 && !uuo.mutation.SocialsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.SocialsTable, Columns: []string{user.SocialsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(usersocial.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uuo.mutation.SocialsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.SocialsTable, Columns: []string{user.SocialsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(usersocial.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if uuo.mutation.DepartmentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: user.DepartmentsTable, Columns: user.DepartmentsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(department.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uuo.mutation.RemovedDepartmentsIDs(); len(nodes) > 0 && !uuo.mutation.DepartmentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: user.DepartmentsTable, Columns: user.DepartmentsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(department.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uuo.mutation.DepartmentsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: user.DepartmentsTable, Columns: user.DepartmentsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(department.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if uuo.mutation.TokenCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.TokenTable, Columns: []string{user.TokenColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(token.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uuo.mutation.RemovedTokenIDs(); len(nodes) > 0 && !uuo.mutation.TokenCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.TokenTable, Columns: []string{user.TokenColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(token.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uuo.mutation.TokenIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: user.TokenTable, Columns: []string{user.TokenColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(token.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if uuo.mutation.LoginRecordCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2O, Inverse: false, Table: user.LoginRecordTable, Columns: []string{user.LoginRecordColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(loginrecord.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := uuo.mutation.LoginRecordIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2O, Inverse: false, Table: user.LoginRecordTable, Columns: []string{user.LoginRecordColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(loginrecord.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } _spec.AddModifiers(uuo.modifiers...) _node = &User{config: uuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } uuo.mutation.done = true return _node, nil }