12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421 |
- // 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
- }
- // SetWorkidIdx sets the "workid_idx" field.
- func (cac *CompapiAsynctaskCreate) SetWorkidIdx(i int8) *CompapiAsynctaskCreate {
- cac.mutation.SetWorkidIdx(i)
- return cac
- }
- // SetNillableWorkidIdx sets the "workid_idx" field if the given value is not nil.
- func (cac *CompapiAsynctaskCreate) SetNillableWorkidIdx(i *int8) *CompapiAsynctaskCreate {
- if i != nil {
- cac.SetWorkidIdx(*i)
- }
- 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
- }
- // 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.WorkidIdx(); !ok {
- v := compapiasynctask.DefaultWorkidIdx
- cac.mutation.SetWorkidIdx(v)
- }
- if _, ok := cac.mutation.ResponseRaw(); !ok {
- v := compapiasynctask.DefaultResponseRaw
- cac.mutation.SetResponseRaw(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.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.WorkidIdx(); ok {
- _spec.SetField(compapiasynctask.FieldWorkidIdx, field.TypeInt8, value)
- _node.WorkidIdx = 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.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
- }
- // SetWorkidIdx sets the "workid_idx" field.
- func (u *CompapiAsynctaskUpsert) SetWorkidIdx(v int8) *CompapiAsynctaskUpsert {
- u.Set(compapiasynctask.FieldWorkidIdx, v)
- return u
- }
- // UpdateWorkidIdx sets the "workid_idx" field to the value that was provided on create.
- func (u *CompapiAsynctaskUpsert) UpdateWorkidIdx() *CompapiAsynctaskUpsert {
- u.SetExcluded(compapiasynctask.FieldWorkidIdx)
- return u
- }
- // AddWorkidIdx adds v to the "workid_idx" field.
- func (u *CompapiAsynctaskUpsert) AddWorkidIdx(v int8) *CompapiAsynctaskUpsert {
- u.Add(compapiasynctask.FieldWorkidIdx, v)
- return u
- }
- // ClearWorkidIdx clears the value of the "workid_idx" field.
- func (u *CompapiAsynctaskUpsert) ClearWorkidIdx() *CompapiAsynctaskUpsert {
- u.SetNull(compapiasynctask.FieldWorkidIdx)
- 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
- }
- // 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()
- })
- }
- // SetWorkidIdx sets the "workid_idx" field.
- func (u *CompapiAsynctaskUpsertOne) SetWorkidIdx(v int8) *CompapiAsynctaskUpsertOne {
- return u.Update(func(s *CompapiAsynctaskUpsert) {
- s.SetWorkidIdx(v)
- })
- }
- // AddWorkidIdx adds v to the "workid_idx" field.
- func (u *CompapiAsynctaskUpsertOne) AddWorkidIdx(v int8) *CompapiAsynctaskUpsertOne {
- return u.Update(func(s *CompapiAsynctaskUpsert) {
- s.AddWorkidIdx(v)
- })
- }
- // UpdateWorkidIdx sets the "workid_idx" field to the value that was provided on create.
- func (u *CompapiAsynctaskUpsertOne) UpdateWorkidIdx() *CompapiAsynctaskUpsertOne {
- return u.Update(func(s *CompapiAsynctaskUpsert) {
- s.UpdateWorkidIdx()
- })
- }
- // ClearWorkidIdx clears the value of the "workid_idx" field.
- func (u *CompapiAsynctaskUpsertOne) ClearWorkidIdx() *CompapiAsynctaskUpsertOne {
- return u.Update(func(s *CompapiAsynctaskUpsert) {
- s.ClearWorkidIdx()
- })
- }
- // 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()
- })
- }
- // 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()
- })
- }
- // SetWorkidIdx sets the "workid_idx" field.
- func (u *CompapiAsynctaskUpsertBulk) SetWorkidIdx(v int8) *CompapiAsynctaskUpsertBulk {
- return u.Update(func(s *CompapiAsynctaskUpsert) {
- s.SetWorkidIdx(v)
- })
- }
- // AddWorkidIdx adds v to the "workid_idx" field.
- func (u *CompapiAsynctaskUpsertBulk) AddWorkidIdx(v int8) *CompapiAsynctaskUpsertBulk {
- return u.Update(func(s *CompapiAsynctaskUpsert) {
- s.AddWorkidIdx(v)
- })
- }
- // UpdateWorkidIdx sets the "workid_idx" field to the value that was provided on create.
- func (u *CompapiAsynctaskUpsertBulk) UpdateWorkidIdx() *CompapiAsynctaskUpsertBulk {
- return u.Update(func(s *CompapiAsynctaskUpsert) {
- s.UpdateWorkidIdx()
- })
- }
- // ClearWorkidIdx clears the value of the "workid_idx" field.
- func (u *CompapiAsynctaskUpsertBulk) ClearWorkidIdx() *CompapiAsynctaskUpsertBulk {
- return u.Update(func(s *CompapiAsynctaskUpsert) {
- s.ClearWorkidIdx()
- })
- }
- // 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()
- })
- }
- // 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)
- }
- }
|