compapijob_create.go 39 KB

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