// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "time" "wechat-api/ent/custom_types" "wechat-api/ent/usagestatisticmonth" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // UsageStatisticMonthCreate is the builder for creating a UsageStatisticMonth entity. type UsageStatisticMonthCreate struct { config mutation *UsageStatisticMonthMutation hooks []Hook conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. func (usmc *UsageStatisticMonthCreate) SetCreatedAt(t time.Time) *UsageStatisticMonthCreate { usmc.mutation.SetCreatedAt(t) return usmc } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (usmc *UsageStatisticMonthCreate) SetNillableCreatedAt(t *time.Time) *UsageStatisticMonthCreate { if t != nil { usmc.SetCreatedAt(*t) } return usmc } // SetUpdatedAt sets the "updated_at" field. func (usmc *UsageStatisticMonthCreate) SetUpdatedAt(t time.Time) *UsageStatisticMonthCreate { usmc.mutation.SetUpdatedAt(t) return usmc } // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. func (usmc *UsageStatisticMonthCreate) SetNillableUpdatedAt(t *time.Time) *UsageStatisticMonthCreate { if t != nil { usmc.SetUpdatedAt(*t) } return usmc } // SetStatus sets the "status" field. func (usmc *UsageStatisticMonthCreate) SetStatus(u uint8) *UsageStatisticMonthCreate { usmc.mutation.SetStatus(u) return usmc } // SetNillableStatus sets the "status" field if the given value is not nil. func (usmc *UsageStatisticMonthCreate) SetNillableStatus(u *uint8) *UsageStatisticMonthCreate { if u != nil { usmc.SetStatus(*u) } return usmc } // SetDeletedAt sets the "deleted_at" field. func (usmc *UsageStatisticMonthCreate) SetDeletedAt(t time.Time) *UsageStatisticMonthCreate { usmc.mutation.SetDeletedAt(t) return usmc } // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. func (usmc *UsageStatisticMonthCreate) SetNillableDeletedAt(t *time.Time) *UsageStatisticMonthCreate { if t != nil { usmc.SetDeletedAt(*t) } return usmc } // SetAddtime sets the "addtime" field. func (usmc *UsageStatisticMonthCreate) SetAddtime(u uint64) *UsageStatisticMonthCreate { usmc.mutation.SetAddtime(u) return usmc } // SetType sets the "type" field. func (usmc *UsageStatisticMonthCreate) SetType(i int) *UsageStatisticMonthCreate { usmc.mutation.SetType(i) return usmc } // SetBotID sets the "bot_id" field. func (usmc *UsageStatisticMonthCreate) SetBotID(s string) *UsageStatisticMonthCreate { usmc.mutation.SetBotID(s) return usmc } // SetNillableBotID sets the "bot_id" field if the given value is not nil. func (usmc *UsageStatisticMonthCreate) SetNillableBotID(s *string) *UsageStatisticMonthCreate { if s != nil { usmc.SetBotID(*s) } return usmc } // SetOrganizationID sets the "organization_id" field. func (usmc *UsageStatisticMonthCreate) SetOrganizationID(u uint64) *UsageStatisticMonthCreate { usmc.mutation.SetOrganizationID(u) return usmc } // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil. func (usmc *UsageStatisticMonthCreate) SetNillableOrganizationID(u *uint64) *UsageStatisticMonthCreate { if u != nil { usmc.SetOrganizationID(*u) } return usmc } // SetAiResponse sets the "ai_response" field. func (usmc *UsageStatisticMonthCreate) SetAiResponse(u uint64) *UsageStatisticMonthCreate { usmc.mutation.SetAiResponse(u) return usmc } // SetSopRun sets the "sop_run" field. func (usmc *UsageStatisticMonthCreate) SetSopRun(u uint64) *UsageStatisticMonthCreate { usmc.mutation.SetSopRun(u) return usmc } // SetTotalFriend sets the "total_friend" field. func (usmc *UsageStatisticMonthCreate) SetTotalFriend(u uint64) *UsageStatisticMonthCreate { usmc.mutation.SetTotalFriend(u) return usmc } // SetTotalGroup sets the "total_group" field. func (usmc *UsageStatisticMonthCreate) SetTotalGroup(u uint64) *UsageStatisticMonthCreate { usmc.mutation.SetTotalGroup(u) return usmc } // SetAccountBalance sets the "account_balance" field. func (usmc *UsageStatisticMonthCreate) SetAccountBalance(u uint64) *UsageStatisticMonthCreate { usmc.mutation.SetAccountBalance(u) return usmc } // SetConsumeToken sets the "consume_token" field. func (usmc *UsageStatisticMonthCreate) SetConsumeToken(u uint64) *UsageStatisticMonthCreate { usmc.mutation.SetConsumeToken(u) return usmc } // SetActiveUser sets the "active_user" field. func (usmc *UsageStatisticMonthCreate) SetActiveUser(u uint64) *UsageStatisticMonthCreate { usmc.mutation.SetActiveUser(u) return usmc } // SetNewUser sets the "new_user" field. func (usmc *UsageStatisticMonthCreate) SetNewUser(i int64) *UsageStatisticMonthCreate { usmc.mutation.SetNewUser(i) return usmc } // SetLabelDist sets the "label_dist" field. func (usmc *UsageStatisticMonthCreate) SetLabelDist(ctd []custom_types.LabelDist) *UsageStatisticMonthCreate { usmc.mutation.SetLabelDist(ctd) return usmc } // SetID sets the "id" field. func (usmc *UsageStatisticMonthCreate) SetID(u uint64) *UsageStatisticMonthCreate { usmc.mutation.SetID(u) return usmc } // Mutation returns the UsageStatisticMonthMutation object of the builder. func (usmc *UsageStatisticMonthCreate) Mutation() *UsageStatisticMonthMutation { return usmc.mutation } // Save creates the UsageStatisticMonth in the database. func (usmc *UsageStatisticMonthCreate) Save(ctx context.Context) (*UsageStatisticMonth, error) { if err := usmc.defaults(); err != nil { return nil, err } return withHooks(ctx, usmc.sqlSave, usmc.mutation, usmc.hooks) } // SaveX calls Save and panics if Save returns an error. func (usmc *UsageStatisticMonthCreate) SaveX(ctx context.Context) *UsageStatisticMonth { v, err := usmc.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (usmc *UsageStatisticMonthCreate) Exec(ctx context.Context) error { _, err := usmc.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (usmc *UsageStatisticMonthCreate) ExecX(ctx context.Context) { if err := usmc.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. func (usmc *UsageStatisticMonthCreate) defaults() error { if _, ok := usmc.mutation.CreatedAt(); !ok { if usagestatisticmonth.DefaultCreatedAt == nil { return fmt.Errorf("ent: uninitialized usagestatisticmonth.DefaultCreatedAt (forgotten import ent/runtime?)") } v := usagestatisticmonth.DefaultCreatedAt() usmc.mutation.SetCreatedAt(v) } if _, ok := usmc.mutation.UpdatedAt(); !ok { if usagestatisticmonth.DefaultUpdatedAt == nil { return fmt.Errorf("ent: uninitialized usagestatisticmonth.DefaultUpdatedAt (forgotten import ent/runtime?)") } v := usagestatisticmonth.DefaultUpdatedAt() usmc.mutation.SetUpdatedAt(v) } if _, ok := usmc.mutation.Status(); !ok { v := usagestatisticmonth.DefaultStatus usmc.mutation.SetStatus(v) } return nil } // check runs all checks and user-defined validators on the builder. func (usmc *UsageStatisticMonthCreate) check() error { if _, ok := usmc.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "UsageStatisticMonth.created_at"`)} } if _, ok := usmc.mutation.UpdatedAt(); !ok { return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "UsageStatisticMonth.updated_at"`)} } if _, ok := usmc.mutation.Addtime(); !ok { return &ValidationError{Name: "addtime", err: errors.New(`ent: missing required field "UsageStatisticMonth.addtime"`)} } if _, ok := usmc.mutation.GetType(); !ok { return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "UsageStatisticMonth.type"`)} } if _, ok := usmc.mutation.AiResponse(); !ok { return &ValidationError{Name: "ai_response", err: errors.New(`ent: missing required field "UsageStatisticMonth.ai_response"`)} } if _, ok := usmc.mutation.SopRun(); !ok { return &ValidationError{Name: "sop_run", err: errors.New(`ent: missing required field "UsageStatisticMonth.sop_run"`)} } if _, ok := usmc.mutation.TotalFriend(); !ok { return &ValidationError{Name: "total_friend", err: errors.New(`ent: missing required field "UsageStatisticMonth.total_friend"`)} } if _, ok := usmc.mutation.TotalGroup(); !ok { return &ValidationError{Name: "total_group", err: errors.New(`ent: missing required field "UsageStatisticMonth.total_group"`)} } if _, ok := usmc.mutation.AccountBalance(); !ok { return &ValidationError{Name: "account_balance", err: errors.New(`ent: missing required field "UsageStatisticMonth.account_balance"`)} } if _, ok := usmc.mutation.ConsumeToken(); !ok { return &ValidationError{Name: "consume_token", err: errors.New(`ent: missing required field "UsageStatisticMonth.consume_token"`)} } if _, ok := usmc.mutation.ActiveUser(); !ok { return &ValidationError{Name: "active_user", err: errors.New(`ent: missing required field "UsageStatisticMonth.active_user"`)} } if _, ok := usmc.mutation.NewUser(); !ok { return &ValidationError{Name: "new_user", err: errors.New(`ent: missing required field "UsageStatisticMonth.new_user"`)} } if _, ok := usmc.mutation.LabelDist(); !ok { return &ValidationError{Name: "label_dist", err: errors.New(`ent: missing required field "UsageStatisticMonth.label_dist"`)} } return nil } func (usmc *UsageStatisticMonthCreate) sqlSave(ctx context.Context) (*UsageStatisticMonth, error) { if err := usmc.check(); err != nil { return nil, err } _node, _spec := usmc.createSpec() if err := sqlgraph.CreateNode(ctx, usmc.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } if _spec.ID.Value != _node.ID { id := _spec.ID.Value.(int64) _node.ID = uint64(id) } usmc.mutation.id = &_node.ID usmc.mutation.done = true return _node, nil } func (usmc *UsageStatisticMonthCreate) createSpec() (*UsageStatisticMonth, *sqlgraph.CreateSpec) { var ( _node = &UsageStatisticMonth{config: usmc.config} _spec = sqlgraph.NewCreateSpec(usagestatisticmonth.Table, sqlgraph.NewFieldSpec(usagestatisticmonth.FieldID, field.TypeUint64)) ) _spec.OnConflict = usmc.conflict if id, ok := usmc.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id } if value, ok := usmc.mutation.CreatedAt(); ok { _spec.SetField(usagestatisticmonth.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value } if value, ok := usmc.mutation.UpdatedAt(); ok { _spec.SetField(usagestatisticmonth.FieldUpdatedAt, field.TypeTime, value) _node.UpdatedAt = value } if value, ok := usmc.mutation.Status(); ok { _spec.SetField(usagestatisticmonth.FieldStatus, field.TypeUint8, value) _node.Status = value } if value, ok := usmc.mutation.DeletedAt(); ok { _spec.SetField(usagestatisticmonth.FieldDeletedAt, field.TypeTime, value) _node.DeletedAt = value } if value, ok := usmc.mutation.Addtime(); ok { _spec.SetField(usagestatisticmonth.FieldAddtime, field.TypeUint64, value) _node.Addtime = value } if value, ok := usmc.mutation.GetType(); ok { _spec.SetField(usagestatisticmonth.FieldType, field.TypeInt, value) _node.Type = value } if value, ok := usmc.mutation.BotID(); ok { _spec.SetField(usagestatisticmonth.FieldBotID, field.TypeString, value) _node.BotID = value } if value, ok := usmc.mutation.OrganizationID(); ok { _spec.SetField(usagestatisticmonth.FieldOrganizationID, field.TypeUint64, value) _node.OrganizationID = value } if value, ok := usmc.mutation.AiResponse(); ok { _spec.SetField(usagestatisticmonth.FieldAiResponse, field.TypeUint64, value) _node.AiResponse = value } if value, ok := usmc.mutation.SopRun(); ok { _spec.SetField(usagestatisticmonth.FieldSopRun, field.TypeUint64, value) _node.SopRun = value } if value, ok := usmc.mutation.TotalFriend(); ok { _spec.SetField(usagestatisticmonth.FieldTotalFriend, field.TypeUint64, value) _node.TotalFriend = value } if value, ok := usmc.mutation.TotalGroup(); ok { _spec.SetField(usagestatisticmonth.FieldTotalGroup, field.TypeUint64, value) _node.TotalGroup = value } if value, ok := usmc.mutation.AccountBalance(); ok { _spec.SetField(usagestatisticmonth.FieldAccountBalance, field.TypeUint64, value) _node.AccountBalance = value } if value, ok := usmc.mutation.ConsumeToken(); ok { _spec.SetField(usagestatisticmonth.FieldConsumeToken, field.TypeUint64, value) _node.ConsumeToken = value } if value, ok := usmc.mutation.ActiveUser(); ok { _spec.SetField(usagestatisticmonth.FieldActiveUser, field.TypeUint64, value) _node.ActiveUser = value } if value, ok := usmc.mutation.NewUser(); ok { _spec.SetField(usagestatisticmonth.FieldNewUser, field.TypeInt64, value) _node.NewUser = value } if value, ok := usmc.mutation.LabelDist(); ok { _spec.SetField(usagestatisticmonth.FieldLabelDist, field.TypeJSON, value) _node.LabelDist = value } return _node, _spec } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.UsageStatisticMonth.Create(). // SetCreatedAt(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. // sql.ResolveWithNewValues(), // ). // // Override some of the fields with custom // // update values. // Update(func(u *ent.UsageStatisticMonthUpsert) { // SetCreatedAt(v+v). // }). // Exec(ctx) func (usmc *UsageStatisticMonthCreate) OnConflict(opts ...sql.ConflictOption) *UsageStatisticMonthUpsertOne { usmc.conflict = opts return &UsageStatisticMonthUpsertOne{ create: usmc, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.UsageStatisticMonth.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (usmc *UsageStatisticMonthCreate) OnConflictColumns(columns ...string) *UsageStatisticMonthUpsertOne { usmc.conflict = append(usmc.conflict, sql.ConflictColumns(columns...)) return &UsageStatisticMonthUpsertOne{ create: usmc, } } type ( // UsageStatisticMonthUpsertOne is the builder for "upsert"-ing // one UsageStatisticMonth node. UsageStatisticMonthUpsertOne struct { create *UsageStatisticMonthCreate } // UsageStatisticMonthUpsert is the "OnConflict" setter. UsageStatisticMonthUpsert struct { *sql.UpdateSet } ) // SetUpdatedAt sets the "updated_at" field. func (u *UsageStatisticMonthUpsert) SetUpdatedAt(v time.Time) *UsageStatisticMonthUpsert { u.Set(usagestatisticmonth.FieldUpdatedAt, v) return u } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *UsageStatisticMonthUpsert) UpdateUpdatedAt() *UsageStatisticMonthUpsert { u.SetExcluded(usagestatisticmonth.FieldUpdatedAt) return u } // SetStatus sets the "status" field. func (u *UsageStatisticMonthUpsert) SetStatus(v uint8) *UsageStatisticMonthUpsert { u.Set(usagestatisticmonth.FieldStatus, v) return u } // UpdateStatus sets the "status" field to the value that was provided on create. func (u *UsageStatisticMonthUpsert) UpdateStatus() *UsageStatisticMonthUpsert { u.SetExcluded(usagestatisticmonth.FieldStatus) return u } // AddStatus adds v to the "status" field. func (u *UsageStatisticMonthUpsert) AddStatus(v uint8) *UsageStatisticMonthUpsert { u.Add(usagestatisticmonth.FieldStatus, v) return u } // ClearStatus clears the value of the "status" field. func (u *UsageStatisticMonthUpsert) ClearStatus() *UsageStatisticMonthUpsert { u.SetNull(usagestatisticmonth.FieldStatus) return u } // SetDeletedAt sets the "deleted_at" field. func (u *UsageStatisticMonthUpsert) SetDeletedAt(v time.Time) *UsageStatisticMonthUpsert { u.Set(usagestatisticmonth.FieldDeletedAt, v) return u } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *UsageStatisticMonthUpsert) UpdateDeletedAt() *UsageStatisticMonthUpsert { u.SetExcluded(usagestatisticmonth.FieldDeletedAt) return u } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *UsageStatisticMonthUpsert) ClearDeletedAt() *UsageStatisticMonthUpsert { u.SetNull(usagestatisticmonth.FieldDeletedAt) return u } // SetAddtime sets the "addtime" field. func (u *UsageStatisticMonthUpsert) SetAddtime(v uint64) *UsageStatisticMonthUpsert { u.Set(usagestatisticmonth.FieldAddtime, v) return u } // UpdateAddtime sets the "addtime" field to the value that was provided on create. func (u *UsageStatisticMonthUpsert) UpdateAddtime() *UsageStatisticMonthUpsert { u.SetExcluded(usagestatisticmonth.FieldAddtime) return u } // AddAddtime adds v to the "addtime" field. func (u *UsageStatisticMonthUpsert) AddAddtime(v uint64) *UsageStatisticMonthUpsert { u.Add(usagestatisticmonth.FieldAddtime, v) return u } // SetType sets the "type" field. func (u *UsageStatisticMonthUpsert) SetType(v int) *UsageStatisticMonthUpsert { u.Set(usagestatisticmonth.FieldType, v) return u } // UpdateType sets the "type" field to the value that was provided on create. func (u *UsageStatisticMonthUpsert) UpdateType() *UsageStatisticMonthUpsert { u.SetExcluded(usagestatisticmonth.FieldType) return u } // AddType adds v to the "type" field. func (u *UsageStatisticMonthUpsert) AddType(v int) *UsageStatisticMonthUpsert { u.Add(usagestatisticmonth.FieldType, v) return u } // SetBotID sets the "bot_id" field. func (u *UsageStatisticMonthUpsert) SetBotID(v string) *UsageStatisticMonthUpsert { u.Set(usagestatisticmonth.FieldBotID, v) return u } // UpdateBotID sets the "bot_id" field to the value that was provided on create. func (u *UsageStatisticMonthUpsert) UpdateBotID() *UsageStatisticMonthUpsert { u.SetExcluded(usagestatisticmonth.FieldBotID) return u } // ClearBotID clears the value of the "bot_id" field. func (u *UsageStatisticMonthUpsert) ClearBotID() *UsageStatisticMonthUpsert { u.SetNull(usagestatisticmonth.FieldBotID) return u } // SetOrganizationID sets the "organization_id" field. func (u *UsageStatisticMonthUpsert) SetOrganizationID(v uint64) *UsageStatisticMonthUpsert { u.Set(usagestatisticmonth.FieldOrganizationID, v) return u } // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create. func (u *UsageStatisticMonthUpsert) UpdateOrganizationID() *UsageStatisticMonthUpsert { u.SetExcluded(usagestatisticmonth.FieldOrganizationID) return u } // AddOrganizationID adds v to the "organization_id" field. func (u *UsageStatisticMonthUpsert) AddOrganizationID(v uint64) *UsageStatisticMonthUpsert { u.Add(usagestatisticmonth.FieldOrganizationID, v) return u } // ClearOrganizationID clears the value of the "organization_id" field. func (u *UsageStatisticMonthUpsert) ClearOrganizationID() *UsageStatisticMonthUpsert { u.SetNull(usagestatisticmonth.FieldOrganizationID) return u } // SetAiResponse sets the "ai_response" field. func (u *UsageStatisticMonthUpsert) SetAiResponse(v uint64) *UsageStatisticMonthUpsert { u.Set(usagestatisticmonth.FieldAiResponse, v) return u } // UpdateAiResponse sets the "ai_response" field to the value that was provided on create. func (u *UsageStatisticMonthUpsert) UpdateAiResponse() *UsageStatisticMonthUpsert { u.SetExcluded(usagestatisticmonth.FieldAiResponse) return u } // AddAiResponse adds v to the "ai_response" field. func (u *UsageStatisticMonthUpsert) AddAiResponse(v uint64) *UsageStatisticMonthUpsert { u.Add(usagestatisticmonth.FieldAiResponse, v) return u } // SetSopRun sets the "sop_run" field. func (u *UsageStatisticMonthUpsert) SetSopRun(v uint64) *UsageStatisticMonthUpsert { u.Set(usagestatisticmonth.FieldSopRun, v) return u } // UpdateSopRun sets the "sop_run" field to the value that was provided on create. func (u *UsageStatisticMonthUpsert) UpdateSopRun() *UsageStatisticMonthUpsert { u.SetExcluded(usagestatisticmonth.FieldSopRun) return u } // AddSopRun adds v to the "sop_run" field. func (u *UsageStatisticMonthUpsert) AddSopRun(v uint64) *UsageStatisticMonthUpsert { u.Add(usagestatisticmonth.FieldSopRun, v) return u } // SetTotalFriend sets the "total_friend" field. func (u *UsageStatisticMonthUpsert) SetTotalFriend(v uint64) *UsageStatisticMonthUpsert { u.Set(usagestatisticmonth.FieldTotalFriend, v) return u } // UpdateTotalFriend sets the "total_friend" field to the value that was provided on create. func (u *UsageStatisticMonthUpsert) UpdateTotalFriend() *UsageStatisticMonthUpsert { u.SetExcluded(usagestatisticmonth.FieldTotalFriend) return u } // AddTotalFriend adds v to the "total_friend" field. func (u *UsageStatisticMonthUpsert) AddTotalFriend(v uint64) *UsageStatisticMonthUpsert { u.Add(usagestatisticmonth.FieldTotalFriend, v) return u } // SetTotalGroup sets the "total_group" field. func (u *UsageStatisticMonthUpsert) SetTotalGroup(v uint64) *UsageStatisticMonthUpsert { u.Set(usagestatisticmonth.FieldTotalGroup, v) return u } // UpdateTotalGroup sets the "total_group" field to the value that was provided on create. func (u *UsageStatisticMonthUpsert) UpdateTotalGroup() *UsageStatisticMonthUpsert { u.SetExcluded(usagestatisticmonth.FieldTotalGroup) return u } // AddTotalGroup adds v to the "total_group" field. func (u *UsageStatisticMonthUpsert) AddTotalGroup(v uint64) *UsageStatisticMonthUpsert { u.Add(usagestatisticmonth.FieldTotalGroup, v) return u } // SetAccountBalance sets the "account_balance" field. func (u *UsageStatisticMonthUpsert) SetAccountBalance(v uint64) *UsageStatisticMonthUpsert { u.Set(usagestatisticmonth.FieldAccountBalance, v) return u } // UpdateAccountBalance sets the "account_balance" field to the value that was provided on create. func (u *UsageStatisticMonthUpsert) UpdateAccountBalance() *UsageStatisticMonthUpsert { u.SetExcluded(usagestatisticmonth.FieldAccountBalance) return u } // AddAccountBalance adds v to the "account_balance" field. func (u *UsageStatisticMonthUpsert) AddAccountBalance(v uint64) *UsageStatisticMonthUpsert { u.Add(usagestatisticmonth.FieldAccountBalance, v) return u } // SetConsumeToken sets the "consume_token" field. func (u *UsageStatisticMonthUpsert) SetConsumeToken(v uint64) *UsageStatisticMonthUpsert { u.Set(usagestatisticmonth.FieldConsumeToken, v) return u } // UpdateConsumeToken sets the "consume_token" field to the value that was provided on create. func (u *UsageStatisticMonthUpsert) UpdateConsumeToken() *UsageStatisticMonthUpsert { u.SetExcluded(usagestatisticmonth.FieldConsumeToken) return u } // AddConsumeToken adds v to the "consume_token" field. func (u *UsageStatisticMonthUpsert) AddConsumeToken(v uint64) *UsageStatisticMonthUpsert { u.Add(usagestatisticmonth.FieldConsumeToken, v) return u } // SetActiveUser sets the "active_user" field. func (u *UsageStatisticMonthUpsert) SetActiveUser(v uint64) *UsageStatisticMonthUpsert { u.Set(usagestatisticmonth.FieldActiveUser, v) return u } // UpdateActiveUser sets the "active_user" field to the value that was provided on create. func (u *UsageStatisticMonthUpsert) UpdateActiveUser() *UsageStatisticMonthUpsert { u.SetExcluded(usagestatisticmonth.FieldActiveUser) return u } // AddActiveUser adds v to the "active_user" field. func (u *UsageStatisticMonthUpsert) AddActiveUser(v uint64) *UsageStatisticMonthUpsert { u.Add(usagestatisticmonth.FieldActiveUser, v) return u } // SetNewUser sets the "new_user" field. func (u *UsageStatisticMonthUpsert) SetNewUser(v int64) *UsageStatisticMonthUpsert { u.Set(usagestatisticmonth.FieldNewUser, v) return u } // UpdateNewUser sets the "new_user" field to the value that was provided on create. func (u *UsageStatisticMonthUpsert) UpdateNewUser() *UsageStatisticMonthUpsert { u.SetExcluded(usagestatisticmonth.FieldNewUser) return u } // AddNewUser adds v to the "new_user" field. func (u *UsageStatisticMonthUpsert) AddNewUser(v int64) *UsageStatisticMonthUpsert { u.Add(usagestatisticmonth.FieldNewUser, v) return u } // SetLabelDist sets the "label_dist" field. func (u *UsageStatisticMonthUpsert) SetLabelDist(v []custom_types.LabelDist) *UsageStatisticMonthUpsert { u.Set(usagestatisticmonth.FieldLabelDist, v) return u } // UpdateLabelDist sets the "label_dist" field to the value that was provided on create. func (u *UsageStatisticMonthUpsert) UpdateLabelDist() *UsageStatisticMonthUpsert { u.SetExcluded(usagestatisticmonth.FieldLabelDist) return u } // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. // Using this option is equivalent to using: // // client.UsageStatisticMonth.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(usagestatisticmonth.FieldID) // }), // ). // Exec(ctx) func (u *UsageStatisticMonthUpsertOne) UpdateNewValues() *UsageStatisticMonthUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { if _, exists := u.create.mutation.ID(); exists { s.SetIgnore(usagestatisticmonth.FieldID) } if _, exists := u.create.mutation.CreatedAt(); exists { s.SetIgnore(usagestatisticmonth.FieldCreatedAt) } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.UsageStatisticMonth.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *UsageStatisticMonthUpsertOne) Ignore() *UsageStatisticMonthUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) return u } // DoNothing configures the conflict_action to `DO NOTHING`. // Supported only by SQLite and PostgreSQL. func (u *UsageStatisticMonthUpsertOne) DoNothing() *UsageStatisticMonthUpsertOne { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the UsageStatisticMonthCreate.OnConflict // documentation for more info. func (u *UsageStatisticMonthUpsertOne) Update(set func(*UsageStatisticMonthUpsert)) *UsageStatisticMonthUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&UsageStatisticMonthUpsert{UpdateSet: update}) })) return u } // SetUpdatedAt sets the "updated_at" field. func (u *UsageStatisticMonthUpsertOne) SetUpdatedAt(v time.Time) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetUpdatedAt(v) }) } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertOne) UpdateUpdatedAt() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateUpdatedAt() }) } // SetStatus sets the "status" field. func (u *UsageStatisticMonthUpsertOne) SetStatus(v uint8) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetStatus(v) }) } // AddStatus adds v to the "status" field. func (u *UsageStatisticMonthUpsertOne) AddStatus(v uint8) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddStatus(v) }) } // UpdateStatus sets the "status" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertOne) UpdateStatus() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateStatus() }) } // ClearStatus clears the value of the "status" field. func (u *UsageStatisticMonthUpsertOne) ClearStatus() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.ClearStatus() }) } // SetDeletedAt sets the "deleted_at" field. func (u *UsageStatisticMonthUpsertOne) SetDeletedAt(v time.Time) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetDeletedAt(v) }) } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertOne) UpdateDeletedAt() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateDeletedAt() }) } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *UsageStatisticMonthUpsertOne) ClearDeletedAt() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.ClearDeletedAt() }) } // SetAddtime sets the "addtime" field. func (u *UsageStatisticMonthUpsertOne) SetAddtime(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetAddtime(v) }) } // AddAddtime adds v to the "addtime" field. func (u *UsageStatisticMonthUpsertOne) AddAddtime(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddAddtime(v) }) } // UpdateAddtime sets the "addtime" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertOne) UpdateAddtime() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateAddtime() }) } // SetType sets the "type" field. func (u *UsageStatisticMonthUpsertOne) SetType(v int) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetType(v) }) } // AddType adds v to the "type" field. func (u *UsageStatisticMonthUpsertOne) AddType(v int) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddType(v) }) } // UpdateType sets the "type" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertOne) UpdateType() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateType() }) } // SetBotID sets the "bot_id" field. func (u *UsageStatisticMonthUpsertOne) SetBotID(v string) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetBotID(v) }) } // UpdateBotID sets the "bot_id" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertOne) UpdateBotID() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateBotID() }) } // ClearBotID clears the value of the "bot_id" field. func (u *UsageStatisticMonthUpsertOne) ClearBotID() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.ClearBotID() }) } // SetOrganizationID sets the "organization_id" field. func (u *UsageStatisticMonthUpsertOne) SetOrganizationID(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetOrganizationID(v) }) } // AddOrganizationID adds v to the "organization_id" field. func (u *UsageStatisticMonthUpsertOne) AddOrganizationID(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddOrganizationID(v) }) } // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertOne) UpdateOrganizationID() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateOrganizationID() }) } // ClearOrganizationID clears the value of the "organization_id" field. func (u *UsageStatisticMonthUpsertOne) ClearOrganizationID() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.ClearOrganizationID() }) } // SetAiResponse sets the "ai_response" field. func (u *UsageStatisticMonthUpsertOne) SetAiResponse(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetAiResponse(v) }) } // AddAiResponse adds v to the "ai_response" field. func (u *UsageStatisticMonthUpsertOne) AddAiResponse(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddAiResponse(v) }) } // UpdateAiResponse sets the "ai_response" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertOne) UpdateAiResponse() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateAiResponse() }) } // SetSopRun sets the "sop_run" field. func (u *UsageStatisticMonthUpsertOne) SetSopRun(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetSopRun(v) }) } // AddSopRun adds v to the "sop_run" field. func (u *UsageStatisticMonthUpsertOne) AddSopRun(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddSopRun(v) }) } // UpdateSopRun sets the "sop_run" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertOne) UpdateSopRun() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateSopRun() }) } // SetTotalFriend sets the "total_friend" field. func (u *UsageStatisticMonthUpsertOne) SetTotalFriend(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetTotalFriend(v) }) } // AddTotalFriend adds v to the "total_friend" field. func (u *UsageStatisticMonthUpsertOne) AddTotalFriend(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddTotalFriend(v) }) } // UpdateTotalFriend sets the "total_friend" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertOne) UpdateTotalFriend() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateTotalFriend() }) } // SetTotalGroup sets the "total_group" field. func (u *UsageStatisticMonthUpsertOne) SetTotalGroup(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetTotalGroup(v) }) } // AddTotalGroup adds v to the "total_group" field. func (u *UsageStatisticMonthUpsertOne) AddTotalGroup(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddTotalGroup(v) }) } // UpdateTotalGroup sets the "total_group" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertOne) UpdateTotalGroup() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateTotalGroup() }) } // SetAccountBalance sets the "account_balance" field. func (u *UsageStatisticMonthUpsertOne) SetAccountBalance(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetAccountBalance(v) }) } // AddAccountBalance adds v to the "account_balance" field. func (u *UsageStatisticMonthUpsertOne) AddAccountBalance(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddAccountBalance(v) }) } // UpdateAccountBalance sets the "account_balance" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertOne) UpdateAccountBalance() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateAccountBalance() }) } // SetConsumeToken sets the "consume_token" field. func (u *UsageStatisticMonthUpsertOne) SetConsumeToken(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetConsumeToken(v) }) } // AddConsumeToken adds v to the "consume_token" field. func (u *UsageStatisticMonthUpsertOne) AddConsumeToken(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddConsumeToken(v) }) } // UpdateConsumeToken sets the "consume_token" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertOne) UpdateConsumeToken() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateConsumeToken() }) } // SetActiveUser sets the "active_user" field. func (u *UsageStatisticMonthUpsertOne) SetActiveUser(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetActiveUser(v) }) } // AddActiveUser adds v to the "active_user" field. func (u *UsageStatisticMonthUpsertOne) AddActiveUser(v uint64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddActiveUser(v) }) } // UpdateActiveUser sets the "active_user" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertOne) UpdateActiveUser() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateActiveUser() }) } // SetNewUser sets the "new_user" field. func (u *UsageStatisticMonthUpsertOne) SetNewUser(v int64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetNewUser(v) }) } // AddNewUser adds v to the "new_user" field. func (u *UsageStatisticMonthUpsertOne) AddNewUser(v int64) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddNewUser(v) }) } // UpdateNewUser sets the "new_user" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertOne) UpdateNewUser() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateNewUser() }) } // SetLabelDist sets the "label_dist" field. func (u *UsageStatisticMonthUpsertOne) SetLabelDist(v []custom_types.LabelDist) *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetLabelDist(v) }) } // UpdateLabelDist sets the "label_dist" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertOne) UpdateLabelDist() *UsageStatisticMonthUpsertOne { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateLabelDist() }) } // Exec executes the query. func (u *UsageStatisticMonthUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { return errors.New("ent: missing options for UsageStatisticMonthCreate.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *UsageStatisticMonthUpsertOne) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } } // Exec executes the UPSERT query and returns the inserted/updated ID. func (u *UsageStatisticMonthUpsertOne) ID(ctx context.Context) (id uint64, err error) { node, err := u.create.Save(ctx) if err != nil { return id, err } return node.ID, nil } // IDX is like ID, but panics if an error occurs. func (u *UsageStatisticMonthUpsertOne) IDX(ctx context.Context) uint64 { id, err := u.ID(ctx) if err != nil { panic(err) } return id } // UsageStatisticMonthCreateBulk is the builder for creating many UsageStatisticMonth entities in bulk. type UsageStatisticMonthCreateBulk struct { config err error builders []*UsageStatisticMonthCreate conflict []sql.ConflictOption } // Save creates the UsageStatisticMonth entities in the database. func (usmcb *UsageStatisticMonthCreateBulk) Save(ctx context.Context) ([]*UsageStatisticMonth, error) { if usmcb.err != nil { return nil, usmcb.err } specs := make([]*sqlgraph.CreateSpec, len(usmcb.builders)) nodes := make([]*UsageStatisticMonth, len(usmcb.builders)) mutators := make([]Mutator, len(usmcb.builders)) for i := range usmcb.builders { func(i int, root context.Context) { builder := usmcb.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*UsageStatisticMonthMutation) if !ok { return nil, fmt.Errorf("unexpected mutation type %T", m) } if err := builder.check(); err != nil { return nil, err } builder.mutation = mutation var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { _, err = mutators[i+1].Mutate(root, usmcb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} spec.OnConflict = usmcb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, usmcb.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } } } if err != nil { return nil, err } mutation.id = &nodes[i].ID if specs[i].ID.Value != nil && nodes[i].ID == 0 { id := specs[i].ID.Value.(int64) nodes[i].ID = uint64(id) } mutation.done = true return nodes[i], nil }) for i := len(builder.hooks) - 1; i >= 0; i-- { mut = builder.hooks[i](mut) } mutators[i] = mut }(i, ctx) } if len(mutators) > 0 { if _, err := mutators[0].Mutate(ctx, usmcb.builders[0].mutation); err != nil { return nil, err } } return nodes, nil } // SaveX is like Save, but panics if an error occurs. func (usmcb *UsageStatisticMonthCreateBulk) SaveX(ctx context.Context) []*UsageStatisticMonth { v, err := usmcb.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (usmcb *UsageStatisticMonthCreateBulk) Exec(ctx context.Context) error { _, err := usmcb.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (usmcb *UsageStatisticMonthCreateBulk) ExecX(ctx context.Context) { if err := usmcb.Exec(ctx); err != nil { panic(err) } } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.UsageStatisticMonth.CreateBulk(builders...). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. // sql.ResolveWithNewValues(), // ). // // Override some of the fields with custom // // update values. // Update(func(u *ent.UsageStatisticMonthUpsert) { // SetCreatedAt(v+v). // }). // Exec(ctx) func (usmcb *UsageStatisticMonthCreateBulk) OnConflict(opts ...sql.ConflictOption) *UsageStatisticMonthUpsertBulk { usmcb.conflict = opts return &UsageStatisticMonthUpsertBulk{ create: usmcb, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.UsageStatisticMonth.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (usmcb *UsageStatisticMonthCreateBulk) OnConflictColumns(columns ...string) *UsageStatisticMonthUpsertBulk { usmcb.conflict = append(usmcb.conflict, sql.ConflictColumns(columns...)) return &UsageStatisticMonthUpsertBulk{ create: usmcb, } } // UsageStatisticMonthUpsertBulk is the builder for "upsert"-ing // a bulk of UsageStatisticMonth nodes. type UsageStatisticMonthUpsertBulk struct { create *UsageStatisticMonthCreateBulk } // UpdateNewValues updates the mutable fields using the new values that // were set on create. Using this option is equivalent to using: // // client.UsageStatisticMonth.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(usagestatisticmonth.FieldID) // }), // ). // Exec(ctx) func (u *UsageStatisticMonthUpsertBulk) UpdateNewValues() *UsageStatisticMonthUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { for _, b := range u.create.builders { if _, exists := b.mutation.ID(); exists { s.SetIgnore(usagestatisticmonth.FieldID) } if _, exists := b.mutation.CreatedAt(); exists { s.SetIgnore(usagestatisticmonth.FieldCreatedAt) } } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.UsageStatisticMonth.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *UsageStatisticMonthUpsertBulk) Ignore() *UsageStatisticMonthUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) return u } // DoNothing configures the conflict_action to `DO NOTHING`. // Supported only by SQLite and PostgreSQL. func (u *UsageStatisticMonthUpsertBulk) DoNothing() *UsageStatisticMonthUpsertBulk { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the UsageStatisticMonthCreateBulk.OnConflict // documentation for more info. func (u *UsageStatisticMonthUpsertBulk) Update(set func(*UsageStatisticMonthUpsert)) *UsageStatisticMonthUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&UsageStatisticMonthUpsert{UpdateSet: update}) })) return u } // SetUpdatedAt sets the "updated_at" field. func (u *UsageStatisticMonthUpsertBulk) SetUpdatedAt(v time.Time) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetUpdatedAt(v) }) } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertBulk) UpdateUpdatedAt() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateUpdatedAt() }) } // SetStatus sets the "status" field. func (u *UsageStatisticMonthUpsertBulk) SetStatus(v uint8) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetStatus(v) }) } // AddStatus adds v to the "status" field. func (u *UsageStatisticMonthUpsertBulk) AddStatus(v uint8) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddStatus(v) }) } // UpdateStatus sets the "status" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertBulk) UpdateStatus() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateStatus() }) } // ClearStatus clears the value of the "status" field. func (u *UsageStatisticMonthUpsertBulk) ClearStatus() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.ClearStatus() }) } // SetDeletedAt sets the "deleted_at" field. func (u *UsageStatisticMonthUpsertBulk) SetDeletedAt(v time.Time) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetDeletedAt(v) }) } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertBulk) UpdateDeletedAt() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateDeletedAt() }) } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *UsageStatisticMonthUpsertBulk) ClearDeletedAt() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.ClearDeletedAt() }) } // SetAddtime sets the "addtime" field. func (u *UsageStatisticMonthUpsertBulk) SetAddtime(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetAddtime(v) }) } // AddAddtime adds v to the "addtime" field. func (u *UsageStatisticMonthUpsertBulk) AddAddtime(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddAddtime(v) }) } // UpdateAddtime sets the "addtime" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertBulk) UpdateAddtime() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateAddtime() }) } // SetType sets the "type" field. func (u *UsageStatisticMonthUpsertBulk) SetType(v int) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetType(v) }) } // AddType adds v to the "type" field. func (u *UsageStatisticMonthUpsertBulk) AddType(v int) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddType(v) }) } // UpdateType sets the "type" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertBulk) UpdateType() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateType() }) } // SetBotID sets the "bot_id" field. func (u *UsageStatisticMonthUpsertBulk) SetBotID(v string) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetBotID(v) }) } // UpdateBotID sets the "bot_id" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertBulk) UpdateBotID() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateBotID() }) } // ClearBotID clears the value of the "bot_id" field. func (u *UsageStatisticMonthUpsertBulk) ClearBotID() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.ClearBotID() }) } // SetOrganizationID sets the "organization_id" field. func (u *UsageStatisticMonthUpsertBulk) SetOrganizationID(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetOrganizationID(v) }) } // AddOrganizationID adds v to the "organization_id" field. func (u *UsageStatisticMonthUpsertBulk) AddOrganizationID(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddOrganizationID(v) }) } // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertBulk) UpdateOrganizationID() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateOrganizationID() }) } // ClearOrganizationID clears the value of the "organization_id" field. func (u *UsageStatisticMonthUpsertBulk) ClearOrganizationID() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.ClearOrganizationID() }) } // SetAiResponse sets the "ai_response" field. func (u *UsageStatisticMonthUpsertBulk) SetAiResponse(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetAiResponse(v) }) } // AddAiResponse adds v to the "ai_response" field. func (u *UsageStatisticMonthUpsertBulk) AddAiResponse(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddAiResponse(v) }) } // UpdateAiResponse sets the "ai_response" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertBulk) UpdateAiResponse() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateAiResponse() }) } // SetSopRun sets the "sop_run" field. func (u *UsageStatisticMonthUpsertBulk) SetSopRun(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetSopRun(v) }) } // AddSopRun adds v to the "sop_run" field. func (u *UsageStatisticMonthUpsertBulk) AddSopRun(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddSopRun(v) }) } // UpdateSopRun sets the "sop_run" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertBulk) UpdateSopRun() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateSopRun() }) } // SetTotalFriend sets the "total_friend" field. func (u *UsageStatisticMonthUpsertBulk) SetTotalFriend(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetTotalFriend(v) }) } // AddTotalFriend adds v to the "total_friend" field. func (u *UsageStatisticMonthUpsertBulk) AddTotalFriend(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddTotalFriend(v) }) } // UpdateTotalFriend sets the "total_friend" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertBulk) UpdateTotalFriend() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateTotalFriend() }) } // SetTotalGroup sets the "total_group" field. func (u *UsageStatisticMonthUpsertBulk) SetTotalGroup(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetTotalGroup(v) }) } // AddTotalGroup adds v to the "total_group" field. func (u *UsageStatisticMonthUpsertBulk) AddTotalGroup(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddTotalGroup(v) }) } // UpdateTotalGroup sets the "total_group" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertBulk) UpdateTotalGroup() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateTotalGroup() }) } // SetAccountBalance sets the "account_balance" field. func (u *UsageStatisticMonthUpsertBulk) SetAccountBalance(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetAccountBalance(v) }) } // AddAccountBalance adds v to the "account_balance" field. func (u *UsageStatisticMonthUpsertBulk) AddAccountBalance(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddAccountBalance(v) }) } // UpdateAccountBalance sets the "account_balance" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertBulk) UpdateAccountBalance() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateAccountBalance() }) } // SetConsumeToken sets the "consume_token" field. func (u *UsageStatisticMonthUpsertBulk) SetConsumeToken(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetConsumeToken(v) }) } // AddConsumeToken adds v to the "consume_token" field. func (u *UsageStatisticMonthUpsertBulk) AddConsumeToken(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddConsumeToken(v) }) } // UpdateConsumeToken sets the "consume_token" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertBulk) UpdateConsumeToken() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateConsumeToken() }) } // SetActiveUser sets the "active_user" field. func (u *UsageStatisticMonthUpsertBulk) SetActiveUser(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetActiveUser(v) }) } // AddActiveUser adds v to the "active_user" field. func (u *UsageStatisticMonthUpsertBulk) AddActiveUser(v uint64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddActiveUser(v) }) } // UpdateActiveUser sets the "active_user" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertBulk) UpdateActiveUser() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateActiveUser() }) } // SetNewUser sets the "new_user" field. func (u *UsageStatisticMonthUpsertBulk) SetNewUser(v int64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetNewUser(v) }) } // AddNewUser adds v to the "new_user" field. func (u *UsageStatisticMonthUpsertBulk) AddNewUser(v int64) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.AddNewUser(v) }) } // UpdateNewUser sets the "new_user" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertBulk) UpdateNewUser() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateNewUser() }) } // SetLabelDist sets the "label_dist" field. func (u *UsageStatisticMonthUpsertBulk) SetLabelDist(v []custom_types.LabelDist) *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.SetLabelDist(v) }) } // UpdateLabelDist sets the "label_dist" field to the value that was provided on create. func (u *UsageStatisticMonthUpsertBulk) UpdateLabelDist() *UsageStatisticMonthUpsertBulk { return u.Update(func(s *UsageStatisticMonthUpsert) { s.UpdateLabelDist() }) } // Exec executes the query. func (u *UsageStatisticMonthUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { return u.create.err } for i, b := range u.create.builders { if len(b.conflict) != 0 { return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the UsageStatisticMonthCreateBulk instead", i) } } if len(u.create.conflict) == 0 { return errors.New("ent: missing options for UsageStatisticMonthCreateBulk.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *UsageStatisticMonthUpsertBulk) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } }