batchimageitem_create.go 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "time"
  8. "entgo.io/ent/dialect/sql"
  9. "entgo.io/ent/dialect/sql/sqlgraph"
  10. "entgo.io/ent/schema/field"
  11. "github.com/Wei-Shaw/sub2api/ent/batchimageitem"
  12. )
  13. // BatchImageItemCreate is the builder for creating a BatchImageItem entity.
  14. type BatchImageItemCreate struct {
  15. config
  16. mutation *BatchImageItemMutation
  17. hooks []Hook
  18. conflict []sql.ConflictOption
  19. }
  20. // SetJobID sets the "job_id" field.
  21. func (_c *BatchImageItemCreate) SetJobID(v string) *BatchImageItemCreate {
  22. _c.mutation.SetJobID(v)
  23. return _c
  24. }
  25. // SetCustomID sets the "custom_id" field.
  26. func (_c *BatchImageItemCreate) SetCustomID(v string) *BatchImageItemCreate {
  27. _c.mutation.SetCustomID(v)
  28. return _c
  29. }
  30. // SetStatus sets the "status" field.
  31. func (_c *BatchImageItemCreate) SetStatus(v string) *BatchImageItemCreate {
  32. _c.mutation.SetStatus(v)
  33. return _c
  34. }
  35. // SetRequestHash sets the "request_hash" field.
  36. func (_c *BatchImageItemCreate) SetRequestHash(v string) *BatchImageItemCreate {
  37. _c.mutation.SetRequestHash(v)
  38. return _c
  39. }
  40. // SetNillableRequestHash sets the "request_hash" field if the given value is not nil.
  41. func (_c *BatchImageItemCreate) SetNillableRequestHash(v *string) *BatchImageItemCreate {
  42. if v != nil {
  43. _c.SetRequestHash(*v)
  44. }
  45. return _c
  46. }
  47. // SetPromptPreview sets the "prompt_preview" field.
  48. func (_c *BatchImageItemCreate) SetPromptPreview(v string) *BatchImageItemCreate {
  49. _c.mutation.SetPromptPreview(v)
  50. return _c
  51. }
  52. // SetNillablePromptPreview sets the "prompt_preview" field if the given value is not nil.
  53. func (_c *BatchImageItemCreate) SetNillablePromptPreview(v *string) *BatchImageItemCreate {
  54. if v != nil {
  55. _c.SetPromptPreview(*v)
  56. }
  57. return _c
  58. }
  59. // SetProviderSourceObject sets the "provider_source_object" field.
  60. func (_c *BatchImageItemCreate) SetProviderSourceObject(v string) *BatchImageItemCreate {
  61. _c.mutation.SetProviderSourceObject(v)
  62. return _c
  63. }
  64. // SetNillableProviderSourceObject sets the "provider_source_object" field if the given value is not nil.
  65. func (_c *BatchImageItemCreate) SetNillableProviderSourceObject(v *string) *BatchImageItemCreate {
  66. if v != nil {
  67. _c.SetProviderSourceObject(*v)
  68. }
  69. return _c
  70. }
  71. // SetSourceLineNumber sets the "source_line_number" field.
  72. func (_c *BatchImageItemCreate) SetSourceLineNumber(v int) *BatchImageItemCreate {
  73. _c.mutation.SetSourceLineNumber(v)
  74. return _c
  75. }
  76. // SetNillableSourceLineNumber sets the "source_line_number" field if the given value is not nil.
  77. func (_c *BatchImageItemCreate) SetNillableSourceLineNumber(v *int) *BatchImageItemCreate {
  78. if v != nil {
  79. _c.SetSourceLineNumber(*v)
  80. }
  81. return _c
  82. }
  83. // SetSourceByteOffset sets the "source_byte_offset" field.
  84. func (_c *BatchImageItemCreate) SetSourceByteOffset(v int64) *BatchImageItemCreate {
  85. _c.mutation.SetSourceByteOffset(v)
  86. return _c
  87. }
  88. // SetNillableSourceByteOffset sets the "source_byte_offset" field if the given value is not nil.
  89. func (_c *BatchImageItemCreate) SetNillableSourceByteOffset(v *int64) *BatchImageItemCreate {
  90. if v != nil {
  91. _c.SetSourceByteOffset(*v)
  92. }
  93. return _c
  94. }
  95. // SetSourceByteLength sets the "source_byte_length" field.
  96. func (_c *BatchImageItemCreate) SetSourceByteLength(v int64) *BatchImageItemCreate {
  97. _c.mutation.SetSourceByteLength(v)
  98. return _c
  99. }
  100. // SetNillableSourceByteLength sets the "source_byte_length" field if the given value is not nil.
  101. func (_c *BatchImageItemCreate) SetNillableSourceByteLength(v *int64) *BatchImageItemCreate {
  102. if v != nil {
  103. _c.SetSourceByteLength(*v)
  104. }
  105. return _c
  106. }
  107. // SetMimeType sets the "mime_type" field.
  108. func (_c *BatchImageItemCreate) SetMimeType(v string) *BatchImageItemCreate {
  109. _c.mutation.SetMimeType(v)
  110. return _c
  111. }
  112. // SetNillableMimeType sets the "mime_type" field if the given value is not nil.
  113. func (_c *BatchImageItemCreate) SetNillableMimeType(v *string) *BatchImageItemCreate {
  114. if v != nil {
  115. _c.SetMimeType(*v)
  116. }
  117. return _c
  118. }
  119. // SetFileExtension sets the "file_extension" field.
  120. func (_c *BatchImageItemCreate) SetFileExtension(v string) *BatchImageItemCreate {
  121. _c.mutation.SetFileExtension(v)
  122. return _c
  123. }
  124. // SetNillableFileExtension sets the "file_extension" field if the given value is not nil.
  125. func (_c *BatchImageItemCreate) SetNillableFileExtension(v *string) *BatchImageItemCreate {
  126. if v != nil {
  127. _c.SetFileExtension(*v)
  128. }
  129. return _c
  130. }
  131. // SetImageCount sets the "image_count" field.
  132. func (_c *BatchImageItemCreate) SetImageCount(v int) *BatchImageItemCreate {
  133. _c.mutation.SetImageCount(v)
  134. return _c
  135. }
  136. // SetNillableImageCount sets the "image_count" field if the given value is not nil.
  137. func (_c *BatchImageItemCreate) SetNillableImageCount(v *int) *BatchImageItemCreate {
  138. if v != nil {
  139. _c.SetImageCount(*v)
  140. }
  141. return _c
  142. }
  143. // SetErrorCode sets the "error_code" field.
  144. func (_c *BatchImageItemCreate) SetErrorCode(v string) *BatchImageItemCreate {
  145. _c.mutation.SetErrorCode(v)
  146. return _c
  147. }
  148. // SetNillableErrorCode sets the "error_code" field if the given value is not nil.
  149. func (_c *BatchImageItemCreate) SetNillableErrorCode(v *string) *BatchImageItemCreate {
  150. if v != nil {
  151. _c.SetErrorCode(*v)
  152. }
  153. return _c
  154. }
  155. // SetErrorMessage sets the "error_message" field.
  156. func (_c *BatchImageItemCreate) SetErrorMessage(v string) *BatchImageItemCreate {
  157. _c.mutation.SetErrorMessage(v)
  158. return _c
  159. }
  160. // SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
  161. func (_c *BatchImageItemCreate) SetNillableErrorMessage(v *string) *BatchImageItemCreate {
  162. if v != nil {
  163. _c.SetErrorMessage(*v)
  164. }
  165. return _c
  166. }
  167. // SetBilledAmount sets the "billed_amount" field.
  168. func (_c *BatchImageItemCreate) SetBilledAmount(v float64) *BatchImageItemCreate {
  169. _c.mutation.SetBilledAmount(v)
  170. return _c
  171. }
  172. // SetNillableBilledAmount sets the "billed_amount" field if the given value is not nil.
  173. func (_c *BatchImageItemCreate) SetNillableBilledAmount(v *float64) *BatchImageItemCreate {
  174. if v != nil {
  175. _c.SetBilledAmount(*v)
  176. }
  177. return _c
  178. }
  179. // SetCreatedAt sets the "created_at" field.
  180. func (_c *BatchImageItemCreate) SetCreatedAt(v time.Time) *BatchImageItemCreate {
  181. _c.mutation.SetCreatedAt(v)
  182. return _c
  183. }
  184. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  185. func (_c *BatchImageItemCreate) SetNillableCreatedAt(v *time.Time) *BatchImageItemCreate {
  186. if v != nil {
  187. _c.SetCreatedAt(*v)
  188. }
  189. return _c
  190. }
  191. // SetIndexedAt sets the "indexed_at" field.
  192. func (_c *BatchImageItemCreate) SetIndexedAt(v time.Time) *BatchImageItemCreate {
  193. _c.mutation.SetIndexedAt(v)
  194. return _c
  195. }
  196. // SetNillableIndexedAt sets the "indexed_at" field if the given value is not nil.
  197. func (_c *BatchImageItemCreate) SetNillableIndexedAt(v *time.Time) *BatchImageItemCreate {
  198. if v != nil {
  199. _c.SetIndexedAt(*v)
  200. }
  201. return _c
  202. }
  203. // Mutation returns the BatchImageItemMutation object of the builder.
  204. func (_c *BatchImageItemCreate) Mutation() *BatchImageItemMutation {
  205. return _c.mutation
  206. }
  207. // Save creates the BatchImageItem in the database.
  208. func (_c *BatchImageItemCreate) Save(ctx context.Context) (*BatchImageItem, error) {
  209. _c.defaults()
  210. return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
  211. }
  212. // SaveX calls Save and panics if Save returns an error.
  213. func (_c *BatchImageItemCreate) SaveX(ctx context.Context) *BatchImageItem {
  214. v, err := _c.Save(ctx)
  215. if err != nil {
  216. panic(err)
  217. }
  218. return v
  219. }
  220. // Exec executes the query.
  221. func (_c *BatchImageItemCreate) Exec(ctx context.Context) error {
  222. _, err := _c.Save(ctx)
  223. return err
  224. }
  225. // ExecX is like Exec, but panics if an error occurs.
  226. func (_c *BatchImageItemCreate) ExecX(ctx context.Context) {
  227. if err := _c.Exec(ctx); err != nil {
  228. panic(err)
  229. }
  230. }
  231. // defaults sets the default values of the builder before save.
  232. func (_c *BatchImageItemCreate) defaults() {
  233. if _, ok := _c.mutation.ImageCount(); !ok {
  234. v := batchimageitem.DefaultImageCount
  235. _c.mutation.SetImageCount(v)
  236. }
  237. if _, ok := _c.mutation.CreatedAt(); !ok {
  238. v := batchimageitem.DefaultCreatedAt()
  239. _c.mutation.SetCreatedAt(v)
  240. }
  241. }
  242. // check runs all checks and user-defined validators on the builder.
  243. func (_c *BatchImageItemCreate) check() error {
  244. if _, ok := _c.mutation.JobID(); !ok {
  245. return &ValidationError{Name: "job_id", err: errors.New(`ent: missing required field "BatchImageItem.job_id"`)}
  246. }
  247. if v, ok := _c.mutation.JobID(); ok {
  248. if err := batchimageitem.JobIDValidator(v); err != nil {
  249. return &ValidationError{Name: "job_id", err: fmt.Errorf(`ent: validator failed for field "BatchImageItem.job_id": %w`, err)}
  250. }
  251. }
  252. if _, ok := _c.mutation.CustomID(); !ok {
  253. return &ValidationError{Name: "custom_id", err: errors.New(`ent: missing required field "BatchImageItem.custom_id"`)}
  254. }
  255. if v, ok := _c.mutation.CustomID(); ok {
  256. if err := batchimageitem.CustomIDValidator(v); err != nil {
  257. return &ValidationError{Name: "custom_id", err: fmt.Errorf(`ent: validator failed for field "BatchImageItem.custom_id": %w`, err)}
  258. }
  259. }
  260. if _, ok := _c.mutation.Status(); !ok {
  261. return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "BatchImageItem.status"`)}
  262. }
  263. if v, ok := _c.mutation.Status(); ok {
  264. if err := batchimageitem.StatusValidator(v); err != nil {
  265. return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "BatchImageItem.status": %w`, err)}
  266. }
  267. }
  268. if v, ok := _c.mutation.RequestHash(); ok {
  269. if err := batchimageitem.RequestHashValidator(v); err != nil {
  270. return &ValidationError{Name: "request_hash", err: fmt.Errorf(`ent: validator failed for field "BatchImageItem.request_hash": %w`, err)}
  271. }
  272. }
  273. if v, ok := _c.mutation.ProviderSourceObject(); ok {
  274. if err := batchimageitem.ProviderSourceObjectValidator(v); err != nil {
  275. return &ValidationError{Name: "provider_source_object", err: fmt.Errorf(`ent: validator failed for field "BatchImageItem.provider_source_object": %w`, err)}
  276. }
  277. }
  278. if v, ok := _c.mutation.MimeType(); ok {
  279. if err := batchimageitem.MimeTypeValidator(v); err != nil {
  280. return &ValidationError{Name: "mime_type", err: fmt.Errorf(`ent: validator failed for field "BatchImageItem.mime_type": %w`, err)}
  281. }
  282. }
  283. if v, ok := _c.mutation.FileExtension(); ok {
  284. if err := batchimageitem.FileExtensionValidator(v); err != nil {
  285. return &ValidationError{Name: "file_extension", err: fmt.Errorf(`ent: validator failed for field "BatchImageItem.file_extension": %w`, err)}
  286. }
  287. }
  288. if _, ok := _c.mutation.ImageCount(); !ok {
  289. return &ValidationError{Name: "image_count", err: errors.New(`ent: missing required field "BatchImageItem.image_count"`)}
  290. }
  291. if v, ok := _c.mutation.ErrorCode(); ok {
  292. if err := batchimageitem.ErrorCodeValidator(v); err != nil {
  293. return &ValidationError{Name: "error_code", err: fmt.Errorf(`ent: validator failed for field "BatchImageItem.error_code": %w`, err)}
  294. }
  295. }
  296. if _, ok := _c.mutation.CreatedAt(); !ok {
  297. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "BatchImageItem.created_at"`)}
  298. }
  299. return nil
  300. }
  301. func (_c *BatchImageItemCreate) sqlSave(ctx context.Context) (*BatchImageItem, error) {
  302. if err := _c.check(); err != nil {
  303. return nil, err
  304. }
  305. _node, _spec := _c.createSpec()
  306. if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
  307. if sqlgraph.IsConstraintError(err) {
  308. err = &ConstraintError{msg: err.Error(), wrap: err}
  309. }
  310. return nil, err
  311. }
  312. id := _spec.ID.Value.(int64)
  313. _node.ID = int64(id)
  314. _c.mutation.id = &_node.ID
  315. _c.mutation.done = true
  316. return _node, nil
  317. }
  318. func (_c *BatchImageItemCreate) createSpec() (*BatchImageItem, *sqlgraph.CreateSpec) {
  319. var (
  320. _node = &BatchImageItem{config: _c.config}
  321. _spec = sqlgraph.NewCreateSpec(batchimageitem.Table, sqlgraph.NewFieldSpec(batchimageitem.FieldID, field.TypeInt64))
  322. )
  323. _spec.OnConflict = _c.conflict
  324. if value, ok := _c.mutation.JobID(); ok {
  325. _spec.SetField(batchimageitem.FieldJobID, field.TypeString, value)
  326. _node.JobID = value
  327. }
  328. if value, ok := _c.mutation.CustomID(); ok {
  329. _spec.SetField(batchimageitem.FieldCustomID, field.TypeString, value)
  330. _node.CustomID = value
  331. }
  332. if value, ok := _c.mutation.Status(); ok {
  333. _spec.SetField(batchimageitem.FieldStatus, field.TypeString, value)
  334. _node.Status = value
  335. }
  336. if value, ok := _c.mutation.RequestHash(); ok {
  337. _spec.SetField(batchimageitem.FieldRequestHash, field.TypeString, value)
  338. _node.RequestHash = &value
  339. }
  340. if value, ok := _c.mutation.PromptPreview(); ok {
  341. _spec.SetField(batchimageitem.FieldPromptPreview, field.TypeString, value)
  342. _node.PromptPreview = &value
  343. }
  344. if value, ok := _c.mutation.ProviderSourceObject(); ok {
  345. _spec.SetField(batchimageitem.FieldProviderSourceObject, field.TypeString, value)
  346. _node.ProviderSourceObject = &value
  347. }
  348. if value, ok := _c.mutation.SourceLineNumber(); ok {
  349. _spec.SetField(batchimageitem.FieldSourceLineNumber, field.TypeInt, value)
  350. _node.SourceLineNumber = &value
  351. }
  352. if value, ok := _c.mutation.SourceByteOffset(); ok {
  353. _spec.SetField(batchimageitem.FieldSourceByteOffset, field.TypeInt64, value)
  354. _node.SourceByteOffset = &value
  355. }
  356. if value, ok := _c.mutation.SourceByteLength(); ok {
  357. _spec.SetField(batchimageitem.FieldSourceByteLength, field.TypeInt64, value)
  358. _node.SourceByteLength = &value
  359. }
  360. if value, ok := _c.mutation.MimeType(); ok {
  361. _spec.SetField(batchimageitem.FieldMimeType, field.TypeString, value)
  362. _node.MimeType = &value
  363. }
  364. if value, ok := _c.mutation.FileExtension(); ok {
  365. _spec.SetField(batchimageitem.FieldFileExtension, field.TypeString, value)
  366. _node.FileExtension = &value
  367. }
  368. if value, ok := _c.mutation.ImageCount(); ok {
  369. _spec.SetField(batchimageitem.FieldImageCount, field.TypeInt, value)
  370. _node.ImageCount = value
  371. }
  372. if value, ok := _c.mutation.ErrorCode(); ok {
  373. _spec.SetField(batchimageitem.FieldErrorCode, field.TypeString, value)
  374. _node.ErrorCode = &value
  375. }
  376. if value, ok := _c.mutation.ErrorMessage(); ok {
  377. _spec.SetField(batchimageitem.FieldErrorMessage, field.TypeString, value)
  378. _node.ErrorMessage = &value
  379. }
  380. if value, ok := _c.mutation.BilledAmount(); ok {
  381. _spec.SetField(batchimageitem.FieldBilledAmount, field.TypeFloat64, value)
  382. _node.BilledAmount = &value
  383. }
  384. if value, ok := _c.mutation.CreatedAt(); ok {
  385. _spec.SetField(batchimageitem.FieldCreatedAt, field.TypeTime, value)
  386. _node.CreatedAt = value
  387. }
  388. if value, ok := _c.mutation.IndexedAt(); ok {
  389. _spec.SetField(batchimageitem.FieldIndexedAt, field.TypeTime, value)
  390. _node.IndexedAt = &value
  391. }
  392. return _node, _spec
  393. }
  394. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  395. // of the `INSERT` statement. For example:
  396. //
  397. // client.BatchImageItem.Create().
  398. // SetJobID(v).
  399. // OnConflict(
  400. // // Update the row with the new values
  401. // // the was proposed for insertion.
  402. // sql.ResolveWithNewValues(),
  403. // ).
  404. // // Override some of the fields with custom
  405. // // update values.
  406. // Update(func(u *ent.BatchImageItemUpsert) {
  407. // SetJobID(v+v).
  408. // }).
  409. // Exec(ctx)
  410. func (_c *BatchImageItemCreate) OnConflict(opts ...sql.ConflictOption) *BatchImageItemUpsertOne {
  411. _c.conflict = opts
  412. return &BatchImageItemUpsertOne{
  413. create: _c,
  414. }
  415. }
  416. // OnConflictColumns calls `OnConflict` and configures the columns
  417. // as conflict target. Using this option is equivalent to using:
  418. //
  419. // client.BatchImageItem.Create().
  420. // OnConflict(sql.ConflictColumns(columns...)).
  421. // Exec(ctx)
  422. func (_c *BatchImageItemCreate) OnConflictColumns(columns ...string) *BatchImageItemUpsertOne {
  423. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  424. return &BatchImageItemUpsertOne{
  425. create: _c,
  426. }
  427. }
  428. type (
  429. // BatchImageItemUpsertOne is the builder for "upsert"-ing
  430. // one BatchImageItem node.
  431. BatchImageItemUpsertOne struct {
  432. create *BatchImageItemCreate
  433. }
  434. // BatchImageItemUpsert is the "OnConflict" setter.
  435. BatchImageItemUpsert struct {
  436. *sql.UpdateSet
  437. }
  438. )
  439. // SetJobID sets the "job_id" field.
  440. func (u *BatchImageItemUpsert) SetJobID(v string) *BatchImageItemUpsert {
  441. u.Set(batchimageitem.FieldJobID, v)
  442. return u
  443. }
  444. // UpdateJobID sets the "job_id" field to the value that was provided on create.
  445. func (u *BatchImageItemUpsert) UpdateJobID() *BatchImageItemUpsert {
  446. u.SetExcluded(batchimageitem.FieldJobID)
  447. return u
  448. }
  449. // SetCustomID sets the "custom_id" field.
  450. func (u *BatchImageItemUpsert) SetCustomID(v string) *BatchImageItemUpsert {
  451. u.Set(batchimageitem.FieldCustomID, v)
  452. return u
  453. }
  454. // UpdateCustomID sets the "custom_id" field to the value that was provided on create.
  455. func (u *BatchImageItemUpsert) UpdateCustomID() *BatchImageItemUpsert {
  456. u.SetExcluded(batchimageitem.FieldCustomID)
  457. return u
  458. }
  459. // SetStatus sets the "status" field.
  460. func (u *BatchImageItemUpsert) SetStatus(v string) *BatchImageItemUpsert {
  461. u.Set(batchimageitem.FieldStatus, v)
  462. return u
  463. }
  464. // UpdateStatus sets the "status" field to the value that was provided on create.
  465. func (u *BatchImageItemUpsert) UpdateStatus() *BatchImageItemUpsert {
  466. u.SetExcluded(batchimageitem.FieldStatus)
  467. return u
  468. }
  469. // SetRequestHash sets the "request_hash" field.
  470. func (u *BatchImageItemUpsert) SetRequestHash(v string) *BatchImageItemUpsert {
  471. u.Set(batchimageitem.FieldRequestHash, v)
  472. return u
  473. }
  474. // UpdateRequestHash sets the "request_hash" field to the value that was provided on create.
  475. func (u *BatchImageItemUpsert) UpdateRequestHash() *BatchImageItemUpsert {
  476. u.SetExcluded(batchimageitem.FieldRequestHash)
  477. return u
  478. }
  479. // ClearRequestHash clears the value of the "request_hash" field.
  480. func (u *BatchImageItemUpsert) ClearRequestHash() *BatchImageItemUpsert {
  481. u.SetNull(batchimageitem.FieldRequestHash)
  482. return u
  483. }
  484. // SetPromptPreview sets the "prompt_preview" field.
  485. func (u *BatchImageItemUpsert) SetPromptPreview(v string) *BatchImageItemUpsert {
  486. u.Set(batchimageitem.FieldPromptPreview, v)
  487. return u
  488. }
  489. // UpdatePromptPreview sets the "prompt_preview" field to the value that was provided on create.
  490. func (u *BatchImageItemUpsert) UpdatePromptPreview() *BatchImageItemUpsert {
  491. u.SetExcluded(batchimageitem.FieldPromptPreview)
  492. return u
  493. }
  494. // ClearPromptPreview clears the value of the "prompt_preview" field.
  495. func (u *BatchImageItemUpsert) ClearPromptPreview() *BatchImageItemUpsert {
  496. u.SetNull(batchimageitem.FieldPromptPreview)
  497. return u
  498. }
  499. // SetProviderSourceObject sets the "provider_source_object" field.
  500. func (u *BatchImageItemUpsert) SetProviderSourceObject(v string) *BatchImageItemUpsert {
  501. u.Set(batchimageitem.FieldProviderSourceObject, v)
  502. return u
  503. }
  504. // UpdateProviderSourceObject sets the "provider_source_object" field to the value that was provided on create.
  505. func (u *BatchImageItemUpsert) UpdateProviderSourceObject() *BatchImageItemUpsert {
  506. u.SetExcluded(batchimageitem.FieldProviderSourceObject)
  507. return u
  508. }
  509. // ClearProviderSourceObject clears the value of the "provider_source_object" field.
  510. func (u *BatchImageItemUpsert) ClearProviderSourceObject() *BatchImageItemUpsert {
  511. u.SetNull(batchimageitem.FieldProviderSourceObject)
  512. return u
  513. }
  514. // SetSourceLineNumber sets the "source_line_number" field.
  515. func (u *BatchImageItemUpsert) SetSourceLineNumber(v int) *BatchImageItemUpsert {
  516. u.Set(batchimageitem.FieldSourceLineNumber, v)
  517. return u
  518. }
  519. // UpdateSourceLineNumber sets the "source_line_number" field to the value that was provided on create.
  520. func (u *BatchImageItemUpsert) UpdateSourceLineNumber() *BatchImageItemUpsert {
  521. u.SetExcluded(batchimageitem.FieldSourceLineNumber)
  522. return u
  523. }
  524. // AddSourceLineNumber adds v to the "source_line_number" field.
  525. func (u *BatchImageItemUpsert) AddSourceLineNumber(v int) *BatchImageItemUpsert {
  526. u.Add(batchimageitem.FieldSourceLineNumber, v)
  527. return u
  528. }
  529. // ClearSourceLineNumber clears the value of the "source_line_number" field.
  530. func (u *BatchImageItemUpsert) ClearSourceLineNumber() *BatchImageItemUpsert {
  531. u.SetNull(batchimageitem.FieldSourceLineNumber)
  532. return u
  533. }
  534. // SetSourceByteOffset sets the "source_byte_offset" field.
  535. func (u *BatchImageItemUpsert) SetSourceByteOffset(v int64) *BatchImageItemUpsert {
  536. u.Set(batchimageitem.FieldSourceByteOffset, v)
  537. return u
  538. }
  539. // UpdateSourceByteOffset sets the "source_byte_offset" field to the value that was provided on create.
  540. func (u *BatchImageItemUpsert) UpdateSourceByteOffset() *BatchImageItemUpsert {
  541. u.SetExcluded(batchimageitem.FieldSourceByteOffset)
  542. return u
  543. }
  544. // AddSourceByteOffset adds v to the "source_byte_offset" field.
  545. func (u *BatchImageItemUpsert) AddSourceByteOffset(v int64) *BatchImageItemUpsert {
  546. u.Add(batchimageitem.FieldSourceByteOffset, v)
  547. return u
  548. }
  549. // ClearSourceByteOffset clears the value of the "source_byte_offset" field.
  550. func (u *BatchImageItemUpsert) ClearSourceByteOffset() *BatchImageItemUpsert {
  551. u.SetNull(batchimageitem.FieldSourceByteOffset)
  552. return u
  553. }
  554. // SetSourceByteLength sets the "source_byte_length" field.
  555. func (u *BatchImageItemUpsert) SetSourceByteLength(v int64) *BatchImageItemUpsert {
  556. u.Set(batchimageitem.FieldSourceByteLength, v)
  557. return u
  558. }
  559. // UpdateSourceByteLength sets the "source_byte_length" field to the value that was provided on create.
  560. func (u *BatchImageItemUpsert) UpdateSourceByteLength() *BatchImageItemUpsert {
  561. u.SetExcluded(batchimageitem.FieldSourceByteLength)
  562. return u
  563. }
  564. // AddSourceByteLength adds v to the "source_byte_length" field.
  565. func (u *BatchImageItemUpsert) AddSourceByteLength(v int64) *BatchImageItemUpsert {
  566. u.Add(batchimageitem.FieldSourceByteLength, v)
  567. return u
  568. }
  569. // ClearSourceByteLength clears the value of the "source_byte_length" field.
  570. func (u *BatchImageItemUpsert) ClearSourceByteLength() *BatchImageItemUpsert {
  571. u.SetNull(batchimageitem.FieldSourceByteLength)
  572. return u
  573. }
  574. // SetMimeType sets the "mime_type" field.
  575. func (u *BatchImageItemUpsert) SetMimeType(v string) *BatchImageItemUpsert {
  576. u.Set(batchimageitem.FieldMimeType, v)
  577. return u
  578. }
  579. // UpdateMimeType sets the "mime_type" field to the value that was provided on create.
  580. func (u *BatchImageItemUpsert) UpdateMimeType() *BatchImageItemUpsert {
  581. u.SetExcluded(batchimageitem.FieldMimeType)
  582. return u
  583. }
  584. // ClearMimeType clears the value of the "mime_type" field.
  585. func (u *BatchImageItemUpsert) ClearMimeType() *BatchImageItemUpsert {
  586. u.SetNull(batchimageitem.FieldMimeType)
  587. return u
  588. }
  589. // SetFileExtension sets the "file_extension" field.
  590. func (u *BatchImageItemUpsert) SetFileExtension(v string) *BatchImageItemUpsert {
  591. u.Set(batchimageitem.FieldFileExtension, v)
  592. return u
  593. }
  594. // UpdateFileExtension sets the "file_extension" field to the value that was provided on create.
  595. func (u *BatchImageItemUpsert) UpdateFileExtension() *BatchImageItemUpsert {
  596. u.SetExcluded(batchimageitem.FieldFileExtension)
  597. return u
  598. }
  599. // ClearFileExtension clears the value of the "file_extension" field.
  600. func (u *BatchImageItemUpsert) ClearFileExtension() *BatchImageItemUpsert {
  601. u.SetNull(batchimageitem.FieldFileExtension)
  602. return u
  603. }
  604. // SetImageCount sets the "image_count" field.
  605. func (u *BatchImageItemUpsert) SetImageCount(v int) *BatchImageItemUpsert {
  606. u.Set(batchimageitem.FieldImageCount, v)
  607. return u
  608. }
  609. // UpdateImageCount sets the "image_count" field to the value that was provided on create.
  610. func (u *BatchImageItemUpsert) UpdateImageCount() *BatchImageItemUpsert {
  611. u.SetExcluded(batchimageitem.FieldImageCount)
  612. return u
  613. }
  614. // AddImageCount adds v to the "image_count" field.
  615. func (u *BatchImageItemUpsert) AddImageCount(v int) *BatchImageItemUpsert {
  616. u.Add(batchimageitem.FieldImageCount, v)
  617. return u
  618. }
  619. // SetErrorCode sets the "error_code" field.
  620. func (u *BatchImageItemUpsert) SetErrorCode(v string) *BatchImageItemUpsert {
  621. u.Set(batchimageitem.FieldErrorCode, v)
  622. return u
  623. }
  624. // UpdateErrorCode sets the "error_code" field to the value that was provided on create.
  625. func (u *BatchImageItemUpsert) UpdateErrorCode() *BatchImageItemUpsert {
  626. u.SetExcluded(batchimageitem.FieldErrorCode)
  627. return u
  628. }
  629. // ClearErrorCode clears the value of the "error_code" field.
  630. func (u *BatchImageItemUpsert) ClearErrorCode() *BatchImageItemUpsert {
  631. u.SetNull(batchimageitem.FieldErrorCode)
  632. return u
  633. }
  634. // SetErrorMessage sets the "error_message" field.
  635. func (u *BatchImageItemUpsert) SetErrorMessage(v string) *BatchImageItemUpsert {
  636. u.Set(batchimageitem.FieldErrorMessage, v)
  637. return u
  638. }
  639. // UpdateErrorMessage sets the "error_message" field to the value that was provided on create.
  640. func (u *BatchImageItemUpsert) UpdateErrorMessage() *BatchImageItemUpsert {
  641. u.SetExcluded(batchimageitem.FieldErrorMessage)
  642. return u
  643. }
  644. // ClearErrorMessage clears the value of the "error_message" field.
  645. func (u *BatchImageItemUpsert) ClearErrorMessage() *BatchImageItemUpsert {
  646. u.SetNull(batchimageitem.FieldErrorMessage)
  647. return u
  648. }
  649. // SetBilledAmount sets the "billed_amount" field.
  650. func (u *BatchImageItemUpsert) SetBilledAmount(v float64) *BatchImageItemUpsert {
  651. u.Set(batchimageitem.FieldBilledAmount, v)
  652. return u
  653. }
  654. // UpdateBilledAmount sets the "billed_amount" field to the value that was provided on create.
  655. func (u *BatchImageItemUpsert) UpdateBilledAmount() *BatchImageItemUpsert {
  656. u.SetExcluded(batchimageitem.FieldBilledAmount)
  657. return u
  658. }
  659. // AddBilledAmount adds v to the "billed_amount" field.
  660. func (u *BatchImageItemUpsert) AddBilledAmount(v float64) *BatchImageItemUpsert {
  661. u.Add(batchimageitem.FieldBilledAmount, v)
  662. return u
  663. }
  664. // ClearBilledAmount clears the value of the "billed_amount" field.
  665. func (u *BatchImageItemUpsert) ClearBilledAmount() *BatchImageItemUpsert {
  666. u.SetNull(batchimageitem.FieldBilledAmount)
  667. return u
  668. }
  669. // SetIndexedAt sets the "indexed_at" field.
  670. func (u *BatchImageItemUpsert) SetIndexedAt(v time.Time) *BatchImageItemUpsert {
  671. u.Set(batchimageitem.FieldIndexedAt, v)
  672. return u
  673. }
  674. // UpdateIndexedAt sets the "indexed_at" field to the value that was provided on create.
  675. func (u *BatchImageItemUpsert) UpdateIndexedAt() *BatchImageItemUpsert {
  676. u.SetExcluded(batchimageitem.FieldIndexedAt)
  677. return u
  678. }
  679. // ClearIndexedAt clears the value of the "indexed_at" field.
  680. func (u *BatchImageItemUpsert) ClearIndexedAt() *BatchImageItemUpsert {
  681. u.SetNull(batchimageitem.FieldIndexedAt)
  682. return u
  683. }
  684. // UpdateNewValues updates the mutable fields using the new values that were set on create.
  685. // Using this option is equivalent to using:
  686. //
  687. // client.BatchImageItem.Create().
  688. // OnConflict(
  689. // sql.ResolveWithNewValues(),
  690. // ).
  691. // Exec(ctx)
  692. func (u *BatchImageItemUpsertOne) UpdateNewValues() *BatchImageItemUpsertOne {
  693. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  694. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  695. if _, exists := u.create.mutation.CreatedAt(); exists {
  696. s.SetIgnore(batchimageitem.FieldCreatedAt)
  697. }
  698. }))
  699. return u
  700. }
  701. // Ignore sets each column to itself in case of conflict.
  702. // Using this option is equivalent to using:
  703. //
  704. // client.BatchImageItem.Create().
  705. // OnConflict(sql.ResolveWithIgnore()).
  706. // Exec(ctx)
  707. func (u *BatchImageItemUpsertOne) Ignore() *BatchImageItemUpsertOne {
  708. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  709. return u
  710. }
  711. // DoNothing configures the conflict_action to `DO NOTHING`.
  712. // Supported only by SQLite and PostgreSQL.
  713. func (u *BatchImageItemUpsertOne) DoNothing() *BatchImageItemUpsertOne {
  714. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  715. return u
  716. }
  717. // Update allows overriding fields `UPDATE` values. See the BatchImageItemCreate.OnConflict
  718. // documentation for more info.
  719. func (u *BatchImageItemUpsertOne) Update(set func(*BatchImageItemUpsert)) *BatchImageItemUpsertOne {
  720. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  721. set(&BatchImageItemUpsert{UpdateSet: update})
  722. }))
  723. return u
  724. }
  725. // SetJobID sets the "job_id" field.
  726. func (u *BatchImageItemUpsertOne) SetJobID(v string) *BatchImageItemUpsertOne {
  727. return u.Update(func(s *BatchImageItemUpsert) {
  728. s.SetJobID(v)
  729. })
  730. }
  731. // UpdateJobID sets the "job_id" field to the value that was provided on create.
  732. func (u *BatchImageItemUpsertOne) UpdateJobID() *BatchImageItemUpsertOne {
  733. return u.Update(func(s *BatchImageItemUpsert) {
  734. s.UpdateJobID()
  735. })
  736. }
  737. // SetCustomID sets the "custom_id" field.
  738. func (u *BatchImageItemUpsertOne) SetCustomID(v string) *BatchImageItemUpsertOne {
  739. return u.Update(func(s *BatchImageItemUpsert) {
  740. s.SetCustomID(v)
  741. })
  742. }
  743. // UpdateCustomID sets the "custom_id" field to the value that was provided on create.
  744. func (u *BatchImageItemUpsertOne) UpdateCustomID() *BatchImageItemUpsertOne {
  745. return u.Update(func(s *BatchImageItemUpsert) {
  746. s.UpdateCustomID()
  747. })
  748. }
  749. // SetStatus sets the "status" field.
  750. func (u *BatchImageItemUpsertOne) SetStatus(v string) *BatchImageItemUpsertOne {
  751. return u.Update(func(s *BatchImageItemUpsert) {
  752. s.SetStatus(v)
  753. })
  754. }
  755. // UpdateStatus sets the "status" field to the value that was provided on create.
  756. func (u *BatchImageItemUpsertOne) UpdateStatus() *BatchImageItemUpsertOne {
  757. return u.Update(func(s *BatchImageItemUpsert) {
  758. s.UpdateStatus()
  759. })
  760. }
  761. // SetRequestHash sets the "request_hash" field.
  762. func (u *BatchImageItemUpsertOne) SetRequestHash(v string) *BatchImageItemUpsertOne {
  763. return u.Update(func(s *BatchImageItemUpsert) {
  764. s.SetRequestHash(v)
  765. })
  766. }
  767. // UpdateRequestHash sets the "request_hash" field to the value that was provided on create.
  768. func (u *BatchImageItemUpsertOne) UpdateRequestHash() *BatchImageItemUpsertOne {
  769. return u.Update(func(s *BatchImageItemUpsert) {
  770. s.UpdateRequestHash()
  771. })
  772. }
  773. // ClearRequestHash clears the value of the "request_hash" field.
  774. func (u *BatchImageItemUpsertOne) ClearRequestHash() *BatchImageItemUpsertOne {
  775. return u.Update(func(s *BatchImageItemUpsert) {
  776. s.ClearRequestHash()
  777. })
  778. }
  779. // SetPromptPreview sets the "prompt_preview" field.
  780. func (u *BatchImageItemUpsertOne) SetPromptPreview(v string) *BatchImageItemUpsertOne {
  781. return u.Update(func(s *BatchImageItemUpsert) {
  782. s.SetPromptPreview(v)
  783. })
  784. }
  785. // UpdatePromptPreview sets the "prompt_preview" field to the value that was provided on create.
  786. func (u *BatchImageItemUpsertOne) UpdatePromptPreview() *BatchImageItemUpsertOne {
  787. return u.Update(func(s *BatchImageItemUpsert) {
  788. s.UpdatePromptPreview()
  789. })
  790. }
  791. // ClearPromptPreview clears the value of the "prompt_preview" field.
  792. func (u *BatchImageItemUpsertOne) ClearPromptPreview() *BatchImageItemUpsertOne {
  793. return u.Update(func(s *BatchImageItemUpsert) {
  794. s.ClearPromptPreview()
  795. })
  796. }
  797. // SetProviderSourceObject sets the "provider_source_object" field.
  798. func (u *BatchImageItemUpsertOne) SetProviderSourceObject(v string) *BatchImageItemUpsertOne {
  799. return u.Update(func(s *BatchImageItemUpsert) {
  800. s.SetProviderSourceObject(v)
  801. })
  802. }
  803. // UpdateProviderSourceObject sets the "provider_source_object" field to the value that was provided on create.
  804. func (u *BatchImageItemUpsertOne) UpdateProviderSourceObject() *BatchImageItemUpsertOne {
  805. return u.Update(func(s *BatchImageItemUpsert) {
  806. s.UpdateProviderSourceObject()
  807. })
  808. }
  809. // ClearProviderSourceObject clears the value of the "provider_source_object" field.
  810. func (u *BatchImageItemUpsertOne) ClearProviderSourceObject() *BatchImageItemUpsertOne {
  811. return u.Update(func(s *BatchImageItemUpsert) {
  812. s.ClearProviderSourceObject()
  813. })
  814. }
  815. // SetSourceLineNumber sets the "source_line_number" field.
  816. func (u *BatchImageItemUpsertOne) SetSourceLineNumber(v int) *BatchImageItemUpsertOne {
  817. return u.Update(func(s *BatchImageItemUpsert) {
  818. s.SetSourceLineNumber(v)
  819. })
  820. }
  821. // AddSourceLineNumber adds v to the "source_line_number" field.
  822. func (u *BatchImageItemUpsertOne) AddSourceLineNumber(v int) *BatchImageItemUpsertOne {
  823. return u.Update(func(s *BatchImageItemUpsert) {
  824. s.AddSourceLineNumber(v)
  825. })
  826. }
  827. // UpdateSourceLineNumber sets the "source_line_number" field to the value that was provided on create.
  828. func (u *BatchImageItemUpsertOne) UpdateSourceLineNumber() *BatchImageItemUpsertOne {
  829. return u.Update(func(s *BatchImageItemUpsert) {
  830. s.UpdateSourceLineNumber()
  831. })
  832. }
  833. // ClearSourceLineNumber clears the value of the "source_line_number" field.
  834. func (u *BatchImageItemUpsertOne) ClearSourceLineNumber() *BatchImageItemUpsertOne {
  835. return u.Update(func(s *BatchImageItemUpsert) {
  836. s.ClearSourceLineNumber()
  837. })
  838. }
  839. // SetSourceByteOffset sets the "source_byte_offset" field.
  840. func (u *BatchImageItemUpsertOne) SetSourceByteOffset(v int64) *BatchImageItemUpsertOne {
  841. return u.Update(func(s *BatchImageItemUpsert) {
  842. s.SetSourceByteOffset(v)
  843. })
  844. }
  845. // AddSourceByteOffset adds v to the "source_byte_offset" field.
  846. func (u *BatchImageItemUpsertOne) AddSourceByteOffset(v int64) *BatchImageItemUpsertOne {
  847. return u.Update(func(s *BatchImageItemUpsert) {
  848. s.AddSourceByteOffset(v)
  849. })
  850. }
  851. // UpdateSourceByteOffset sets the "source_byte_offset" field to the value that was provided on create.
  852. func (u *BatchImageItemUpsertOne) UpdateSourceByteOffset() *BatchImageItemUpsertOne {
  853. return u.Update(func(s *BatchImageItemUpsert) {
  854. s.UpdateSourceByteOffset()
  855. })
  856. }
  857. // ClearSourceByteOffset clears the value of the "source_byte_offset" field.
  858. func (u *BatchImageItemUpsertOne) ClearSourceByteOffset() *BatchImageItemUpsertOne {
  859. return u.Update(func(s *BatchImageItemUpsert) {
  860. s.ClearSourceByteOffset()
  861. })
  862. }
  863. // SetSourceByteLength sets the "source_byte_length" field.
  864. func (u *BatchImageItemUpsertOne) SetSourceByteLength(v int64) *BatchImageItemUpsertOne {
  865. return u.Update(func(s *BatchImageItemUpsert) {
  866. s.SetSourceByteLength(v)
  867. })
  868. }
  869. // AddSourceByteLength adds v to the "source_byte_length" field.
  870. func (u *BatchImageItemUpsertOne) AddSourceByteLength(v int64) *BatchImageItemUpsertOne {
  871. return u.Update(func(s *BatchImageItemUpsert) {
  872. s.AddSourceByteLength(v)
  873. })
  874. }
  875. // UpdateSourceByteLength sets the "source_byte_length" field to the value that was provided on create.
  876. func (u *BatchImageItemUpsertOne) UpdateSourceByteLength() *BatchImageItemUpsertOne {
  877. return u.Update(func(s *BatchImageItemUpsert) {
  878. s.UpdateSourceByteLength()
  879. })
  880. }
  881. // ClearSourceByteLength clears the value of the "source_byte_length" field.
  882. func (u *BatchImageItemUpsertOne) ClearSourceByteLength() *BatchImageItemUpsertOne {
  883. return u.Update(func(s *BatchImageItemUpsert) {
  884. s.ClearSourceByteLength()
  885. })
  886. }
  887. // SetMimeType sets the "mime_type" field.
  888. func (u *BatchImageItemUpsertOne) SetMimeType(v string) *BatchImageItemUpsertOne {
  889. return u.Update(func(s *BatchImageItemUpsert) {
  890. s.SetMimeType(v)
  891. })
  892. }
  893. // UpdateMimeType sets the "mime_type" field to the value that was provided on create.
  894. func (u *BatchImageItemUpsertOne) UpdateMimeType() *BatchImageItemUpsertOne {
  895. return u.Update(func(s *BatchImageItemUpsert) {
  896. s.UpdateMimeType()
  897. })
  898. }
  899. // ClearMimeType clears the value of the "mime_type" field.
  900. func (u *BatchImageItemUpsertOne) ClearMimeType() *BatchImageItemUpsertOne {
  901. return u.Update(func(s *BatchImageItemUpsert) {
  902. s.ClearMimeType()
  903. })
  904. }
  905. // SetFileExtension sets the "file_extension" field.
  906. func (u *BatchImageItemUpsertOne) SetFileExtension(v string) *BatchImageItemUpsertOne {
  907. return u.Update(func(s *BatchImageItemUpsert) {
  908. s.SetFileExtension(v)
  909. })
  910. }
  911. // UpdateFileExtension sets the "file_extension" field to the value that was provided on create.
  912. func (u *BatchImageItemUpsertOne) UpdateFileExtension() *BatchImageItemUpsertOne {
  913. return u.Update(func(s *BatchImageItemUpsert) {
  914. s.UpdateFileExtension()
  915. })
  916. }
  917. // ClearFileExtension clears the value of the "file_extension" field.
  918. func (u *BatchImageItemUpsertOne) ClearFileExtension() *BatchImageItemUpsertOne {
  919. return u.Update(func(s *BatchImageItemUpsert) {
  920. s.ClearFileExtension()
  921. })
  922. }
  923. // SetImageCount sets the "image_count" field.
  924. func (u *BatchImageItemUpsertOne) SetImageCount(v int) *BatchImageItemUpsertOne {
  925. return u.Update(func(s *BatchImageItemUpsert) {
  926. s.SetImageCount(v)
  927. })
  928. }
  929. // AddImageCount adds v to the "image_count" field.
  930. func (u *BatchImageItemUpsertOne) AddImageCount(v int) *BatchImageItemUpsertOne {
  931. return u.Update(func(s *BatchImageItemUpsert) {
  932. s.AddImageCount(v)
  933. })
  934. }
  935. // UpdateImageCount sets the "image_count" field to the value that was provided on create.
  936. func (u *BatchImageItemUpsertOne) UpdateImageCount() *BatchImageItemUpsertOne {
  937. return u.Update(func(s *BatchImageItemUpsert) {
  938. s.UpdateImageCount()
  939. })
  940. }
  941. // SetErrorCode sets the "error_code" field.
  942. func (u *BatchImageItemUpsertOne) SetErrorCode(v string) *BatchImageItemUpsertOne {
  943. return u.Update(func(s *BatchImageItemUpsert) {
  944. s.SetErrorCode(v)
  945. })
  946. }
  947. // UpdateErrorCode sets the "error_code" field to the value that was provided on create.
  948. func (u *BatchImageItemUpsertOne) UpdateErrorCode() *BatchImageItemUpsertOne {
  949. return u.Update(func(s *BatchImageItemUpsert) {
  950. s.UpdateErrorCode()
  951. })
  952. }
  953. // ClearErrorCode clears the value of the "error_code" field.
  954. func (u *BatchImageItemUpsertOne) ClearErrorCode() *BatchImageItemUpsertOne {
  955. return u.Update(func(s *BatchImageItemUpsert) {
  956. s.ClearErrorCode()
  957. })
  958. }
  959. // SetErrorMessage sets the "error_message" field.
  960. func (u *BatchImageItemUpsertOne) SetErrorMessage(v string) *BatchImageItemUpsertOne {
  961. return u.Update(func(s *BatchImageItemUpsert) {
  962. s.SetErrorMessage(v)
  963. })
  964. }
  965. // UpdateErrorMessage sets the "error_message" field to the value that was provided on create.
  966. func (u *BatchImageItemUpsertOne) UpdateErrorMessage() *BatchImageItemUpsertOne {
  967. return u.Update(func(s *BatchImageItemUpsert) {
  968. s.UpdateErrorMessage()
  969. })
  970. }
  971. // ClearErrorMessage clears the value of the "error_message" field.
  972. func (u *BatchImageItemUpsertOne) ClearErrorMessage() *BatchImageItemUpsertOne {
  973. return u.Update(func(s *BatchImageItemUpsert) {
  974. s.ClearErrorMessage()
  975. })
  976. }
  977. // SetBilledAmount sets the "billed_amount" field.
  978. func (u *BatchImageItemUpsertOne) SetBilledAmount(v float64) *BatchImageItemUpsertOne {
  979. return u.Update(func(s *BatchImageItemUpsert) {
  980. s.SetBilledAmount(v)
  981. })
  982. }
  983. // AddBilledAmount adds v to the "billed_amount" field.
  984. func (u *BatchImageItemUpsertOne) AddBilledAmount(v float64) *BatchImageItemUpsertOne {
  985. return u.Update(func(s *BatchImageItemUpsert) {
  986. s.AddBilledAmount(v)
  987. })
  988. }
  989. // UpdateBilledAmount sets the "billed_amount" field to the value that was provided on create.
  990. func (u *BatchImageItemUpsertOne) UpdateBilledAmount() *BatchImageItemUpsertOne {
  991. return u.Update(func(s *BatchImageItemUpsert) {
  992. s.UpdateBilledAmount()
  993. })
  994. }
  995. // ClearBilledAmount clears the value of the "billed_amount" field.
  996. func (u *BatchImageItemUpsertOne) ClearBilledAmount() *BatchImageItemUpsertOne {
  997. return u.Update(func(s *BatchImageItemUpsert) {
  998. s.ClearBilledAmount()
  999. })
  1000. }
  1001. // SetIndexedAt sets the "indexed_at" field.
  1002. func (u *BatchImageItemUpsertOne) SetIndexedAt(v time.Time) *BatchImageItemUpsertOne {
  1003. return u.Update(func(s *BatchImageItemUpsert) {
  1004. s.SetIndexedAt(v)
  1005. })
  1006. }
  1007. // UpdateIndexedAt sets the "indexed_at" field to the value that was provided on create.
  1008. func (u *BatchImageItemUpsertOne) UpdateIndexedAt() *BatchImageItemUpsertOne {
  1009. return u.Update(func(s *BatchImageItemUpsert) {
  1010. s.UpdateIndexedAt()
  1011. })
  1012. }
  1013. // ClearIndexedAt clears the value of the "indexed_at" field.
  1014. func (u *BatchImageItemUpsertOne) ClearIndexedAt() *BatchImageItemUpsertOne {
  1015. return u.Update(func(s *BatchImageItemUpsert) {
  1016. s.ClearIndexedAt()
  1017. })
  1018. }
  1019. // Exec executes the query.
  1020. func (u *BatchImageItemUpsertOne) Exec(ctx context.Context) error {
  1021. if len(u.create.conflict) == 0 {
  1022. return errors.New("ent: missing options for BatchImageItemCreate.OnConflict")
  1023. }
  1024. return u.create.Exec(ctx)
  1025. }
  1026. // ExecX is like Exec, but panics if an error occurs.
  1027. func (u *BatchImageItemUpsertOne) ExecX(ctx context.Context) {
  1028. if err := u.create.Exec(ctx); err != nil {
  1029. panic(err)
  1030. }
  1031. }
  1032. // Exec executes the UPSERT query and returns the inserted/updated ID.
  1033. func (u *BatchImageItemUpsertOne) ID(ctx context.Context) (id int64, err error) {
  1034. node, err := u.create.Save(ctx)
  1035. if err != nil {
  1036. return id, err
  1037. }
  1038. return node.ID, nil
  1039. }
  1040. // IDX is like ID, but panics if an error occurs.
  1041. func (u *BatchImageItemUpsertOne) IDX(ctx context.Context) int64 {
  1042. id, err := u.ID(ctx)
  1043. if err != nil {
  1044. panic(err)
  1045. }
  1046. return id
  1047. }
  1048. // BatchImageItemCreateBulk is the builder for creating many BatchImageItem entities in bulk.
  1049. type BatchImageItemCreateBulk struct {
  1050. config
  1051. err error
  1052. builders []*BatchImageItemCreate
  1053. conflict []sql.ConflictOption
  1054. }
  1055. // Save creates the BatchImageItem entities in the database.
  1056. func (_c *BatchImageItemCreateBulk) Save(ctx context.Context) ([]*BatchImageItem, error) {
  1057. if _c.err != nil {
  1058. return nil, _c.err
  1059. }
  1060. specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
  1061. nodes := make([]*BatchImageItem, len(_c.builders))
  1062. mutators := make([]Mutator, len(_c.builders))
  1063. for i := range _c.builders {
  1064. func(i int, root context.Context) {
  1065. builder := _c.builders[i]
  1066. builder.defaults()
  1067. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  1068. mutation, ok := m.(*BatchImageItemMutation)
  1069. if !ok {
  1070. return nil, fmt.Errorf("unexpected mutation type %T", m)
  1071. }
  1072. if err := builder.check(); err != nil {
  1073. return nil, err
  1074. }
  1075. builder.mutation = mutation
  1076. var err error
  1077. nodes[i], specs[i] = builder.createSpec()
  1078. if i < len(mutators)-1 {
  1079. _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
  1080. } else {
  1081. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  1082. spec.OnConflict = _c.conflict
  1083. // Invoke the actual operation on the latest mutation in the chain.
  1084. if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
  1085. if sqlgraph.IsConstraintError(err) {
  1086. err = &ConstraintError{msg: err.Error(), wrap: err}
  1087. }
  1088. }
  1089. }
  1090. if err != nil {
  1091. return nil, err
  1092. }
  1093. mutation.id = &nodes[i].ID
  1094. if specs[i].ID.Value != nil {
  1095. id := specs[i].ID.Value.(int64)
  1096. nodes[i].ID = int64(id)
  1097. }
  1098. mutation.done = true
  1099. return nodes[i], nil
  1100. })
  1101. for i := len(builder.hooks) - 1; i >= 0; i-- {
  1102. mut = builder.hooks[i](mut)
  1103. }
  1104. mutators[i] = mut
  1105. }(i, ctx)
  1106. }
  1107. if len(mutators) > 0 {
  1108. if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
  1109. return nil, err
  1110. }
  1111. }
  1112. return nodes, nil
  1113. }
  1114. // SaveX is like Save, but panics if an error occurs.
  1115. func (_c *BatchImageItemCreateBulk) SaveX(ctx context.Context) []*BatchImageItem {
  1116. v, err := _c.Save(ctx)
  1117. if err != nil {
  1118. panic(err)
  1119. }
  1120. return v
  1121. }
  1122. // Exec executes the query.
  1123. func (_c *BatchImageItemCreateBulk) Exec(ctx context.Context) error {
  1124. _, err := _c.Save(ctx)
  1125. return err
  1126. }
  1127. // ExecX is like Exec, but panics if an error occurs.
  1128. func (_c *BatchImageItemCreateBulk) ExecX(ctx context.Context) {
  1129. if err := _c.Exec(ctx); err != nil {
  1130. panic(err)
  1131. }
  1132. }
  1133. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  1134. // of the `INSERT` statement. For example:
  1135. //
  1136. // client.BatchImageItem.CreateBulk(builders...).
  1137. // OnConflict(
  1138. // // Update the row with the new values
  1139. // // the was proposed for insertion.
  1140. // sql.ResolveWithNewValues(),
  1141. // ).
  1142. // // Override some of the fields with custom
  1143. // // update values.
  1144. // Update(func(u *ent.BatchImageItemUpsert) {
  1145. // SetJobID(v+v).
  1146. // }).
  1147. // Exec(ctx)
  1148. func (_c *BatchImageItemCreateBulk) OnConflict(opts ...sql.ConflictOption) *BatchImageItemUpsertBulk {
  1149. _c.conflict = opts
  1150. return &BatchImageItemUpsertBulk{
  1151. create: _c,
  1152. }
  1153. }
  1154. // OnConflictColumns calls `OnConflict` and configures the columns
  1155. // as conflict target. Using this option is equivalent to using:
  1156. //
  1157. // client.BatchImageItem.Create().
  1158. // OnConflict(sql.ConflictColumns(columns...)).
  1159. // Exec(ctx)
  1160. func (_c *BatchImageItemCreateBulk) OnConflictColumns(columns ...string) *BatchImageItemUpsertBulk {
  1161. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  1162. return &BatchImageItemUpsertBulk{
  1163. create: _c,
  1164. }
  1165. }
  1166. // BatchImageItemUpsertBulk is the builder for "upsert"-ing
  1167. // a bulk of BatchImageItem nodes.
  1168. type BatchImageItemUpsertBulk struct {
  1169. create *BatchImageItemCreateBulk
  1170. }
  1171. // UpdateNewValues updates the mutable fields using the new values that
  1172. // were set on create. Using this option is equivalent to using:
  1173. //
  1174. // client.BatchImageItem.Create().
  1175. // OnConflict(
  1176. // sql.ResolveWithNewValues(),
  1177. // ).
  1178. // Exec(ctx)
  1179. func (u *BatchImageItemUpsertBulk) UpdateNewValues() *BatchImageItemUpsertBulk {
  1180. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1181. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1182. for _, b := range u.create.builders {
  1183. if _, exists := b.mutation.CreatedAt(); exists {
  1184. s.SetIgnore(batchimageitem.FieldCreatedAt)
  1185. }
  1186. }
  1187. }))
  1188. return u
  1189. }
  1190. // Ignore sets each column to itself in case of conflict.
  1191. // Using this option is equivalent to using:
  1192. //
  1193. // client.BatchImageItem.Create().
  1194. // OnConflict(sql.ResolveWithIgnore()).
  1195. // Exec(ctx)
  1196. func (u *BatchImageItemUpsertBulk) Ignore() *BatchImageItemUpsertBulk {
  1197. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1198. return u
  1199. }
  1200. // DoNothing configures the conflict_action to `DO NOTHING`.
  1201. // Supported only by SQLite and PostgreSQL.
  1202. func (u *BatchImageItemUpsertBulk) DoNothing() *BatchImageItemUpsertBulk {
  1203. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1204. return u
  1205. }
  1206. // Update allows overriding fields `UPDATE` values. See the BatchImageItemCreateBulk.OnConflict
  1207. // documentation for more info.
  1208. func (u *BatchImageItemUpsertBulk) Update(set func(*BatchImageItemUpsert)) *BatchImageItemUpsertBulk {
  1209. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1210. set(&BatchImageItemUpsert{UpdateSet: update})
  1211. }))
  1212. return u
  1213. }
  1214. // SetJobID sets the "job_id" field.
  1215. func (u *BatchImageItemUpsertBulk) SetJobID(v string) *BatchImageItemUpsertBulk {
  1216. return u.Update(func(s *BatchImageItemUpsert) {
  1217. s.SetJobID(v)
  1218. })
  1219. }
  1220. // UpdateJobID sets the "job_id" field to the value that was provided on create.
  1221. func (u *BatchImageItemUpsertBulk) UpdateJobID() *BatchImageItemUpsertBulk {
  1222. return u.Update(func(s *BatchImageItemUpsert) {
  1223. s.UpdateJobID()
  1224. })
  1225. }
  1226. // SetCustomID sets the "custom_id" field.
  1227. func (u *BatchImageItemUpsertBulk) SetCustomID(v string) *BatchImageItemUpsertBulk {
  1228. return u.Update(func(s *BatchImageItemUpsert) {
  1229. s.SetCustomID(v)
  1230. })
  1231. }
  1232. // UpdateCustomID sets the "custom_id" field to the value that was provided on create.
  1233. func (u *BatchImageItemUpsertBulk) UpdateCustomID() *BatchImageItemUpsertBulk {
  1234. return u.Update(func(s *BatchImageItemUpsert) {
  1235. s.UpdateCustomID()
  1236. })
  1237. }
  1238. // SetStatus sets the "status" field.
  1239. func (u *BatchImageItemUpsertBulk) SetStatus(v string) *BatchImageItemUpsertBulk {
  1240. return u.Update(func(s *BatchImageItemUpsert) {
  1241. s.SetStatus(v)
  1242. })
  1243. }
  1244. // UpdateStatus sets the "status" field to the value that was provided on create.
  1245. func (u *BatchImageItemUpsertBulk) UpdateStatus() *BatchImageItemUpsertBulk {
  1246. return u.Update(func(s *BatchImageItemUpsert) {
  1247. s.UpdateStatus()
  1248. })
  1249. }
  1250. // SetRequestHash sets the "request_hash" field.
  1251. func (u *BatchImageItemUpsertBulk) SetRequestHash(v string) *BatchImageItemUpsertBulk {
  1252. return u.Update(func(s *BatchImageItemUpsert) {
  1253. s.SetRequestHash(v)
  1254. })
  1255. }
  1256. // UpdateRequestHash sets the "request_hash" field to the value that was provided on create.
  1257. func (u *BatchImageItemUpsertBulk) UpdateRequestHash() *BatchImageItemUpsertBulk {
  1258. return u.Update(func(s *BatchImageItemUpsert) {
  1259. s.UpdateRequestHash()
  1260. })
  1261. }
  1262. // ClearRequestHash clears the value of the "request_hash" field.
  1263. func (u *BatchImageItemUpsertBulk) ClearRequestHash() *BatchImageItemUpsertBulk {
  1264. return u.Update(func(s *BatchImageItemUpsert) {
  1265. s.ClearRequestHash()
  1266. })
  1267. }
  1268. // SetPromptPreview sets the "prompt_preview" field.
  1269. func (u *BatchImageItemUpsertBulk) SetPromptPreview(v string) *BatchImageItemUpsertBulk {
  1270. return u.Update(func(s *BatchImageItemUpsert) {
  1271. s.SetPromptPreview(v)
  1272. })
  1273. }
  1274. // UpdatePromptPreview sets the "prompt_preview" field to the value that was provided on create.
  1275. func (u *BatchImageItemUpsertBulk) UpdatePromptPreview() *BatchImageItemUpsertBulk {
  1276. return u.Update(func(s *BatchImageItemUpsert) {
  1277. s.UpdatePromptPreview()
  1278. })
  1279. }
  1280. // ClearPromptPreview clears the value of the "prompt_preview" field.
  1281. func (u *BatchImageItemUpsertBulk) ClearPromptPreview() *BatchImageItemUpsertBulk {
  1282. return u.Update(func(s *BatchImageItemUpsert) {
  1283. s.ClearPromptPreview()
  1284. })
  1285. }
  1286. // SetProviderSourceObject sets the "provider_source_object" field.
  1287. func (u *BatchImageItemUpsertBulk) SetProviderSourceObject(v string) *BatchImageItemUpsertBulk {
  1288. return u.Update(func(s *BatchImageItemUpsert) {
  1289. s.SetProviderSourceObject(v)
  1290. })
  1291. }
  1292. // UpdateProviderSourceObject sets the "provider_source_object" field to the value that was provided on create.
  1293. func (u *BatchImageItemUpsertBulk) UpdateProviderSourceObject() *BatchImageItemUpsertBulk {
  1294. return u.Update(func(s *BatchImageItemUpsert) {
  1295. s.UpdateProviderSourceObject()
  1296. })
  1297. }
  1298. // ClearProviderSourceObject clears the value of the "provider_source_object" field.
  1299. func (u *BatchImageItemUpsertBulk) ClearProviderSourceObject() *BatchImageItemUpsertBulk {
  1300. return u.Update(func(s *BatchImageItemUpsert) {
  1301. s.ClearProviderSourceObject()
  1302. })
  1303. }
  1304. // SetSourceLineNumber sets the "source_line_number" field.
  1305. func (u *BatchImageItemUpsertBulk) SetSourceLineNumber(v int) *BatchImageItemUpsertBulk {
  1306. return u.Update(func(s *BatchImageItemUpsert) {
  1307. s.SetSourceLineNumber(v)
  1308. })
  1309. }
  1310. // AddSourceLineNumber adds v to the "source_line_number" field.
  1311. func (u *BatchImageItemUpsertBulk) AddSourceLineNumber(v int) *BatchImageItemUpsertBulk {
  1312. return u.Update(func(s *BatchImageItemUpsert) {
  1313. s.AddSourceLineNumber(v)
  1314. })
  1315. }
  1316. // UpdateSourceLineNumber sets the "source_line_number" field to the value that was provided on create.
  1317. func (u *BatchImageItemUpsertBulk) UpdateSourceLineNumber() *BatchImageItemUpsertBulk {
  1318. return u.Update(func(s *BatchImageItemUpsert) {
  1319. s.UpdateSourceLineNumber()
  1320. })
  1321. }
  1322. // ClearSourceLineNumber clears the value of the "source_line_number" field.
  1323. func (u *BatchImageItemUpsertBulk) ClearSourceLineNumber() *BatchImageItemUpsertBulk {
  1324. return u.Update(func(s *BatchImageItemUpsert) {
  1325. s.ClearSourceLineNumber()
  1326. })
  1327. }
  1328. // SetSourceByteOffset sets the "source_byte_offset" field.
  1329. func (u *BatchImageItemUpsertBulk) SetSourceByteOffset(v int64) *BatchImageItemUpsertBulk {
  1330. return u.Update(func(s *BatchImageItemUpsert) {
  1331. s.SetSourceByteOffset(v)
  1332. })
  1333. }
  1334. // AddSourceByteOffset adds v to the "source_byte_offset" field.
  1335. func (u *BatchImageItemUpsertBulk) AddSourceByteOffset(v int64) *BatchImageItemUpsertBulk {
  1336. return u.Update(func(s *BatchImageItemUpsert) {
  1337. s.AddSourceByteOffset(v)
  1338. })
  1339. }
  1340. // UpdateSourceByteOffset sets the "source_byte_offset" field to the value that was provided on create.
  1341. func (u *BatchImageItemUpsertBulk) UpdateSourceByteOffset() *BatchImageItemUpsertBulk {
  1342. return u.Update(func(s *BatchImageItemUpsert) {
  1343. s.UpdateSourceByteOffset()
  1344. })
  1345. }
  1346. // ClearSourceByteOffset clears the value of the "source_byte_offset" field.
  1347. func (u *BatchImageItemUpsertBulk) ClearSourceByteOffset() *BatchImageItemUpsertBulk {
  1348. return u.Update(func(s *BatchImageItemUpsert) {
  1349. s.ClearSourceByteOffset()
  1350. })
  1351. }
  1352. // SetSourceByteLength sets the "source_byte_length" field.
  1353. func (u *BatchImageItemUpsertBulk) SetSourceByteLength(v int64) *BatchImageItemUpsertBulk {
  1354. return u.Update(func(s *BatchImageItemUpsert) {
  1355. s.SetSourceByteLength(v)
  1356. })
  1357. }
  1358. // AddSourceByteLength adds v to the "source_byte_length" field.
  1359. func (u *BatchImageItemUpsertBulk) AddSourceByteLength(v int64) *BatchImageItemUpsertBulk {
  1360. return u.Update(func(s *BatchImageItemUpsert) {
  1361. s.AddSourceByteLength(v)
  1362. })
  1363. }
  1364. // UpdateSourceByteLength sets the "source_byte_length" field to the value that was provided on create.
  1365. func (u *BatchImageItemUpsertBulk) UpdateSourceByteLength() *BatchImageItemUpsertBulk {
  1366. return u.Update(func(s *BatchImageItemUpsert) {
  1367. s.UpdateSourceByteLength()
  1368. })
  1369. }
  1370. // ClearSourceByteLength clears the value of the "source_byte_length" field.
  1371. func (u *BatchImageItemUpsertBulk) ClearSourceByteLength() *BatchImageItemUpsertBulk {
  1372. return u.Update(func(s *BatchImageItemUpsert) {
  1373. s.ClearSourceByteLength()
  1374. })
  1375. }
  1376. // SetMimeType sets the "mime_type" field.
  1377. func (u *BatchImageItemUpsertBulk) SetMimeType(v string) *BatchImageItemUpsertBulk {
  1378. return u.Update(func(s *BatchImageItemUpsert) {
  1379. s.SetMimeType(v)
  1380. })
  1381. }
  1382. // UpdateMimeType sets the "mime_type" field to the value that was provided on create.
  1383. func (u *BatchImageItemUpsertBulk) UpdateMimeType() *BatchImageItemUpsertBulk {
  1384. return u.Update(func(s *BatchImageItemUpsert) {
  1385. s.UpdateMimeType()
  1386. })
  1387. }
  1388. // ClearMimeType clears the value of the "mime_type" field.
  1389. func (u *BatchImageItemUpsertBulk) ClearMimeType() *BatchImageItemUpsertBulk {
  1390. return u.Update(func(s *BatchImageItemUpsert) {
  1391. s.ClearMimeType()
  1392. })
  1393. }
  1394. // SetFileExtension sets the "file_extension" field.
  1395. func (u *BatchImageItemUpsertBulk) SetFileExtension(v string) *BatchImageItemUpsertBulk {
  1396. return u.Update(func(s *BatchImageItemUpsert) {
  1397. s.SetFileExtension(v)
  1398. })
  1399. }
  1400. // UpdateFileExtension sets the "file_extension" field to the value that was provided on create.
  1401. func (u *BatchImageItemUpsertBulk) UpdateFileExtension() *BatchImageItemUpsertBulk {
  1402. return u.Update(func(s *BatchImageItemUpsert) {
  1403. s.UpdateFileExtension()
  1404. })
  1405. }
  1406. // ClearFileExtension clears the value of the "file_extension" field.
  1407. func (u *BatchImageItemUpsertBulk) ClearFileExtension() *BatchImageItemUpsertBulk {
  1408. return u.Update(func(s *BatchImageItemUpsert) {
  1409. s.ClearFileExtension()
  1410. })
  1411. }
  1412. // SetImageCount sets the "image_count" field.
  1413. func (u *BatchImageItemUpsertBulk) SetImageCount(v int) *BatchImageItemUpsertBulk {
  1414. return u.Update(func(s *BatchImageItemUpsert) {
  1415. s.SetImageCount(v)
  1416. })
  1417. }
  1418. // AddImageCount adds v to the "image_count" field.
  1419. func (u *BatchImageItemUpsertBulk) AddImageCount(v int) *BatchImageItemUpsertBulk {
  1420. return u.Update(func(s *BatchImageItemUpsert) {
  1421. s.AddImageCount(v)
  1422. })
  1423. }
  1424. // UpdateImageCount sets the "image_count" field to the value that was provided on create.
  1425. func (u *BatchImageItemUpsertBulk) UpdateImageCount() *BatchImageItemUpsertBulk {
  1426. return u.Update(func(s *BatchImageItemUpsert) {
  1427. s.UpdateImageCount()
  1428. })
  1429. }
  1430. // SetErrorCode sets the "error_code" field.
  1431. func (u *BatchImageItemUpsertBulk) SetErrorCode(v string) *BatchImageItemUpsertBulk {
  1432. return u.Update(func(s *BatchImageItemUpsert) {
  1433. s.SetErrorCode(v)
  1434. })
  1435. }
  1436. // UpdateErrorCode sets the "error_code" field to the value that was provided on create.
  1437. func (u *BatchImageItemUpsertBulk) UpdateErrorCode() *BatchImageItemUpsertBulk {
  1438. return u.Update(func(s *BatchImageItemUpsert) {
  1439. s.UpdateErrorCode()
  1440. })
  1441. }
  1442. // ClearErrorCode clears the value of the "error_code" field.
  1443. func (u *BatchImageItemUpsertBulk) ClearErrorCode() *BatchImageItemUpsertBulk {
  1444. return u.Update(func(s *BatchImageItemUpsert) {
  1445. s.ClearErrorCode()
  1446. })
  1447. }
  1448. // SetErrorMessage sets the "error_message" field.
  1449. func (u *BatchImageItemUpsertBulk) SetErrorMessage(v string) *BatchImageItemUpsertBulk {
  1450. return u.Update(func(s *BatchImageItemUpsert) {
  1451. s.SetErrorMessage(v)
  1452. })
  1453. }
  1454. // UpdateErrorMessage sets the "error_message" field to the value that was provided on create.
  1455. func (u *BatchImageItemUpsertBulk) UpdateErrorMessage() *BatchImageItemUpsertBulk {
  1456. return u.Update(func(s *BatchImageItemUpsert) {
  1457. s.UpdateErrorMessage()
  1458. })
  1459. }
  1460. // ClearErrorMessage clears the value of the "error_message" field.
  1461. func (u *BatchImageItemUpsertBulk) ClearErrorMessage() *BatchImageItemUpsertBulk {
  1462. return u.Update(func(s *BatchImageItemUpsert) {
  1463. s.ClearErrorMessage()
  1464. })
  1465. }
  1466. // SetBilledAmount sets the "billed_amount" field.
  1467. func (u *BatchImageItemUpsertBulk) SetBilledAmount(v float64) *BatchImageItemUpsertBulk {
  1468. return u.Update(func(s *BatchImageItemUpsert) {
  1469. s.SetBilledAmount(v)
  1470. })
  1471. }
  1472. // AddBilledAmount adds v to the "billed_amount" field.
  1473. func (u *BatchImageItemUpsertBulk) AddBilledAmount(v float64) *BatchImageItemUpsertBulk {
  1474. return u.Update(func(s *BatchImageItemUpsert) {
  1475. s.AddBilledAmount(v)
  1476. })
  1477. }
  1478. // UpdateBilledAmount sets the "billed_amount" field to the value that was provided on create.
  1479. func (u *BatchImageItemUpsertBulk) UpdateBilledAmount() *BatchImageItemUpsertBulk {
  1480. return u.Update(func(s *BatchImageItemUpsert) {
  1481. s.UpdateBilledAmount()
  1482. })
  1483. }
  1484. // ClearBilledAmount clears the value of the "billed_amount" field.
  1485. func (u *BatchImageItemUpsertBulk) ClearBilledAmount() *BatchImageItemUpsertBulk {
  1486. return u.Update(func(s *BatchImageItemUpsert) {
  1487. s.ClearBilledAmount()
  1488. })
  1489. }
  1490. // SetIndexedAt sets the "indexed_at" field.
  1491. func (u *BatchImageItemUpsertBulk) SetIndexedAt(v time.Time) *BatchImageItemUpsertBulk {
  1492. return u.Update(func(s *BatchImageItemUpsert) {
  1493. s.SetIndexedAt(v)
  1494. })
  1495. }
  1496. // UpdateIndexedAt sets the "indexed_at" field to the value that was provided on create.
  1497. func (u *BatchImageItemUpsertBulk) UpdateIndexedAt() *BatchImageItemUpsertBulk {
  1498. return u.Update(func(s *BatchImageItemUpsert) {
  1499. s.UpdateIndexedAt()
  1500. })
  1501. }
  1502. // ClearIndexedAt clears the value of the "indexed_at" field.
  1503. func (u *BatchImageItemUpsertBulk) ClearIndexedAt() *BatchImageItemUpsertBulk {
  1504. return u.Update(func(s *BatchImageItemUpsert) {
  1505. s.ClearIndexedAt()
  1506. })
  1507. }
  1508. // Exec executes the query.
  1509. func (u *BatchImageItemUpsertBulk) Exec(ctx context.Context) error {
  1510. if u.create.err != nil {
  1511. return u.create.err
  1512. }
  1513. for i, b := range u.create.builders {
  1514. if len(b.conflict) != 0 {
  1515. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the BatchImageItemCreateBulk instead", i)
  1516. }
  1517. }
  1518. if len(u.create.conflict) == 0 {
  1519. return errors.New("ent: missing options for BatchImageItemCreateBulk.OnConflict")
  1520. }
  1521. return u.create.Exec(ctx)
  1522. }
  1523. // ExecX is like Exec, but panics if an error occurs.
  1524. func (u *BatchImageItemUpsertBulk) ExecX(ctx context.Context) {
  1525. if err := u.create.Exec(ctx); err != nil {
  1526. panic(err)
  1527. }
  1528. }