572 lines
18 KiB
Go
572 lines
18 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
"tss-rocks-be/ent/daily"
|
|
"tss-rocks-be/ent/dailycategory"
|
|
"tss-rocks-be/ent/dailycategorycontent"
|
|
"tss-rocks-be/ent/predicate"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// DailyCategoryUpdate is the builder for updating DailyCategory entities.
|
|
type DailyCategoryUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *DailyCategoryMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the DailyCategoryUpdate builder.
|
|
func (dcu *DailyCategoryUpdate) Where(ps ...predicate.DailyCategory) *DailyCategoryUpdate {
|
|
dcu.mutation.Where(ps...)
|
|
return dcu
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (dcu *DailyCategoryUpdate) SetCreatedAt(t time.Time) *DailyCategoryUpdate {
|
|
dcu.mutation.SetCreatedAt(t)
|
|
return dcu
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (dcu *DailyCategoryUpdate) SetNillableCreatedAt(t *time.Time) *DailyCategoryUpdate {
|
|
if t != nil {
|
|
dcu.SetCreatedAt(*t)
|
|
}
|
|
return dcu
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (dcu *DailyCategoryUpdate) SetUpdatedAt(t time.Time) *DailyCategoryUpdate {
|
|
dcu.mutation.SetUpdatedAt(t)
|
|
return dcu
|
|
}
|
|
|
|
// AddContentIDs adds the "contents" edge to the DailyCategoryContent entity by IDs.
|
|
func (dcu *DailyCategoryUpdate) AddContentIDs(ids ...int) *DailyCategoryUpdate {
|
|
dcu.mutation.AddContentIDs(ids...)
|
|
return dcu
|
|
}
|
|
|
|
// AddContents adds the "contents" edges to the DailyCategoryContent entity.
|
|
func (dcu *DailyCategoryUpdate) AddContents(d ...*DailyCategoryContent) *DailyCategoryUpdate {
|
|
ids := make([]int, len(d))
|
|
for i := range d {
|
|
ids[i] = d[i].ID
|
|
}
|
|
return dcu.AddContentIDs(ids...)
|
|
}
|
|
|
|
// AddDailyItemIDs adds the "daily_items" edge to the Daily entity by IDs.
|
|
func (dcu *DailyCategoryUpdate) AddDailyItemIDs(ids ...string) *DailyCategoryUpdate {
|
|
dcu.mutation.AddDailyItemIDs(ids...)
|
|
return dcu
|
|
}
|
|
|
|
// AddDailyItems adds the "daily_items" edges to the Daily entity.
|
|
func (dcu *DailyCategoryUpdate) AddDailyItems(d ...*Daily) *DailyCategoryUpdate {
|
|
ids := make([]string, len(d))
|
|
for i := range d {
|
|
ids[i] = d[i].ID
|
|
}
|
|
return dcu.AddDailyItemIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the DailyCategoryMutation object of the builder.
|
|
func (dcu *DailyCategoryUpdate) Mutation() *DailyCategoryMutation {
|
|
return dcu.mutation
|
|
}
|
|
|
|
// ClearContents clears all "contents" edges to the DailyCategoryContent entity.
|
|
func (dcu *DailyCategoryUpdate) ClearContents() *DailyCategoryUpdate {
|
|
dcu.mutation.ClearContents()
|
|
return dcu
|
|
}
|
|
|
|
// RemoveContentIDs removes the "contents" edge to DailyCategoryContent entities by IDs.
|
|
func (dcu *DailyCategoryUpdate) RemoveContentIDs(ids ...int) *DailyCategoryUpdate {
|
|
dcu.mutation.RemoveContentIDs(ids...)
|
|
return dcu
|
|
}
|
|
|
|
// RemoveContents removes "contents" edges to DailyCategoryContent entities.
|
|
func (dcu *DailyCategoryUpdate) RemoveContents(d ...*DailyCategoryContent) *DailyCategoryUpdate {
|
|
ids := make([]int, len(d))
|
|
for i := range d {
|
|
ids[i] = d[i].ID
|
|
}
|
|
return dcu.RemoveContentIDs(ids...)
|
|
}
|
|
|
|
// ClearDailyItems clears all "daily_items" edges to the Daily entity.
|
|
func (dcu *DailyCategoryUpdate) ClearDailyItems() *DailyCategoryUpdate {
|
|
dcu.mutation.ClearDailyItems()
|
|
return dcu
|
|
}
|
|
|
|
// RemoveDailyItemIDs removes the "daily_items" edge to Daily entities by IDs.
|
|
func (dcu *DailyCategoryUpdate) RemoveDailyItemIDs(ids ...string) *DailyCategoryUpdate {
|
|
dcu.mutation.RemoveDailyItemIDs(ids...)
|
|
return dcu
|
|
}
|
|
|
|
// RemoveDailyItems removes "daily_items" edges to Daily entities.
|
|
func (dcu *DailyCategoryUpdate) RemoveDailyItems(d ...*Daily) *DailyCategoryUpdate {
|
|
ids := make([]string, len(d))
|
|
for i := range d {
|
|
ids[i] = d[i].ID
|
|
}
|
|
return dcu.RemoveDailyItemIDs(ids...)
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (dcu *DailyCategoryUpdate) Save(ctx context.Context) (int, error) {
|
|
dcu.defaults()
|
|
return withHooks(ctx, dcu.sqlSave, dcu.mutation, dcu.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (dcu *DailyCategoryUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := dcu.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (dcu *DailyCategoryUpdate) Exec(ctx context.Context) error {
|
|
_, err := dcu.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (dcu *DailyCategoryUpdate) ExecX(ctx context.Context) {
|
|
if err := dcu.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (dcu *DailyCategoryUpdate) defaults() {
|
|
if _, ok := dcu.mutation.UpdatedAt(); !ok {
|
|
v := dailycategory.UpdateDefaultUpdatedAt()
|
|
dcu.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
func (dcu *DailyCategoryUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|
_spec := sqlgraph.NewUpdateSpec(dailycategory.Table, dailycategory.Columns, sqlgraph.NewFieldSpec(dailycategory.FieldID, field.TypeInt))
|
|
if ps := dcu.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := dcu.mutation.CreatedAt(); ok {
|
|
_spec.SetField(dailycategory.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := dcu.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(dailycategory.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if dcu.mutation.ContentsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: dailycategory.ContentsTable,
|
|
Columns: []string{dailycategory.ContentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(dailycategorycontent.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := dcu.mutation.RemovedContentsIDs(); len(nodes) > 0 && !dcu.mutation.ContentsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: dailycategory.ContentsTable,
|
|
Columns: []string{dailycategory.ContentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(dailycategorycontent.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 := dcu.mutation.ContentsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: dailycategory.ContentsTable,
|
|
Columns: []string{dailycategory.ContentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(dailycategorycontent.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if dcu.mutation.DailyItemsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: dailycategory.DailyItemsTable,
|
|
Columns: []string{dailycategory.DailyItemsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(daily.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := dcu.mutation.RemovedDailyItemsIDs(); len(nodes) > 0 && !dcu.mutation.DailyItemsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: dailycategory.DailyItemsTable,
|
|
Columns: []string{dailycategory.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 := dcu.mutation.DailyItemsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: dailycategory.DailyItemsTable,
|
|
Columns: []string{dailycategory.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, dcu.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{dailycategory.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
dcu.mutation.done = true
|
|
return n, nil
|
|
}
|
|
|
|
// DailyCategoryUpdateOne is the builder for updating a single DailyCategory entity.
|
|
type DailyCategoryUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *DailyCategoryMutation
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (dcuo *DailyCategoryUpdateOne) SetCreatedAt(t time.Time) *DailyCategoryUpdateOne {
|
|
dcuo.mutation.SetCreatedAt(t)
|
|
return dcuo
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (dcuo *DailyCategoryUpdateOne) SetNillableCreatedAt(t *time.Time) *DailyCategoryUpdateOne {
|
|
if t != nil {
|
|
dcuo.SetCreatedAt(*t)
|
|
}
|
|
return dcuo
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (dcuo *DailyCategoryUpdateOne) SetUpdatedAt(t time.Time) *DailyCategoryUpdateOne {
|
|
dcuo.mutation.SetUpdatedAt(t)
|
|
return dcuo
|
|
}
|
|
|
|
// AddContentIDs adds the "contents" edge to the DailyCategoryContent entity by IDs.
|
|
func (dcuo *DailyCategoryUpdateOne) AddContentIDs(ids ...int) *DailyCategoryUpdateOne {
|
|
dcuo.mutation.AddContentIDs(ids...)
|
|
return dcuo
|
|
}
|
|
|
|
// AddContents adds the "contents" edges to the DailyCategoryContent entity.
|
|
func (dcuo *DailyCategoryUpdateOne) AddContents(d ...*DailyCategoryContent) *DailyCategoryUpdateOne {
|
|
ids := make([]int, len(d))
|
|
for i := range d {
|
|
ids[i] = d[i].ID
|
|
}
|
|
return dcuo.AddContentIDs(ids...)
|
|
}
|
|
|
|
// AddDailyItemIDs adds the "daily_items" edge to the Daily entity by IDs.
|
|
func (dcuo *DailyCategoryUpdateOne) AddDailyItemIDs(ids ...string) *DailyCategoryUpdateOne {
|
|
dcuo.mutation.AddDailyItemIDs(ids...)
|
|
return dcuo
|
|
}
|
|
|
|
// AddDailyItems adds the "daily_items" edges to the Daily entity.
|
|
func (dcuo *DailyCategoryUpdateOne) AddDailyItems(d ...*Daily) *DailyCategoryUpdateOne {
|
|
ids := make([]string, len(d))
|
|
for i := range d {
|
|
ids[i] = d[i].ID
|
|
}
|
|
return dcuo.AddDailyItemIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the DailyCategoryMutation object of the builder.
|
|
func (dcuo *DailyCategoryUpdateOne) Mutation() *DailyCategoryMutation {
|
|
return dcuo.mutation
|
|
}
|
|
|
|
// ClearContents clears all "contents" edges to the DailyCategoryContent entity.
|
|
func (dcuo *DailyCategoryUpdateOne) ClearContents() *DailyCategoryUpdateOne {
|
|
dcuo.mutation.ClearContents()
|
|
return dcuo
|
|
}
|
|
|
|
// RemoveContentIDs removes the "contents" edge to DailyCategoryContent entities by IDs.
|
|
func (dcuo *DailyCategoryUpdateOne) RemoveContentIDs(ids ...int) *DailyCategoryUpdateOne {
|
|
dcuo.mutation.RemoveContentIDs(ids...)
|
|
return dcuo
|
|
}
|
|
|
|
// RemoveContents removes "contents" edges to DailyCategoryContent entities.
|
|
func (dcuo *DailyCategoryUpdateOne) RemoveContents(d ...*DailyCategoryContent) *DailyCategoryUpdateOne {
|
|
ids := make([]int, len(d))
|
|
for i := range d {
|
|
ids[i] = d[i].ID
|
|
}
|
|
return dcuo.RemoveContentIDs(ids...)
|
|
}
|
|
|
|
// ClearDailyItems clears all "daily_items" edges to the Daily entity.
|
|
func (dcuo *DailyCategoryUpdateOne) ClearDailyItems() *DailyCategoryUpdateOne {
|
|
dcuo.mutation.ClearDailyItems()
|
|
return dcuo
|
|
}
|
|
|
|
// RemoveDailyItemIDs removes the "daily_items" edge to Daily entities by IDs.
|
|
func (dcuo *DailyCategoryUpdateOne) RemoveDailyItemIDs(ids ...string) *DailyCategoryUpdateOne {
|
|
dcuo.mutation.RemoveDailyItemIDs(ids...)
|
|
return dcuo
|
|
}
|
|
|
|
// RemoveDailyItems removes "daily_items" edges to Daily entities.
|
|
func (dcuo *DailyCategoryUpdateOne) RemoveDailyItems(d ...*Daily) *DailyCategoryUpdateOne {
|
|
ids := make([]string, len(d))
|
|
for i := range d {
|
|
ids[i] = d[i].ID
|
|
}
|
|
return dcuo.RemoveDailyItemIDs(ids...)
|
|
}
|
|
|
|
// Where appends a list predicates to the DailyCategoryUpdate builder.
|
|
func (dcuo *DailyCategoryUpdateOne) Where(ps ...predicate.DailyCategory) *DailyCategoryUpdateOne {
|
|
dcuo.mutation.Where(ps...)
|
|
return dcuo
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (dcuo *DailyCategoryUpdateOne) Select(field string, fields ...string) *DailyCategoryUpdateOne {
|
|
dcuo.fields = append([]string{field}, fields...)
|
|
return dcuo
|
|
}
|
|
|
|
// Save executes the query and returns the updated DailyCategory entity.
|
|
func (dcuo *DailyCategoryUpdateOne) Save(ctx context.Context) (*DailyCategory, error) {
|
|
dcuo.defaults()
|
|
return withHooks(ctx, dcuo.sqlSave, dcuo.mutation, dcuo.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (dcuo *DailyCategoryUpdateOne) SaveX(ctx context.Context) *DailyCategory {
|
|
node, err := dcuo.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (dcuo *DailyCategoryUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := dcuo.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (dcuo *DailyCategoryUpdateOne) ExecX(ctx context.Context) {
|
|
if err := dcuo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (dcuo *DailyCategoryUpdateOne) defaults() {
|
|
if _, ok := dcuo.mutation.UpdatedAt(); !ok {
|
|
v := dailycategory.UpdateDefaultUpdatedAt()
|
|
dcuo.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
func (dcuo *DailyCategoryUpdateOne) sqlSave(ctx context.Context) (_node *DailyCategory, err error) {
|
|
_spec := sqlgraph.NewUpdateSpec(dailycategory.Table, dailycategory.Columns, sqlgraph.NewFieldSpec(dailycategory.FieldID, field.TypeInt))
|
|
id, ok := dcuo.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "DailyCategory.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := dcuo.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, dailycategory.FieldID)
|
|
for _, f := range fields {
|
|
if !dailycategory.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != dailycategory.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := dcuo.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := dcuo.mutation.CreatedAt(); ok {
|
|
_spec.SetField(dailycategory.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := dcuo.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(dailycategory.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if dcuo.mutation.ContentsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: dailycategory.ContentsTable,
|
|
Columns: []string{dailycategory.ContentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(dailycategorycontent.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := dcuo.mutation.RemovedContentsIDs(); len(nodes) > 0 && !dcuo.mutation.ContentsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: dailycategory.ContentsTable,
|
|
Columns: []string{dailycategory.ContentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(dailycategorycontent.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 := dcuo.mutation.ContentsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: dailycategory.ContentsTable,
|
|
Columns: []string{dailycategory.ContentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(dailycategorycontent.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if dcuo.mutation.DailyItemsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: dailycategory.DailyItemsTable,
|
|
Columns: []string{dailycategory.DailyItemsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(daily.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := dcuo.mutation.RemovedDailyItemsIDs(); len(nodes) > 0 && !dcuo.mutation.DailyItemsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: dailycategory.DailyItemsTable,
|
|
Columns: []string{dailycategory.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 := dcuo.mutation.DailyItemsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: dailycategory.DailyItemsTable,
|
|
Columns: []string{dailycategory.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 = &DailyCategory{config: dcuo.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, dcuo.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{dailycategory.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
dcuo.mutation.done = true
|
|
return _node, nil
|
|
}
|