compapiasynctask_create.go 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "time"
  8. "wechat-api/ent/compapiasynctask"
  9. "entgo.io/ent/dialect/sql"
  10. "entgo.io/ent/dialect/sql/sqlgraph"
  11. "entgo.io/ent/schema/field"
  12. )
  13. // CompapiAsynctaskCreate is the builder for creating a CompapiAsynctask entity.
  14. type CompapiAsynctaskCreate struct {
  15. config
  16. mutation *CompapiAsynctaskMutation
  17. hooks []Hook
  18. conflict []sql.ConflictOption
  19. }
  20. // SetCreatedAt sets the "created_at" field.
  21. func (cac *CompapiAsynctaskCreate) SetCreatedAt(t time.Time) *CompapiAsynctaskCreate {
  22. cac.mutation.SetCreatedAt(t)
  23. return cac
  24. }
  25. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  26. func (cac *CompapiAsynctaskCreate) SetNillableCreatedAt(t *time.Time) *CompapiAsynctaskCreate {
  27. if t != nil {
  28. cac.SetCreatedAt(*t)
  29. }
  30. return cac
  31. }
  32. // SetUpdatedAt sets the "updated_at" field.
  33. func (cac *CompapiAsynctaskCreate) SetUpdatedAt(t time.Time) *CompapiAsynctaskCreate {
  34. cac.mutation.SetUpdatedAt(t)
  35. return cac
  36. }
  37. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  38. func (cac *CompapiAsynctaskCreate) SetNillableUpdatedAt(t *time.Time) *CompapiAsynctaskCreate {
  39. if t != nil {
  40. cac.SetUpdatedAt(*t)
  41. }
  42. return cac
  43. }
  44. // SetAuthToken sets the "auth_token" field.
  45. func (cac *CompapiAsynctaskCreate) SetAuthToken(s string) *CompapiAsynctaskCreate {
  46. cac.mutation.SetAuthToken(s)
  47. return cac
  48. }
  49. // SetEventType sets the "event_type" field.
  50. func (cac *CompapiAsynctaskCreate) SetEventType(s string) *CompapiAsynctaskCreate {
  51. cac.mutation.SetEventType(s)
  52. return cac
  53. }
  54. // SetNillableEventType sets the "event_type" field if the given value is not nil.
  55. func (cac *CompapiAsynctaskCreate) SetNillableEventType(s *string) *CompapiAsynctaskCreate {
  56. if s != nil {
  57. cac.SetEventType(*s)
  58. }
  59. return cac
  60. }
  61. // SetChatID sets the "chat_id" field.
  62. func (cac *CompapiAsynctaskCreate) SetChatID(s string) *CompapiAsynctaskCreate {
  63. cac.mutation.SetChatID(s)
  64. return cac
  65. }
  66. // SetNillableChatID sets the "chat_id" field if the given value is not nil.
  67. func (cac *CompapiAsynctaskCreate) SetNillableChatID(s *string) *CompapiAsynctaskCreate {
  68. if s != nil {
  69. cac.SetChatID(*s)
  70. }
  71. return cac
  72. }
  73. // SetOrganizationID sets the "organization_id" field.
  74. func (cac *CompapiAsynctaskCreate) SetOrganizationID(u uint64) *CompapiAsynctaskCreate {
  75. cac.mutation.SetOrganizationID(u)
  76. return cac
  77. }
  78. // SetOpenaiBase sets the "openai_base" field.
  79. func (cac *CompapiAsynctaskCreate) SetOpenaiBase(s string) *CompapiAsynctaskCreate {
  80. cac.mutation.SetOpenaiBase(s)
  81. return cac
  82. }
  83. // SetOpenaiKey sets the "openai_key" field.
  84. func (cac *CompapiAsynctaskCreate) SetOpenaiKey(s string) *CompapiAsynctaskCreate {
  85. cac.mutation.SetOpenaiKey(s)
  86. return cac
  87. }
  88. // SetRequestRaw sets the "request_raw" field.
  89. func (cac *CompapiAsynctaskCreate) SetRequestRaw(s string) *CompapiAsynctaskCreate {
  90. cac.mutation.SetRequestRaw(s)
  91. return cac
  92. }
  93. // SetResponseRaw sets the "response_raw" field.
  94. func (cac *CompapiAsynctaskCreate) SetResponseRaw(s string) *CompapiAsynctaskCreate {
  95. cac.mutation.SetResponseRaw(s)
  96. return cac
  97. }
  98. // SetNillableResponseRaw sets the "response_raw" field if the given value is not nil.
  99. func (cac *CompapiAsynctaskCreate) SetNillableResponseRaw(s *string) *CompapiAsynctaskCreate {
  100. if s != nil {
  101. cac.SetResponseRaw(*s)
  102. }
  103. return cac
  104. }
  105. // SetCallbackURL sets the "callback_url" field.
  106. func (cac *CompapiAsynctaskCreate) SetCallbackURL(s string) *CompapiAsynctaskCreate {
  107. cac.mutation.SetCallbackURL(s)
  108. return cac
  109. }
  110. // SetCallbackResponseRaw sets the "callback_response_raw" field.
  111. func (cac *CompapiAsynctaskCreate) SetCallbackResponseRaw(s string) *CompapiAsynctaskCreate {
  112. cac.mutation.SetCallbackResponseRaw(s)
  113. return cac
  114. }
  115. // SetNillableCallbackResponseRaw sets the "callback_response_raw" field if the given value is not nil.
  116. func (cac *CompapiAsynctaskCreate) SetNillableCallbackResponseRaw(s *string) *CompapiAsynctaskCreate {
  117. if s != nil {
  118. cac.SetCallbackResponseRaw(*s)
  119. }
  120. return cac
  121. }
  122. // SetModel sets the "model" field.
  123. func (cac *CompapiAsynctaskCreate) SetModel(s string) *CompapiAsynctaskCreate {
  124. cac.mutation.SetModel(s)
  125. return cac
  126. }
  127. // SetNillableModel sets the "model" field if the given value is not nil.
  128. func (cac *CompapiAsynctaskCreate) SetNillableModel(s *string) *CompapiAsynctaskCreate {
  129. if s != nil {
  130. cac.SetModel(*s)
  131. }
  132. return cac
  133. }
  134. // SetTaskStatus sets the "task_status" field.
  135. func (cac *CompapiAsynctaskCreate) SetTaskStatus(i int8) *CompapiAsynctaskCreate {
  136. cac.mutation.SetTaskStatus(i)
  137. return cac
  138. }
  139. // SetNillableTaskStatus sets the "task_status" field if the given value is not nil.
  140. func (cac *CompapiAsynctaskCreate) SetNillableTaskStatus(i *int8) *CompapiAsynctaskCreate {
  141. if i != nil {
  142. cac.SetTaskStatus(*i)
  143. }
  144. return cac
  145. }
  146. // SetRetryCount sets the "retry_count" field.
  147. func (cac *CompapiAsynctaskCreate) SetRetryCount(i int8) *CompapiAsynctaskCreate {
  148. cac.mutation.SetRetryCount(i)
  149. return cac
  150. }
  151. // SetNillableRetryCount sets the "retry_count" field if the given value is not nil.
  152. func (cac *CompapiAsynctaskCreate) SetNillableRetryCount(i *int8) *CompapiAsynctaskCreate {
  153. if i != nil {
  154. cac.SetRetryCount(*i)
  155. }
  156. return cac
  157. }
  158. // SetLastError sets the "last_error" field.
  159. func (cac *CompapiAsynctaskCreate) SetLastError(s string) *CompapiAsynctaskCreate {
  160. cac.mutation.SetLastError(s)
  161. return cac
  162. }
  163. // SetNillableLastError sets the "last_error" field if the given value is not nil.
  164. func (cac *CompapiAsynctaskCreate) SetNillableLastError(s *string) *CompapiAsynctaskCreate {
  165. if s != nil {
  166. cac.SetLastError(*s)
  167. }
  168. return cac
  169. }
  170. // SetID sets the "id" field.
  171. func (cac *CompapiAsynctaskCreate) SetID(u uint64) *CompapiAsynctaskCreate {
  172. cac.mutation.SetID(u)
  173. return cac
  174. }
  175. // Mutation returns the CompapiAsynctaskMutation object of the builder.
  176. func (cac *CompapiAsynctaskCreate) Mutation() *CompapiAsynctaskMutation {
  177. return cac.mutation
  178. }
  179. // Save creates the CompapiAsynctask in the database.
  180. func (cac *CompapiAsynctaskCreate) Save(ctx context.Context) (*CompapiAsynctask, error) {
  181. cac.defaults()
  182. return withHooks(ctx, cac.sqlSave, cac.mutation, cac.hooks)
  183. }
  184. // SaveX calls Save and panics if Save returns an error.
  185. func (cac *CompapiAsynctaskCreate) SaveX(ctx context.Context) *CompapiAsynctask {
  186. v, err := cac.Save(ctx)
  187. if err != nil {
  188. panic(err)
  189. }
  190. return v
  191. }
  192. // Exec executes the query.
  193. func (cac *CompapiAsynctaskCreate) Exec(ctx context.Context) error {
  194. _, err := cac.Save(ctx)
  195. return err
  196. }
  197. // ExecX is like Exec, but panics if an error occurs.
  198. func (cac *CompapiAsynctaskCreate) ExecX(ctx context.Context) {
  199. if err := cac.Exec(ctx); err != nil {
  200. panic(err)
  201. }
  202. }
  203. // defaults sets the default values of the builder before save.
  204. func (cac *CompapiAsynctaskCreate) defaults() {
  205. if _, ok := cac.mutation.CreatedAt(); !ok {
  206. v := compapiasynctask.DefaultCreatedAt()
  207. cac.mutation.SetCreatedAt(v)
  208. }
  209. if _, ok := cac.mutation.UpdatedAt(); !ok {
  210. v := compapiasynctask.DefaultUpdatedAt()
  211. cac.mutation.SetUpdatedAt(v)
  212. }
  213. if _, ok := cac.mutation.EventType(); !ok {
  214. v := compapiasynctask.DefaultEventType
  215. cac.mutation.SetEventType(v)
  216. }
  217. if _, ok := cac.mutation.ChatID(); !ok {
  218. v := compapiasynctask.DefaultChatID
  219. cac.mutation.SetChatID(v)
  220. }
  221. if _, ok := cac.mutation.ResponseRaw(); !ok {
  222. v := compapiasynctask.DefaultResponseRaw
  223. cac.mutation.SetResponseRaw(v)
  224. }
  225. if _, ok := cac.mutation.CallbackResponseRaw(); !ok {
  226. v := compapiasynctask.DefaultCallbackResponseRaw
  227. cac.mutation.SetCallbackResponseRaw(v)
  228. }
  229. if _, ok := cac.mutation.Model(); !ok {
  230. v := compapiasynctask.DefaultModel
  231. cac.mutation.SetModel(v)
  232. }
  233. if _, ok := cac.mutation.TaskStatus(); !ok {
  234. v := compapiasynctask.DefaultTaskStatus
  235. cac.mutation.SetTaskStatus(v)
  236. }
  237. if _, ok := cac.mutation.RetryCount(); !ok {
  238. v := compapiasynctask.DefaultRetryCount
  239. cac.mutation.SetRetryCount(v)
  240. }
  241. if _, ok := cac.mutation.LastError(); !ok {
  242. v := compapiasynctask.DefaultLastError
  243. cac.mutation.SetLastError(v)
  244. }
  245. }
  246. // check runs all checks and user-defined validators on the builder.
  247. func (cac *CompapiAsynctaskCreate) check() error {
  248. if _, ok := cac.mutation.CreatedAt(); !ok {
  249. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "CompapiAsynctask.created_at"`)}
  250. }
  251. if _, ok := cac.mutation.UpdatedAt(); !ok {
  252. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "CompapiAsynctask.updated_at"`)}
  253. }
  254. if _, ok := cac.mutation.AuthToken(); !ok {
  255. return &ValidationError{Name: "auth_token", err: errors.New(`ent: missing required field "CompapiAsynctask.auth_token"`)}
  256. }
  257. if _, ok := cac.mutation.EventType(); !ok {
  258. return &ValidationError{Name: "event_type", err: errors.New(`ent: missing required field "CompapiAsynctask.event_type"`)}
  259. }
  260. if _, ok := cac.mutation.OrganizationID(); !ok {
  261. return &ValidationError{Name: "organization_id", err: errors.New(`ent: missing required field "CompapiAsynctask.organization_id"`)}
  262. }
  263. if v, ok := cac.mutation.OrganizationID(); ok {
  264. if err := compapiasynctask.OrganizationIDValidator(v); err != nil {
  265. return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "CompapiAsynctask.organization_id": %w`, err)}
  266. }
  267. }
  268. if _, ok := cac.mutation.OpenaiBase(); !ok {
  269. return &ValidationError{Name: "openai_base", err: errors.New(`ent: missing required field "CompapiAsynctask.openai_base"`)}
  270. }
  271. if _, ok := cac.mutation.OpenaiKey(); !ok {
  272. return &ValidationError{Name: "openai_key", err: errors.New(`ent: missing required field "CompapiAsynctask.openai_key"`)}
  273. }
  274. if _, ok := cac.mutation.RequestRaw(); !ok {
  275. return &ValidationError{Name: "request_raw", err: errors.New(`ent: missing required field "CompapiAsynctask.request_raw"`)}
  276. }
  277. if _, ok := cac.mutation.CallbackURL(); !ok {
  278. return &ValidationError{Name: "callback_url", err: errors.New(`ent: missing required field "CompapiAsynctask.callback_url"`)}
  279. }
  280. if v, ok := cac.mutation.CallbackURL(); ok {
  281. if err := compapiasynctask.CallbackURLValidator(v); err != nil {
  282. return &ValidationError{Name: "callback_url", err: fmt.Errorf(`ent: validator failed for field "CompapiAsynctask.callback_url": %w`, err)}
  283. }
  284. }
  285. return nil
  286. }
  287. func (cac *CompapiAsynctaskCreate) sqlSave(ctx context.Context) (*CompapiAsynctask, error) {
  288. if err := cac.check(); err != nil {
  289. return nil, err
  290. }
  291. _node, _spec := cac.createSpec()
  292. if err := sqlgraph.CreateNode(ctx, cac.driver, _spec); err != nil {
  293. if sqlgraph.IsConstraintError(err) {
  294. err = &ConstraintError{msg: err.Error(), wrap: err}
  295. }
  296. return nil, err
  297. }
  298. if _spec.ID.Value != _node.ID {
  299. id := _spec.ID.Value.(int64)
  300. _node.ID = uint64(id)
  301. }
  302. cac.mutation.id = &_node.ID
  303. cac.mutation.done = true
  304. return _node, nil
  305. }
  306. func (cac *CompapiAsynctaskCreate) createSpec() (*CompapiAsynctask, *sqlgraph.CreateSpec) {
  307. var (
  308. _node = &CompapiAsynctask{config: cac.config}
  309. _spec = sqlgraph.NewCreateSpec(compapiasynctask.Table, sqlgraph.NewFieldSpec(compapiasynctask.FieldID, field.TypeUint64))
  310. )
  311. _spec.OnConflict = cac.conflict
  312. if id, ok := cac.mutation.ID(); ok {
  313. _node.ID = id
  314. _spec.ID.Value = id
  315. }
  316. if value, ok := cac.mutation.CreatedAt(); ok {
  317. _spec.SetField(compapiasynctask.FieldCreatedAt, field.TypeTime, value)
  318. _node.CreatedAt = value
  319. }
  320. if value, ok := cac.mutation.UpdatedAt(); ok {
  321. _spec.SetField(compapiasynctask.FieldUpdatedAt, field.TypeTime, value)
  322. _node.UpdatedAt = value
  323. }
  324. if value, ok := cac.mutation.AuthToken(); ok {
  325. _spec.SetField(compapiasynctask.FieldAuthToken, field.TypeString, value)
  326. _node.AuthToken = value
  327. }
  328. if value, ok := cac.mutation.EventType(); ok {
  329. _spec.SetField(compapiasynctask.FieldEventType, field.TypeString, value)
  330. _node.EventType = value
  331. }
  332. if value, ok := cac.mutation.ChatID(); ok {
  333. _spec.SetField(compapiasynctask.FieldChatID, field.TypeString, value)
  334. _node.ChatID = value
  335. }
  336. if value, ok := cac.mutation.OrganizationID(); ok {
  337. _spec.SetField(compapiasynctask.FieldOrganizationID, field.TypeUint64, value)
  338. _node.OrganizationID = value
  339. }
  340. if value, ok := cac.mutation.OpenaiBase(); ok {
  341. _spec.SetField(compapiasynctask.FieldOpenaiBase, field.TypeString, value)
  342. _node.OpenaiBase = value
  343. }
  344. if value, ok := cac.mutation.OpenaiKey(); ok {
  345. _spec.SetField(compapiasynctask.FieldOpenaiKey, field.TypeString, value)
  346. _node.OpenaiKey = value
  347. }
  348. if value, ok := cac.mutation.RequestRaw(); ok {
  349. _spec.SetField(compapiasynctask.FieldRequestRaw, field.TypeString, value)
  350. _node.RequestRaw = value
  351. }
  352. if value, ok := cac.mutation.ResponseRaw(); ok {
  353. _spec.SetField(compapiasynctask.FieldResponseRaw, field.TypeString, value)
  354. _node.ResponseRaw = value
  355. }
  356. if value, ok := cac.mutation.CallbackURL(); ok {
  357. _spec.SetField(compapiasynctask.FieldCallbackURL, field.TypeString, value)
  358. _node.CallbackURL = value
  359. }
  360. if value, ok := cac.mutation.CallbackResponseRaw(); ok {
  361. _spec.SetField(compapiasynctask.FieldCallbackResponseRaw, field.TypeString, value)
  362. _node.CallbackResponseRaw = value
  363. }
  364. if value, ok := cac.mutation.Model(); ok {
  365. _spec.SetField(compapiasynctask.FieldModel, field.TypeString, value)
  366. _node.Model = value
  367. }
  368. if value, ok := cac.mutation.TaskStatus(); ok {
  369. _spec.SetField(compapiasynctask.FieldTaskStatus, field.TypeInt8, value)
  370. _node.TaskStatus = value
  371. }
  372. if value, ok := cac.mutation.RetryCount(); ok {
  373. _spec.SetField(compapiasynctask.FieldRetryCount, field.TypeInt8, value)
  374. _node.RetryCount = value
  375. }
  376. if value, ok := cac.mutation.LastError(); ok {
  377. _spec.SetField(compapiasynctask.FieldLastError, field.TypeString, value)
  378. _node.LastError = value
  379. }
  380. return _node, _spec
  381. }
  382. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  383. // of the `INSERT` statement. For example:
  384. //
  385. // client.CompapiAsynctask.Create().
  386. // SetCreatedAt(v).
  387. // OnConflict(
  388. // // Update the row with the new values
  389. // // the was proposed for insertion.
  390. // sql.ResolveWithNewValues(),
  391. // ).
  392. // // Override some of the fields with custom
  393. // // update values.
  394. // Update(func(u *ent.CompapiAsynctaskUpsert) {
  395. // SetCreatedAt(v+v).
  396. // }).
  397. // Exec(ctx)
  398. func (cac *CompapiAsynctaskCreate) OnConflict(opts ...sql.ConflictOption) *CompapiAsynctaskUpsertOne {
  399. cac.conflict = opts
  400. return &CompapiAsynctaskUpsertOne{
  401. create: cac,
  402. }
  403. }
  404. // OnConflictColumns calls `OnConflict` and configures the columns
  405. // as conflict target. Using this option is equivalent to using:
  406. //
  407. // client.CompapiAsynctask.Create().
  408. // OnConflict(sql.ConflictColumns(columns...)).
  409. // Exec(ctx)
  410. func (cac *CompapiAsynctaskCreate) OnConflictColumns(columns ...string) *CompapiAsynctaskUpsertOne {
  411. cac.conflict = append(cac.conflict, sql.ConflictColumns(columns...))
  412. return &CompapiAsynctaskUpsertOne{
  413. create: cac,
  414. }
  415. }
  416. type (
  417. // CompapiAsynctaskUpsertOne is the builder for "upsert"-ing
  418. // one CompapiAsynctask node.
  419. CompapiAsynctaskUpsertOne struct {
  420. create *CompapiAsynctaskCreate
  421. }
  422. // CompapiAsynctaskUpsert is the "OnConflict" setter.
  423. CompapiAsynctaskUpsert struct {
  424. *sql.UpdateSet
  425. }
  426. )
  427. // SetUpdatedAt sets the "updated_at" field.
  428. func (u *CompapiAsynctaskUpsert) SetUpdatedAt(v time.Time) *CompapiAsynctaskUpsert {
  429. u.Set(compapiasynctask.FieldUpdatedAt, v)
  430. return u
  431. }
  432. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  433. func (u *CompapiAsynctaskUpsert) UpdateUpdatedAt() *CompapiAsynctaskUpsert {
  434. u.SetExcluded(compapiasynctask.FieldUpdatedAt)
  435. return u
  436. }
  437. // SetAuthToken sets the "auth_token" field.
  438. func (u *CompapiAsynctaskUpsert) SetAuthToken(v string) *CompapiAsynctaskUpsert {
  439. u.Set(compapiasynctask.FieldAuthToken, v)
  440. return u
  441. }
  442. // UpdateAuthToken sets the "auth_token" field to the value that was provided on create.
  443. func (u *CompapiAsynctaskUpsert) UpdateAuthToken() *CompapiAsynctaskUpsert {
  444. u.SetExcluded(compapiasynctask.FieldAuthToken)
  445. return u
  446. }
  447. // SetEventType sets the "event_type" field.
  448. func (u *CompapiAsynctaskUpsert) SetEventType(v string) *CompapiAsynctaskUpsert {
  449. u.Set(compapiasynctask.FieldEventType, v)
  450. return u
  451. }
  452. // UpdateEventType sets the "event_type" field to the value that was provided on create.
  453. func (u *CompapiAsynctaskUpsert) UpdateEventType() *CompapiAsynctaskUpsert {
  454. u.SetExcluded(compapiasynctask.FieldEventType)
  455. return u
  456. }
  457. // SetChatID sets the "chat_id" field.
  458. func (u *CompapiAsynctaskUpsert) SetChatID(v string) *CompapiAsynctaskUpsert {
  459. u.Set(compapiasynctask.FieldChatID, v)
  460. return u
  461. }
  462. // UpdateChatID sets the "chat_id" field to the value that was provided on create.
  463. func (u *CompapiAsynctaskUpsert) UpdateChatID() *CompapiAsynctaskUpsert {
  464. u.SetExcluded(compapiasynctask.FieldChatID)
  465. return u
  466. }
  467. // ClearChatID clears the value of the "chat_id" field.
  468. func (u *CompapiAsynctaskUpsert) ClearChatID() *CompapiAsynctaskUpsert {
  469. u.SetNull(compapiasynctask.FieldChatID)
  470. return u
  471. }
  472. // SetOrganizationID sets the "organization_id" field.
  473. func (u *CompapiAsynctaskUpsert) SetOrganizationID(v uint64) *CompapiAsynctaskUpsert {
  474. u.Set(compapiasynctask.FieldOrganizationID, v)
  475. return u
  476. }
  477. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  478. func (u *CompapiAsynctaskUpsert) UpdateOrganizationID() *CompapiAsynctaskUpsert {
  479. u.SetExcluded(compapiasynctask.FieldOrganizationID)
  480. return u
  481. }
  482. // AddOrganizationID adds v to the "organization_id" field.
  483. func (u *CompapiAsynctaskUpsert) AddOrganizationID(v uint64) *CompapiAsynctaskUpsert {
  484. u.Add(compapiasynctask.FieldOrganizationID, v)
  485. return u
  486. }
  487. // SetOpenaiBase sets the "openai_base" field.
  488. func (u *CompapiAsynctaskUpsert) SetOpenaiBase(v string) *CompapiAsynctaskUpsert {
  489. u.Set(compapiasynctask.FieldOpenaiBase, v)
  490. return u
  491. }
  492. // UpdateOpenaiBase sets the "openai_base" field to the value that was provided on create.
  493. func (u *CompapiAsynctaskUpsert) UpdateOpenaiBase() *CompapiAsynctaskUpsert {
  494. u.SetExcluded(compapiasynctask.FieldOpenaiBase)
  495. return u
  496. }
  497. // SetOpenaiKey sets the "openai_key" field.
  498. func (u *CompapiAsynctaskUpsert) SetOpenaiKey(v string) *CompapiAsynctaskUpsert {
  499. u.Set(compapiasynctask.FieldOpenaiKey, v)
  500. return u
  501. }
  502. // UpdateOpenaiKey sets the "openai_key" field to the value that was provided on create.
  503. func (u *CompapiAsynctaskUpsert) UpdateOpenaiKey() *CompapiAsynctaskUpsert {
  504. u.SetExcluded(compapiasynctask.FieldOpenaiKey)
  505. return u
  506. }
  507. // SetRequestRaw sets the "request_raw" field.
  508. func (u *CompapiAsynctaskUpsert) SetRequestRaw(v string) *CompapiAsynctaskUpsert {
  509. u.Set(compapiasynctask.FieldRequestRaw, v)
  510. return u
  511. }
  512. // UpdateRequestRaw sets the "request_raw" field to the value that was provided on create.
  513. func (u *CompapiAsynctaskUpsert) UpdateRequestRaw() *CompapiAsynctaskUpsert {
  514. u.SetExcluded(compapiasynctask.FieldRequestRaw)
  515. return u
  516. }
  517. // SetResponseRaw sets the "response_raw" field.
  518. func (u *CompapiAsynctaskUpsert) SetResponseRaw(v string) *CompapiAsynctaskUpsert {
  519. u.Set(compapiasynctask.FieldResponseRaw, v)
  520. return u
  521. }
  522. // UpdateResponseRaw sets the "response_raw" field to the value that was provided on create.
  523. func (u *CompapiAsynctaskUpsert) UpdateResponseRaw() *CompapiAsynctaskUpsert {
  524. u.SetExcluded(compapiasynctask.FieldResponseRaw)
  525. return u
  526. }
  527. // ClearResponseRaw clears the value of the "response_raw" field.
  528. func (u *CompapiAsynctaskUpsert) ClearResponseRaw() *CompapiAsynctaskUpsert {
  529. u.SetNull(compapiasynctask.FieldResponseRaw)
  530. return u
  531. }
  532. // SetCallbackURL sets the "callback_url" field.
  533. func (u *CompapiAsynctaskUpsert) SetCallbackURL(v string) *CompapiAsynctaskUpsert {
  534. u.Set(compapiasynctask.FieldCallbackURL, v)
  535. return u
  536. }
  537. // UpdateCallbackURL sets the "callback_url" field to the value that was provided on create.
  538. func (u *CompapiAsynctaskUpsert) UpdateCallbackURL() *CompapiAsynctaskUpsert {
  539. u.SetExcluded(compapiasynctask.FieldCallbackURL)
  540. return u
  541. }
  542. // SetCallbackResponseRaw sets the "callback_response_raw" field.
  543. func (u *CompapiAsynctaskUpsert) SetCallbackResponseRaw(v string) *CompapiAsynctaskUpsert {
  544. u.Set(compapiasynctask.FieldCallbackResponseRaw, v)
  545. return u
  546. }
  547. // UpdateCallbackResponseRaw sets the "callback_response_raw" field to the value that was provided on create.
  548. func (u *CompapiAsynctaskUpsert) UpdateCallbackResponseRaw() *CompapiAsynctaskUpsert {
  549. u.SetExcluded(compapiasynctask.FieldCallbackResponseRaw)
  550. return u
  551. }
  552. // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field.
  553. func (u *CompapiAsynctaskUpsert) ClearCallbackResponseRaw() *CompapiAsynctaskUpsert {
  554. u.SetNull(compapiasynctask.FieldCallbackResponseRaw)
  555. return u
  556. }
  557. // SetModel sets the "model" field.
  558. func (u *CompapiAsynctaskUpsert) SetModel(v string) *CompapiAsynctaskUpsert {
  559. u.Set(compapiasynctask.FieldModel, v)
  560. return u
  561. }
  562. // UpdateModel sets the "model" field to the value that was provided on create.
  563. func (u *CompapiAsynctaskUpsert) UpdateModel() *CompapiAsynctaskUpsert {
  564. u.SetExcluded(compapiasynctask.FieldModel)
  565. return u
  566. }
  567. // ClearModel clears the value of the "model" field.
  568. func (u *CompapiAsynctaskUpsert) ClearModel() *CompapiAsynctaskUpsert {
  569. u.SetNull(compapiasynctask.FieldModel)
  570. return u
  571. }
  572. // SetTaskStatus sets the "task_status" field.
  573. func (u *CompapiAsynctaskUpsert) SetTaskStatus(v int8) *CompapiAsynctaskUpsert {
  574. u.Set(compapiasynctask.FieldTaskStatus, v)
  575. return u
  576. }
  577. // UpdateTaskStatus sets the "task_status" field to the value that was provided on create.
  578. func (u *CompapiAsynctaskUpsert) UpdateTaskStatus() *CompapiAsynctaskUpsert {
  579. u.SetExcluded(compapiasynctask.FieldTaskStatus)
  580. return u
  581. }
  582. // AddTaskStatus adds v to the "task_status" field.
  583. func (u *CompapiAsynctaskUpsert) AddTaskStatus(v int8) *CompapiAsynctaskUpsert {
  584. u.Add(compapiasynctask.FieldTaskStatus, v)
  585. return u
  586. }
  587. // ClearTaskStatus clears the value of the "task_status" field.
  588. func (u *CompapiAsynctaskUpsert) ClearTaskStatus() *CompapiAsynctaskUpsert {
  589. u.SetNull(compapiasynctask.FieldTaskStatus)
  590. return u
  591. }
  592. // SetRetryCount sets the "retry_count" field.
  593. func (u *CompapiAsynctaskUpsert) SetRetryCount(v int8) *CompapiAsynctaskUpsert {
  594. u.Set(compapiasynctask.FieldRetryCount, v)
  595. return u
  596. }
  597. // UpdateRetryCount sets the "retry_count" field to the value that was provided on create.
  598. func (u *CompapiAsynctaskUpsert) UpdateRetryCount() *CompapiAsynctaskUpsert {
  599. u.SetExcluded(compapiasynctask.FieldRetryCount)
  600. return u
  601. }
  602. // AddRetryCount adds v to the "retry_count" field.
  603. func (u *CompapiAsynctaskUpsert) AddRetryCount(v int8) *CompapiAsynctaskUpsert {
  604. u.Add(compapiasynctask.FieldRetryCount, v)
  605. return u
  606. }
  607. // ClearRetryCount clears the value of the "retry_count" field.
  608. func (u *CompapiAsynctaskUpsert) ClearRetryCount() *CompapiAsynctaskUpsert {
  609. u.SetNull(compapiasynctask.FieldRetryCount)
  610. return u
  611. }
  612. // SetLastError sets the "last_error" field.
  613. func (u *CompapiAsynctaskUpsert) SetLastError(v string) *CompapiAsynctaskUpsert {
  614. u.Set(compapiasynctask.FieldLastError, v)
  615. return u
  616. }
  617. // UpdateLastError sets the "last_error" field to the value that was provided on create.
  618. func (u *CompapiAsynctaskUpsert) UpdateLastError() *CompapiAsynctaskUpsert {
  619. u.SetExcluded(compapiasynctask.FieldLastError)
  620. return u
  621. }
  622. // ClearLastError clears the value of the "last_error" field.
  623. func (u *CompapiAsynctaskUpsert) ClearLastError() *CompapiAsynctaskUpsert {
  624. u.SetNull(compapiasynctask.FieldLastError)
  625. return u
  626. }
  627. // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
  628. // Using this option is equivalent to using:
  629. //
  630. // client.CompapiAsynctask.Create().
  631. // OnConflict(
  632. // sql.ResolveWithNewValues(),
  633. // sql.ResolveWith(func(u *sql.UpdateSet) {
  634. // u.SetIgnore(compapiasynctask.FieldID)
  635. // }),
  636. // ).
  637. // Exec(ctx)
  638. func (u *CompapiAsynctaskUpsertOne) UpdateNewValues() *CompapiAsynctaskUpsertOne {
  639. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  640. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  641. if _, exists := u.create.mutation.ID(); exists {
  642. s.SetIgnore(compapiasynctask.FieldID)
  643. }
  644. if _, exists := u.create.mutation.CreatedAt(); exists {
  645. s.SetIgnore(compapiasynctask.FieldCreatedAt)
  646. }
  647. }))
  648. return u
  649. }
  650. // Ignore sets each column to itself in case of conflict.
  651. // Using this option is equivalent to using:
  652. //
  653. // client.CompapiAsynctask.Create().
  654. // OnConflict(sql.ResolveWithIgnore()).
  655. // Exec(ctx)
  656. func (u *CompapiAsynctaskUpsertOne) Ignore() *CompapiAsynctaskUpsertOne {
  657. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  658. return u
  659. }
  660. // DoNothing configures the conflict_action to `DO NOTHING`.
  661. // Supported only by SQLite and PostgreSQL.
  662. func (u *CompapiAsynctaskUpsertOne) DoNothing() *CompapiAsynctaskUpsertOne {
  663. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  664. return u
  665. }
  666. // Update allows overriding fields `UPDATE` values. See the CompapiAsynctaskCreate.OnConflict
  667. // documentation for more info.
  668. func (u *CompapiAsynctaskUpsertOne) Update(set func(*CompapiAsynctaskUpsert)) *CompapiAsynctaskUpsertOne {
  669. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  670. set(&CompapiAsynctaskUpsert{UpdateSet: update})
  671. }))
  672. return u
  673. }
  674. // SetUpdatedAt sets the "updated_at" field.
  675. func (u *CompapiAsynctaskUpsertOne) SetUpdatedAt(v time.Time) *CompapiAsynctaskUpsertOne {
  676. return u.Update(func(s *CompapiAsynctaskUpsert) {
  677. s.SetUpdatedAt(v)
  678. })
  679. }
  680. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  681. func (u *CompapiAsynctaskUpsertOne) UpdateUpdatedAt() *CompapiAsynctaskUpsertOne {
  682. return u.Update(func(s *CompapiAsynctaskUpsert) {
  683. s.UpdateUpdatedAt()
  684. })
  685. }
  686. // SetAuthToken sets the "auth_token" field.
  687. func (u *CompapiAsynctaskUpsertOne) SetAuthToken(v string) *CompapiAsynctaskUpsertOne {
  688. return u.Update(func(s *CompapiAsynctaskUpsert) {
  689. s.SetAuthToken(v)
  690. })
  691. }
  692. // UpdateAuthToken sets the "auth_token" field to the value that was provided on create.
  693. func (u *CompapiAsynctaskUpsertOne) UpdateAuthToken() *CompapiAsynctaskUpsertOne {
  694. return u.Update(func(s *CompapiAsynctaskUpsert) {
  695. s.UpdateAuthToken()
  696. })
  697. }
  698. // SetEventType sets the "event_type" field.
  699. func (u *CompapiAsynctaskUpsertOne) SetEventType(v string) *CompapiAsynctaskUpsertOne {
  700. return u.Update(func(s *CompapiAsynctaskUpsert) {
  701. s.SetEventType(v)
  702. })
  703. }
  704. // UpdateEventType sets the "event_type" field to the value that was provided on create.
  705. func (u *CompapiAsynctaskUpsertOne) UpdateEventType() *CompapiAsynctaskUpsertOne {
  706. return u.Update(func(s *CompapiAsynctaskUpsert) {
  707. s.UpdateEventType()
  708. })
  709. }
  710. // SetChatID sets the "chat_id" field.
  711. func (u *CompapiAsynctaskUpsertOne) SetChatID(v string) *CompapiAsynctaskUpsertOne {
  712. return u.Update(func(s *CompapiAsynctaskUpsert) {
  713. s.SetChatID(v)
  714. })
  715. }
  716. // UpdateChatID sets the "chat_id" field to the value that was provided on create.
  717. func (u *CompapiAsynctaskUpsertOne) UpdateChatID() *CompapiAsynctaskUpsertOne {
  718. return u.Update(func(s *CompapiAsynctaskUpsert) {
  719. s.UpdateChatID()
  720. })
  721. }
  722. // ClearChatID clears the value of the "chat_id" field.
  723. func (u *CompapiAsynctaskUpsertOne) ClearChatID() *CompapiAsynctaskUpsertOne {
  724. return u.Update(func(s *CompapiAsynctaskUpsert) {
  725. s.ClearChatID()
  726. })
  727. }
  728. // SetOrganizationID sets the "organization_id" field.
  729. func (u *CompapiAsynctaskUpsertOne) SetOrganizationID(v uint64) *CompapiAsynctaskUpsertOne {
  730. return u.Update(func(s *CompapiAsynctaskUpsert) {
  731. s.SetOrganizationID(v)
  732. })
  733. }
  734. // AddOrganizationID adds v to the "organization_id" field.
  735. func (u *CompapiAsynctaskUpsertOne) AddOrganizationID(v uint64) *CompapiAsynctaskUpsertOne {
  736. return u.Update(func(s *CompapiAsynctaskUpsert) {
  737. s.AddOrganizationID(v)
  738. })
  739. }
  740. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  741. func (u *CompapiAsynctaskUpsertOne) UpdateOrganizationID() *CompapiAsynctaskUpsertOne {
  742. return u.Update(func(s *CompapiAsynctaskUpsert) {
  743. s.UpdateOrganizationID()
  744. })
  745. }
  746. // SetOpenaiBase sets the "openai_base" field.
  747. func (u *CompapiAsynctaskUpsertOne) SetOpenaiBase(v string) *CompapiAsynctaskUpsertOne {
  748. return u.Update(func(s *CompapiAsynctaskUpsert) {
  749. s.SetOpenaiBase(v)
  750. })
  751. }
  752. // UpdateOpenaiBase sets the "openai_base" field to the value that was provided on create.
  753. func (u *CompapiAsynctaskUpsertOne) UpdateOpenaiBase() *CompapiAsynctaskUpsertOne {
  754. return u.Update(func(s *CompapiAsynctaskUpsert) {
  755. s.UpdateOpenaiBase()
  756. })
  757. }
  758. // SetOpenaiKey sets the "openai_key" field.
  759. func (u *CompapiAsynctaskUpsertOne) SetOpenaiKey(v string) *CompapiAsynctaskUpsertOne {
  760. return u.Update(func(s *CompapiAsynctaskUpsert) {
  761. s.SetOpenaiKey(v)
  762. })
  763. }
  764. // UpdateOpenaiKey sets the "openai_key" field to the value that was provided on create.
  765. func (u *CompapiAsynctaskUpsertOne) UpdateOpenaiKey() *CompapiAsynctaskUpsertOne {
  766. return u.Update(func(s *CompapiAsynctaskUpsert) {
  767. s.UpdateOpenaiKey()
  768. })
  769. }
  770. // SetRequestRaw sets the "request_raw" field.
  771. func (u *CompapiAsynctaskUpsertOne) SetRequestRaw(v string) *CompapiAsynctaskUpsertOne {
  772. return u.Update(func(s *CompapiAsynctaskUpsert) {
  773. s.SetRequestRaw(v)
  774. })
  775. }
  776. // UpdateRequestRaw sets the "request_raw" field to the value that was provided on create.
  777. func (u *CompapiAsynctaskUpsertOne) UpdateRequestRaw() *CompapiAsynctaskUpsertOne {
  778. return u.Update(func(s *CompapiAsynctaskUpsert) {
  779. s.UpdateRequestRaw()
  780. })
  781. }
  782. // SetResponseRaw sets the "response_raw" field.
  783. func (u *CompapiAsynctaskUpsertOne) SetResponseRaw(v string) *CompapiAsynctaskUpsertOne {
  784. return u.Update(func(s *CompapiAsynctaskUpsert) {
  785. s.SetResponseRaw(v)
  786. })
  787. }
  788. // UpdateResponseRaw sets the "response_raw" field to the value that was provided on create.
  789. func (u *CompapiAsynctaskUpsertOne) UpdateResponseRaw() *CompapiAsynctaskUpsertOne {
  790. return u.Update(func(s *CompapiAsynctaskUpsert) {
  791. s.UpdateResponseRaw()
  792. })
  793. }
  794. // ClearResponseRaw clears the value of the "response_raw" field.
  795. func (u *CompapiAsynctaskUpsertOne) ClearResponseRaw() *CompapiAsynctaskUpsertOne {
  796. return u.Update(func(s *CompapiAsynctaskUpsert) {
  797. s.ClearResponseRaw()
  798. })
  799. }
  800. // SetCallbackURL sets the "callback_url" field.
  801. func (u *CompapiAsynctaskUpsertOne) SetCallbackURL(v string) *CompapiAsynctaskUpsertOne {
  802. return u.Update(func(s *CompapiAsynctaskUpsert) {
  803. s.SetCallbackURL(v)
  804. })
  805. }
  806. // UpdateCallbackURL sets the "callback_url" field to the value that was provided on create.
  807. func (u *CompapiAsynctaskUpsertOne) UpdateCallbackURL() *CompapiAsynctaskUpsertOne {
  808. return u.Update(func(s *CompapiAsynctaskUpsert) {
  809. s.UpdateCallbackURL()
  810. })
  811. }
  812. // SetCallbackResponseRaw sets the "callback_response_raw" field.
  813. func (u *CompapiAsynctaskUpsertOne) SetCallbackResponseRaw(v string) *CompapiAsynctaskUpsertOne {
  814. return u.Update(func(s *CompapiAsynctaskUpsert) {
  815. s.SetCallbackResponseRaw(v)
  816. })
  817. }
  818. // UpdateCallbackResponseRaw sets the "callback_response_raw" field to the value that was provided on create.
  819. func (u *CompapiAsynctaskUpsertOne) UpdateCallbackResponseRaw() *CompapiAsynctaskUpsertOne {
  820. return u.Update(func(s *CompapiAsynctaskUpsert) {
  821. s.UpdateCallbackResponseRaw()
  822. })
  823. }
  824. // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field.
  825. func (u *CompapiAsynctaskUpsertOne) ClearCallbackResponseRaw() *CompapiAsynctaskUpsertOne {
  826. return u.Update(func(s *CompapiAsynctaskUpsert) {
  827. s.ClearCallbackResponseRaw()
  828. })
  829. }
  830. // SetModel sets the "model" field.
  831. func (u *CompapiAsynctaskUpsertOne) SetModel(v string) *CompapiAsynctaskUpsertOne {
  832. return u.Update(func(s *CompapiAsynctaskUpsert) {
  833. s.SetModel(v)
  834. })
  835. }
  836. // UpdateModel sets the "model" field to the value that was provided on create.
  837. func (u *CompapiAsynctaskUpsertOne) UpdateModel() *CompapiAsynctaskUpsertOne {
  838. return u.Update(func(s *CompapiAsynctaskUpsert) {
  839. s.UpdateModel()
  840. })
  841. }
  842. // ClearModel clears the value of the "model" field.
  843. func (u *CompapiAsynctaskUpsertOne) ClearModel() *CompapiAsynctaskUpsertOne {
  844. return u.Update(func(s *CompapiAsynctaskUpsert) {
  845. s.ClearModel()
  846. })
  847. }
  848. // SetTaskStatus sets the "task_status" field.
  849. func (u *CompapiAsynctaskUpsertOne) SetTaskStatus(v int8) *CompapiAsynctaskUpsertOne {
  850. return u.Update(func(s *CompapiAsynctaskUpsert) {
  851. s.SetTaskStatus(v)
  852. })
  853. }
  854. // AddTaskStatus adds v to the "task_status" field.
  855. func (u *CompapiAsynctaskUpsertOne) AddTaskStatus(v int8) *CompapiAsynctaskUpsertOne {
  856. return u.Update(func(s *CompapiAsynctaskUpsert) {
  857. s.AddTaskStatus(v)
  858. })
  859. }
  860. // UpdateTaskStatus sets the "task_status" field to the value that was provided on create.
  861. func (u *CompapiAsynctaskUpsertOne) UpdateTaskStatus() *CompapiAsynctaskUpsertOne {
  862. return u.Update(func(s *CompapiAsynctaskUpsert) {
  863. s.UpdateTaskStatus()
  864. })
  865. }
  866. // ClearTaskStatus clears the value of the "task_status" field.
  867. func (u *CompapiAsynctaskUpsertOne) ClearTaskStatus() *CompapiAsynctaskUpsertOne {
  868. return u.Update(func(s *CompapiAsynctaskUpsert) {
  869. s.ClearTaskStatus()
  870. })
  871. }
  872. // SetRetryCount sets the "retry_count" field.
  873. func (u *CompapiAsynctaskUpsertOne) SetRetryCount(v int8) *CompapiAsynctaskUpsertOne {
  874. return u.Update(func(s *CompapiAsynctaskUpsert) {
  875. s.SetRetryCount(v)
  876. })
  877. }
  878. // AddRetryCount adds v to the "retry_count" field.
  879. func (u *CompapiAsynctaskUpsertOne) AddRetryCount(v int8) *CompapiAsynctaskUpsertOne {
  880. return u.Update(func(s *CompapiAsynctaskUpsert) {
  881. s.AddRetryCount(v)
  882. })
  883. }
  884. // UpdateRetryCount sets the "retry_count" field to the value that was provided on create.
  885. func (u *CompapiAsynctaskUpsertOne) UpdateRetryCount() *CompapiAsynctaskUpsertOne {
  886. return u.Update(func(s *CompapiAsynctaskUpsert) {
  887. s.UpdateRetryCount()
  888. })
  889. }
  890. // ClearRetryCount clears the value of the "retry_count" field.
  891. func (u *CompapiAsynctaskUpsertOne) ClearRetryCount() *CompapiAsynctaskUpsertOne {
  892. return u.Update(func(s *CompapiAsynctaskUpsert) {
  893. s.ClearRetryCount()
  894. })
  895. }
  896. // SetLastError sets the "last_error" field.
  897. func (u *CompapiAsynctaskUpsertOne) SetLastError(v string) *CompapiAsynctaskUpsertOne {
  898. return u.Update(func(s *CompapiAsynctaskUpsert) {
  899. s.SetLastError(v)
  900. })
  901. }
  902. // UpdateLastError sets the "last_error" field to the value that was provided on create.
  903. func (u *CompapiAsynctaskUpsertOne) UpdateLastError() *CompapiAsynctaskUpsertOne {
  904. return u.Update(func(s *CompapiAsynctaskUpsert) {
  905. s.UpdateLastError()
  906. })
  907. }
  908. // ClearLastError clears the value of the "last_error" field.
  909. func (u *CompapiAsynctaskUpsertOne) ClearLastError() *CompapiAsynctaskUpsertOne {
  910. return u.Update(func(s *CompapiAsynctaskUpsert) {
  911. s.ClearLastError()
  912. })
  913. }
  914. // Exec executes the query.
  915. func (u *CompapiAsynctaskUpsertOne) Exec(ctx context.Context) error {
  916. if len(u.create.conflict) == 0 {
  917. return errors.New("ent: missing options for CompapiAsynctaskCreate.OnConflict")
  918. }
  919. return u.create.Exec(ctx)
  920. }
  921. // ExecX is like Exec, but panics if an error occurs.
  922. func (u *CompapiAsynctaskUpsertOne) ExecX(ctx context.Context) {
  923. if err := u.create.Exec(ctx); err != nil {
  924. panic(err)
  925. }
  926. }
  927. // Exec executes the UPSERT query and returns the inserted/updated ID.
  928. func (u *CompapiAsynctaskUpsertOne) ID(ctx context.Context) (id uint64, err error) {
  929. node, err := u.create.Save(ctx)
  930. if err != nil {
  931. return id, err
  932. }
  933. return node.ID, nil
  934. }
  935. // IDX is like ID, but panics if an error occurs.
  936. func (u *CompapiAsynctaskUpsertOne) IDX(ctx context.Context) uint64 {
  937. id, err := u.ID(ctx)
  938. if err != nil {
  939. panic(err)
  940. }
  941. return id
  942. }
  943. // CompapiAsynctaskCreateBulk is the builder for creating many CompapiAsynctask entities in bulk.
  944. type CompapiAsynctaskCreateBulk struct {
  945. config
  946. err error
  947. builders []*CompapiAsynctaskCreate
  948. conflict []sql.ConflictOption
  949. }
  950. // Save creates the CompapiAsynctask entities in the database.
  951. func (cacb *CompapiAsynctaskCreateBulk) Save(ctx context.Context) ([]*CompapiAsynctask, error) {
  952. if cacb.err != nil {
  953. return nil, cacb.err
  954. }
  955. specs := make([]*sqlgraph.CreateSpec, len(cacb.builders))
  956. nodes := make([]*CompapiAsynctask, len(cacb.builders))
  957. mutators := make([]Mutator, len(cacb.builders))
  958. for i := range cacb.builders {
  959. func(i int, root context.Context) {
  960. builder := cacb.builders[i]
  961. builder.defaults()
  962. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  963. mutation, ok := m.(*CompapiAsynctaskMutation)
  964. if !ok {
  965. return nil, fmt.Errorf("unexpected mutation type %T", m)
  966. }
  967. if err := builder.check(); err != nil {
  968. return nil, err
  969. }
  970. builder.mutation = mutation
  971. var err error
  972. nodes[i], specs[i] = builder.createSpec()
  973. if i < len(mutators)-1 {
  974. _, err = mutators[i+1].Mutate(root, cacb.builders[i+1].mutation)
  975. } else {
  976. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  977. spec.OnConflict = cacb.conflict
  978. // Invoke the actual operation on the latest mutation in the chain.
  979. if err = sqlgraph.BatchCreate(ctx, cacb.driver, spec); err != nil {
  980. if sqlgraph.IsConstraintError(err) {
  981. err = &ConstraintError{msg: err.Error(), wrap: err}
  982. }
  983. }
  984. }
  985. if err != nil {
  986. return nil, err
  987. }
  988. mutation.id = &nodes[i].ID
  989. if specs[i].ID.Value != nil && nodes[i].ID == 0 {
  990. id := specs[i].ID.Value.(int64)
  991. nodes[i].ID = uint64(id)
  992. }
  993. mutation.done = true
  994. return nodes[i], nil
  995. })
  996. for i := len(builder.hooks) - 1; i >= 0; i-- {
  997. mut = builder.hooks[i](mut)
  998. }
  999. mutators[i] = mut
  1000. }(i, ctx)
  1001. }
  1002. if len(mutators) > 0 {
  1003. if _, err := mutators[0].Mutate(ctx, cacb.builders[0].mutation); err != nil {
  1004. return nil, err
  1005. }
  1006. }
  1007. return nodes, nil
  1008. }
  1009. // SaveX is like Save, but panics if an error occurs.
  1010. func (cacb *CompapiAsynctaskCreateBulk) SaveX(ctx context.Context) []*CompapiAsynctask {
  1011. v, err := cacb.Save(ctx)
  1012. if err != nil {
  1013. panic(err)
  1014. }
  1015. return v
  1016. }
  1017. // Exec executes the query.
  1018. func (cacb *CompapiAsynctaskCreateBulk) Exec(ctx context.Context) error {
  1019. _, err := cacb.Save(ctx)
  1020. return err
  1021. }
  1022. // ExecX is like Exec, but panics if an error occurs.
  1023. func (cacb *CompapiAsynctaskCreateBulk) ExecX(ctx context.Context) {
  1024. if err := cacb.Exec(ctx); err != nil {
  1025. panic(err)
  1026. }
  1027. }
  1028. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  1029. // of the `INSERT` statement. For example:
  1030. //
  1031. // client.CompapiAsynctask.CreateBulk(builders...).
  1032. // OnConflict(
  1033. // // Update the row with the new values
  1034. // // the was proposed for insertion.
  1035. // sql.ResolveWithNewValues(),
  1036. // ).
  1037. // // Override some of the fields with custom
  1038. // // update values.
  1039. // Update(func(u *ent.CompapiAsynctaskUpsert) {
  1040. // SetCreatedAt(v+v).
  1041. // }).
  1042. // Exec(ctx)
  1043. func (cacb *CompapiAsynctaskCreateBulk) OnConflict(opts ...sql.ConflictOption) *CompapiAsynctaskUpsertBulk {
  1044. cacb.conflict = opts
  1045. return &CompapiAsynctaskUpsertBulk{
  1046. create: cacb,
  1047. }
  1048. }
  1049. // OnConflictColumns calls `OnConflict` and configures the columns
  1050. // as conflict target. Using this option is equivalent to using:
  1051. //
  1052. // client.CompapiAsynctask.Create().
  1053. // OnConflict(sql.ConflictColumns(columns...)).
  1054. // Exec(ctx)
  1055. func (cacb *CompapiAsynctaskCreateBulk) OnConflictColumns(columns ...string) *CompapiAsynctaskUpsertBulk {
  1056. cacb.conflict = append(cacb.conflict, sql.ConflictColumns(columns...))
  1057. return &CompapiAsynctaskUpsertBulk{
  1058. create: cacb,
  1059. }
  1060. }
  1061. // CompapiAsynctaskUpsertBulk is the builder for "upsert"-ing
  1062. // a bulk of CompapiAsynctask nodes.
  1063. type CompapiAsynctaskUpsertBulk struct {
  1064. create *CompapiAsynctaskCreateBulk
  1065. }
  1066. // UpdateNewValues updates the mutable fields using the new values that
  1067. // were set on create. Using this option is equivalent to using:
  1068. //
  1069. // client.CompapiAsynctask.Create().
  1070. // OnConflict(
  1071. // sql.ResolveWithNewValues(),
  1072. // sql.ResolveWith(func(u *sql.UpdateSet) {
  1073. // u.SetIgnore(compapiasynctask.FieldID)
  1074. // }),
  1075. // ).
  1076. // Exec(ctx)
  1077. func (u *CompapiAsynctaskUpsertBulk) UpdateNewValues() *CompapiAsynctaskUpsertBulk {
  1078. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1079. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1080. for _, b := range u.create.builders {
  1081. if _, exists := b.mutation.ID(); exists {
  1082. s.SetIgnore(compapiasynctask.FieldID)
  1083. }
  1084. if _, exists := b.mutation.CreatedAt(); exists {
  1085. s.SetIgnore(compapiasynctask.FieldCreatedAt)
  1086. }
  1087. }
  1088. }))
  1089. return u
  1090. }
  1091. // Ignore sets each column to itself in case of conflict.
  1092. // Using this option is equivalent to using:
  1093. //
  1094. // client.CompapiAsynctask.Create().
  1095. // OnConflict(sql.ResolveWithIgnore()).
  1096. // Exec(ctx)
  1097. func (u *CompapiAsynctaskUpsertBulk) Ignore() *CompapiAsynctaskUpsertBulk {
  1098. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1099. return u
  1100. }
  1101. // DoNothing configures the conflict_action to `DO NOTHING`.
  1102. // Supported only by SQLite and PostgreSQL.
  1103. func (u *CompapiAsynctaskUpsertBulk) DoNothing() *CompapiAsynctaskUpsertBulk {
  1104. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1105. return u
  1106. }
  1107. // Update allows overriding fields `UPDATE` values. See the CompapiAsynctaskCreateBulk.OnConflict
  1108. // documentation for more info.
  1109. func (u *CompapiAsynctaskUpsertBulk) Update(set func(*CompapiAsynctaskUpsert)) *CompapiAsynctaskUpsertBulk {
  1110. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1111. set(&CompapiAsynctaskUpsert{UpdateSet: update})
  1112. }))
  1113. return u
  1114. }
  1115. // SetUpdatedAt sets the "updated_at" field.
  1116. func (u *CompapiAsynctaskUpsertBulk) SetUpdatedAt(v time.Time) *CompapiAsynctaskUpsertBulk {
  1117. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1118. s.SetUpdatedAt(v)
  1119. })
  1120. }
  1121. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1122. func (u *CompapiAsynctaskUpsertBulk) UpdateUpdatedAt() *CompapiAsynctaskUpsertBulk {
  1123. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1124. s.UpdateUpdatedAt()
  1125. })
  1126. }
  1127. // SetAuthToken sets the "auth_token" field.
  1128. func (u *CompapiAsynctaskUpsertBulk) SetAuthToken(v string) *CompapiAsynctaskUpsertBulk {
  1129. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1130. s.SetAuthToken(v)
  1131. })
  1132. }
  1133. // UpdateAuthToken sets the "auth_token" field to the value that was provided on create.
  1134. func (u *CompapiAsynctaskUpsertBulk) UpdateAuthToken() *CompapiAsynctaskUpsertBulk {
  1135. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1136. s.UpdateAuthToken()
  1137. })
  1138. }
  1139. // SetEventType sets the "event_type" field.
  1140. func (u *CompapiAsynctaskUpsertBulk) SetEventType(v string) *CompapiAsynctaskUpsertBulk {
  1141. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1142. s.SetEventType(v)
  1143. })
  1144. }
  1145. // UpdateEventType sets the "event_type" field to the value that was provided on create.
  1146. func (u *CompapiAsynctaskUpsertBulk) UpdateEventType() *CompapiAsynctaskUpsertBulk {
  1147. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1148. s.UpdateEventType()
  1149. })
  1150. }
  1151. // SetChatID sets the "chat_id" field.
  1152. func (u *CompapiAsynctaskUpsertBulk) SetChatID(v string) *CompapiAsynctaskUpsertBulk {
  1153. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1154. s.SetChatID(v)
  1155. })
  1156. }
  1157. // UpdateChatID sets the "chat_id" field to the value that was provided on create.
  1158. func (u *CompapiAsynctaskUpsertBulk) UpdateChatID() *CompapiAsynctaskUpsertBulk {
  1159. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1160. s.UpdateChatID()
  1161. })
  1162. }
  1163. // ClearChatID clears the value of the "chat_id" field.
  1164. func (u *CompapiAsynctaskUpsertBulk) ClearChatID() *CompapiAsynctaskUpsertBulk {
  1165. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1166. s.ClearChatID()
  1167. })
  1168. }
  1169. // SetOrganizationID sets the "organization_id" field.
  1170. func (u *CompapiAsynctaskUpsertBulk) SetOrganizationID(v uint64) *CompapiAsynctaskUpsertBulk {
  1171. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1172. s.SetOrganizationID(v)
  1173. })
  1174. }
  1175. // AddOrganizationID adds v to the "organization_id" field.
  1176. func (u *CompapiAsynctaskUpsertBulk) AddOrganizationID(v uint64) *CompapiAsynctaskUpsertBulk {
  1177. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1178. s.AddOrganizationID(v)
  1179. })
  1180. }
  1181. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  1182. func (u *CompapiAsynctaskUpsertBulk) UpdateOrganizationID() *CompapiAsynctaskUpsertBulk {
  1183. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1184. s.UpdateOrganizationID()
  1185. })
  1186. }
  1187. // SetOpenaiBase sets the "openai_base" field.
  1188. func (u *CompapiAsynctaskUpsertBulk) SetOpenaiBase(v string) *CompapiAsynctaskUpsertBulk {
  1189. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1190. s.SetOpenaiBase(v)
  1191. })
  1192. }
  1193. // UpdateOpenaiBase sets the "openai_base" field to the value that was provided on create.
  1194. func (u *CompapiAsynctaskUpsertBulk) UpdateOpenaiBase() *CompapiAsynctaskUpsertBulk {
  1195. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1196. s.UpdateOpenaiBase()
  1197. })
  1198. }
  1199. // SetOpenaiKey sets the "openai_key" field.
  1200. func (u *CompapiAsynctaskUpsertBulk) SetOpenaiKey(v string) *CompapiAsynctaskUpsertBulk {
  1201. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1202. s.SetOpenaiKey(v)
  1203. })
  1204. }
  1205. // UpdateOpenaiKey sets the "openai_key" field to the value that was provided on create.
  1206. func (u *CompapiAsynctaskUpsertBulk) UpdateOpenaiKey() *CompapiAsynctaskUpsertBulk {
  1207. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1208. s.UpdateOpenaiKey()
  1209. })
  1210. }
  1211. // SetRequestRaw sets the "request_raw" field.
  1212. func (u *CompapiAsynctaskUpsertBulk) SetRequestRaw(v string) *CompapiAsynctaskUpsertBulk {
  1213. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1214. s.SetRequestRaw(v)
  1215. })
  1216. }
  1217. // UpdateRequestRaw sets the "request_raw" field to the value that was provided on create.
  1218. func (u *CompapiAsynctaskUpsertBulk) UpdateRequestRaw() *CompapiAsynctaskUpsertBulk {
  1219. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1220. s.UpdateRequestRaw()
  1221. })
  1222. }
  1223. // SetResponseRaw sets the "response_raw" field.
  1224. func (u *CompapiAsynctaskUpsertBulk) SetResponseRaw(v string) *CompapiAsynctaskUpsertBulk {
  1225. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1226. s.SetResponseRaw(v)
  1227. })
  1228. }
  1229. // UpdateResponseRaw sets the "response_raw" field to the value that was provided on create.
  1230. func (u *CompapiAsynctaskUpsertBulk) UpdateResponseRaw() *CompapiAsynctaskUpsertBulk {
  1231. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1232. s.UpdateResponseRaw()
  1233. })
  1234. }
  1235. // ClearResponseRaw clears the value of the "response_raw" field.
  1236. func (u *CompapiAsynctaskUpsertBulk) ClearResponseRaw() *CompapiAsynctaskUpsertBulk {
  1237. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1238. s.ClearResponseRaw()
  1239. })
  1240. }
  1241. // SetCallbackURL sets the "callback_url" field.
  1242. func (u *CompapiAsynctaskUpsertBulk) SetCallbackURL(v string) *CompapiAsynctaskUpsertBulk {
  1243. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1244. s.SetCallbackURL(v)
  1245. })
  1246. }
  1247. // UpdateCallbackURL sets the "callback_url" field to the value that was provided on create.
  1248. func (u *CompapiAsynctaskUpsertBulk) UpdateCallbackURL() *CompapiAsynctaskUpsertBulk {
  1249. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1250. s.UpdateCallbackURL()
  1251. })
  1252. }
  1253. // SetCallbackResponseRaw sets the "callback_response_raw" field.
  1254. func (u *CompapiAsynctaskUpsertBulk) SetCallbackResponseRaw(v string) *CompapiAsynctaskUpsertBulk {
  1255. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1256. s.SetCallbackResponseRaw(v)
  1257. })
  1258. }
  1259. // UpdateCallbackResponseRaw sets the "callback_response_raw" field to the value that was provided on create.
  1260. func (u *CompapiAsynctaskUpsertBulk) UpdateCallbackResponseRaw() *CompapiAsynctaskUpsertBulk {
  1261. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1262. s.UpdateCallbackResponseRaw()
  1263. })
  1264. }
  1265. // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field.
  1266. func (u *CompapiAsynctaskUpsertBulk) ClearCallbackResponseRaw() *CompapiAsynctaskUpsertBulk {
  1267. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1268. s.ClearCallbackResponseRaw()
  1269. })
  1270. }
  1271. // SetModel sets the "model" field.
  1272. func (u *CompapiAsynctaskUpsertBulk) SetModel(v string) *CompapiAsynctaskUpsertBulk {
  1273. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1274. s.SetModel(v)
  1275. })
  1276. }
  1277. // UpdateModel sets the "model" field to the value that was provided on create.
  1278. func (u *CompapiAsynctaskUpsertBulk) UpdateModel() *CompapiAsynctaskUpsertBulk {
  1279. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1280. s.UpdateModel()
  1281. })
  1282. }
  1283. // ClearModel clears the value of the "model" field.
  1284. func (u *CompapiAsynctaskUpsertBulk) ClearModel() *CompapiAsynctaskUpsertBulk {
  1285. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1286. s.ClearModel()
  1287. })
  1288. }
  1289. // SetTaskStatus sets the "task_status" field.
  1290. func (u *CompapiAsynctaskUpsertBulk) SetTaskStatus(v int8) *CompapiAsynctaskUpsertBulk {
  1291. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1292. s.SetTaskStatus(v)
  1293. })
  1294. }
  1295. // AddTaskStatus adds v to the "task_status" field.
  1296. func (u *CompapiAsynctaskUpsertBulk) AddTaskStatus(v int8) *CompapiAsynctaskUpsertBulk {
  1297. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1298. s.AddTaskStatus(v)
  1299. })
  1300. }
  1301. // UpdateTaskStatus sets the "task_status" field to the value that was provided on create.
  1302. func (u *CompapiAsynctaskUpsertBulk) UpdateTaskStatus() *CompapiAsynctaskUpsertBulk {
  1303. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1304. s.UpdateTaskStatus()
  1305. })
  1306. }
  1307. // ClearTaskStatus clears the value of the "task_status" field.
  1308. func (u *CompapiAsynctaskUpsertBulk) ClearTaskStatus() *CompapiAsynctaskUpsertBulk {
  1309. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1310. s.ClearTaskStatus()
  1311. })
  1312. }
  1313. // SetRetryCount sets the "retry_count" field.
  1314. func (u *CompapiAsynctaskUpsertBulk) SetRetryCount(v int8) *CompapiAsynctaskUpsertBulk {
  1315. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1316. s.SetRetryCount(v)
  1317. })
  1318. }
  1319. // AddRetryCount adds v to the "retry_count" field.
  1320. func (u *CompapiAsynctaskUpsertBulk) AddRetryCount(v int8) *CompapiAsynctaskUpsertBulk {
  1321. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1322. s.AddRetryCount(v)
  1323. })
  1324. }
  1325. // UpdateRetryCount sets the "retry_count" field to the value that was provided on create.
  1326. func (u *CompapiAsynctaskUpsertBulk) UpdateRetryCount() *CompapiAsynctaskUpsertBulk {
  1327. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1328. s.UpdateRetryCount()
  1329. })
  1330. }
  1331. // ClearRetryCount clears the value of the "retry_count" field.
  1332. func (u *CompapiAsynctaskUpsertBulk) ClearRetryCount() *CompapiAsynctaskUpsertBulk {
  1333. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1334. s.ClearRetryCount()
  1335. })
  1336. }
  1337. // SetLastError sets the "last_error" field.
  1338. func (u *CompapiAsynctaskUpsertBulk) SetLastError(v string) *CompapiAsynctaskUpsertBulk {
  1339. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1340. s.SetLastError(v)
  1341. })
  1342. }
  1343. // UpdateLastError sets the "last_error" field to the value that was provided on create.
  1344. func (u *CompapiAsynctaskUpsertBulk) UpdateLastError() *CompapiAsynctaskUpsertBulk {
  1345. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1346. s.UpdateLastError()
  1347. })
  1348. }
  1349. // ClearLastError clears the value of the "last_error" field.
  1350. func (u *CompapiAsynctaskUpsertBulk) ClearLastError() *CompapiAsynctaskUpsertBulk {
  1351. return u.Update(func(s *CompapiAsynctaskUpsert) {
  1352. s.ClearLastError()
  1353. })
  1354. }
  1355. // Exec executes the query.
  1356. func (u *CompapiAsynctaskUpsertBulk) Exec(ctx context.Context) error {
  1357. if u.create.err != nil {
  1358. return u.create.err
  1359. }
  1360. for i, b := range u.create.builders {
  1361. if len(b.conflict) != 0 {
  1362. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the CompapiAsynctaskCreateBulk instead", i)
  1363. }
  1364. }
  1365. if len(u.create.conflict) == 0 {
  1366. return errors.New("ent: missing options for CompapiAsynctaskCreateBulk.OnConflict")
  1367. }
  1368. return u.create.Exec(ctx)
  1369. }
  1370. // ExecX is like Exec, but panics if an error occurs.
  1371. func (u *CompapiAsynctaskUpsertBulk) ExecX(ctx context.Context) {
  1372. if err := u.create.Exec(ctx); err != nil {
  1373. panic(err)
  1374. }
  1375. }