// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "time" "tss-rocks-be/ent/contributor" "tss-rocks-be/ent/contributorsociallink" "tss-rocks-be/ent/postcontributor" "tss-rocks-be/ent/predicate" "tss-rocks-be/ent/user" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // ContributorUpdate is the builder for updating Contributor entities. type ContributorUpdate struct { config hooks []Hook mutation *ContributorMutation } // Where appends a list predicates to the ContributorUpdate builder. func (cu *ContributorUpdate) Where(ps ...predicate.Contributor) *ContributorUpdate { cu.mutation.Where(ps...) return cu } // SetName sets the "name" field. func (cu *ContributorUpdate) SetName(s string) *ContributorUpdate { cu.mutation.SetName(s) return cu } // SetNillableName sets the "name" field if the given value is not nil. func (cu *ContributorUpdate) SetNillableName(s *string) *ContributorUpdate { if s != nil { cu.SetName(*s) } return cu } // SetAvatarURL sets the "avatar_url" field. func (cu *ContributorUpdate) SetAvatarURL(s string) *ContributorUpdate { cu.mutation.SetAvatarURL(s) return cu } // SetNillableAvatarURL sets the "avatar_url" field if the given value is not nil. func (cu *ContributorUpdate) SetNillableAvatarURL(s *string) *ContributorUpdate { if s != nil { cu.SetAvatarURL(*s) } return cu } // ClearAvatarURL clears the value of the "avatar_url" field. func (cu *ContributorUpdate) ClearAvatarURL() *ContributorUpdate { cu.mutation.ClearAvatarURL() return cu } // SetBio sets the "bio" field. func (cu *ContributorUpdate) SetBio(s string) *ContributorUpdate { cu.mutation.SetBio(s) return cu } // SetNillableBio sets the "bio" field if the given value is not nil. func (cu *ContributorUpdate) SetNillableBio(s *string) *ContributorUpdate { if s != nil { cu.SetBio(*s) } return cu } // ClearBio clears the value of the "bio" field. func (cu *ContributorUpdate) ClearBio() *ContributorUpdate { cu.mutation.ClearBio() return cu } // SetCreatedAt sets the "created_at" field. func (cu *ContributorUpdate) SetCreatedAt(t time.Time) *ContributorUpdate { cu.mutation.SetCreatedAt(t) return cu } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (cu *ContributorUpdate) SetNillableCreatedAt(t *time.Time) *ContributorUpdate { if t != nil { cu.SetCreatedAt(*t) } return cu } // SetUpdatedAt sets the "updated_at" field. func (cu *ContributorUpdate) SetUpdatedAt(t time.Time) *ContributorUpdate { cu.mutation.SetUpdatedAt(t) return cu } // SetUserID sets the "user" edge to the User entity by ID. func (cu *ContributorUpdate) SetUserID(id int) *ContributorUpdate { cu.mutation.SetUserID(id) return cu } // SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil. func (cu *ContributorUpdate) SetNillableUserID(id *int) *ContributorUpdate { if id != nil { cu = cu.SetUserID(*id) } return cu } // SetUser sets the "user" edge to the User entity. func (cu *ContributorUpdate) SetUser(u *User) *ContributorUpdate { return cu.SetUserID(u.ID) } // AddSocialLinkIDs adds the "social_links" edge to the ContributorSocialLink entity by IDs. func (cu *ContributorUpdate) AddSocialLinkIDs(ids ...int) *ContributorUpdate { cu.mutation.AddSocialLinkIDs(ids...) return cu } // AddSocialLinks adds the "social_links" edges to the ContributorSocialLink entity. func (cu *ContributorUpdate) AddSocialLinks(c ...*ContributorSocialLink) *ContributorUpdate { ids := make([]int, len(c)) for i := range c { ids[i] = c[i].ID } return cu.AddSocialLinkIDs(ids...) } // AddPostIDs adds the "posts" edge to the PostContributor entity by IDs. func (cu *ContributorUpdate) AddPostIDs(ids ...int) *ContributorUpdate { cu.mutation.AddPostIDs(ids...) return cu } // AddPosts adds the "posts" edges to the PostContributor entity. func (cu *ContributorUpdate) AddPosts(p ...*PostContributor) *ContributorUpdate { ids := make([]int, len(p)) for i := range p { ids[i] = p[i].ID } return cu.AddPostIDs(ids...) } // Mutation returns the ContributorMutation object of the builder. func (cu *ContributorUpdate) Mutation() *ContributorMutation { return cu.mutation } // ClearUser clears the "user" edge to the User entity. func (cu *ContributorUpdate) ClearUser() *ContributorUpdate { cu.mutation.ClearUser() return cu } // ClearSocialLinks clears all "social_links" edges to the ContributorSocialLink entity. func (cu *ContributorUpdate) ClearSocialLinks() *ContributorUpdate { cu.mutation.ClearSocialLinks() return cu } // RemoveSocialLinkIDs removes the "social_links" edge to ContributorSocialLink entities by IDs. func (cu *ContributorUpdate) RemoveSocialLinkIDs(ids ...int) *ContributorUpdate { cu.mutation.RemoveSocialLinkIDs(ids...) return cu } // RemoveSocialLinks removes "social_links" edges to ContributorSocialLink entities. func (cu *ContributorUpdate) RemoveSocialLinks(c ...*ContributorSocialLink) *ContributorUpdate { ids := make([]int, len(c)) for i := range c { ids[i] = c[i].ID } return cu.RemoveSocialLinkIDs(ids...) } // ClearPosts clears all "posts" edges to the PostContributor entity. func (cu *ContributorUpdate) ClearPosts() *ContributorUpdate { cu.mutation.ClearPosts() return cu } // RemovePostIDs removes the "posts" edge to PostContributor entities by IDs. func (cu *ContributorUpdate) RemovePostIDs(ids ...int) *ContributorUpdate { cu.mutation.RemovePostIDs(ids...) return cu } // RemovePosts removes "posts" edges to PostContributor entities. func (cu *ContributorUpdate) RemovePosts(p ...*PostContributor) *ContributorUpdate { ids := make([]int, len(p)) for i := range p { ids[i] = p[i].ID } return cu.RemovePostIDs(ids...) } // Save executes the query and returns the number of nodes affected by the update operation. func (cu *ContributorUpdate) Save(ctx context.Context) (int, error) { cu.defaults() return withHooks(ctx, cu.sqlSave, cu.mutation, cu.hooks) } // SaveX is like Save, but panics if an error occurs. func (cu *ContributorUpdate) SaveX(ctx context.Context) int { affected, err := cu.Save(ctx) if err != nil { panic(err) } return affected } // Exec executes the query. func (cu *ContributorUpdate) Exec(ctx context.Context) error { _, err := cu.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (cu *ContributorUpdate) ExecX(ctx context.Context) { if err := cu.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. func (cu *ContributorUpdate) defaults() { if _, ok := cu.mutation.UpdatedAt(); !ok { v := contributor.UpdateDefaultUpdatedAt() cu.mutation.SetUpdatedAt(v) } } // check runs all checks and user-defined validators on the builder. func (cu *ContributorUpdate) check() error { if v, ok := cu.mutation.Name(); ok { if err := contributor.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Contributor.name": %w`, err)} } } return nil } func (cu *ContributorUpdate) sqlSave(ctx context.Context) (n int, err error) { if err := cu.check(); err != nil { return n, err } _spec := sqlgraph.NewUpdateSpec(contributor.Table, contributor.Columns, sqlgraph.NewFieldSpec(contributor.FieldID, field.TypeInt)) if ps := cu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := cu.mutation.Name(); ok { _spec.SetField(contributor.FieldName, field.TypeString, value) } if value, ok := cu.mutation.AvatarURL(); ok { _spec.SetField(contributor.FieldAvatarURL, field.TypeString, value) } if cu.mutation.AvatarURLCleared() { _spec.ClearField(contributor.FieldAvatarURL, field.TypeString) } if value, ok := cu.mutation.Bio(); ok { _spec.SetField(contributor.FieldBio, field.TypeString, value) } if cu.mutation.BioCleared() { _spec.ClearField(contributor.FieldBio, field.TypeString) } if value, ok := cu.mutation.CreatedAt(); ok { _spec.SetField(contributor.FieldCreatedAt, field.TypeTime, value) } if value, ok := cu.mutation.UpdatedAt(); ok { _spec.SetField(contributor.FieldUpdatedAt, field.TypeTime, value) } if cu.mutation.UserCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: contributor.UserTable, Columns: []string{contributor.UserColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := cu.mutation.UserIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: contributor.UserTable, Columns: []string{contributor.UserColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if cu.mutation.SocialLinksCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: contributor.SocialLinksTable, Columns: []string{contributor.SocialLinksColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(contributorsociallink.FieldID, field.TypeInt), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := cu.mutation.RemovedSocialLinksIDs(); len(nodes) > 0 && !cu.mutation.SocialLinksCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: contributor.SocialLinksTable, Columns: []string{contributor.SocialLinksColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(contributorsociallink.FieldID, field.TypeInt), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := cu.mutation.SocialLinksIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: contributor.SocialLinksTable, Columns: []string{contributor.SocialLinksColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(contributorsociallink.FieldID, field.TypeInt), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if cu.mutation.PostsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: contributor.PostsTable, Columns: []string{contributor.PostsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(postcontributor.FieldID, field.TypeInt), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := cu.mutation.RemovedPostsIDs(); len(nodes) > 0 && !cu.mutation.PostsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: contributor.PostsTable, Columns: []string{contributor.PostsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(postcontributor.FieldID, field.TypeInt), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := cu.mutation.PostsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: contributor.PostsTable, Columns: []string{contributor.PostsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(postcontributor.FieldID, field.TypeInt), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{contributor.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return 0, err } cu.mutation.done = true return n, nil } // ContributorUpdateOne is the builder for updating a single Contributor entity. type ContributorUpdateOne struct { config fields []string hooks []Hook mutation *ContributorMutation } // SetName sets the "name" field. func (cuo *ContributorUpdateOne) SetName(s string) *ContributorUpdateOne { cuo.mutation.SetName(s) return cuo } // SetNillableName sets the "name" field if the given value is not nil. func (cuo *ContributorUpdateOne) SetNillableName(s *string) *ContributorUpdateOne { if s != nil { cuo.SetName(*s) } return cuo } // SetAvatarURL sets the "avatar_url" field. func (cuo *ContributorUpdateOne) SetAvatarURL(s string) *ContributorUpdateOne { cuo.mutation.SetAvatarURL(s) return cuo } // SetNillableAvatarURL sets the "avatar_url" field if the given value is not nil. func (cuo *ContributorUpdateOne) SetNillableAvatarURL(s *string) *ContributorUpdateOne { if s != nil { cuo.SetAvatarURL(*s) } return cuo } // ClearAvatarURL clears the value of the "avatar_url" field. func (cuo *ContributorUpdateOne) ClearAvatarURL() *ContributorUpdateOne { cuo.mutation.ClearAvatarURL() return cuo } // SetBio sets the "bio" field. func (cuo *ContributorUpdateOne) SetBio(s string) *ContributorUpdateOne { cuo.mutation.SetBio(s) return cuo } // SetNillableBio sets the "bio" field if the given value is not nil. func (cuo *ContributorUpdateOne) SetNillableBio(s *string) *ContributorUpdateOne { if s != nil { cuo.SetBio(*s) } return cuo } // ClearBio clears the value of the "bio" field. func (cuo *ContributorUpdateOne) ClearBio() *ContributorUpdateOne { cuo.mutation.ClearBio() return cuo } // SetCreatedAt sets the "created_at" field. func (cuo *ContributorUpdateOne) SetCreatedAt(t time.Time) *ContributorUpdateOne { cuo.mutation.SetCreatedAt(t) return cuo } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (cuo *ContributorUpdateOne) SetNillableCreatedAt(t *time.Time) *ContributorUpdateOne { if t != nil { cuo.SetCreatedAt(*t) } return cuo } // SetUpdatedAt sets the "updated_at" field. func (cuo *ContributorUpdateOne) SetUpdatedAt(t time.Time) *ContributorUpdateOne { cuo.mutation.SetUpdatedAt(t) return cuo } // SetUserID sets the "user" edge to the User entity by ID. func (cuo *ContributorUpdateOne) SetUserID(id int) *ContributorUpdateOne { cuo.mutation.SetUserID(id) return cuo } // SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil. func (cuo *ContributorUpdateOne) SetNillableUserID(id *int) *ContributorUpdateOne { if id != nil { cuo = cuo.SetUserID(*id) } return cuo } // SetUser sets the "user" edge to the User entity. func (cuo *ContributorUpdateOne) SetUser(u *User) *ContributorUpdateOne { return cuo.SetUserID(u.ID) } // AddSocialLinkIDs adds the "social_links" edge to the ContributorSocialLink entity by IDs. func (cuo *ContributorUpdateOne) AddSocialLinkIDs(ids ...int) *ContributorUpdateOne { cuo.mutation.AddSocialLinkIDs(ids...) return cuo } // AddSocialLinks adds the "social_links" edges to the ContributorSocialLink entity. func (cuo *ContributorUpdateOne) AddSocialLinks(c ...*ContributorSocialLink) *ContributorUpdateOne { ids := make([]int, len(c)) for i := range c { ids[i] = c[i].ID } return cuo.AddSocialLinkIDs(ids...) } // AddPostIDs adds the "posts" edge to the PostContributor entity by IDs. func (cuo *ContributorUpdateOne) AddPostIDs(ids ...int) *ContributorUpdateOne { cuo.mutation.AddPostIDs(ids...) return cuo } // AddPosts adds the "posts" edges to the PostContributor entity. func (cuo *ContributorUpdateOne) AddPosts(p ...*PostContributor) *ContributorUpdateOne { ids := make([]int, len(p)) for i := range p { ids[i] = p[i].ID } return cuo.AddPostIDs(ids...) } // Mutation returns the ContributorMutation object of the builder. func (cuo *ContributorUpdateOne) Mutation() *ContributorMutation { return cuo.mutation } // ClearUser clears the "user" edge to the User entity. func (cuo *ContributorUpdateOne) ClearUser() *ContributorUpdateOne { cuo.mutation.ClearUser() return cuo } // ClearSocialLinks clears all "social_links" edges to the ContributorSocialLink entity. func (cuo *ContributorUpdateOne) ClearSocialLinks() *ContributorUpdateOne { cuo.mutation.ClearSocialLinks() return cuo } // RemoveSocialLinkIDs removes the "social_links" edge to ContributorSocialLink entities by IDs. func (cuo *ContributorUpdateOne) RemoveSocialLinkIDs(ids ...int) *ContributorUpdateOne { cuo.mutation.RemoveSocialLinkIDs(ids...) return cuo } // RemoveSocialLinks removes "social_links" edges to ContributorSocialLink entities. func (cuo *ContributorUpdateOne) RemoveSocialLinks(c ...*ContributorSocialLink) *ContributorUpdateOne { ids := make([]int, len(c)) for i := range c { ids[i] = c[i].ID } return cuo.RemoveSocialLinkIDs(ids...) } // ClearPosts clears all "posts" edges to the PostContributor entity. func (cuo *ContributorUpdateOne) ClearPosts() *ContributorUpdateOne { cuo.mutation.ClearPosts() return cuo } // RemovePostIDs removes the "posts" edge to PostContributor entities by IDs. func (cuo *ContributorUpdateOne) RemovePostIDs(ids ...int) *ContributorUpdateOne { cuo.mutation.RemovePostIDs(ids...) return cuo } // RemovePosts removes "posts" edges to PostContributor entities. func (cuo *ContributorUpdateOne) RemovePosts(p ...*PostContributor) *ContributorUpdateOne { ids := make([]int, len(p)) for i := range p { ids[i] = p[i].ID } return cuo.RemovePostIDs(ids...) } // Where appends a list predicates to the ContributorUpdate builder. func (cuo *ContributorUpdateOne) Where(ps ...predicate.Contributor) *ContributorUpdateOne { cuo.mutation.Where(ps...) return cuo } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. func (cuo *ContributorUpdateOne) Select(field string, fields ...string) *ContributorUpdateOne { cuo.fields = append([]string{field}, fields...) return cuo } // Save executes the query and returns the updated Contributor entity. func (cuo *ContributorUpdateOne) Save(ctx context.Context) (*Contributor, error) { cuo.defaults() return withHooks(ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) } // SaveX is like Save, but panics if an error occurs. func (cuo *ContributorUpdateOne) SaveX(ctx context.Context) *Contributor { node, err := cuo.Save(ctx) if err != nil { panic(err) } return node } // Exec executes the query on the entity. func (cuo *ContributorUpdateOne) Exec(ctx context.Context) error { _, err := cuo.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (cuo *ContributorUpdateOne) ExecX(ctx context.Context) { if err := cuo.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. func (cuo *ContributorUpdateOne) defaults() { if _, ok := cuo.mutation.UpdatedAt(); !ok { v := contributor.UpdateDefaultUpdatedAt() cuo.mutation.SetUpdatedAt(v) } } // check runs all checks and user-defined validators on the builder. func (cuo *ContributorUpdateOne) check() error { if v, ok := cuo.mutation.Name(); ok { if err := contributor.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Contributor.name": %w`, err)} } } return nil } func (cuo *ContributorUpdateOne) sqlSave(ctx context.Context) (_node *Contributor, err error) { if err := cuo.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(contributor.Table, contributor.Columns, sqlgraph.NewFieldSpec(contributor.FieldID, field.TypeInt)) id, ok := cuo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Contributor.id" for update`)} } _spec.Node.ID.Value = id if fields := cuo.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, contributor.FieldID) for _, f := range fields { if !contributor.ValidColumn(f) { return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } if f != contributor.FieldID { _spec.Node.Columns = append(_spec.Node.Columns, f) } } } if ps := cuo.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := cuo.mutation.Name(); ok { _spec.SetField(contributor.FieldName, field.TypeString, value) } if value, ok := cuo.mutation.AvatarURL(); ok { _spec.SetField(contributor.FieldAvatarURL, field.TypeString, value) } if cuo.mutation.AvatarURLCleared() { _spec.ClearField(contributor.FieldAvatarURL, field.TypeString) } if value, ok := cuo.mutation.Bio(); ok { _spec.SetField(contributor.FieldBio, field.TypeString, value) } if cuo.mutation.BioCleared() { _spec.ClearField(contributor.FieldBio, field.TypeString) } if value, ok := cuo.mutation.CreatedAt(); ok { _spec.SetField(contributor.FieldCreatedAt, field.TypeTime, value) } if value, ok := cuo.mutation.UpdatedAt(); ok { _spec.SetField(contributor.FieldUpdatedAt, field.TypeTime, value) } if cuo.mutation.UserCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: contributor.UserTable, Columns: []string{contributor.UserColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := cuo.mutation.UserIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: contributor.UserTable, Columns: []string{contributor.UserColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if cuo.mutation.SocialLinksCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: contributor.SocialLinksTable, Columns: []string{contributor.SocialLinksColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(contributorsociallink.FieldID, field.TypeInt), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := cuo.mutation.RemovedSocialLinksIDs(); len(nodes) > 0 && !cuo.mutation.SocialLinksCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: contributor.SocialLinksTable, Columns: []string{contributor.SocialLinksColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(contributorsociallink.FieldID, field.TypeInt), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := cuo.mutation.SocialLinksIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: contributor.SocialLinksTable, Columns: []string{contributor.SocialLinksColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(contributorsociallink.FieldID, field.TypeInt), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if cuo.mutation.PostsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: contributor.PostsTable, Columns: []string{contributor.PostsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(postcontributor.FieldID, field.TypeInt), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := cuo.mutation.RemovedPostsIDs(); len(nodes) > 0 && !cuo.mutation.PostsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: contributor.PostsTable, Columns: []string{contributor.PostsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(postcontributor.FieldID, field.TypeInt), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := cuo.mutation.PostsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: contributor.PostsTable, Columns: []string{contributor.PostsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(postcontributor.FieldID, field.TypeInt), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } _node = &Contributor{config: cuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{contributor.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } cuo.mutation.done = true return _node, nil }