compapiasynctask_create.go 53 KB

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