// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "time" "wechat-api/ent/compapiasynctask" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // CompapiAsynctaskCreate is the builder for creating a CompapiAsynctask entity. type CompapiAsynctaskCreate struct { config mutation *CompapiAsynctaskMutation hooks []Hook conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. func (cac *CompapiAsynctaskCreate) SetCreatedAt(t time.Time) *CompapiAsynctaskCreate { cac.mutation.SetCreatedAt(t) return cac } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (cac *CompapiAsynctaskCreate) SetNillableCreatedAt(t *time.Time) *CompapiAsynctaskCreate { if t != nil { cac.SetCreatedAt(*t) } return cac } // SetUpdatedAt sets the "updated_at" field. func (cac *CompapiAsynctaskCreate) SetUpdatedAt(t time.Time) *CompapiAsynctaskCreate { cac.mutation.SetUpdatedAt(t) return cac } // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. func (cac *CompapiAsynctaskCreate) SetNillableUpdatedAt(t *time.Time) *CompapiAsynctaskCreate { if t != nil { cac.SetUpdatedAt(*t) } return cac } // SetAuthToken sets the "auth_token" field. func (cac *CompapiAsynctaskCreate) SetAuthToken(s string) *CompapiAsynctaskCreate { cac.mutation.SetAuthToken(s) return cac } // SetEventType sets the "event_type" field. func (cac *CompapiAsynctaskCreate) SetEventType(s string) *CompapiAsynctaskCreate { cac.mutation.SetEventType(s) return cac } // SetNillableEventType sets the "event_type" field if the given value is not nil. func (cac *CompapiAsynctaskCreate) SetNillableEventType(s *string) *CompapiAsynctaskCreate { if s != nil { cac.SetEventType(*s) } return cac } // SetChatID sets the "chat_id" field. func (cac *CompapiAsynctaskCreate) SetChatID(s string) *CompapiAsynctaskCreate { cac.mutation.SetChatID(s) return cac } // SetNillableChatID sets the "chat_id" field if the given value is not nil. func (cac *CompapiAsynctaskCreate) SetNillableChatID(s *string) *CompapiAsynctaskCreate { if s != nil { cac.SetChatID(*s) } return cac } // SetResponseChatItemID sets the "response_chat_item_id" field. func (cac *CompapiAsynctaskCreate) SetResponseChatItemID(s string) *CompapiAsynctaskCreate { cac.mutation.SetResponseChatItemID(s) return cac } // SetNillableResponseChatItemID sets the "response_chat_item_id" field if the given value is not nil. func (cac *CompapiAsynctaskCreate) SetNillableResponseChatItemID(s *string) *CompapiAsynctaskCreate { if s != nil { cac.SetResponseChatItemID(*s) } return cac } // SetOrganizationID sets the "organization_id" field. func (cac *CompapiAsynctaskCreate) SetOrganizationID(u uint64) *CompapiAsynctaskCreate { cac.mutation.SetOrganizationID(u) return cac } // SetOpenaiBase sets the "openai_base" field. func (cac *CompapiAsynctaskCreate) SetOpenaiBase(s string) *CompapiAsynctaskCreate { cac.mutation.SetOpenaiBase(s) return cac } // SetOpenaiKey sets the "openai_key" field. func (cac *CompapiAsynctaskCreate) SetOpenaiKey(s string) *CompapiAsynctaskCreate { cac.mutation.SetOpenaiKey(s) return cac } // SetRequestRaw sets the "request_raw" field. func (cac *CompapiAsynctaskCreate) SetRequestRaw(s string) *CompapiAsynctaskCreate { cac.mutation.SetRequestRaw(s) return cac } // SetResponseRaw sets the "response_raw" field. func (cac *CompapiAsynctaskCreate) SetResponseRaw(s string) *CompapiAsynctaskCreate { cac.mutation.SetResponseRaw(s) return cac } // SetNillableResponseRaw sets the "response_raw" field if the given value is not nil. func (cac *CompapiAsynctaskCreate) SetNillableResponseRaw(s *string) *CompapiAsynctaskCreate { if s != nil { cac.SetResponseRaw(*s) } return cac } // SetCallbackURL sets the "callback_url" field. func (cac *CompapiAsynctaskCreate) SetCallbackURL(s string) *CompapiAsynctaskCreate { cac.mutation.SetCallbackURL(s) return cac } // SetCallbackResponseRaw sets the "callback_response_raw" field. func (cac *CompapiAsynctaskCreate) SetCallbackResponseRaw(s string) *CompapiAsynctaskCreate { cac.mutation.SetCallbackResponseRaw(s) return cac } // SetNillableCallbackResponseRaw sets the "callback_response_raw" field if the given value is not nil. func (cac *CompapiAsynctaskCreate) SetNillableCallbackResponseRaw(s *string) *CompapiAsynctaskCreate { if s != nil { cac.SetCallbackResponseRaw(*s) } return cac } // SetModel sets the "model" field. func (cac *CompapiAsynctaskCreate) SetModel(s string) *CompapiAsynctaskCreate { cac.mutation.SetModel(s) return cac } // SetNillableModel sets the "model" field if the given value is not nil. func (cac *CompapiAsynctaskCreate) SetNillableModel(s *string) *CompapiAsynctaskCreate { if s != nil { cac.SetModel(*s) } return cac } // SetTaskStatus sets the "task_status" field. func (cac *CompapiAsynctaskCreate) SetTaskStatus(i int8) *CompapiAsynctaskCreate { cac.mutation.SetTaskStatus(i) return cac } // SetNillableTaskStatus sets the "task_status" field if the given value is not nil. func (cac *CompapiAsynctaskCreate) SetNillableTaskStatus(i *int8) *CompapiAsynctaskCreate { if i != nil { cac.SetTaskStatus(*i) } return cac } // SetRetryCount sets the "retry_count" field. func (cac *CompapiAsynctaskCreate) SetRetryCount(i int8) *CompapiAsynctaskCreate { cac.mutation.SetRetryCount(i) return cac } // SetNillableRetryCount sets the "retry_count" field if the given value is not nil. func (cac *CompapiAsynctaskCreate) SetNillableRetryCount(i *int8) *CompapiAsynctaskCreate { if i != nil { cac.SetRetryCount(*i) } return cac } // SetLastError sets the "last_error" field. func (cac *CompapiAsynctaskCreate) SetLastError(s string) *CompapiAsynctaskCreate { cac.mutation.SetLastError(s) return cac } // SetNillableLastError sets the "last_error" field if the given value is not nil. func (cac *CompapiAsynctaskCreate) SetNillableLastError(s *string) *CompapiAsynctaskCreate { if s != nil { cac.SetLastError(*s) } return cac } // SetID sets the "id" field. func (cac *CompapiAsynctaskCreate) SetID(u uint64) *CompapiAsynctaskCreate { cac.mutation.SetID(u) return cac } // Mutation returns the CompapiAsynctaskMutation object of the builder. func (cac *CompapiAsynctaskCreate) Mutation() *CompapiAsynctaskMutation { return cac.mutation } // Save creates the CompapiAsynctask in the database. func (cac *CompapiAsynctaskCreate) Save(ctx context.Context) (*CompapiAsynctask, error) { cac.defaults() return withHooks(ctx, cac.sqlSave, cac.mutation, cac.hooks) } // SaveX calls Save and panics if Save returns an error. func (cac *CompapiAsynctaskCreate) SaveX(ctx context.Context) *CompapiAsynctask { v, err := cac.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (cac *CompapiAsynctaskCreate) Exec(ctx context.Context) error { _, err := cac.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (cac *CompapiAsynctaskCreate) ExecX(ctx context.Context) { if err := cac.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. func (cac *CompapiAsynctaskCreate) defaults() { if _, ok := cac.mutation.CreatedAt(); !ok { v := compapiasynctask.DefaultCreatedAt() cac.mutation.SetCreatedAt(v) } if _, ok := cac.mutation.UpdatedAt(); !ok { v := compapiasynctask.DefaultUpdatedAt() cac.mutation.SetUpdatedAt(v) } if _, ok := cac.mutation.EventType(); !ok { v := compapiasynctask.DefaultEventType cac.mutation.SetEventType(v) } if _, ok := cac.mutation.ChatID(); !ok { v := compapiasynctask.DefaultChatID cac.mutation.SetChatID(v) } if _, ok := cac.mutation.ResponseChatItemID(); !ok { v := compapiasynctask.DefaultResponseChatItemID cac.mutation.SetResponseChatItemID(v) } if _, ok := cac.mutation.ResponseRaw(); !ok { v := compapiasynctask.DefaultResponseRaw cac.mutation.SetResponseRaw(v) } if _, ok := cac.mutation.CallbackResponseRaw(); !ok { v := compapiasynctask.DefaultCallbackResponseRaw cac.mutation.SetCallbackResponseRaw(v) } if _, ok := cac.mutation.Model(); !ok { v := compapiasynctask.DefaultModel cac.mutation.SetModel(v) } if _, ok := cac.mutation.TaskStatus(); !ok { v := compapiasynctask.DefaultTaskStatus cac.mutation.SetTaskStatus(v) } if _, ok := cac.mutation.RetryCount(); !ok { v := compapiasynctask.DefaultRetryCount cac.mutation.SetRetryCount(v) } if _, ok := cac.mutation.LastError(); !ok { v := compapiasynctask.DefaultLastError cac.mutation.SetLastError(v) } } // check runs all checks and user-defined validators on the builder. func (cac *CompapiAsynctaskCreate) check() error { if _, ok := cac.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "CompapiAsynctask.created_at"`)} } if _, ok := cac.mutation.UpdatedAt(); !ok { return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "CompapiAsynctask.updated_at"`)} } if _, ok := cac.mutation.AuthToken(); !ok { return &ValidationError{Name: "auth_token", err: errors.New(`ent: missing required field "CompapiAsynctask.auth_token"`)} } if _, ok := cac.mutation.EventType(); !ok { return &ValidationError{Name: "event_type", err: errors.New(`ent: missing required field "CompapiAsynctask.event_type"`)} } if _, ok := cac.mutation.OrganizationID(); !ok { return &ValidationError{Name: "organization_id", err: errors.New(`ent: missing required field "CompapiAsynctask.organization_id"`)} } if v, ok := cac.mutation.OrganizationID(); ok { if err := compapiasynctask.OrganizationIDValidator(v); err != nil { return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "CompapiAsynctask.organization_id": %w`, err)} } } if _, ok := cac.mutation.OpenaiBase(); !ok { return &ValidationError{Name: "openai_base", err: errors.New(`ent: missing required field "CompapiAsynctask.openai_base"`)} } if _, ok := cac.mutation.OpenaiKey(); !ok { return &ValidationError{Name: "openai_key", err: errors.New(`ent: missing required field "CompapiAsynctask.openai_key"`)} } if _, ok := cac.mutation.RequestRaw(); !ok { return &ValidationError{Name: "request_raw", err: errors.New(`ent: missing required field "CompapiAsynctask.request_raw"`)} } if _, ok := cac.mutation.CallbackURL(); !ok { return &ValidationError{Name: "callback_url", err: errors.New(`ent: missing required field "CompapiAsynctask.callback_url"`)} } if v, ok := cac.mutation.CallbackURL(); ok { if err := compapiasynctask.CallbackURLValidator(v); err != nil { return &ValidationError{Name: "callback_url", err: fmt.Errorf(`ent: validator failed for field "CompapiAsynctask.callback_url": %w`, err)} } } return nil } func (cac *CompapiAsynctaskCreate) sqlSave(ctx context.Context) (*CompapiAsynctask, error) { if err := cac.check(); err != nil { return nil, err } _node, _spec := cac.createSpec() if err := sqlgraph.CreateNode(ctx, cac.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) } cac.mutation.id = &_node.ID cac.mutation.done = true return _node, nil } func (cac *CompapiAsynctaskCreate) createSpec() (*CompapiAsynctask, *sqlgraph.CreateSpec) { var ( _node = &CompapiAsynctask{config: cac.config} _spec = sqlgraph.NewCreateSpec(compapiasynctask.Table, sqlgraph.NewFieldSpec(compapiasynctask.FieldID, field.TypeUint64)) ) _spec.OnConflict = cac.conflict if id, ok := cac.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id } if value, ok := cac.mutation.CreatedAt(); ok { _spec.SetField(compapiasynctask.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value } if value, ok := cac.mutation.UpdatedAt(); ok { _spec.SetField(compapiasynctask.FieldUpdatedAt, field.TypeTime, value) _node.UpdatedAt = value } if value, ok := cac.mutation.AuthToken(); ok { _spec.SetField(compapiasynctask.FieldAuthToken, field.TypeString, value) _node.AuthToken = value } if value, ok := cac.mutation.EventType(); ok { _spec.SetField(compapiasynctask.FieldEventType, field.TypeString, value) _node.EventType = value } if value, ok := cac.mutation.ChatID(); ok { _spec.SetField(compapiasynctask.FieldChatID, field.TypeString, value) _node.ChatID = value } if value, ok := cac.mutation.ResponseChatItemID(); ok { _spec.SetField(compapiasynctask.FieldResponseChatItemID, field.TypeString, value) _node.ResponseChatItemID = value } if value, ok := cac.mutation.OrganizationID(); ok { _spec.SetField(compapiasynctask.FieldOrganizationID, field.TypeUint64, value) _node.OrganizationID = value } if value, ok := cac.mutation.OpenaiBase(); ok { _spec.SetField(compapiasynctask.FieldOpenaiBase, field.TypeString, value) _node.OpenaiBase = value } if value, ok := cac.mutation.OpenaiKey(); ok { _spec.SetField(compapiasynctask.FieldOpenaiKey, field.TypeString, value) _node.OpenaiKey = value } if value, ok := cac.mutation.RequestRaw(); ok { _spec.SetField(compapiasynctask.FieldRequestRaw, field.TypeString, value) _node.RequestRaw = value } if value, ok := cac.mutation.ResponseRaw(); ok { _spec.SetField(compapiasynctask.FieldResponseRaw, field.TypeString, value) _node.ResponseRaw = value } if value, ok := cac.mutation.CallbackURL(); ok { _spec.SetField(compapiasynctask.FieldCallbackURL, field.TypeString, value) _node.CallbackURL = value } if value, ok := cac.mutation.CallbackResponseRaw(); ok { _spec.SetField(compapiasynctask.FieldCallbackResponseRaw, field.TypeString, value) _node.CallbackResponseRaw = value } if value, ok := cac.mutation.Model(); ok { _spec.SetField(compapiasynctask.FieldModel, field.TypeString, value) _node.Model = value } if value, ok := cac.mutation.TaskStatus(); ok { _spec.SetField(compapiasynctask.FieldTaskStatus, field.TypeInt8, value) _node.TaskStatus = value } if value, ok := cac.mutation.RetryCount(); ok { _spec.SetField(compapiasynctask.FieldRetryCount, field.TypeInt8, value) _node.RetryCount = value } if value, ok := cac.mutation.LastError(); ok { _spec.SetField(compapiasynctask.FieldLastError, field.TypeString, value) _node.LastError = value } return _node, _spec } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.CompapiAsynctask.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.CompapiAsynctaskUpsert) { // SetCreatedAt(v+v). // }). // Exec(ctx) func (cac *CompapiAsynctaskCreate) OnConflict(opts ...sql.ConflictOption) *CompapiAsynctaskUpsertOne { cac.conflict = opts return &CompapiAsynctaskUpsertOne{ create: cac, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.CompapiAsynctask.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (cac *CompapiAsynctaskCreate) OnConflictColumns(columns ...string) *CompapiAsynctaskUpsertOne { cac.conflict = append(cac.conflict, sql.ConflictColumns(columns...)) return &CompapiAsynctaskUpsertOne{ create: cac, } } type ( // CompapiAsynctaskUpsertOne is the builder for "upsert"-ing // one CompapiAsynctask node. CompapiAsynctaskUpsertOne struct { create *CompapiAsynctaskCreate } // CompapiAsynctaskUpsert is the "OnConflict" setter. CompapiAsynctaskUpsert struct { *sql.UpdateSet } ) // SetUpdatedAt sets the "updated_at" field. func (u *CompapiAsynctaskUpsert) SetUpdatedAt(v time.Time) *CompapiAsynctaskUpsert { u.Set(compapiasynctask.FieldUpdatedAt, v) return u } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *CompapiAsynctaskUpsert) UpdateUpdatedAt() *CompapiAsynctaskUpsert { u.SetExcluded(compapiasynctask.FieldUpdatedAt) return u } // SetAuthToken sets the "auth_token" field. func (u *CompapiAsynctaskUpsert) SetAuthToken(v string) *CompapiAsynctaskUpsert { u.Set(compapiasynctask.FieldAuthToken, v) return u } // UpdateAuthToken sets the "auth_token" field to the value that was provided on create. func (u *CompapiAsynctaskUpsert) UpdateAuthToken() *CompapiAsynctaskUpsert { u.SetExcluded(compapiasynctask.FieldAuthToken) return u } // SetEventType sets the "event_type" field. func (u *CompapiAsynctaskUpsert) SetEventType(v string) *CompapiAsynctaskUpsert { u.Set(compapiasynctask.FieldEventType, v) return u } // UpdateEventType sets the "event_type" field to the value that was provided on create. func (u *CompapiAsynctaskUpsert) UpdateEventType() *CompapiAsynctaskUpsert { u.SetExcluded(compapiasynctask.FieldEventType) return u } // SetChatID sets the "chat_id" field. func (u *CompapiAsynctaskUpsert) SetChatID(v string) *CompapiAsynctaskUpsert { u.Set(compapiasynctask.FieldChatID, v) return u } // UpdateChatID sets the "chat_id" field to the value that was provided on create. func (u *CompapiAsynctaskUpsert) UpdateChatID() *CompapiAsynctaskUpsert { u.SetExcluded(compapiasynctask.FieldChatID) return u } // ClearChatID clears the value of the "chat_id" field. func (u *CompapiAsynctaskUpsert) ClearChatID() *CompapiAsynctaskUpsert { u.SetNull(compapiasynctask.FieldChatID) return u } // SetResponseChatItemID sets the "response_chat_item_id" field. func (u *CompapiAsynctaskUpsert) SetResponseChatItemID(v string) *CompapiAsynctaskUpsert { u.Set(compapiasynctask.FieldResponseChatItemID, v) return u } // UpdateResponseChatItemID sets the "response_chat_item_id" field to the value that was provided on create. func (u *CompapiAsynctaskUpsert) UpdateResponseChatItemID() *CompapiAsynctaskUpsert { u.SetExcluded(compapiasynctask.FieldResponseChatItemID) return u } // ClearResponseChatItemID clears the value of the "response_chat_item_id" field. func (u *CompapiAsynctaskUpsert) ClearResponseChatItemID() *CompapiAsynctaskUpsert { u.SetNull(compapiasynctask.FieldResponseChatItemID) return u } // SetOrganizationID sets the "organization_id" field. func (u *CompapiAsynctaskUpsert) SetOrganizationID(v uint64) *CompapiAsynctaskUpsert { u.Set(compapiasynctask.FieldOrganizationID, v) return u } // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create. func (u *CompapiAsynctaskUpsert) UpdateOrganizationID() *CompapiAsynctaskUpsert { u.SetExcluded(compapiasynctask.FieldOrganizationID) return u } // AddOrganizationID adds v to the "organization_id" field. func (u *CompapiAsynctaskUpsert) AddOrganizationID(v uint64) *CompapiAsynctaskUpsert { u.Add(compapiasynctask.FieldOrganizationID, v) return u } // SetOpenaiBase sets the "openai_base" field. func (u *CompapiAsynctaskUpsert) SetOpenaiBase(v string) *CompapiAsynctaskUpsert { u.Set(compapiasynctask.FieldOpenaiBase, v) return u } // UpdateOpenaiBase sets the "openai_base" field to the value that was provided on create. func (u *CompapiAsynctaskUpsert) UpdateOpenaiBase() *CompapiAsynctaskUpsert { u.SetExcluded(compapiasynctask.FieldOpenaiBase) return u } // SetOpenaiKey sets the "openai_key" field. func (u *CompapiAsynctaskUpsert) SetOpenaiKey(v string) *CompapiAsynctaskUpsert { u.Set(compapiasynctask.FieldOpenaiKey, v) return u } // UpdateOpenaiKey sets the "openai_key" field to the value that was provided on create. func (u *CompapiAsynctaskUpsert) UpdateOpenaiKey() *CompapiAsynctaskUpsert { u.SetExcluded(compapiasynctask.FieldOpenaiKey) return u } // SetRequestRaw sets the "request_raw" field. func (u *CompapiAsynctaskUpsert) SetRequestRaw(v string) *CompapiAsynctaskUpsert { u.Set(compapiasynctask.FieldRequestRaw, v) return u } // UpdateRequestRaw sets the "request_raw" field to the value that was provided on create. func (u *CompapiAsynctaskUpsert) UpdateRequestRaw() *CompapiAsynctaskUpsert { u.SetExcluded(compapiasynctask.FieldRequestRaw) return u } // SetResponseRaw sets the "response_raw" field. func (u *CompapiAsynctaskUpsert) SetResponseRaw(v string) *CompapiAsynctaskUpsert { u.Set(compapiasynctask.FieldResponseRaw, v) return u } // UpdateResponseRaw sets the "response_raw" field to the value that was provided on create. func (u *CompapiAsynctaskUpsert) UpdateResponseRaw() *CompapiAsynctaskUpsert { u.SetExcluded(compapiasynctask.FieldResponseRaw) return u } // ClearResponseRaw clears the value of the "response_raw" field. func (u *CompapiAsynctaskUpsert) ClearResponseRaw() *CompapiAsynctaskUpsert { u.SetNull(compapiasynctask.FieldResponseRaw) return u } // SetCallbackURL sets the "callback_url" field. func (u *CompapiAsynctaskUpsert) SetCallbackURL(v string) *CompapiAsynctaskUpsert { u.Set(compapiasynctask.FieldCallbackURL, v) return u } // UpdateCallbackURL sets the "callback_url" field to the value that was provided on create. func (u *CompapiAsynctaskUpsert) UpdateCallbackURL() *CompapiAsynctaskUpsert { u.SetExcluded(compapiasynctask.FieldCallbackURL) return u } // SetCallbackResponseRaw sets the "callback_response_raw" field. func (u *CompapiAsynctaskUpsert) SetCallbackResponseRaw(v string) *CompapiAsynctaskUpsert { u.Set(compapiasynctask.FieldCallbackResponseRaw, v) return u } // UpdateCallbackResponseRaw sets the "callback_response_raw" field to the value that was provided on create. func (u *CompapiAsynctaskUpsert) UpdateCallbackResponseRaw() *CompapiAsynctaskUpsert { u.SetExcluded(compapiasynctask.FieldCallbackResponseRaw) return u } // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field. func (u *CompapiAsynctaskUpsert) ClearCallbackResponseRaw() *CompapiAsynctaskUpsert { u.SetNull(compapiasynctask.FieldCallbackResponseRaw) return u } // SetModel sets the "model" field. func (u *CompapiAsynctaskUpsert) SetModel(v string) *CompapiAsynctaskUpsert { u.Set(compapiasynctask.FieldModel, v) return u } // UpdateModel sets the "model" field to the value that was provided on create. func (u *CompapiAsynctaskUpsert) UpdateModel() *CompapiAsynctaskUpsert { u.SetExcluded(compapiasynctask.FieldModel) return u } // ClearModel clears the value of the "model" field. func (u *CompapiAsynctaskUpsert) ClearModel() *CompapiAsynctaskUpsert { u.SetNull(compapiasynctask.FieldModel) return u } // SetTaskStatus sets the "task_status" field. func (u *CompapiAsynctaskUpsert) SetTaskStatus(v int8) *CompapiAsynctaskUpsert { u.Set(compapiasynctask.FieldTaskStatus, v) return u } // UpdateTaskStatus sets the "task_status" field to the value that was provided on create. func (u *CompapiAsynctaskUpsert) UpdateTaskStatus() *CompapiAsynctaskUpsert { u.SetExcluded(compapiasynctask.FieldTaskStatus) return u } // AddTaskStatus adds v to the "task_status" field. func (u *CompapiAsynctaskUpsert) AddTaskStatus(v int8) *CompapiAsynctaskUpsert { u.Add(compapiasynctask.FieldTaskStatus, v) return u } // ClearTaskStatus clears the value of the "task_status" field. func (u *CompapiAsynctaskUpsert) ClearTaskStatus() *CompapiAsynctaskUpsert { u.SetNull(compapiasynctask.FieldTaskStatus) return u } // SetRetryCount sets the "retry_count" field. func (u *CompapiAsynctaskUpsert) SetRetryCount(v int8) *CompapiAsynctaskUpsert { u.Set(compapiasynctask.FieldRetryCount, v) return u } // UpdateRetryCount sets the "retry_count" field to the value that was provided on create. func (u *CompapiAsynctaskUpsert) UpdateRetryCount() *CompapiAsynctaskUpsert { u.SetExcluded(compapiasynctask.FieldRetryCount) return u } // AddRetryCount adds v to the "retry_count" field. func (u *CompapiAsynctaskUpsert) AddRetryCount(v int8) *CompapiAsynctaskUpsert { u.Add(compapiasynctask.FieldRetryCount, v) return u } // ClearRetryCount clears the value of the "retry_count" field. func (u *CompapiAsynctaskUpsert) ClearRetryCount() *CompapiAsynctaskUpsert { u.SetNull(compapiasynctask.FieldRetryCount) return u } // SetLastError sets the "last_error" field. func (u *CompapiAsynctaskUpsert) SetLastError(v string) *CompapiAsynctaskUpsert { u.Set(compapiasynctask.FieldLastError, v) return u } // UpdateLastError sets the "last_error" field to the value that was provided on create. func (u *CompapiAsynctaskUpsert) UpdateLastError() *CompapiAsynctaskUpsert { u.SetExcluded(compapiasynctask.FieldLastError) return u } // ClearLastError clears the value of the "last_error" field. func (u *CompapiAsynctaskUpsert) ClearLastError() *CompapiAsynctaskUpsert { u.SetNull(compapiasynctask.FieldLastError) 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.CompapiAsynctask.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(compapiasynctask.FieldID) // }), // ). // Exec(ctx) func (u *CompapiAsynctaskUpsertOne) UpdateNewValues() *CompapiAsynctaskUpsertOne { 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(compapiasynctask.FieldID) } if _, exists := u.create.mutation.CreatedAt(); exists { s.SetIgnore(compapiasynctask.FieldCreatedAt) } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.CompapiAsynctask.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *CompapiAsynctaskUpsertOne) Ignore() *CompapiAsynctaskUpsertOne { 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 *CompapiAsynctaskUpsertOne) DoNothing() *CompapiAsynctaskUpsertOne { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the CompapiAsynctaskCreate.OnConflict // documentation for more info. func (u *CompapiAsynctaskUpsertOne) Update(set func(*CompapiAsynctaskUpsert)) *CompapiAsynctaskUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&CompapiAsynctaskUpsert{UpdateSet: update}) })) return u } // SetUpdatedAt sets the "updated_at" field. func (u *CompapiAsynctaskUpsertOne) SetUpdatedAt(v time.Time) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetUpdatedAt(v) }) } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertOne) UpdateUpdatedAt() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateUpdatedAt() }) } // SetAuthToken sets the "auth_token" field. func (u *CompapiAsynctaskUpsertOne) SetAuthToken(v string) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetAuthToken(v) }) } // UpdateAuthToken sets the "auth_token" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertOne) UpdateAuthToken() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateAuthToken() }) } // SetEventType sets the "event_type" field. func (u *CompapiAsynctaskUpsertOne) SetEventType(v string) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetEventType(v) }) } // UpdateEventType sets the "event_type" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertOne) UpdateEventType() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateEventType() }) } // SetChatID sets the "chat_id" field. func (u *CompapiAsynctaskUpsertOne) SetChatID(v string) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetChatID(v) }) } // UpdateChatID sets the "chat_id" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertOne) UpdateChatID() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateChatID() }) } // ClearChatID clears the value of the "chat_id" field. func (u *CompapiAsynctaskUpsertOne) ClearChatID() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.ClearChatID() }) } // SetResponseChatItemID sets the "response_chat_item_id" field. func (u *CompapiAsynctaskUpsertOne) SetResponseChatItemID(v string) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetResponseChatItemID(v) }) } // UpdateResponseChatItemID sets the "response_chat_item_id" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertOne) UpdateResponseChatItemID() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateResponseChatItemID() }) } // ClearResponseChatItemID clears the value of the "response_chat_item_id" field. func (u *CompapiAsynctaskUpsertOne) ClearResponseChatItemID() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.ClearResponseChatItemID() }) } // SetOrganizationID sets the "organization_id" field. func (u *CompapiAsynctaskUpsertOne) SetOrganizationID(v uint64) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetOrganizationID(v) }) } // AddOrganizationID adds v to the "organization_id" field. func (u *CompapiAsynctaskUpsertOne) AddOrganizationID(v uint64) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.AddOrganizationID(v) }) } // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertOne) UpdateOrganizationID() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateOrganizationID() }) } // SetOpenaiBase sets the "openai_base" field. func (u *CompapiAsynctaskUpsertOne) SetOpenaiBase(v string) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetOpenaiBase(v) }) } // UpdateOpenaiBase sets the "openai_base" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertOne) UpdateOpenaiBase() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateOpenaiBase() }) } // SetOpenaiKey sets the "openai_key" field. func (u *CompapiAsynctaskUpsertOne) SetOpenaiKey(v string) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetOpenaiKey(v) }) } // UpdateOpenaiKey sets the "openai_key" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertOne) UpdateOpenaiKey() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateOpenaiKey() }) } // SetRequestRaw sets the "request_raw" field. func (u *CompapiAsynctaskUpsertOne) SetRequestRaw(v string) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetRequestRaw(v) }) } // UpdateRequestRaw sets the "request_raw" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertOne) UpdateRequestRaw() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateRequestRaw() }) } // SetResponseRaw sets the "response_raw" field. func (u *CompapiAsynctaskUpsertOne) SetResponseRaw(v string) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetResponseRaw(v) }) } // UpdateResponseRaw sets the "response_raw" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertOne) UpdateResponseRaw() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateResponseRaw() }) } // ClearResponseRaw clears the value of the "response_raw" field. func (u *CompapiAsynctaskUpsertOne) ClearResponseRaw() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.ClearResponseRaw() }) } // SetCallbackURL sets the "callback_url" field. func (u *CompapiAsynctaskUpsertOne) SetCallbackURL(v string) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetCallbackURL(v) }) } // UpdateCallbackURL sets the "callback_url" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertOne) UpdateCallbackURL() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateCallbackURL() }) } // SetCallbackResponseRaw sets the "callback_response_raw" field. func (u *CompapiAsynctaskUpsertOne) SetCallbackResponseRaw(v string) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetCallbackResponseRaw(v) }) } // UpdateCallbackResponseRaw sets the "callback_response_raw" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertOne) UpdateCallbackResponseRaw() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateCallbackResponseRaw() }) } // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field. func (u *CompapiAsynctaskUpsertOne) ClearCallbackResponseRaw() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.ClearCallbackResponseRaw() }) } // SetModel sets the "model" field. func (u *CompapiAsynctaskUpsertOne) SetModel(v string) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetModel(v) }) } // UpdateModel sets the "model" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertOne) UpdateModel() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateModel() }) } // ClearModel clears the value of the "model" field. func (u *CompapiAsynctaskUpsertOne) ClearModel() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.ClearModel() }) } // SetTaskStatus sets the "task_status" field. func (u *CompapiAsynctaskUpsertOne) SetTaskStatus(v int8) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetTaskStatus(v) }) } // AddTaskStatus adds v to the "task_status" field. func (u *CompapiAsynctaskUpsertOne) AddTaskStatus(v int8) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.AddTaskStatus(v) }) } // UpdateTaskStatus sets the "task_status" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertOne) UpdateTaskStatus() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateTaskStatus() }) } // ClearTaskStatus clears the value of the "task_status" field. func (u *CompapiAsynctaskUpsertOne) ClearTaskStatus() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.ClearTaskStatus() }) } // SetRetryCount sets the "retry_count" field. func (u *CompapiAsynctaskUpsertOne) SetRetryCount(v int8) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetRetryCount(v) }) } // AddRetryCount adds v to the "retry_count" field. func (u *CompapiAsynctaskUpsertOne) AddRetryCount(v int8) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.AddRetryCount(v) }) } // UpdateRetryCount sets the "retry_count" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertOne) UpdateRetryCount() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateRetryCount() }) } // ClearRetryCount clears the value of the "retry_count" field. func (u *CompapiAsynctaskUpsertOne) ClearRetryCount() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.ClearRetryCount() }) } // SetLastError sets the "last_error" field. func (u *CompapiAsynctaskUpsertOne) SetLastError(v string) *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetLastError(v) }) } // UpdateLastError sets the "last_error" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertOne) UpdateLastError() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateLastError() }) } // ClearLastError clears the value of the "last_error" field. func (u *CompapiAsynctaskUpsertOne) ClearLastError() *CompapiAsynctaskUpsertOne { return u.Update(func(s *CompapiAsynctaskUpsert) { s.ClearLastError() }) } // Exec executes the query. func (u *CompapiAsynctaskUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { return errors.New("ent: missing options for CompapiAsynctaskCreate.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *CompapiAsynctaskUpsertOne) 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 *CompapiAsynctaskUpsertOne) 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 *CompapiAsynctaskUpsertOne) IDX(ctx context.Context) uint64 { id, err := u.ID(ctx) if err != nil { panic(err) } return id } // CompapiAsynctaskCreateBulk is the builder for creating many CompapiAsynctask entities in bulk. type CompapiAsynctaskCreateBulk struct { config err error builders []*CompapiAsynctaskCreate conflict []sql.ConflictOption } // Save creates the CompapiAsynctask entities in the database. func (cacb *CompapiAsynctaskCreateBulk) Save(ctx context.Context) ([]*CompapiAsynctask, error) { if cacb.err != nil { return nil, cacb.err } specs := make([]*sqlgraph.CreateSpec, len(cacb.builders)) nodes := make([]*CompapiAsynctask, len(cacb.builders)) mutators := make([]Mutator, len(cacb.builders)) for i := range cacb.builders { func(i int, root context.Context) { builder := cacb.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*CompapiAsynctaskMutation) 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, cacb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} spec.OnConflict = cacb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, cacb.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, cacb.builders[0].mutation); err != nil { return nil, err } } return nodes, nil } // SaveX is like Save, but panics if an error occurs. func (cacb *CompapiAsynctaskCreateBulk) SaveX(ctx context.Context) []*CompapiAsynctask { v, err := cacb.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (cacb *CompapiAsynctaskCreateBulk) Exec(ctx context.Context) error { _, err := cacb.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (cacb *CompapiAsynctaskCreateBulk) ExecX(ctx context.Context) { if err := cacb.Exec(ctx); err != nil { panic(err) } } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.CompapiAsynctask.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.CompapiAsynctaskUpsert) { // SetCreatedAt(v+v). // }). // Exec(ctx) func (cacb *CompapiAsynctaskCreateBulk) OnConflict(opts ...sql.ConflictOption) *CompapiAsynctaskUpsertBulk { cacb.conflict = opts return &CompapiAsynctaskUpsertBulk{ create: cacb, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.CompapiAsynctask.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (cacb *CompapiAsynctaskCreateBulk) OnConflictColumns(columns ...string) *CompapiAsynctaskUpsertBulk { cacb.conflict = append(cacb.conflict, sql.ConflictColumns(columns...)) return &CompapiAsynctaskUpsertBulk{ create: cacb, } } // CompapiAsynctaskUpsertBulk is the builder for "upsert"-ing // a bulk of CompapiAsynctask nodes. type CompapiAsynctaskUpsertBulk struct { create *CompapiAsynctaskCreateBulk } // UpdateNewValues updates the mutable fields using the new values that // were set on create. Using this option is equivalent to using: // // client.CompapiAsynctask.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(compapiasynctask.FieldID) // }), // ). // Exec(ctx) func (u *CompapiAsynctaskUpsertBulk) UpdateNewValues() *CompapiAsynctaskUpsertBulk { 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(compapiasynctask.FieldID) } if _, exists := b.mutation.CreatedAt(); exists { s.SetIgnore(compapiasynctask.FieldCreatedAt) } } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.CompapiAsynctask.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *CompapiAsynctaskUpsertBulk) Ignore() *CompapiAsynctaskUpsertBulk { 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 *CompapiAsynctaskUpsertBulk) DoNothing() *CompapiAsynctaskUpsertBulk { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the CompapiAsynctaskCreateBulk.OnConflict // documentation for more info. func (u *CompapiAsynctaskUpsertBulk) Update(set func(*CompapiAsynctaskUpsert)) *CompapiAsynctaskUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&CompapiAsynctaskUpsert{UpdateSet: update}) })) return u } // SetUpdatedAt sets the "updated_at" field. func (u *CompapiAsynctaskUpsertBulk) SetUpdatedAt(v time.Time) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetUpdatedAt(v) }) } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertBulk) UpdateUpdatedAt() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateUpdatedAt() }) } // SetAuthToken sets the "auth_token" field. func (u *CompapiAsynctaskUpsertBulk) SetAuthToken(v string) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetAuthToken(v) }) } // UpdateAuthToken sets the "auth_token" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertBulk) UpdateAuthToken() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateAuthToken() }) } // SetEventType sets the "event_type" field. func (u *CompapiAsynctaskUpsertBulk) SetEventType(v string) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetEventType(v) }) } // UpdateEventType sets the "event_type" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertBulk) UpdateEventType() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateEventType() }) } // SetChatID sets the "chat_id" field. func (u *CompapiAsynctaskUpsertBulk) SetChatID(v string) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetChatID(v) }) } // UpdateChatID sets the "chat_id" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertBulk) UpdateChatID() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateChatID() }) } // ClearChatID clears the value of the "chat_id" field. func (u *CompapiAsynctaskUpsertBulk) ClearChatID() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.ClearChatID() }) } // SetResponseChatItemID sets the "response_chat_item_id" field. func (u *CompapiAsynctaskUpsertBulk) SetResponseChatItemID(v string) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetResponseChatItemID(v) }) } // UpdateResponseChatItemID sets the "response_chat_item_id" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertBulk) UpdateResponseChatItemID() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateResponseChatItemID() }) } // ClearResponseChatItemID clears the value of the "response_chat_item_id" field. func (u *CompapiAsynctaskUpsertBulk) ClearResponseChatItemID() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.ClearResponseChatItemID() }) } // SetOrganizationID sets the "organization_id" field. func (u *CompapiAsynctaskUpsertBulk) SetOrganizationID(v uint64) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetOrganizationID(v) }) } // AddOrganizationID adds v to the "organization_id" field. func (u *CompapiAsynctaskUpsertBulk) AddOrganizationID(v uint64) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.AddOrganizationID(v) }) } // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertBulk) UpdateOrganizationID() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateOrganizationID() }) } // SetOpenaiBase sets the "openai_base" field. func (u *CompapiAsynctaskUpsertBulk) SetOpenaiBase(v string) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetOpenaiBase(v) }) } // UpdateOpenaiBase sets the "openai_base" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertBulk) UpdateOpenaiBase() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateOpenaiBase() }) } // SetOpenaiKey sets the "openai_key" field. func (u *CompapiAsynctaskUpsertBulk) SetOpenaiKey(v string) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetOpenaiKey(v) }) } // UpdateOpenaiKey sets the "openai_key" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertBulk) UpdateOpenaiKey() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateOpenaiKey() }) } // SetRequestRaw sets the "request_raw" field. func (u *CompapiAsynctaskUpsertBulk) SetRequestRaw(v string) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetRequestRaw(v) }) } // UpdateRequestRaw sets the "request_raw" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertBulk) UpdateRequestRaw() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateRequestRaw() }) } // SetResponseRaw sets the "response_raw" field. func (u *CompapiAsynctaskUpsertBulk) SetResponseRaw(v string) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetResponseRaw(v) }) } // UpdateResponseRaw sets the "response_raw" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertBulk) UpdateResponseRaw() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateResponseRaw() }) } // ClearResponseRaw clears the value of the "response_raw" field. func (u *CompapiAsynctaskUpsertBulk) ClearResponseRaw() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.ClearResponseRaw() }) } // SetCallbackURL sets the "callback_url" field. func (u *CompapiAsynctaskUpsertBulk) SetCallbackURL(v string) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetCallbackURL(v) }) } // UpdateCallbackURL sets the "callback_url" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertBulk) UpdateCallbackURL() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateCallbackURL() }) } // SetCallbackResponseRaw sets the "callback_response_raw" field. func (u *CompapiAsynctaskUpsertBulk) SetCallbackResponseRaw(v string) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetCallbackResponseRaw(v) }) } // UpdateCallbackResponseRaw sets the "callback_response_raw" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertBulk) UpdateCallbackResponseRaw() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateCallbackResponseRaw() }) } // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field. func (u *CompapiAsynctaskUpsertBulk) ClearCallbackResponseRaw() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.ClearCallbackResponseRaw() }) } // SetModel sets the "model" field. func (u *CompapiAsynctaskUpsertBulk) SetModel(v string) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetModel(v) }) } // UpdateModel sets the "model" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertBulk) UpdateModel() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateModel() }) } // ClearModel clears the value of the "model" field. func (u *CompapiAsynctaskUpsertBulk) ClearModel() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.ClearModel() }) } // SetTaskStatus sets the "task_status" field. func (u *CompapiAsynctaskUpsertBulk) SetTaskStatus(v int8) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetTaskStatus(v) }) } // AddTaskStatus adds v to the "task_status" field. func (u *CompapiAsynctaskUpsertBulk) AddTaskStatus(v int8) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.AddTaskStatus(v) }) } // UpdateTaskStatus sets the "task_status" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertBulk) UpdateTaskStatus() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateTaskStatus() }) } // ClearTaskStatus clears the value of the "task_status" field. func (u *CompapiAsynctaskUpsertBulk) ClearTaskStatus() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.ClearTaskStatus() }) } // SetRetryCount sets the "retry_count" field. func (u *CompapiAsynctaskUpsertBulk) SetRetryCount(v int8) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetRetryCount(v) }) } // AddRetryCount adds v to the "retry_count" field. func (u *CompapiAsynctaskUpsertBulk) AddRetryCount(v int8) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.AddRetryCount(v) }) } // UpdateRetryCount sets the "retry_count" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertBulk) UpdateRetryCount() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateRetryCount() }) } // ClearRetryCount clears the value of the "retry_count" field. func (u *CompapiAsynctaskUpsertBulk) ClearRetryCount() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.ClearRetryCount() }) } // SetLastError sets the "last_error" field. func (u *CompapiAsynctaskUpsertBulk) SetLastError(v string) *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.SetLastError(v) }) } // UpdateLastError sets the "last_error" field to the value that was provided on create. func (u *CompapiAsynctaskUpsertBulk) UpdateLastError() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.UpdateLastError() }) } // ClearLastError clears the value of the "last_error" field. func (u *CompapiAsynctaskUpsertBulk) ClearLastError() *CompapiAsynctaskUpsertBulk { return u.Update(func(s *CompapiAsynctaskUpsert) { s.ClearLastError() }) } // Exec executes the query. func (u *CompapiAsynctaskUpsertBulk) 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 CompapiAsynctaskCreateBulk instead", i) } } if len(u.create.conflict) == 0 { return errors.New("ent: missing options for CompapiAsynctaskCreateBulk.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *CompapiAsynctaskUpsertBulk) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } }