1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561 |
- // 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
- }
- // 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.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.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
- }
- // 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()
- })
- }
- // 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()
- })
- }
- // 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)
- }
- }
|