// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "time" "tss-rocks-be/ent/category" "tss-rocks-be/ent/categorycontent" "tss-rocks-be/ent/daily" "tss-rocks-be/ent/post" "tss-rocks-be/ent/predicate" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // CategoryUpdate is the builder for updating Category entities. type CategoryUpdate struct { config hooks []Hook mutation *CategoryMutation } // Where appends a list predicates to the CategoryUpdate builder. func (cu *CategoryUpdate) Where(ps ...predicate.Category) *CategoryUpdate { cu.mutation.Where(ps...) return cu } // SetCreatedAt sets the "created_at" field. func (cu *CategoryUpdate) SetCreatedAt(t time.Time) *CategoryUpdate { cu.mutation.SetCreatedAt(t) return cu } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (cu *CategoryUpdate) SetNillableCreatedAt(t *time.Time) *CategoryUpdate { if t != nil { cu.SetCreatedAt(*t) } return cu } // SetUpdatedAt sets the "updated_at" field. func (cu *CategoryUpdate) SetUpdatedAt(t time.Time) *CategoryUpdate { cu.mutation.SetUpdatedAt(t) return cu } // AddContentIDs adds the "contents" edge to the CategoryContent entity by IDs. func (cu *CategoryUpdate) AddContentIDs(ids ...int) *CategoryUpdate { cu.mutation.AddContentIDs(ids...) return cu } // AddContents adds the "contents" edges to the CategoryContent entity. func (cu *CategoryUpdate) AddContents(c ...*CategoryContent) *CategoryUpdate { ids := make([]int, len(c)) for i := range c { ids[i] = c[i].ID } return cu.AddContentIDs(ids...) } // AddPostIDs adds the "posts" edge to the Post entity by IDs. func (cu *CategoryUpdate) AddPostIDs(ids ...int) *CategoryUpdate { cu.mutation.AddPostIDs(ids...) return cu } // AddPosts adds the "posts" edges to the Post entity. func (cu *CategoryUpdate) AddPosts(p ...*Post) *CategoryUpdate { ids := make([]int, len(p)) for i := range p { ids[i] = p[i].ID } return cu.AddPostIDs(ids...) } // AddDailyItemIDs adds the "daily_items" edge to the Daily entity by IDs. func (cu *CategoryUpdate) AddDailyItemIDs(ids ...string) *CategoryUpdate { cu.mutation.AddDailyItemIDs(ids...) return cu } // AddDailyItems adds the "daily_items" edges to the Daily entity. func (cu *CategoryUpdate) AddDailyItems(d ...*Daily) *CategoryUpdate { ids := make([]string, len(d)) for i := range d { ids[i] = d[i].ID } return cu.AddDailyItemIDs(ids...) } // Mutation returns the CategoryMutation object of the builder. func (cu *CategoryUpdate) Mutation() *CategoryMutation { return cu.mutation } // ClearContents clears all "contents" edges to the CategoryContent entity. func (cu *CategoryUpdate) ClearContents() *CategoryUpdate { cu.mutation.ClearContents() return cu } // RemoveContentIDs removes the "contents" edge to CategoryContent entities by IDs. func (cu *CategoryUpdate) RemoveContentIDs(ids ...int) *CategoryUpdate { cu.mutation.RemoveContentIDs(ids...) return cu } // RemoveContents removes "contents" edges to CategoryContent entities. func (cu *CategoryUpdate) RemoveContents(c ...*CategoryContent) *CategoryUpdate { ids := make([]int, len(c)) for i := range c { ids[i] = c[i].ID } return cu.RemoveContentIDs(ids...) } // ClearPosts clears all "posts" edges to the Post entity. func (cu *CategoryUpdate) ClearPosts() *CategoryUpdate { cu.mutation.ClearPosts() return cu } // RemovePostIDs removes the "posts" edge to Post entities by IDs. func (cu *CategoryUpdate) RemovePostIDs(ids ...int) *CategoryUpdate { cu.mutation.RemovePostIDs(ids...) return cu } // RemovePosts removes "posts" edges to Post entities. func (cu *CategoryUpdate) RemovePosts(p ...*Post) *CategoryUpdate { ids := make([]int, len(p)) for i := range p { ids[i] = p[i].ID } return cu.RemovePostIDs(ids...) } // ClearDailyItems clears all "daily_items" edges to the Daily entity. func (cu *CategoryUpdate) ClearDailyItems() *CategoryUpdate { cu.mutation.ClearDailyItems() return cu } // RemoveDailyItemIDs removes the "daily_items" edge to Daily entities by IDs. func (cu *CategoryUpdate) RemoveDailyItemIDs(ids ...string) *CategoryUpdate { cu.mutation.RemoveDailyItemIDs(ids...) return cu } // RemoveDailyItems removes "daily_items" edges to Daily entities. func (cu *CategoryUpdate) RemoveDailyItems(d ...*Daily) *CategoryUpdate { ids := make([]string, len(d)) for i := range d { ids[i] = d[i].ID } return cu.RemoveDailyItemIDs(ids...) } // Save executes the query and returns the number of nodes affected by the update operation. func (cu *CategoryUpdate) 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 *CategoryUpdate) SaveX(ctx context.Context) int { affected, err := cu.Save(ctx) if err != nil { panic(err) } return affected } // Exec executes the query. func (cu *CategoryUpdate) Exec(ctx context.Context) error { _, err := cu.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (cu *CategoryUpdate) 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 *CategoryUpdate) defaults() { if _, ok := cu.mutation.UpdatedAt(); !ok { v := category.UpdateDefaultUpdatedAt() cu.mutation.SetUpdatedAt(v) } } func (cu *CategoryUpdate) sqlSave(ctx context.Context) (n int, err error) { _spec := sqlgraph.NewUpdateSpec(category.Table, category.Columns, sqlgraph.NewFieldSpec(category.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.CreatedAt(); ok { _spec.SetField(category.FieldCreatedAt, field.TypeTime, value) } if value, ok := cu.mutation.UpdatedAt(); ok { _spec.SetField(category.FieldUpdatedAt, field.TypeTime, value) } if cu.mutation.ContentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: category.ContentsTable, Columns: []string{category.ContentsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(categorycontent.FieldID, field.TypeInt), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := cu.mutation.RemovedContentsIDs(); len(nodes) > 0 && !cu.mutation.ContentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: category.ContentsTable, Columns: []string{category.ContentsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(categorycontent.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.ContentsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: category.ContentsTable, Columns: []string{category.ContentsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(categorycontent.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.M2M, Inverse: false, Table: category.PostsTable, Columns: category.PostsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.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.M2M, Inverse: false, Table: category.PostsTable, Columns: category.PostsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.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.M2M, Inverse: false, Table: category.PostsTable, Columns: category.PostsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.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.DailyItemsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: category.DailyItemsTable, Columns: []string{category.DailyItemsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(daily.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := cu.mutation.RemovedDailyItemsIDs(); len(nodes) > 0 && !cu.mutation.DailyItemsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: category.DailyItemsTable, Columns: []string{category.DailyItemsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(daily.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := cu.mutation.DailyItemsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: category.DailyItemsTable, Columns: []string{category.DailyItemsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(daily.FieldID, field.TypeString), }, } 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{category.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return 0, err } cu.mutation.done = true return n, nil } // CategoryUpdateOne is the builder for updating a single Category entity. type CategoryUpdateOne struct { config fields []string hooks []Hook mutation *CategoryMutation } // SetCreatedAt sets the "created_at" field. func (cuo *CategoryUpdateOne) SetCreatedAt(t time.Time) *CategoryUpdateOne { cuo.mutation.SetCreatedAt(t) return cuo } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (cuo *CategoryUpdateOne) SetNillableCreatedAt(t *time.Time) *CategoryUpdateOne { if t != nil { cuo.SetCreatedAt(*t) } return cuo } // SetUpdatedAt sets the "updated_at" field. func (cuo *CategoryUpdateOne) SetUpdatedAt(t time.Time) *CategoryUpdateOne { cuo.mutation.SetUpdatedAt(t) return cuo } // AddContentIDs adds the "contents" edge to the CategoryContent entity by IDs. func (cuo *CategoryUpdateOne) AddContentIDs(ids ...int) *CategoryUpdateOne { cuo.mutation.AddContentIDs(ids...) return cuo } // AddContents adds the "contents" edges to the CategoryContent entity. func (cuo *CategoryUpdateOne) AddContents(c ...*CategoryContent) *CategoryUpdateOne { ids := make([]int, len(c)) for i := range c { ids[i] = c[i].ID } return cuo.AddContentIDs(ids...) } // AddPostIDs adds the "posts" edge to the Post entity by IDs. func (cuo *CategoryUpdateOne) AddPostIDs(ids ...int) *CategoryUpdateOne { cuo.mutation.AddPostIDs(ids...) return cuo } // AddPosts adds the "posts" edges to the Post entity. func (cuo *CategoryUpdateOne) AddPosts(p ...*Post) *CategoryUpdateOne { ids := make([]int, len(p)) for i := range p { ids[i] = p[i].ID } return cuo.AddPostIDs(ids...) } // AddDailyItemIDs adds the "daily_items" edge to the Daily entity by IDs. func (cuo *CategoryUpdateOne) AddDailyItemIDs(ids ...string) *CategoryUpdateOne { cuo.mutation.AddDailyItemIDs(ids...) return cuo } // AddDailyItems adds the "daily_items" edges to the Daily entity. func (cuo *CategoryUpdateOne) AddDailyItems(d ...*Daily) *CategoryUpdateOne { ids := make([]string, len(d)) for i := range d { ids[i] = d[i].ID } return cuo.AddDailyItemIDs(ids...) } // Mutation returns the CategoryMutation object of the builder. func (cuo *CategoryUpdateOne) Mutation() *CategoryMutation { return cuo.mutation } // ClearContents clears all "contents" edges to the CategoryContent entity. func (cuo *CategoryUpdateOne) ClearContents() *CategoryUpdateOne { cuo.mutation.ClearContents() return cuo } // RemoveContentIDs removes the "contents" edge to CategoryContent entities by IDs. func (cuo *CategoryUpdateOne) RemoveContentIDs(ids ...int) *CategoryUpdateOne { cuo.mutation.RemoveContentIDs(ids...) return cuo } // RemoveContents removes "contents" edges to CategoryContent entities. func (cuo *CategoryUpdateOne) RemoveContents(c ...*CategoryContent) *CategoryUpdateOne { ids := make([]int, len(c)) for i := range c { ids[i] = c[i].ID } return cuo.RemoveContentIDs(ids...) } // ClearPosts clears all "posts" edges to the Post entity. func (cuo *CategoryUpdateOne) ClearPosts() *CategoryUpdateOne { cuo.mutation.ClearPosts() return cuo } // RemovePostIDs removes the "posts" edge to Post entities by IDs. func (cuo *CategoryUpdateOne) RemovePostIDs(ids ...int) *CategoryUpdateOne { cuo.mutation.RemovePostIDs(ids...) return cuo } // RemovePosts removes "posts" edges to Post entities. func (cuo *CategoryUpdateOne) RemovePosts(p ...*Post) *CategoryUpdateOne { ids := make([]int, len(p)) for i := range p { ids[i] = p[i].ID } return cuo.RemovePostIDs(ids...) } // ClearDailyItems clears all "daily_items" edges to the Daily entity. func (cuo *CategoryUpdateOne) ClearDailyItems() *CategoryUpdateOne { cuo.mutation.ClearDailyItems() return cuo } // RemoveDailyItemIDs removes the "daily_items" edge to Daily entities by IDs. func (cuo *CategoryUpdateOne) RemoveDailyItemIDs(ids ...string) *CategoryUpdateOne { cuo.mutation.RemoveDailyItemIDs(ids...) return cuo } // RemoveDailyItems removes "daily_items" edges to Daily entities. func (cuo *CategoryUpdateOne) RemoveDailyItems(d ...*Daily) *CategoryUpdateOne { ids := make([]string, len(d)) for i := range d { ids[i] = d[i].ID } return cuo.RemoveDailyItemIDs(ids...) } // Where appends a list predicates to the CategoryUpdate builder. func (cuo *CategoryUpdateOne) Where(ps ...predicate.Category) *CategoryUpdateOne { 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 *CategoryUpdateOne) Select(field string, fields ...string) *CategoryUpdateOne { cuo.fields = append([]string{field}, fields...) return cuo } // Save executes the query and returns the updated Category entity. func (cuo *CategoryUpdateOne) Save(ctx context.Context) (*Category, error) { cuo.defaults() return withHooks(ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) } // SaveX is like Save, but panics if an error occurs. func (cuo *CategoryUpdateOne) SaveX(ctx context.Context) *Category { node, err := cuo.Save(ctx) if err != nil { panic(err) } return node } // Exec executes the query on the entity. func (cuo *CategoryUpdateOne) Exec(ctx context.Context) error { _, err := cuo.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (cuo *CategoryUpdateOne) 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 *CategoryUpdateOne) defaults() { if _, ok := cuo.mutation.UpdatedAt(); !ok { v := category.UpdateDefaultUpdatedAt() cuo.mutation.SetUpdatedAt(v) } } func (cuo *CategoryUpdateOne) sqlSave(ctx context.Context) (_node *Category, err error) { _spec := sqlgraph.NewUpdateSpec(category.Table, category.Columns, sqlgraph.NewFieldSpec(category.FieldID, field.TypeInt)) id, ok := cuo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Category.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, category.FieldID) for _, f := range fields { if !category.ValidColumn(f) { return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } if f != category.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.CreatedAt(); ok { _spec.SetField(category.FieldCreatedAt, field.TypeTime, value) } if value, ok := cuo.mutation.UpdatedAt(); ok { _spec.SetField(category.FieldUpdatedAt, field.TypeTime, value) } if cuo.mutation.ContentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: category.ContentsTable, Columns: []string{category.ContentsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(categorycontent.FieldID, field.TypeInt), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := cuo.mutation.RemovedContentsIDs(); len(nodes) > 0 && !cuo.mutation.ContentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: category.ContentsTable, Columns: []string{category.ContentsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(categorycontent.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.ContentsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: category.ContentsTable, Columns: []string{category.ContentsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(categorycontent.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.M2M, Inverse: false, Table: category.PostsTable, Columns: category.PostsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.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.M2M, Inverse: false, Table: category.PostsTable, Columns: category.PostsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.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.M2M, Inverse: false, Table: category.PostsTable, Columns: category.PostsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.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.DailyItemsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: category.DailyItemsTable, Columns: []string{category.DailyItemsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(daily.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := cuo.mutation.RemovedDailyItemsIDs(); len(nodes) > 0 && !cuo.mutation.DailyItemsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: category.DailyItemsTable, Columns: []string{category.DailyItemsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(daily.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := cuo.mutation.DailyItemsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: category.DailyItemsTable, Columns: []string{category.DailyItemsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(daily.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } _node = &Category{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{category.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } cuo.mutation.done = true return _node, nil }