account_create.go 87 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859
  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/account"
  12. "github.com/Wei-Shaw/sub2api/ent/group"
  13. "github.com/Wei-Shaw/sub2api/ent/proxy"
  14. "github.com/Wei-Shaw/sub2api/ent/usagelog"
  15. )
  16. // AccountCreate is the builder for creating a Account entity.
  17. type AccountCreate struct {
  18. config
  19. mutation *AccountMutation
  20. hooks []Hook
  21. conflict []sql.ConflictOption
  22. }
  23. // SetCreatedAt sets the "created_at" field.
  24. func (_c *AccountCreate) SetCreatedAt(v time.Time) *AccountCreate {
  25. _c.mutation.SetCreatedAt(v)
  26. return _c
  27. }
  28. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  29. func (_c *AccountCreate) SetNillableCreatedAt(v *time.Time) *AccountCreate {
  30. if v != nil {
  31. _c.SetCreatedAt(*v)
  32. }
  33. return _c
  34. }
  35. // SetUpdatedAt sets the "updated_at" field.
  36. func (_c *AccountCreate) SetUpdatedAt(v time.Time) *AccountCreate {
  37. _c.mutation.SetUpdatedAt(v)
  38. return _c
  39. }
  40. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  41. func (_c *AccountCreate) SetNillableUpdatedAt(v *time.Time) *AccountCreate {
  42. if v != nil {
  43. _c.SetUpdatedAt(*v)
  44. }
  45. return _c
  46. }
  47. // SetDeletedAt sets the "deleted_at" field.
  48. func (_c *AccountCreate) SetDeletedAt(v time.Time) *AccountCreate {
  49. _c.mutation.SetDeletedAt(v)
  50. return _c
  51. }
  52. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  53. func (_c *AccountCreate) SetNillableDeletedAt(v *time.Time) *AccountCreate {
  54. if v != nil {
  55. _c.SetDeletedAt(*v)
  56. }
  57. return _c
  58. }
  59. // SetName sets the "name" field.
  60. func (_c *AccountCreate) SetName(v string) *AccountCreate {
  61. _c.mutation.SetName(v)
  62. return _c
  63. }
  64. // SetNotes sets the "notes" field.
  65. func (_c *AccountCreate) SetNotes(v string) *AccountCreate {
  66. _c.mutation.SetNotes(v)
  67. return _c
  68. }
  69. // SetNillableNotes sets the "notes" field if the given value is not nil.
  70. func (_c *AccountCreate) SetNillableNotes(v *string) *AccountCreate {
  71. if v != nil {
  72. _c.SetNotes(*v)
  73. }
  74. return _c
  75. }
  76. // SetPlatform sets the "platform" field.
  77. func (_c *AccountCreate) SetPlatform(v string) *AccountCreate {
  78. _c.mutation.SetPlatform(v)
  79. return _c
  80. }
  81. // SetType sets the "type" field.
  82. func (_c *AccountCreate) SetType(v string) *AccountCreate {
  83. _c.mutation.SetType(v)
  84. return _c
  85. }
  86. // SetCredentials sets the "credentials" field.
  87. func (_c *AccountCreate) SetCredentials(v map[string]interface{}) *AccountCreate {
  88. _c.mutation.SetCredentials(v)
  89. return _c
  90. }
  91. // SetExtra sets the "extra" field.
  92. func (_c *AccountCreate) SetExtra(v map[string]interface{}) *AccountCreate {
  93. _c.mutation.SetExtra(v)
  94. return _c
  95. }
  96. // SetProxyID sets the "proxy_id" field.
  97. func (_c *AccountCreate) SetProxyID(v int64) *AccountCreate {
  98. _c.mutation.SetProxyID(v)
  99. return _c
  100. }
  101. // SetNillableProxyID sets the "proxy_id" field if the given value is not nil.
  102. func (_c *AccountCreate) SetNillableProxyID(v *int64) *AccountCreate {
  103. if v != nil {
  104. _c.SetProxyID(*v)
  105. }
  106. return _c
  107. }
  108. // SetProxyFallbackOriginID sets the "proxy_fallback_origin_id" field.
  109. func (_c *AccountCreate) SetProxyFallbackOriginID(v int64) *AccountCreate {
  110. _c.mutation.SetProxyFallbackOriginID(v)
  111. return _c
  112. }
  113. // SetNillableProxyFallbackOriginID sets the "proxy_fallback_origin_id" field if the given value is not nil.
  114. func (_c *AccountCreate) SetNillableProxyFallbackOriginID(v *int64) *AccountCreate {
  115. if v != nil {
  116. _c.SetProxyFallbackOriginID(*v)
  117. }
  118. return _c
  119. }
  120. // SetConcurrency sets the "concurrency" field.
  121. func (_c *AccountCreate) SetConcurrency(v int) *AccountCreate {
  122. _c.mutation.SetConcurrency(v)
  123. return _c
  124. }
  125. // SetNillableConcurrency sets the "concurrency" field if the given value is not nil.
  126. func (_c *AccountCreate) SetNillableConcurrency(v *int) *AccountCreate {
  127. if v != nil {
  128. _c.SetConcurrency(*v)
  129. }
  130. return _c
  131. }
  132. // SetLoadFactor sets the "load_factor" field.
  133. func (_c *AccountCreate) SetLoadFactor(v int) *AccountCreate {
  134. _c.mutation.SetLoadFactor(v)
  135. return _c
  136. }
  137. // SetNillableLoadFactor sets the "load_factor" field if the given value is not nil.
  138. func (_c *AccountCreate) SetNillableLoadFactor(v *int) *AccountCreate {
  139. if v != nil {
  140. _c.SetLoadFactor(*v)
  141. }
  142. return _c
  143. }
  144. // SetPriority sets the "priority" field.
  145. func (_c *AccountCreate) SetPriority(v int) *AccountCreate {
  146. _c.mutation.SetPriority(v)
  147. return _c
  148. }
  149. // SetNillablePriority sets the "priority" field if the given value is not nil.
  150. func (_c *AccountCreate) SetNillablePriority(v *int) *AccountCreate {
  151. if v != nil {
  152. _c.SetPriority(*v)
  153. }
  154. return _c
  155. }
  156. // SetRateMultiplier sets the "rate_multiplier" field.
  157. func (_c *AccountCreate) SetRateMultiplier(v float64) *AccountCreate {
  158. _c.mutation.SetRateMultiplier(v)
  159. return _c
  160. }
  161. // SetNillableRateMultiplier sets the "rate_multiplier" field if the given value is not nil.
  162. func (_c *AccountCreate) SetNillableRateMultiplier(v *float64) *AccountCreate {
  163. if v != nil {
  164. _c.SetRateMultiplier(*v)
  165. }
  166. return _c
  167. }
  168. // SetStatus sets the "status" field.
  169. func (_c *AccountCreate) SetStatus(v string) *AccountCreate {
  170. _c.mutation.SetStatus(v)
  171. return _c
  172. }
  173. // SetNillableStatus sets the "status" field if the given value is not nil.
  174. func (_c *AccountCreate) SetNillableStatus(v *string) *AccountCreate {
  175. if v != nil {
  176. _c.SetStatus(*v)
  177. }
  178. return _c
  179. }
  180. // SetErrorMessage sets the "error_message" field.
  181. func (_c *AccountCreate) SetErrorMessage(v string) *AccountCreate {
  182. _c.mutation.SetErrorMessage(v)
  183. return _c
  184. }
  185. // SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
  186. func (_c *AccountCreate) SetNillableErrorMessage(v *string) *AccountCreate {
  187. if v != nil {
  188. _c.SetErrorMessage(*v)
  189. }
  190. return _c
  191. }
  192. // SetLastUsedAt sets the "last_used_at" field.
  193. func (_c *AccountCreate) SetLastUsedAt(v time.Time) *AccountCreate {
  194. _c.mutation.SetLastUsedAt(v)
  195. return _c
  196. }
  197. // SetNillableLastUsedAt sets the "last_used_at" field if the given value is not nil.
  198. func (_c *AccountCreate) SetNillableLastUsedAt(v *time.Time) *AccountCreate {
  199. if v != nil {
  200. _c.SetLastUsedAt(*v)
  201. }
  202. return _c
  203. }
  204. // SetExpiresAt sets the "expires_at" field.
  205. func (_c *AccountCreate) SetExpiresAt(v time.Time) *AccountCreate {
  206. _c.mutation.SetExpiresAt(v)
  207. return _c
  208. }
  209. // SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
  210. func (_c *AccountCreate) SetNillableExpiresAt(v *time.Time) *AccountCreate {
  211. if v != nil {
  212. _c.SetExpiresAt(*v)
  213. }
  214. return _c
  215. }
  216. // SetAutoPauseOnExpired sets the "auto_pause_on_expired" field.
  217. func (_c *AccountCreate) SetAutoPauseOnExpired(v bool) *AccountCreate {
  218. _c.mutation.SetAutoPauseOnExpired(v)
  219. return _c
  220. }
  221. // SetNillableAutoPauseOnExpired sets the "auto_pause_on_expired" field if the given value is not nil.
  222. func (_c *AccountCreate) SetNillableAutoPauseOnExpired(v *bool) *AccountCreate {
  223. if v != nil {
  224. _c.SetAutoPauseOnExpired(*v)
  225. }
  226. return _c
  227. }
  228. // SetSchedulable sets the "schedulable" field.
  229. func (_c *AccountCreate) SetSchedulable(v bool) *AccountCreate {
  230. _c.mutation.SetSchedulable(v)
  231. return _c
  232. }
  233. // SetNillableSchedulable sets the "schedulable" field if the given value is not nil.
  234. func (_c *AccountCreate) SetNillableSchedulable(v *bool) *AccountCreate {
  235. if v != nil {
  236. _c.SetSchedulable(*v)
  237. }
  238. return _c
  239. }
  240. // SetRateLimitedAt sets the "rate_limited_at" field.
  241. func (_c *AccountCreate) SetRateLimitedAt(v time.Time) *AccountCreate {
  242. _c.mutation.SetRateLimitedAt(v)
  243. return _c
  244. }
  245. // SetNillableRateLimitedAt sets the "rate_limited_at" field if the given value is not nil.
  246. func (_c *AccountCreate) SetNillableRateLimitedAt(v *time.Time) *AccountCreate {
  247. if v != nil {
  248. _c.SetRateLimitedAt(*v)
  249. }
  250. return _c
  251. }
  252. // SetRateLimitResetAt sets the "rate_limit_reset_at" field.
  253. func (_c *AccountCreate) SetRateLimitResetAt(v time.Time) *AccountCreate {
  254. _c.mutation.SetRateLimitResetAt(v)
  255. return _c
  256. }
  257. // SetNillableRateLimitResetAt sets the "rate_limit_reset_at" field if the given value is not nil.
  258. func (_c *AccountCreate) SetNillableRateLimitResetAt(v *time.Time) *AccountCreate {
  259. if v != nil {
  260. _c.SetRateLimitResetAt(*v)
  261. }
  262. return _c
  263. }
  264. // SetOverloadUntil sets the "overload_until" field.
  265. func (_c *AccountCreate) SetOverloadUntil(v time.Time) *AccountCreate {
  266. _c.mutation.SetOverloadUntil(v)
  267. return _c
  268. }
  269. // SetNillableOverloadUntil sets the "overload_until" field if the given value is not nil.
  270. func (_c *AccountCreate) SetNillableOverloadUntil(v *time.Time) *AccountCreate {
  271. if v != nil {
  272. _c.SetOverloadUntil(*v)
  273. }
  274. return _c
  275. }
  276. // SetTempUnschedulableUntil sets the "temp_unschedulable_until" field.
  277. func (_c *AccountCreate) SetTempUnschedulableUntil(v time.Time) *AccountCreate {
  278. _c.mutation.SetTempUnschedulableUntil(v)
  279. return _c
  280. }
  281. // SetNillableTempUnschedulableUntil sets the "temp_unschedulable_until" field if the given value is not nil.
  282. func (_c *AccountCreate) SetNillableTempUnschedulableUntil(v *time.Time) *AccountCreate {
  283. if v != nil {
  284. _c.SetTempUnschedulableUntil(*v)
  285. }
  286. return _c
  287. }
  288. // SetTempUnschedulableReason sets the "temp_unschedulable_reason" field.
  289. func (_c *AccountCreate) SetTempUnschedulableReason(v string) *AccountCreate {
  290. _c.mutation.SetTempUnschedulableReason(v)
  291. return _c
  292. }
  293. // SetNillableTempUnschedulableReason sets the "temp_unschedulable_reason" field if the given value is not nil.
  294. func (_c *AccountCreate) SetNillableTempUnschedulableReason(v *string) *AccountCreate {
  295. if v != nil {
  296. _c.SetTempUnschedulableReason(*v)
  297. }
  298. return _c
  299. }
  300. // SetSessionWindowStart sets the "session_window_start" field.
  301. func (_c *AccountCreate) SetSessionWindowStart(v time.Time) *AccountCreate {
  302. _c.mutation.SetSessionWindowStart(v)
  303. return _c
  304. }
  305. // SetNillableSessionWindowStart sets the "session_window_start" field if the given value is not nil.
  306. func (_c *AccountCreate) SetNillableSessionWindowStart(v *time.Time) *AccountCreate {
  307. if v != nil {
  308. _c.SetSessionWindowStart(*v)
  309. }
  310. return _c
  311. }
  312. // SetSessionWindowEnd sets the "session_window_end" field.
  313. func (_c *AccountCreate) SetSessionWindowEnd(v time.Time) *AccountCreate {
  314. _c.mutation.SetSessionWindowEnd(v)
  315. return _c
  316. }
  317. // SetNillableSessionWindowEnd sets the "session_window_end" field if the given value is not nil.
  318. func (_c *AccountCreate) SetNillableSessionWindowEnd(v *time.Time) *AccountCreate {
  319. if v != nil {
  320. _c.SetSessionWindowEnd(*v)
  321. }
  322. return _c
  323. }
  324. // SetSessionWindowStatus sets the "session_window_status" field.
  325. func (_c *AccountCreate) SetSessionWindowStatus(v string) *AccountCreate {
  326. _c.mutation.SetSessionWindowStatus(v)
  327. return _c
  328. }
  329. // SetNillableSessionWindowStatus sets the "session_window_status" field if the given value is not nil.
  330. func (_c *AccountCreate) SetNillableSessionWindowStatus(v *string) *AccountCreate {
  331. if v != nil {
  332. _c.SetSessionWindowStatus(*v)
  333. }
  334. return _c
  335. }
  336. // SetParentAccountID sets the "parent_account_id" field.
  337. func (_c *AccountCreate) SetParentAccountID(v int64) *AccountCreate {
  338. _c.mutation.SetParentAccountID(v)
  339. return _c
  340. }
  341. // SetNillableParentAccountID sets the "parent_account_id" field if the given value is not nil.
  342. func (_c *AccountCreate) SetNillableParentAccountID(v *int64) *AccountCreate {
  343. if v != nil {
  344. _c.SetParentAccountID(*v)
  345. }
  346. return _c
  347. }
  348. // SetQuotaDimension sets the "quota_dimension" field.
  349. func (_c *AccountCreate) SetQuotaDimension(v account.QuotaDimension) *AccountCreate {
  350. _c.mutation.SetQuotaDimension(v)
  351. return _c
  352. }
  353. // SetNillableQuotaDimension sets the "quota_dimension" field if the given value is not nil.
  354. func (_c *AccountCreate) SetNillableQuotaDimension(v *account.QuotaDimension) *AccountCreate {
  355. if v != nil {
  356. _c.SetQuotaDimension(*v)
  357. }
  358. return _c
  359. }
  360. // AddGroupIDs adds the "groups" edge to the Group entity by IDs.
  361. func (_c *AccountCreate) AddGroupIDs(ids ...int64) *AccountCreate {
  362. _c.mutation.AddGroupIDs(ids...)
  363. return _c
  364. }
  365. // AddGroups adds the "groups" edges to the Group entity.
  366. func (_c *AccountCreate) AddGroups(v ...*Group) *AccountCreate {
  367. ids := make([]int64, len(v))
  368. for i := range v {
  369. ids[i] = v[i].ID
  370. }
  371. return _c.AddGroupIDs(ids...)
  372. }
  373. // SetProxy sets the "proxy" edge to the Proxy entity.
  374. func (_c *AccountCreate) SetProxy(v *Proxy) *AccountCreate {
  375. return _c.SetProxyID(v.ID)
  376. }
  377. // SetParentID sets the "parent" edge to the Account entity by ID.
  378. func (_c *AccountCreate) SetParentID(id int64) *AccountCreate {
  379. _c.mutation.SetParentID(id)
  380. return _c
  381. }
  382. // SetNillableParentID sets the "parent" edge to the Account entity by ID if the given value is not nil.
  383. func (_c *AccountCreate) SetNillableParentID(id *int64) *AccountCreate {
  384. if id != nil {
  385. _c = _c.SetParentID(*id)
  386. }
  387. return _c
  388. }
  389. // SetParent sets the "parent" edge to the Account entity.
  390. func (_c *AccountCreate) SetParent(v *Account) *AccountCreate {
  391. return _c.SetParentID(v.ID)
  392. }
  393. // AddChildIDs adds the "children" edge to the Account entity by IDs.
  394. func (_c *AccountCreate) AddChildIDs(ids ...int64) *AccountCreate {
  395. _c.mutation.AddChildIDs(ids...)
  396. return _c
  397. }
  398. // AddChildren adds the "children" edges to the Account entity.
  399. func (_c *AccountCreate) AddChildren(v ...*Account) *AccountCreate {
  400. ids := make([]int64, len(v))
  401. for i := range v {
  402. ids[i] = v[i].ID
  403. }
  404. return _c.AddChildIDs(ids...)
  405. }
  406. // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by IDs.
  407. func (_c *AccountCreate) AddUsageLogIDs(ids ...int64) *AccountCreate {
  408. _c.mutation.AddUsageLogIDs(ids...)
  409. return _c
  410. }
  411. // AddUsageLogs adds the "usage_logs" edges to the UsageLog entity.
  412. func (_c *AccountCreate) AddUsageLogs(v ...*UsageLog) *AccountCreate {
  413. ids := make([]int64, len(v))
  414. for i := range v {
  415. ids[i] = v[i].ID
  416. }
  417. return _c.AddUsageLogIDs(ids...)
  418. }
  419. // Mutation returns the AccountMutation object of the builder.
  420. func (_c *AccountCreate) Mutation() *AccountMutation {
  421. return _c.mutation
  422. }
  423. // Save creates the Account in the database.
  424. func (_c *AccountCreate) Save(ctx context.Context) (*Account, error) {
  425. if err := _c.defaults(); err != nil {
  426. return nil, err
  427. }
  428. return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
  429. }
  430. // SaveX calls Save and panics if Save returns an error.
  431. func (_c *AccountCreate) SaveX(ctx context.Context) *Account {
  432. v, err := _c.Save(ctx)
  433. if err != nil {
  434. panic(err)
  435. }
  436. return v
  437. }
  438. // Exec executes the query.
  439. func (_c *AccountCreate) Exec(ctx context.Context) error {
  440. _, err := _c.Save(ctx)
  441. return err
  442. }
  443. // ExecX is like Exec, but panics if an error occurs.
  444. func (_c *AccountCreate) ExecX(ctx context.Context) {
  445. if err := _c.Exec(ctx); err != nil {
  446. panic(err)
  447. }
  448. }
  449. // defaults sets the default values of the builder before save.
  450. func (_c *AccountCreate) defaults() error {
  451. if _, ok := _c.mutation.CreatedAt(); !ok {
  452. if account.DefaultCreatedAt == nil {
  453. return fmt.Errorf("ent: uninitialized account.DefaultCreatedAt (forgotten import ent/runtime?)")
  454. }
  455. v := account.DefaultCreatedAt()
  456. _c.mutation.SetCreatedAt(v)
  457. }
  458. if _, ok := _c.mutation.UpdatedAt(); !ok {
  459. if account.DefaultUpdatedAt == nil {
  460. return fmt.Errorf("ent: uninitialized account.DefaultUpdatedAt (forgotten import ent/runtime?)")
  461. }
  462. v := account.DefaultUpdatedAt()
  463. _c.mutation.SetUpdatedAt(v)
  464. }
  465. if _, ok := _c.mutation.Credentials(); !ok {
  466. if account.DefaultCredentials == nil {
  467. return fmt.Errorf("ent: uninitialized account.DefaultCredentials (forgotten import ent/runtime?)")
  468. }
  469. v := account.DefaultCredentials()
  470. _c.mutation.SetCredentials(v)
  471. }
  472. if _, ok := _c.mutation.Extra(); !ok {
  473. if account.DefaultExtra == nil {
  474. return fmt.Errorf("ent: uninitialized account.DefaultExtra (forgotten import ent/runtime?)")
  475. }
  476. v := account.DefaultExtra()
  477. _c.mutation.SetExtra(v)
  478. }
  479. if _, ok := _c.mutation.Concurrency(); !ok {
  480. v := account.DefaultConcurrency
  481. _c.mutation.SetConcurrency(v)
  482. }
  483. if _, ok := _c.mutation.Priority(); !ok {
  484. v := account.DefaultPriority
  485. _c.mutation.SetPriority(v)
  486. }
  487. if _, ok := _c.mutation.RateMultiplier(); !ok {
  488. v := account.DefaultRateMultiplier
  489. _c.mutation.SetRateMultiplier(v)
  490. }
  491. if _, ok := _c.mutation.Status(); !ok {
  492. v := account.DefaultStatus
  493. _c.mutation.SetStatus(v)
  494. }
  495. if _, ok := _c.mutation.AutoPauseOnExpired(); !ok {
  496. v := account.DefaultAutoPauseOnExpired
  497. _c.mutation.SetAutoPauseOnExpired(v)
  498. }
  499. if _, ok := _c.mutation.Schedulable(); !ok {
  500. v := account.DefaultSchedulable
  501. _c.mutation.SetSchedulable(v)
  502. }
  503. if _, ok := _c.mutation.QuotaDimension(); !ok {
  504. v := account.DefaultQuotaDimension
  505. _c.mutation.SetQuotaDimension(v)
  506. }
  507. return nil
  508. }
  509. // check runs all checks and user-defined validators on the builder.
  510. func (_c *AccountCreate) check() error {
  511. if _, ok := _c.mutation.CreatedAt(); !ok {
  512. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Account.created_at"`)}
  513. }
  514. if _, ok := _c.mutation.UpdatedAt(); !ok {
  515. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Account.updated_at"`)}
  516. }
  517. if _, ok := _c.mutation.Name(); !ok {
  518. return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Account.name"`)}
  519. }
  520. if v, ok := _c.mutation.Name(); ok {
  521. if err := account.NameValidator(v); err != nil {
  522. return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Account.name": %w`, err)}
  523. }
  524. }
  525. if _, ok := _c.mutation.Platform(); !ok {
  526. return &ValidationError{Name: "platform", err: errors.New(`ent: missing required field "Account.platform"`)}
  527. }
  528. if v, ok := _c.mutation.Platform(); ok {
  529. if err := account.PlatformValidator(v); err != nil {
  530. return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "Account.platform": %w`, err)}
  531. }
  532. }
  533. if _, ok := _c.mutation.GetType(); !ok {
  534. return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Account.type"`)}
  535. }
  536. if v, ok := _c.mutation.GetType(); ok {
  537. if err := account.TypeValidator(v); err != nil {
  538. return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Account.type": %w`, err)}
  539. }
  540. }
  541. if _, ok := _c.mutation.Credentials(); !ok {
  542. return &ValidationError{Name: "credentials", err: errors.New(`ent: missing required field "Account.credentials"`)}
  543. }
  544. if _, ok := _c.mutation.Extra(); !ok {
  545. return &ValidationError{Name: "extra", err: errors.New(`ent: missing required field "Account.extra"`)}
  546. }
  547. if _, ok := _c.mutation.Concurrency(); !ok {
  548. return &ValidationError{Name: "concurrency", err: errors.New(`ent: missing required field "Account.concurrency"`)}
  549. }
  550. if _, ok := _c.mutation.Priority(); !ok {
  551. return &ValidationError{Name: "priority", err: errors.New(`ent: missing required field "Account.priority"`)}
  552. }
  553. if _, ok := _c.mutation.RateMultiplier(); !ok {
  554. return &ValidationError{Name: "rate_multiplier", err: errors.New(`ent: missing required field "Account.rate_multiplier"`)}
  555. }
  556. if _, ok := _c.mutation.Status(); !ok {
  557. return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Account.status"`)}
  558. }
  559. if v, ok := _c.mutation.Status(); ok {
  560. if err := account.StatusValidator(v); err != nil {
  561. return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Account.status": %w`, err)}
  562. }
  563. }
  564. if _, ok := _c.mutation.AutoPauseOnExpired(); !ok {
  565. return &ValidationError{Name: "auto_pause_on_expired", err: errors.New(`ent: missing required field "Account.auto_pause_on_expired"`)}
  566. }
  567. if _, ok := _c.mutation.Schedulable(); !ok {
  568. return &ValidationError{Name: "schedulable", err: errors.New(`ent: missing required field "Account.schedulable"`)}
  569. }
  570. if v, ok := _c.mutation.SessionWindowStatus(); ok {
  571. if err := account.SessionWindowStatusValidator(v); err != nil {
  572. return &ValidationError{Name: "session_window_status", err: fmt.Errorf(`ent: validator failed for field "Account.session_window_status": %w`, err)}
  573. }
  574. }
  575. if _, ok := _c.mutation.QuotaDimension(); !ok {
  576. return &ValidationError{Name: "quota_dimension", err: errors.New(`ent: missing required field "Account.quota_dimension"`)}
  577. }
  578. if v, ok := _c.mutation.QuotaDimension(); ok {
  579. if err := account.QuotaDimensionValidator(v); err != nil {
  580. return &ValidationError{Name: "quota_dimension", err: fmt.Errorf(`ent: validator failed for field "Account.quota_dimension": %w`, err)}
  581. }
  582. }
  583. return nil
  584. }
  585. func (_c *AccountCreate) sqlSave(ctx context.Context) (*Account, error) {
  586. if err := _c.check(); err != nil {
  587. return nil, err
  588. }
  589. _node, _spec := _c.createSpec()
  590. if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
  591. if sqlgraph.IsConstraintError(err) {
  592. err = &ConstraintError{msg: err.Error(), wrap: err}
  593. }
  594. return nil, err
  595. }
  596. id := _spec.ID.Value.(int64)
  597. _node.ID = int64(id)
  598. _c.mutation.id = &_node.ID
  599. _c.mutation.done = true
  600. return _node, nil
  601. }
  602. func (_c *AccountCreate) createSpec() (*Account, *sqlgraph.CreateSpec) {
  603. var (
  604. _node = &Account{config: _c.config}
  605. _spec = sqlgraph.NewCreateSpec(account.Table, sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64))
  606. )
  607. _spec.OnConflict = _c.conflict
  608. if value, ok := _c.mutation.CreatedAt(); ok {
  609. _spec.SetField(account.FieldCreatedAt, field.TypeTime, value)
  610. _node.CreatedAt = value
  611. }
  612. if value, ok := _c.mutation.UpdatedAt(); ok {
  613. _spec.SetField(account.FieldUpdatedAt, field.TypeTime, value)
  614. _node.UpdatedAt = value
  615. }
  616. if value, ok := _c.mutation.DeletedAt(); ok {
  617. _spec.SetField(account.FieldDeletedAt, field.TypeTime, value)
  618. _node.DeletedAt = &value
  619. }
  620. if value, ok := _c.mutation.Name(); ok {
  621. _spec.SetField(account.FieldName, field.TypeString, value)
  622. _node.Name = value
  623. }
  624. if value, ok := _c.mutation.Notes(); ok {
  625. _spec.SetField(account.FieldNotes, field.TypeString, value)
  626. _node.Notes = &value
  627. }
  628. if value, ok := _c.mutation.Platform(); ok {
  629. _spec.SetField(account.FieldPlatform, field.TypeString, value)
  630. _node.Platform = value
  631. }
  632. if value, ok := _c.mutation.GetType(); ok {
  633. _spec.SetField(account.FieldType, field.TypeString, value)
  634. _node.Type = value
  635. }
  636. if value, ok := _c.mutation.Credentials(); ok {
  637. _spec.SetField(account.FieldCredentials, field.TypeJSON, value)
  638. _node.Credentials = value
  639. }
  640. if value, ok := _c.mutation.Extra(); ok {
  641. _spec.SetField(account.FieldExtra, field.TypeJSON, value)
  642. _node.Extra = value
  643. }
  644. if value, ok := _c.mutation.ProxyFallbackOriginID(); ok {
  645. _spec.SetField(account.FieldProxyFallbackOriginID, field.TypeInt64, value)
  646. _node.ProxyFallbackOriginID = &value
  647. }
  648. if value, ok := _c.mutation.Concurrency(); ok {
  649. _spec.SetField(account.FieldConcurrency, field.TypeInt, value)
  650. _node.Concurrency = value
  651. }
  652. if value, ok := _c.mutation.LoadFactor(); ok {
  653. _spec.SetField(account.FieldLoadFactor, field.TypeInt, value)
  654. _node.LoadFactor = &value
  655. }
  656. if value, ok := _c.mutation.Priority(); ok {
  657. _spec.SetField(account.FieldPriority, field.TypeInt, value)
  658. _node.Priority = value
  659. }
  660. if value, ok := _c.mutation.RateMultiplier(); ok {
  661. _spec.SetField(account.FieldRateMultiplier, field.TypeFloat64, value)
  662. _node.RateMultiplier = value
  663. }
  664. if value, ok := _c.mutation.Status(); ok {
  665. _spec.SetField(account.FieldStatus, field.TypeString, value)
  666. _node.Status = value
  667. }
  668. if value, ok := _c.mutation.ErrorMessage(); ok {
  669. _spec.SetField(account.FieldErrorMessage, field.TypeString, value)
  670. _node.ErrorMessage = &value
  671. }
  672. if value, ok := _c.mutation.LastUsedAt(); ok {
  673. _spec.SetField(account.FieldLastUsedAt, field.TypeTime, value)
  674. _node.LastUsedAt = &value
  675. }
  676. if value, ok := _c.mutation.ExpiresAt(); ok {
  677. _spec.SetField(account.FieldExpiresAt, field.TypeTime, value)
  678. _node.ExpiresAt = &value
  679. }
  680. if value, ok := _c.mutation.AutoPauseOnExpired(); ok {
  681. _spec.SetField(account.FieldAutoPauseOnExpired, field.TypeBool, value)
  682. _node.AutoPauseOnExpired = value
  683. }
  684. if value, ok := _c.mutation.Schedulable(); ok {
  685. _spec.SetField(account.FieldSchedulable, field.TypeBool, value)
  686. _node.Schedulable = value
  687. }
  688. if value, ok := _c.mutation.RateLimitedAt(); ok {
  689. _spec.SetField(account.FieldRateLimitedAt, field.TypeTime, value)
  690. _node.RateLimitedAt = &value
  691. }
  692. if value, ok := _c.mutation.RateLimitResetAt(); ok {
  693. _spec.SetField(account.FieldRateLimitResetAt, field.TypeTime, value)
  694. _node.RateLimitResetAt = &value
  695. }
  696. if value, ok := _c.mutation.OverloadUntil(); ok {
  697. _spec.SetField(account.FieldOverloadUntil, field.TypeTime, value)
  698. _node.OverloadUntil = &value
  699. }
  700. if value, ok := _c.mutation.TempUnschedulableUntil(); ok {
  701. _spec.SetField(account.FieldTempUnschedulableUntil, field.TypeTime, value)
  702. _node.TempUnschedulableUntil = &value
  703. }
  704. if value, ok := _c.mutation.TempUnschedulableReason(); ok {
  705. _spec.SetField(account.FieldTempUnschedulableReason, field.TypeString, value)
  706. _node.TempUnschedulableReason = &value
  707. }
  708. if value, ok := _c.mutation.SessionWindowStart(); ok {
  709. _spec.SetField(account.FieldSessionWindowStart, field.TypeTime, value)
  710. _node.SessionWindowStart = &value
  711. }
  712. if value, ok := _c.mutation.SessionWindowEnd(); ok {
  713. _spec.SetField(account.FieldSessionWindowEnd, field.TypeTime, value)
  714. _node.SessionWindowEnd = &value
  715. }
  716. if value, ok := _c.mutation.SessionWindowStatus(); ok {
  717. _spec.SetField(account.FieldSessionWindowStatus, field.TypeString, value)
  718. _node.SessionWindowStatus = &value
  719. }
  720. if value, ok := _c.mutation.QuotaDimension(); ok {
  721. _spec.SetField(account.FieldQuotaDimension, field.TypeEnum, value)
  722. _node.QuotaDimension = value
  723. }
  724. if nodes := _c.mutation.GroupsIDs(); len(nodes) > 0 {
  725. edge := &sqlgraph.EdgeSpec{
  726. Rel: sqlgraph.M2M,
  727. Inverse: false,
  728. Table: account.GroupsTable,
  729. Columns: account.GroupsPrimaryKey,
  730. Bidi: false,
  731. Target: &sqlgraph.EdgeTarget{
  732. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  733. },
  734. }
  735. for _, k := range nodes {
  736. edge.Target.Nodes = append(edge.Target.Nodes, k)
  737. }
  738. createE := &AccountGroupCreate{config: _c.config, mutation: newAccountGroupMutation(_c.config, OpCreate)}
  739. createE.defaults()
  740. _, specE := createE.createSpec()
  741. edge.Target.Fields = specE.Fields
  742. _spec.Edges = append(_spec.Edges, edge)
  743. }
  744. if nodes := _c.mutation.ProxyIDs(); len(nodes) > 0 {
  745. edge := &sqlgraph.EdgeSpec{
  746. Rel: sqlgraph.M2O,
  747. Inverse: false,
  748. Table: account.ProxyTable,
  749. Columns: []string{account.ProxyColumn},
  750. Bidi: false,
  751. Target: &sqlgraph.EdgeTarget{
  752. IDSpec: sqlgraph.NewFieldSpec(proxy.FieldID, field.TypeInt64),
  753. },
  754. }
  755. for _, k := range nodes {
  756. edge.Target.Nodes = append(edge.Target.Nodes, k)
  757. }
  758. _node.ProxyID = &nodes[0]
  759. _spec.Edges = append(_spec.Edges, edge)
  760. }
  761. if nodes := _c.mutation.ParentIDs(); len(nodes) > 0 {
  762. edge := &sqlgraph.EdgeSpec{
  763. Rel: sqlgraph.M2O,
  764. Inverse: true,
  765. Table: account.ParentTable,
  766. Columns: []string{account.ParentColumn},
  767. Bidi: false,
  768. Target: &sqlgraph.EdgeTarget{
  769. IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
  770. },
  771. }
  772. for _, k := range nodes {
  773. edge.Target.Nodes = append(edge.Target.Nodes, k)
  774. }
  775. _node.ParentAccountID = &nodes[0]
  776. _spec.Edges = append(_spec.Edges, edge)
  777. }
  778. if nodes := _c.mutation.ChildrenIDs(); len(nodes) > 0 {
  779. edge := &sqlgraph.EdgeSpec{
  780. Rel: sqlgraph.O2M,
  781. Inverse: false,
  782. Table: account.ChildrenTable,
  783. Columns: []string{account.ChildrenColumn},
  784. Bidi: false,
  785. Target: &sqlgraph.EdgeTarget{
  786. IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
  787. },
  788. }
  789. for _, k := range nodes {
  790. edge.Target.Nodes = append(edge.Target.Nodes, k)
  791. }
  792. _spec.Edges = append(_spec.Edges, edge)
  793. }
  794. if nodes := _c.mutation.UsageLogsIDs(); len(nodes) > 0 {
  795. edge := &sqlgraph.EdgeSpec{
  796. Rel: sqlgraph.O2M,
  797. Inverse: false,
  798. Table: account.UsageLogsTable,
  799. Columns: []string{account.UsageLogsColumn},
  800. Bidi: false,
  801. Target: &sqlgraph.EdgeTarget{
  802. IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
  803. },
  804. }
  805. for _, k := range nodes {
  806. edge.Target.Nodes = append(edge.Target.Nodes, k)
  807. }
  808. _spec.Edges = append(_spec.Edges, edge)
  809. }
  810. return _node, _spec
  811. }
  812. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  813. // of the `INSERT` statement. For example:
  814. //
  815. // client.Account.Create().
  816. // SetCreatedAt(v).
  817. // OnConflict(
  818. // // Update the row with the new values
  819. // // the was proposed for insertion.
  820. // sql.ResolveWithNewValues(),
  821. // ).
  822. // // Override some of the fields with custom
  823. // // update values.
  824. // Update(func(u *ent.AccountUpsert) {
  825. // SetCreatedAt(v+v).
  826. // }).
  827. // Exec(ctx)
  828. func (_c *AccountCreate) OnConflict(opts ...sql.ConflictOption) *AccountUpsertOne {
  829. _c.conflict = opts
  830. return &AccountUpsertOne{
  831. create: _c,
  832. }
  833. }
  834. // OnConflictColumns calls `OnConflict` and configures the columns
  835. // as conflict target. Using this option is equivalent to using:
  836. //
  837. // client.Account.Create().
  838. // OnConflict(sql.ConflictColumns(columns...)).
  839. // Exec(ctx)
  840. func (_c *AccountCreate) OnConflictColumns(columns ...string) *AccountUpsertOne {
  841. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  842. return &AccountUpsertOne{
  843. create: _c,
  844. }
  845. }
  846. type (
  847. // AccountUpsertOne is the builder for "upsert"-ing
  848. // one Account node.
  849. AccountUpsertOne struct {
  850. create *AccountCreate
  851. }
  852. // AccountUpsert is the "OnConflict" setter.
  853. AccountUpsert struct {
  854. *sql.UpdateSet
  855. }
  856. )
  857. // SetUpdatedAt sets the "updated_at" field.
  858. func (u *AccountUpsert) SetUpdatedAt(v time.Time) *AccountUpsert {
  859. u.Set(account.FieldUpdatedAt, v)
  860. return u
  861. }
  862. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  863. func (u *AccountUpsert) UpdateUpdatedAt() *AccountUpsert {
  864. u.SetExcluded(account.FieldUpdatedAt)
  865. return u
  866. }
  867. // SetDeletedAt sets the "deleted_at" field.
  868. func (u *AccountUpsert) SetDeletedAt(v time.Time) *AccountUpsert {
  869. u.Set(account.FieldDeletedAt, v)
  870. return u
  871. }
  872. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  873. func (u *AccountUpsert) UpdateDeletedAt() *AccountUpsert {
  874. u.SetExcluded(account.FieldDeletedAt)
  875. return u
  876. }
  877. // ClearDeletedAt clears the value of the "deleted_at" field.
  878. func (u *AccountUpsert) ClearDeletedAt() *AccountUpsert {
  879. u.SetNull(account.FieldDeletedAt)
  880. return u
  881. }
  882. // SetName sets the "name" field.
  883. func (u *AccountUpsert) SetName(v string) *AccountUpsert {
  884. u.Set(account.FieldName, v)
  885. return u
  886. }
  887. // UpdateName sets the "name" field to the value that was provided on create.
  888. func (u *AccountUpsert) UpdateName() *AccountUpsert {
  889. u.SetExcluded(account.FieldName)
  890. return u
  891. }
  892. // SetNotes sets the "notes" field.
  893. func (u *AccountUpsert) SetNotes(v string) *AccountUpsert {
  894. u.Set(account.FieldNotes, v)
  895. return u
  896. }
  897. // UpdateNotes sets the "notes" field to the value that was provided on create.
  898. func (u *AccountUpsert) UpdateNotes() *AccountUpsert {
  899. u.SetExcluded(account.FieldNotes)
  900. return u
  901. }
  902. // ClearNotes clears the value of the "notes" field.
  903. func (u *AccountUpsert) ClearNotes() *AccountUpsert {
  904. u.SetNull(account.FieldNotes)
  905. return u
  906. }
  907. // SetPlatform sets the "platform" field.
  908. func (u *AccountUpsert) SetPlatform(v string) *AccountUpsert {
  909. u.Set(account.FieldPlatform, v)
  910. return u
  911. }
  912. // UpdatePlatform sets the "platform" field to the value that was provided on create.
  913. func (u *AccountUpsert) UpdatePlatform() *AccountUpsert {
  914. u.SetExcluded(account.FieldPlatform)
  915. return u
  916. }
  917. // SetType sets the "type" field.
  918. func (u *AccountUpsert) SetType(v string) *AccountUpsert {
  919. u.Set(account.FieldType, v)
  920. return u
  921. }
  922. // UpdateType sets the "type" field to the value that was provided on create.
  923. func (u *AccountUpsert) UpdateType() *AccountUpsert {
  924. u.SetExcluded(account.FieldType)
  925. return u
  926. }
  927. // SetCredentials sets the "credentials" field.
  928. func (u *AccountUpsert) SetCredentials(v map[string]interface{}) *AccountUpsert {
  929. u.Set(account.FieldCredentials, v)
  930. return u
  931. }
  932. // UpdateCredentials sets the "credentials" field to the value that was provided on create.
  933. func (u *AccountUpsert) UpdateCredentials() *AccountUpsert {
  934. u.SetExcluded(account.FieldCredentials)
  935. return u
  936. }
  937. // SetExtra sets the "extra" field.
  938. func (u *AccountUpsert) SetExtra(v map[string]interface{}) *AccountUpsert {
  939. u.Set(account.FieldExtra, v)
  940. return u
  941. }
  942. // UpdateExtra sets the "extra" field to the value that was provided on create.
  943. func (u *AccountUpsert) UpdateExtra() *AccountUpsert {
  944. u.SetExcluded(account.FieldExtra)
  945. return u
  946. }
  947. // SetProxyID sets the "proxy_id" field.
  948. func (u *AccountUpsert) SetProxyID(v int64) *AccountUpsert {
  949. u.Set(account.FieldProxyID, v)
  950. return u
  951. }
  952. // UpdateProxyID sets the "proxy_id" field to the value that was provided on create.
  953. func (u *AccountUpsert) UpdateProxyID() *AccountUpsert {
  954. u.SetExcluded(account.FieldProxyID)
  955. return u
  956. }
  957. // ClearProxyID clears the value of the "proxy_id" field.
  958. func (u *AccountUpsert) ClearProxyID() *AccountUpsert {
  959. u.SetNull(account.FieldProxyID)
  960. return u
  961. }
  962. // SetProxyFallbackOriginID sets the "proxy_fallback_origin_id" field.
  963. func (u *AccountUpsert) SetProxyFallbackOriginID(v int64) *AccountUpsert {
  964. u.Set(account.FieldProxyFallbackOriginID, v)
  965. return u
  966. }
  967. // UpdateProxyFallbackOriginID sets the "proxy_fallback_origin_id" field to the value that was provided on create.
  968. func (u *AccountUpsert) UpdateProxyFallbackOriginID() *AccountUpsert {
  969. u.SetExcluded(account.FieldProxyFallbackOriginID)
  970. return u
  971. }
  972. // AddProxyFallbackOriginID adds v to the "proxy_fallback_origin_id" field.
  973. func (u *AccountUpsert) AddProxyFallbackOriginID(v int64) *AccountUpsert {
  974. u.Add(account.FieldProxyFallbackOriginID, v)
  975. return u
  976. }
  977. // ClearProxyFallbackOriginID clears the value of the "proxy_fallback_origin_id" field.
  978. func (u *AccountUpsert) ClearProxyFallbackOriginID() *AccountUpsert {
  979. u.SetNull(account.FieldProxyFallbackOriginID)
  980. return u
  981. }
  982. // SetConcurrency sets the "concurrency" field.
  983. func (u *AccountUpsert) SetConcurrency(v int) *AccountUpsert {
  984. u.Set(account.FieldConcurrency, v)
  985. return u
  986. }
  987. // UpdateConcurrency sets the "concurrency" field to the value that was provided on create.
  988. func (u *AccountUpsert) UpdateConcurrency() *AccountUpsert {
  989. u.SetExcluded(account.FieldConcurrency)
  990. return u
  991. }
  992. // AddConcurrency adds v to the "concurrency" field.
  993. func (u *AccountUpsert) AddConcurrency(v int) *AccountUpsert {
  994. u.Add(account.FieldConcurrency, v)
  995. return u
  996. }
  997. // SetLoadFactor sets the "load_factor" field.
  998. func (u *AccountUpsert) SetLoadFactor(v int) *AccountUpsert {
  999. u.Set(account.FieldLoadFactor, v)
  1000. return u
  1001. }
  1002. // UpdateLoadFactor sets the "load_factor" field to the value that was provided on create.
  1003. func (u *AccountUpsert) UpdateLoadFactor() *AccountUpsert {
  1004. u.SetExcluded(account.FieldLoadFactor)
  1005. return u
  1006. }
  1007. // AddLoadFactor adds v to the "load_factor" field.
  1008. func (u *AccountUpsert) AddLoadFactor(v int) *AccountUpsert {
  1009. u.Add(account.FieldLoadFactor, v)
  1010. return u
  1011. }
  1012. // ClearLoadFactor clears the value of the "load_factor" field.
  1013. func (u *AccountUpsert) ClearLoadFactor() *AccountUpsert {
  1014. u.SetNull(account.FieldLoadFactor)
  1015. return u
  1016. }
  1017. // SetPriority sets the "priority" field.
  1018. func (u *AccountUpsert) SetPriority(v int) *AccountUpsert {
  1019. u.Set(account.FieldPriority, v)
  1020. return u
  1021. }
  1022. // UpdatePriority sets the "priority" field to the value that was provided on create.
  1023. func (u *AccountUpsert) UpdatePriority() *AccountUpsert {
  1024. u.SetExcluded(account.FieldPriority)
  1025. return u
  1026. }
  1027. // AddPriority adds v to the "priority" field.
  1028. func (u *AccountUpsert) AddPriority(v int) *AccountUpsert {
  1029. u.Add(account.FieldPriority, v)
  1030. return u
  1031. }
  1032. // SetRateMultiplier sets the "rate_multiplier" field.
  1033. func (u *AccountUpsert) SetRateMultiplier(v float64) *AccountUpsert {
  1034. u.Set(account.FieldRateMultiplier, v)
  1035. return u
  1036. }
  1037. // UpdateRateMultiplier sets the "rate_multiplier" field to the value that was provided on create.
  1038. func (u *AccountUpsert) UpdateRateMultiplier() *AccountUpsert {
  1039. u.SetExcluded(account.FieldRateMultiplier)
  1040. return u
  1041. }
  1042. // AddRateMultiplier adds v to the "rate_multiplier" field.
  1043. func (u *AccountUpsert) AddRateMultiplier(v float64) *AccountUpsert {
  1044. u.Add(account.FieldRateMultiplier, v)
  1045. return u
  1046. }
  1047. // SetStatus sets the "status" field.
  1048. func (u *AccountUpsert) SetStatus(v string) *AccountUpsert {
  1049. u.Set(account.FieldStatus, v)
  1050. return u
  1051. }
  1052. // UpdateStatus sets the "status" field to the value that was provided on create.
  1053. func (u *AccountUpsert) UpdateStatus() *AccountUpsert {
  1054. u.SetExcluded(account.FieldStatus)
  1055. return u
  1056. }
  1057. // SetErrorMessage sets the "error_message" field.
  1058. func (u *AccountUpsert) SetErrorMessage(v string) *AccountUpsert {
  1059. u.Set(account.FieldErrorMessage, v)
  1060. return u
  1061. }
  1062. // UpdateErrorMessage sets the "error_message" field to the value that was provided on create.
  1063. func (u *AccountUpsert) UpdateErrorMessage() *AccountUpsert {
  1064. u.SetExcluded(account.FieldErrorMessage)
  1065. return u
  1066. }
  1067. // ClearErrorMessage clears the value of the "error_message" field.
  1068. func (u *AccountUpsert) ClearErrorMessage() *AccountUpsert {
  1069. u.SetNull(account.FieldErrorMessage)
  1070. return u
  1071. }
  1072. // SetLastUsedAt sets the "last_used_at" field.
  1073. func (u *AccountUpsert) SetLastUsedAt(v time.Time) *AccountUpsert {
  1074. u.Set(account.FieldLastUsedAt, v)
  1075. return u
  1076. }
  1077. // UpdateLastUsedAt sets the "last_used_at" field to the value that was provided on create.
  1078. func (u *AccountUpsert) UpdateLastUsedAt() *AccountUpsert {
  1079. u.SetExcluded(account.FieldLastUsedAt)
  1080. return u
  1081. }
  1082. // ClearLastUsedAt clears the value of the "last_used_at" field.
  1083. func (u *AccountUpsert) ClearLastUsedAt() *AccountUpsert {
  1084. u.SetNull(account.FieldLastUsedAt)
  1085. return u
  1086. }
  1087. // SetExpiresAt sets the "expires_at" field.
  1088. func (u *AccountUpsert) SetExpiresAt(v time.Time) *AccountUpsert {
  1089. u.Set(account.FieldExpiresAt, v)
  1090. return u
  1091. }
  1092. // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
  1093. func (u *AccountUpsert) UpdateExpiresAt() *AccountUpsert {
  1094. u.SetExcluded(account.FieldExpiresAt)
  1095. return u
  1096. }
  1097. // ClearExpiresAt clears the value of the "expires_at" field.
  1098. func (u *AccountUpsert) ClearExpiresAt() *AccountUpsert {
  1099. u.SetNull(account.FieldExpiresAt)
  1100. return u
  1101. }
  1102. // SetAutoPauseOnExpired sets the "auto_pause_on_expired" field.
  1103. func (u *AccountUpsert) SetAutoPauseOnExpired(v bool) *AccountUpsert {
  1104. u.Set(account.FieldAutoPauseOnExpired, v)
  1105. return u
  1106. }
  1107. // UpdateAutoPauseOnExpired sets the "auto_pause_on_expired" field to the value that was provided on create.
  1108. func (u *AccountUpsert) UpdateAutoPauseOnExpired() *AccountUpsert {
  1109. u.SetExcluded(account.FieldAutoPauseOnExpired)
  1110. return u
  1111. }
  1112. // SetSchedulable sets the "schedulable" field.
  1113. func (u *AccountUpsert) SetSchedulable(v bool) *AccountUpsert {
  1114. u.Set(account.FieldSchedulable, v)
  1115. return u
  1116. }
  1117. // UpdateSchedulable sets the "schedulable" field to the value that was provided on create.
  1118. func (u *AccountUpsert) UpdateSchedulable() *AccountUpsert {
  1119. u.SetExcluded(account.FieldSchedulable)
  1120. return u
  1121. }
  1122. // SetRateLimitedAt sets the "rate_limited_at" field.
  1123. func (u *AccountUpsert) SetRateLimitedAt(v time.Time) *AccountUpsert {
  1124. u.Set(account.FieldRateLimitedAt, v)
  1125. return u
  1126. }
  1127. // UpdateRateLimitedAt sets the "rate_limited_at" field to the value that was provided on create.
  1128. func (u *AccountUpsert) UpdateRateLimitedAt() *AccountUpsert {
  1129. u.SetExcluded(account.FieldRateLimitedAt)
  1130. return u
  1131. }
  1132. // ClearRateLimitedAt clears the value of the "rate_limited_at" field.
  1133. func (u *AccountUpsert) ClearRateLimitedAt() *AccountUpsert {
  1134. u.SetNull(account.FieldRateLimitedAt)
  1135. return u
  1136. }
  1137. // SetRateLimitResetAt sets the "rate_limit_reset_at" field.
  1138. func (u *AccountUpsert) SetRateLimitResetAt(v time.Time) *AccountUpsert {
  1139. u.Set(account.FieldRateLimitResetAt, v)
  1140. return u
  1141. }
  1142. // UpdateRateLimitResetAt sets the "rate_limit_reset_at" field to the value that was provided on create.
  1143. func (u *AccountUpsert) UpdateRateLimitResetAt() *AccountUpsert {
  1144. u.SetExcluded(account.FieldRateLimitResetAt)
  1145. return u
  1146. }
  1147. // ClearRateLimitResetAt clears the value of the "rate_limit_reset_at" field.
  1148. func (u *AccountUpsert) ClearRateLimitResetAt() *AccountUpsert {
  1149. u.SetNull(account.FieldRateLimitResetAt)
  1150. return u
  1151. }
  1152. // SetOverloadUntil sets the "overload_until" field.
  1153. func (u *AccountUpsert) SetOverloadUntil(v time.Time) *AccountUpsert {
  1154. u.Set(account.FieldOverloadUntil, v)
  1155. return u
  1156. }
  1157. // UpdateOverloadUntil sets the "overload_until" field to the value that was provided on create.
  1158. func (u *AccountUpsert) UpdateOverloadUntil() *AccountUpsert {
  1159. u.SetExcluded(account.FieldOverloadUntil)
  1160. return u
  1161. }
  1162. // ClearOverloadUntil clears the value of the "overload_until" field.
  1163. func (u *AccountUpsert) ClearOverloadUntil() *AccountUpsert {
  1164. u.SetNull(account.FieldOverloadUntil)
  1165. return u
  1166. }
  1167. // SetTempUnschedulableUntil sets the "temp_unschedulable_until" field.
  1168. func (u *AccountUpsert) SetTempUnschedulableUntil(v time.Time) *AccountUpsert {
  1169. u.Set(account.FieldTempUnschedulableUntil, v)
  1170. return u
  1171. }
  1172. // UpdateTempUnschedulableUntil sets the "temp_unschedulable_until" field to the value that was provided on create.
  1173. func (u *AccountUpsert) UpdateTempUnschedulableUntil() *AccountUpsert {
  1174. u.SetExcluded(account.FieldTempUnschedulableUntil)
  1175. return u
  1176. }
  1177. // ClearTempUnschedulableUntil clears the value of the "temp_unschedulable_until" field.
  1178. func (u *AccountUpsert) ClearTempUnschedulableUntil() *AccountUpsert {
  1179. u.SetNull(account.FieldTempUnschedulableUntil)
  1180. return u
  1181. }
  1182. // SetTempUnschedulableReason sets the "temp_unschedulable_reason" field.
  1183. func (u *AccountUpsert) SetTempUnschedulableReason(v string) *AccountUpsert {
  1184. u.Set(account.FieldTempUnschedulableReason, v)
  1185. return u
  1186. }
  1187. // UpdateTempUnschedulableReason sets the "temp_unschedulable_reason" field to the value that was provided on create.
  1188. func (u *AccountUpsert) UpdateTempUnschedulableReason() *AccountUpsert {
  1189. u.SetExcluded(account.FieldTempUnschedulableReason)
  1190. return u
  1191. }
  1192. // ClearTempUnschedulableReason clears the value of the "temp_unschedulable_reason" field.
  1193. func (u *AccountUpsert) ClearTempUnschedulableReason() *AccountUpsert {
  1194. u.SetNull(account.FieldTempUnschedulableReason)
  1195. return u
  1196. }
  1197. // SetSessionWindowStart sets the "session_window_start" field.
  1198. func (u *AccountUpsert) SetSessionWindowStart(v time.Time) *AccountUpsert {
  1199. u.Set(account.FieldSessionWindowStart, v)
  1200. return u
  1201. }
  1202. // UpdateSessionWindowStart sets the "session_window_start" field to the value that was provided on create.
  1203. func (u *AccountUpsert) UpdateSessionWindowStart() *AccountUpsert {
  1204. u.SetExcluded(account.FieldSessionWindowStart)
  1205. return u
  1206. }
  1207. // ClearSessionWindowStart clears the value of the "session_window_start" field.
  1208. func (u *AccountUpsert) ClearSessionWindowStart() *AccountUpsert {
  1209. u.SetNull(account.FieldSessionWindowStart)
  1210. return u
  1211. }
  1212. // SetSessionWindowEnd sets the "session_window_end" field.
  1213. func (u *AccountUpsert) SetSessionWindowEnd(v time.Time) *AccountUpsert {
  1214. u.Set(account.FieldSessionWindowEnd, v)
  1215. return u
  1216. }
  1217. // UpdateSessionWindowEnd sets the "session_window_end" field to the value that was provided on create.
  1218. func (u *AccountUpsert) UpdateSessionWindowEnd() *AccountUpsert {
  1219. u.SetExcluded(account.FieldSessionWindowEnd)
  1220. return u
  1221. }
  1222. // ClearSessionWindowEnd clears the value of the "session_window_end" field.
  1223. func (u *AccountUpsert) ClearSessionWindowEnd() *AccountUpsert {
  1224. u.SetNull(account.FieldSessionWindowEnd)
  1225. return u
  1226. }
  1227. // SetSessionWindowStatus sets the "session_window_status" field.
  1228. func (u *AccountUpsert) SetSessionWindowStatus(v string) *AccountUpsert {
  1229. u.Set(account.FieldSessionWindowStatus, v)
  1230. return u
  1231. }
  1232. // UpdateSessionWindowStatus sets the "session_window_status" field to the value that was provided on create.
  1233. func (u *AccountUpsert) UpdateSessionWindowStatus() *AccountUpsert {
  1234. u.SetExcluded(account.FieldSessionWindowStatus)
  1235. return u
  1236. }
  1237. // ClearSessionWindowStatus clears the value of the "session_window_status" field.
  1238. func (u *AccountUpsert) ClearSessionWindowStatus() *AccountUpsert {
  1239. u.SetNull(account.FieldSessionWindowStatus)
  1240. return u
  1241. }
  1242. // SetParentAccountID sets the "parent_account_id" field.
  1243. func (u *AccountUpsert) SetParentAccountID(v int64) *AccountUpsert {
  1244. u.Set(account.FieldParentAccountID, v)
  1245. return u
  1246. }
  1247. // UpdateParentAccountID sets the "parent_account_id" field to the value that was provided on create.
  1248. func (u *AccountUpsert) UpdateParentAccountID() *AccountUpsert {
  1249. u.SetExcluded(account.FieldParentAccountID)
  1250. return u
  1251. }
  1252. // ClearParentAccountID clears the value of the "parent_account_id" field.
  1253. func (u *AccountUpsert) ClearParentAccountID() *AccountUpsert {
  1254. u.SetNull(account.FieldParentAccountID)
  1255. return u
  1256. }
  1257. // SetQuotaDimension sets the "quota_dimension" field.
  1258. func (u *AccountUpsert) SetQuotaDimension(v account.QuotaDimension) *AccountUpsert {
  1259. u.Set(account.FieldQuotaDimension, v)
  1260. return u
  1261. }
  1262. // UpdateQuotaDimension sets the "quota_dimension" field to the value that was provided on create.
  1263. func (u *AccountUpsert) UpdateQuotaDimension() *AccountUpsert {
  1264. u.SetExcluded(account.FieldQuotaDimension)
  1265. return u
  1266. }
  1267. // UpdateNewValues updates the mutable fields using the new values that were set on create.
  1268. // Using this option is equivalent to using:
  1269. //
  1270. // client.Account.Create().
  1271. // OnConflict(
  1272. // sql.ResolveWithNewValues(),
  1273. // ).
  1274. // Exec(ctx)
  1275. func (u *AccountUpsertOne) UpdateNewValues() *AccountUpsertOne {
  1276. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1277. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1278. if _, exists := u.create.mutation.CreatedAt(); exists {
  1279. s.SetIgnore(account.FieldCreatedAt)
  1280. }
  1281. }))
  1282. return u
  1283. }
  1284. // Ignore sets each column to itself in case of conflict.
  1285. // Using this option is equivalent to using:
  1286. //
  1287. // client.Account.Create().
  1288. // OnConflict(sql.ResolveWithIgnore()).
  1289. // Exec(ctx)
  1290. func (u *AccountUpsertOne) Ignore() *AccountUpsertOne {
  1291. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1292. return u
  1293. }
  1294. // DoNothing configures the conflict_action to `DO NOTHING`.
  1295. // Supported only by SQLite and PostgreSQL.
  1296. func (u *AccountUpsertOne) DoNothing() *AccountUpsertOne {
  1297. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1298. return u
  1299. }
  1300. // Update allows overriding fields `UPDATE` values. See the AccountCreate.OnConflict
  1301. // documentation for more info.
  1302. func (u *AccountUpsertOne) Update(set func(*AccountUpsert)) *AccountUpsertOne {
  1303. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1304. set(&AccountUpsert{UpdateSet: update})
  1305. }))
  1306. return u
  1307. }
  1308. // SetUpdatedAt sets the "updated_at" field.
  1309. func (u *AccountUpsertOne) SetUpdatedAt(v time.Time) *AccountUpsertOne {
  1310. return u.Update(func(s *AccountUpsert) {
  1311. s.SetUpdatedAt(v)
  1312. })
  1313. }
  1314. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1315. func (u *AccountUpsertOne) UpdateUpdatedAt() *AccountUpsertOne {
  1316. return u.Update(func(s *AccountUpsert) {
  1317. s.UpdateUpdatedAt()
  1318. })
  1319. }
  1320. // SetDeletedAt sets the "deleted_at" field.
  1321. func (u *AccountUpsertOne) SetDeletedAt(v time.Time) *AccountUpsertOne {
  1322. return u.Update(func(s *AccountUpsert) {
  1323. s.SetDeletedAt(v)
  1324. })
  1325. }
  1326. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  1327. func (u *AccountUpsertOne) UpdateDeletedAt() *AccountUpsertOne {
  1328. return u.Update(func(s *AccountUpsert) {
  1329. s.UpdateDeletedAt()
  1330. })
  1331. }
  1332. // ClearDeletedAt clears the value of the "deleted_at" field.
  1333. func (u *AccountUpsertOne) ClearDeletedAt() *AccountUpsertOne {
  1334. return u.Update(func(s *AccountUpsert) {
  1335. s.ClearDeletedAt()
  1336. })
  1337. }
  1338. // SetName sets the "name" field.
  1339. func (u *AccountUpsertOne) SetName(v string) *AccountUpsertOne {
  1340. return u.Update(func(s *AccountUpsert) {
  1341. s.SetName(v)
  1342. })
  1343. }
  1344. // UpdateName sets the "name" field to the value that was provided on create.
  1345. func (u *AccountUpsertOne) UpdateName() *AccountUpsertOne {
  1346. return u.Update(func(s *AccountUpsert) {
  1347. s.UpdateName()
  1348. })
  1349. }
  1350. // SetNotes sets the "notes" field.
  1351. func (u *AccountUpsertOne) SetNotes(v string) *AccountUpsertOne {
  1352. return u.Update(func(s *AccountUpsert) {
  1353. s.SetNotes(v)
  1354. })
  1355. }
  1356. // UpdateNotes sets the "notes" field to the value that was provided on create.
  1357. func (u *AccountUpsertOne) UpdateNotes() *AccountUpsertOne {
  1358. return u.Update(func(s *AccountUpsert) {
  1359. s.UpdateNotes()
  1360. })
  1361. }
  1362. // ClearNotes clears the value of the "notes" field.
  1363. func (u *AccountUpsertOne) ClearNotes() *AccountUpsertOne {
  1364. return u.Update(func(s *AccountUpsert) {
  1365. s.ClearNotes()
  1366. })
  1367. }
  1368. // SetPlatform sets the "platform" field.
  1369. func (u *AccountUpsertOne) SetPlatform(v string) *AccountUpsertOne {
  1370. return u.Update(func(s *AccountUpsert) {
  1371. s.SetPlatform(v)
  1372. })
  1373. }
  1374. // UpdatePlatform sets the "platform" field to the value that was provided on create.
  1375. func (u *AccountUpsertOne) UpdatePlatform() *AccountUpsertOne {
  1376. return u.Update(func(s *AccountUpsert) {
  1377. s.UpdatePlatform()
  1378. })
  1379. }
  1380. // SetType sets the "type" field.
  1381. func (u *AccountUpsertOne) SetType(v string) *AccountUpsertOne {
  1382. return u.Update(func(s *AccountUpsert) {
  1383. s.SetType(v)
  1384. })
  1385. }
  1386. // UpdateType sets the "type" field to the value that was provided on create.
  1387. func (u *AccountUpsertOne) UpdateType() *AccountUpsertOne {
  1388. return u.Update(func(s *AccountUpsert) {
  1389. s.UpdateType()
  1390. })
  1391. }
  1392. // SetCredentials sets the "credentials" field.
  1393. func (u *AccountUpsertOne) SetCredentials(v map[string]interface{}) *AccountUpsertOne {
  1394. return u.Update(func(s *AccountUpsert) {
  1395. s.SetCredentials(v)
  1396. })
  1397. }
  1398. // UpdateCredentials sets the "credentials" field to the value that was provided on create.
  1399. func (u *AccountUpsertOne) UpdateCredentials() *AccountUpsertOne {
  1400. return u.Update(func(s *AccountUpsert) {
  1401. s.UpdateCredentials()
  1402. })
  1403. }
  1404. // SetExtra sets the "extra" field.
  1405. func (u *AccountUpsertOne) SetExtra(v map[string]interface{}) *AccountUpsertOne {
  1406. return u.Update(func(s *AccountUpsert) {
  1407. s.SetExtra(v)
  1408. })
  1409. }
  1410. // UpdateExtra sets the "extra" field to the value that was provided on create.
  1411. func (u *AccountUpsertOne) UpdateExtra() *AccountUpsertOne {
  1412. return u.Update(func(s *AccountUpsert) {
  1413. s.UpdateExtra()
  1414. })
  1415. }
  1416. // SetProxyID sets the "proxy_id" field.
  1417. func (u *AccountUpsertOne) SetProxyID(v int64) *AccountUpsertOne {
  1418. return u.Update(func(s *AccountUpsert) {
  1419. s.SetProxyID(v)
  1420. })
  1421. }
  1422. // UpdateProxyID sets the "proxy_id" field to the value that was provided on create.
  1423. func (u *AccountUpsertOne) UpdateProxyID() *AccountUpsertOne {
  1424. return u.Update(func(s *AccountUpsert) {
  1425. s.UpdateProxyID()
  1426. })
  1427. }
  1428. // ClearProxyID clears the value of the "proxy_id" field.
  1429. func (u *AccountUpsertOne) ClearProxyID() *AccountUpsertOne {
  1430. return u.Update(func(s *AccountUpsert) {
  1431. s.ClearProxyID()
  1432. })
  1433. }
  1434. // SetProxyFallbackOriginID sets the "proxy_fallback_origin_id" field.
  1435. func (u *AccountUpsertOne) SetProxyFallbackOriginID(v int64) *AccountUpsertOne {
  1436. return u.Update(func(s *AccountUpsert) {
  1437. s.SetProxyFallbackOriginID(v)
  1438. })
  1439. }
  1440. // AddProxyFallbackOriginID adds v to the "proxy_fallback_origin_id" field.
  1441. func (u *AccountUpsertOne) AddProxyFallbackOriginID(v int64) *AccountUpsertOne {
  1442. return u.Update(func(s *AccountUpsert) {
  1443. s.AddProxyFallbackOriginID(v)
  1444. })
  1445. }
  1446. // UpdateProxyFallbackOriginID sets the "proxy_fallback_origin_id" field to the value that was provided on create.
  1447. func (u *AccountUpsertOne) UpdateProxyFallbackOriginID() *AccountUpsertOne {
  1448. return u.Update(func(s *AccountUpsert) {
  1449. s.UpdateProxyFallbackOriginID()
  1450. })
  1451. }
  1452. // ClearProxyFallbackOriginID clears the value of the "proxy_fallback_origin_id" field.
  1453. func (u *AccountUpsertOne) ClearProxyFallbackOriginID() *AccountUpsertOne {
  1454. return u.Update(func(s *AccountUpsert) {
  1455. s.ClearProxyFallbackOriginID()
  1456. })
  1457. }
  1458. // SetConcurrency sets the "concurrency" field.
  1459. func (u *AccountUpsertOne) SetConcurrency(v int) *AccountUpsertOne {
  1460. return u.Update(func(s *AccountUpsert) {
  1461. s.SetConcurrency(v)
  1462. })
  1463. }
  1464. // AddConcurrency adds v to the "concurrency" field.
  1465. func (u *AccountUpsertOne) AddConcurrency(v int) *AccountUpsertOne {
  1466. return u.Update(func(s *AccountUpsert) {
  1467. s.AddConcurrency(v)
  1468. })
  1469. }
  1470. // UpdateConcurrency sets the "concurrency" field to the value that was provided on create.
  1471. func (u *AccountUpsertOne) UpdateConcurrency() *AccountUpsertOne {
  1472. return u.Update(func(s *AccountUpsert) {
  1473. s.UpdateConcurrency()
  1474. })
  1475. }
  1476. // SetLoadFactor sets the "load_factor" field.
  1477. func (u *AccountUpsertOne) SetLoadFactor(v int) *AccountUpsertOne {
  1478. return u.Update(func(s *AccountUpsert) {
  1479. s.SetLoadFactor(v)
  1480. })
  1481. }
  1482. // AddLoadFactor adds v to the "load_factor" field.
  1483. func (u *AccountUpsertOne) AddLoadFactor(v int) *AccountUpsertOne {
  1484. return u.Update(func(s *AccountUpsert) {
  1485. s.AddLoadFactor(v)
  1486. })
  1487. }
  1488. // UpdateLoadFactor sets the "load_factor" field to the value that was provided on create.
  1489. func (u *AccountUpsertOne) UpdateLoadFactor() *AccountUpsertOne {
  1490. return u.Update(func(s *AccountUpsert) {
  1491. s.UpdateLoadFactor()
  1492. })
  1493. }
  1494. // ClearLoadFactor clears the value of the "load_factor" field.
  1495. func (u *AccountUpsertOne) ClearLoadFactor() *AccountUpsertOne {
  1496. return u.Update(func(s *AccountUpsert) {
  1497. s.ClearLoadFactor()
  1498. })
  1499. }
  1500. // SetPriority sets the "priority" field.
  1501. func (u *AccountUpsertOne) SetPriority(v int) *AccountUpsertOne {
  1502. return u.Update(func(s *AccountUpsert) {
  1503. s.SetPriority(v)
  1504. })
  1505. }
  1506. // AddPriority adds v to the "priority" field.
  1507. func (u *AccountUpsertOne) AddPriority(v int) *AccountUpsertOne {
  1508. return u.Update(func(s *AccountUpsert) {
  1509. s.AddPriority(v)
  1510. })
  1511. }
  1512. // UpdatePriority sets the "priority" field to the value that was provided on create.
  1513. func (u *AccountUpsertOne) UpdatePriority() *AccountUpsertOne {
  1514. return u.Update(func(s *AccountUpsert) {
  1515. s.UpdatePriority()
  1516. })
  1517. }
  1518. // SetRateMultiplier sets the "rate_multiplier" field.
  1519. func (u *AccountUpsertOne) SetRateMultiplier(v float64) *AccountUpsertOne {
  1520. return u.Update(func(s *AccountUpsert) {
  1521. s.SetRateMultiplier(v)
  1522. })
  1523. }
  1524. // AddRateMultiplier adds v to the "rate_multiplier" field.
  1525. func (u *AccountUpsertOne) AddRateMultiplier(v float64) *AccountUpsertOne {
  1526. return u.Update(func(s *AccountUpsert) {
  1527. s.AddRateMultiplier(v)
  1528. })
  1529. }
  1530. // UpdateRateMultiplier sets the "rate_multiplier" field to the value that was provided on create.
  1531. func (u *AccountUpsertOne) UpdateRateMultiplier() *AccountUpsertOne {
  1532. return u.Update(func(s *AccountUpsert) {
  1533. s.UpdateRateMultiplier()
  1534. })
  1535. }
  1536. // SetStatus sets the "status" field.
  1537. func (u *AccountUpsertOne) SetStatus(v string) *AccountUpsertOne {
  1538. return u.Update(func(s *AccountUpsert) {
  1539. s.SetStatus(v)
  1540. })
  1541. }
  1542. // UpdateStatus sets the "status" field to the value that was provided on create.
  1543. func (u *AccountUpsertOne) UpdateStatus() *AccountUpsertOne {
  1544. return u.Update(func(s *AccountUpsert) {
  1545. s.UpdateStatus()
  1546. })
  1547. }
  1548. // SetErrorMessage sets the "error_message" field.
  1549. func (u *AccountUpsertOne) SetErrorMessage(v string) *AccountUpsertOne {
  1550. return u.Update(func(s *AccountUpsert) {
  1551. s.SetErrorMessage(v)
  1552. })
  1553. }
  1554. // UpdateErrorMessage sets the "error_message" field to the value that was provided on create.
  1555. func (u *AccountUpsertOne) UpdateErrorMessage() *AccountUpsertOne {
  1556. return u.Update(func(s *AccountUpsert) {
  1557. s.UpdateErrorMessage()
  1558. })
  1559. }
  1560. // ClearErrorMessage clears the value of the "error_message" field.
  1561. func (u *AccountUpsertOne) ClearErrorMessage() *AccountUpsertOne {
  1562. return u.Update(func(s *AccountUpsert) {
  1563. s.ClearErrorMessage()
  1564. })
  1565. }
  1566. // SetLastUsedAt sets the "last_used_at" field.
  1567. func (u *AccountUpsertOne) SetLastUsedAt(v time.Time) *AccountUpsertOne {
  1568. return u.Update(func(s *AccountUpsert) {
  1569. s.SetLastUsedAt(v)
  1570. })
  1571. }
  1572. // UpdateLastUsedAt sets the "last_used_at" field to the value that was provided on create.
  1573. func (u *AccountUpsertOne) UpdateLastUsedAt() *AccountUpsertOne {
  1574. return u.Update(func(s *AccountUpsert) {
  1575. s.UpdateLastUsedAt()
  1576. })
  1577. }
  1578. // ClearLastUsedAt clears the value of the "last_used_at" field.
  1579. func (u *AccountUpsertOne) ClearLastUsedAt() *AccountUpsertOne {
  1580. return u.Update(func(s *AccountUpsert) {
  1581. s.ClearLastUsedAt()
  1582. })
  1583. }
  1584. // SetExpiresAt sets the "expires_at" field.
  1585. func (u *AccountUpsertOne) SetExpiresAt(v time.Time) *AccountUpsertOne {
  1586. return u.Update(func(s *AccountUpsert) {
  1587. s.SetExpiresAt(v)
  1588. })
  1589. }
  1590. // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
  1591. func (u *AccountUpsertOne) UpdateExpiresAt() *AccountUpsertOne {
  1592. return u.Update(func(s *AccountUpsert) {
  1593. s.UpdateExpiresAt()
  1594. })
  1595. }
  1596. // ClearExpiresAt clears the value of the "expires_at" field.
  1597. func (u *AccountUpsertOne) ClearExpiresAt() *AccountUpsertOne {
  1598. return u.Update(func(s *AccountUpsert) {
  1599. s.ClearExpiresAt()
  1600. })
  1601. }
  1602. // SetAutoPauseOnExpired sets the "auto_pause_on_expired" field.
  1603. func (u *AccountUpsertOne) SetAutoPauseOnExpired(v bool) *AccountUpsertOne {
  1604. return u.Update(func(s *AccountUpsert) {
  1605. s.SetAutoPauseOnExpired(v)
  1606. })
  1607. }
  1608. // UpdateAutoPauseOnExpired sets the "auto_pause_on_expired" field to the value that was provided on create.
  1609. func (u *AccountUpsertOne) UpdateAutoPauseOnExpired() *AccountUpsertOne {
  1610. return u.Update(func(s *AccountUpsert) {
  1611. s.UpdateAutoPauseOnExpired()
  1612. })
  1613. }
  1614. // SetSchedulable sets the "schedulable" field.
  1615. func (u *AccountUpsertOne) SetSchedulable(v bool) *AccountUpsertOne {
  1616. return u.Update(func(s *AccountUpsert) {
  1617. s.SetSchedulable(v)
  1618. })
  1619. }
  1620. // UpdateSchedulable sets the "schedulable" field to the value that was provided on create.
  1621. func (u *AccountUpsertOne) UpdateSchedulable() *AccountUpsertOne {
  1622. return u.Update(func(s *AccountUpsert) {
  1623. s.UpdateSchedulable()
  1624. })
  1625. }
  1626. // SetRateLimitedAt sets the "rate_limited_at" field.
  1627. func (u *AccountUpsertOne) SetRateLimitedAt(v time.Time) *AccountUpsertOne {
  1628. return u.Update(func(s *AccountUpsert) {
  1629. s.SetRateLimitedAt(v)
  1630. })
  1631. }
  1632. // UpdateRateLimitedAt sets the "rate_limited_at" field to the value that was provided on create.
  1633. func (u *AccountUpsertOne) UpdateRateLimitedAt() *AccountUpsertOne {
  1634. return u.Update(func(s *AccountUpsert) {
  1635. s.UpdateRateLimitedAt()
  1636. })
  1637. }
  1638. // ClearRateLimitedAt clears the value of the "rate_limited_at" field.
  1639. func (u *AccountUpsertOne) ClearRateLimitedAt() *AccountUpsertOne {
  1640. return u.Update(func(s *AccountUpsert) {
  1641. s.ClearRateLimitedAt()
  1642. })
  1643. }
  1644. // SetRateLimitResetAt sets the "rate_limit_reset_at" field.
  1645. func (u *AccountUpsertOne) SetRateLimitResetAt(v time.Time) *AccountUpsertOne {
  1646. return u.Update(func(s *AccountUpsert) {
  1647. s.SetRateLimitResetAt(v)
  1648. })
  1649. }
  1650. // UpdateRateLimitResetAt sets the "rate_limit_reset_at" field to the value that was provided on create.
  1651. func (u *AccountUpsertOne) UpdateRateLimitResetAt() *AccountUpsertOne {
  1652. return u.Update(func(s *AccountUpsert) {
  1653. s.UpdateRateLimitResetAt()
  1654. })
  1655. }
  1656. // ClearRateLimitResetAt clears the value of the "rate_limit_reset_at" field.
  1657. func (u *AccountUpsertOne) ClearRateLimitResetAt() *AccountUpsertOne {
  1658. return u.Update(func(s *AccountUpsert) {
  1659. s.ClearRateLimitResetAt()
  1660. })
  1661. }
  1662. // SetOverloadUntil sets the "overload_until" field.
  1663. func (u *AccountUpsertOne) SetOverloadUntil(v time.Time) *AccountUpsertOne {
  1664. return u.Update(func(s *AccountUpsert) {
  1665. s.SetOverloadUntil(v)
  1666. })
  1667. }
  1668. // UpdateOverloadUntil sets the "overload_until" field to the value that was provided on create.
  1669. func (u *AccountUpsertOne) UpdateOverloadUntil() *AccountUpsertOne {
  1670. return u.Update(func(s *AccountUpsert) {
  1671. s.UpdateOverloadUntil()
  1672. })
  1673. }
  1674. // ClearOverloadUntil clears the value of the "overload_until" field.
  1675. func (u *AccountUpsertOne) ClearOverloadUntil() *AccountUpsertOne {
  1676. return u.Update(func(s *AccountUpsert) {
  1677. s.ClearOverloadUntil()
  1678. })
  1679. }
  1680. // SetTempUnschedulableUntil sets the "temp_unschedulable_until" field.
  1681. func (u *AccountUpsertOne) SetTempUnschedulableUntil(v time.Time) *AccountUpsertOne {
  1682. return u.Update(func(s *AccountUpsert) {
  1683. s.SetTempUnschedulableUntil(v)
  1684. })
  1685. }
  1686. // UpdateTempUnschedulableUntil sets the "temp_unschedulable_until" field to the value that was provided on create.
  1687. func (u *AccountUpsertOne) UpdateTempUnschedulableUntil() *AccountUpsertOne {
  1688. return u.Update(func(s *AccountUpsert) {
  1689. s.UpdateTempUnschedulableUntil()
  1690. })
  1691. }
  1692. // ClearTempUnschedulableUntil clears the value of the "temp_unschedulable_until" field.
  1693. func (u *AccountUpsertOne) ClearTempUnschedulableUntil() *AccountUpsertOne {
  1694. return u.Update(func(s *AccountUpsert) {
  1695. s.ClearTempUnschedulableUntil()
  1696. })
  1697. }
  1698. // SetTempUnschedulableReason sets the "temp_unschedulable_reason" field.
  1699. func (u *AccountUpsertOne) SetTempUnschedulableReason(v string) *AccountUpsertOne {
  1700. return u.Update(func(s *AccountUpsert) {
  1701. s.SetTempUnschedulableReason(v)
  1702. })
  1703. }
  1704. // UpdateTempUnschedulableReason sets the "temp_unschedulable_reason" field to the value that was provided on create.
  1705. func (u *AccountUpsertOne) UpdateTempUnschedulableReason() *AccountUpsertOne {
  1706. return u.Update(func(s *AccountUpsert) {
  1707. s.UpdateTempUnschedulableReason()
  1708. })
  1709. }
  1710. // ClearTempUnschedulableReason clears the value of the "temp_unschedulable_reason" field.
  1711. func (u *AccountUpsertOne) ClearTempUnschedulableReason() *AccountUpsertOne {
  1712. return u.Update(func(s *AccountUpsert) {
  1713. s.ClearTempUnschedulableReason()
  1714. })
  1715. }
  1716. // SetSessionWindowStart sets the "session_window_start" field.
  1717. func (u *AccountUpsertOne) SetSessionWindowStart(v time.Time) *AccountUpsertOne {
  1718. return u.Update(func(s *AccountUpsert) {
  1719. s.SetSessionWindowStart(v)
  1720. })
  1721. }
  1722. // UpdateSessionWindowStart sets the "session_window_start" field to the value that was provided on create.
  1723. func (u *AccountUpsertOne) UpdateSessionWindowStart() *AccountUpsertOne {
  1724. return u.Update(func(s *AccountUpsert) {
  1725. s.UpdateSessionWindowStart()
  1726. })
  1727. }
  1728. // ClearSessionWindowStart clears the value of the "session_window_start" field.
  1729. func (u *AccountUpsertOne) ClearSessionWindowStart() *AccountUpsertOne {
  1730. return u.Update(func(s *AccountUpsert) {
  1731. s.ClearSessionWindowStart()
  1732. })
  1733. }
  1734. // SetSessionWindowEnd sets the "session_window_end" field.
  1735. func (u *AccountUpsertOne) SetSessionWindowEnd(v time.Time) *AccountUpsertOne {
  1736. return u.Update(func(s *AccountUpsert) {
  1737. s.SetSessionWindowEnd(v)
  1738. })
  1739. }
  1740. // UpdateSessionWindowEnd sets the "session_window_end" field to the value that was provided on create.
  1741. func (u *AccountUpsertOne) UpdateSessionWindowEnd() *AccountUpsertOne {
  1742. return u.Update(func(s *AccountUpsert) {
  1743. s.UpdateSessionWindowEnd()
  1744. })
  1745. }
  1746. // ClearSessionWindowEnd clears the value of the "session_window_end" field.
  1747. func (u *AccountUpsertOne) ClearSessionWindowEnd() *AccountUpsertOne {
  1748. return u.Update(func(s *AccountUpsert) {
  1749. s.ClearSessionWindowEnd()
  1750. })
  1751. }
  1752. // SetSessionWindowStatus sets the "session_window_status" field.
  1753. func (u *AccountUpsertOne) SetSessionWindowStatus(v string) *AccountUpsertOne {
  1754. return u.Update(func(s *AccountUpsert) {
  1755. s.SetSessionWindowStatus(v)
  1756. })
  1757. }
  1758. // UpdateSessionWindowStatus sets the "session_window_status" field to the value that was provided on create.
  1759. func (u *AccountUpsertOne) UpdateSessionWindowStatus() *AccountUpsertOne {
  1760. return u.Update(func(s *AccountUpsert) {
  1761. s.UpdateSessionWindowStatus()
  1762. })
  1763. }
  1764. // ClearSessionWindowStatus clears the value of the "session_window_status" field.
  1765. func (u *AccountUpsertOne) ClearSessionWindowStatus() *AccountUpsertOne {
  1766. return u.Update(func(s *AccountUpsert) {
  1767. s.ClearSessionWindowStatus()
  1768. })
  1769. }
  1770. // SetParentAccountID sets the "parent_account_id" field.
  1771. func (u *AccountUpsertOne) SetParentAccountID(v int64) *AccountUpsertOne {
  1772. return u.Update(func(s *AccountUpsert) {
  1773. s.SetParentAccountID(v)
  1774. })
  1775. }
  1776. // UpdateParentAccountID sets the "parent_account_id" field to the value that was provided on create.
  1777. func (u *AccountUpsertOne) UpdateParentAccountID() *AccountUpsertOne {
  1778. return u.Update(func(s *AccountUpsert) {
  1779. s.UpdateParentAccountID()
  1780. })
  1781. }
  1782. // ClearParentAccountID clears the value of the "parent_account_id" field.
  1783. func (u *AccountUpsertOne) ClearParentAccountID() *AccountUpsertOne {
  1784. return u.Update(func(s *AccountUpsert) {
  1785. s.ClearParentAccountID()
  1786. })
  1787. }
  1788. // SetQuotaDimension sets the "quota_dimension" field.
  1789. func (u *AccountUpsertOne) SetQuotaDimension(v account.QuotaDimension) *AccountUpsertOne {
  1790. return u.Update(func(s *AccountUpsert) {
  1791. s.SetQuotaDimension(v)
  1792. })
  1793. }
  1794. // UpdateQuotaDimension sets the "quota_dimension" field to the value that was provided on create.
  1795. func (u *AccountUpsertOne) UpdateQuotaDimension() *AccountUpsertOne {
  1796. return u.Update(func(s *AccountUpsert) {
  1797. s.UpdateQuotaDimension()
  1798. })
  1799. }
  1800. // Exec executes the query.
  1801. func (u *AccountUpsertOne) Exec(ctx context.Context) error {
  1802. if len(u.create.conflict) == 0 {
  1803. return errors.New("ent: missing options for AccountCreate.OnConflict")
  1804. }
  1805. return u.create.Exec(ctx)
  1806. }
  1807. // ExecX is like Exec, but panics if an error occurs.
  1808. func (u *AccountUpsertOne) ExecX(ctx context.Context) {
  1809. if err := u.create.Exec(ctx); err != nil {
  1810. panic(err)
  1811. }
  1812. }
  1813. // Exec executes the UPSERT query and returns the inserted/updated ID.
  1814. func (u *AccountUpsertOne) ID(ctx context.Context) (id int64, err error) {
  1815. node, err := u.create.Save(ctx)
  1816. if err != nil {
  1817. return id, err
  1818. }
  1819. return node.ID, nil
  1820. }
  1821. // IDX is like ID, but panics if an error occurs.
  1822. func (u *AccountUpsertOne) IDX(ctx context.Context) int64 {
  1823. id, err := u.ID(ctx)
  1824. if err != nil {
  1825. panic(err)
  1826. }
  1827. return id
  1828. }
  1829. // AccountCreateBulk is the builder for creating many Account entities in bulk.
  1830. type AccountCreateBulk struct {
  1831. config
  1832. err error
  1833. builders []*AccountCreate
  1834. conflict []sql.ConflictOption
  1835. }
  1836. // Save creates the Account entities in the database.
  1837. func (_c *AccountCreateBulk) Save(ctx context.Context) ([]*Account, error) {
  1838. if _c.err != nil {
  1839. return nil, _c.err
  1840. }
  1841. specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
  1842. nodes := make([]*Account, len(_c.builders))
  1843. mutators := make([]Mutator, len(_c.builders))
  1844. for i := range _c.builders {
  1845. func(i int, root context.Context) {
  1846. builder := _c.builders[i]
  1847. builder.defaults()
  1848. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  1849. mutation, ok := m.(*AccountMutation)
  1850. if !ok {
  1851. return nil, fmt.Errorf("unexpected mutation type %T", m)
  1852. }
  1853. if err := builder.check(); err != nil {
  1854. return nil, err
  1855. }
  1856. builder.mutation = mutation
  1857. var err error
  1858. nodes[i], specs[i] = builder.createSpec()
  1859. if i < len(mutators)-1 {
  1860. _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
  1861. } else {
  1862. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  1863. spec.OnConflict = _c.conflict
  1864. // Invoke the actual operation on the latest mutation in the chain.
  1865. if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
  1866. if sqlgraph.IsConstraintError(err) {
  1867. err = &ConstraintError{msg: err.Error(), wrap: err}
  1868. }
  1869. }
  1870. }
  1871. if err != nil {
  1872. return nil, err
  1873. }
  1874. mutation.id = &nodes[i].ID
  1875. if specs[i].ID.Value != nil {
  1876. id := specs[i].ID.Value.(int64)
  1877. nodes[i].ID = int64(id)
  1878. }
  1879. mutation.done = true
  1880. return nodes[i], nil
  1881. })
  1882. for i := len(builder.hooks) - 1; i >= 0; i-- {
  1883. mut = builder.hooks[i](mut)
  1884. }
  1885. mutators[i] = mut
  1886. }(i, ctx)
  1887. }
  1888. if len(mutators) > 0 {
  1889. if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
  1890. return nil, err
  1891. }
  1892. }
  1893. return nodes, nil
  1894. }
  1895. // SaveX is like Save, but panics if an error occurs.
  1896. func (_c *AccountCreateBulk) SaveX(ctx context.Context) []*Account {
  1897. v, err := _c.Save(ctx)
  1898. if err != nil {
  1899. panic(err)
  1900. }
  1901. return v
  1902. }
  1903. // Exec executes the query.
  1904. func (_c *AccountCreateBulk) Exec(ctx context.Context) error {
  1905. _, err := _c.Save(ctx)
  1906. return err
  1907. }
  1908. // ExecX is like Exec, but panics if an error occurs.
  1909. func (_c *AccountCreateBulk) ExecX(ctx context.Context) {
  1910. if err := _c.Exec(ctx); err != nil {
  1911. panic(err)
  1912. }
  1913. }
  1914. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  1915. // of the `INSERT` statement. For example:
  1916. //
  1917. // client.Account.CreateBulk(builders...).
  1918. // OnConflict(
  1919. // // Update the row with the new values
  1920. // // the was proposed for insertion.
  1921. // sql.ResolveWithNewValues(),
  1922. // ).
  1923. // // Override some of the fields with custom
  1924. // // update values.
  1925. // Update(func(u *ent.AccountUpsert) {
  1926. // SetCreatedAt(v+v).
  1927. // }).
  1928. // Exec(ctx)
  1929. func (_c *AccountCreateBulk) OnConflict(opts ...sql.ConflictOption) *AccountUpsertBulk {
  1930. _c.conflict = opts
  1931. return &AccountUpsertBulk{
  1932. create: _c,
  1933. }
  1934. }
  1935. // OnConflictColumns calls `OnConflict` and configures the columns
  1936. // as conflict target. Using this option is equivalent to using:
  1937. //
  1938. // client.Account.Create().
  1939. // OnConflict(sql.ConflictColumns(columns...)).
  1940. // Exec(ctx)
  1941. func (_c *AccountCreateBulk) OnConflictColumns(columns ...string) *AccountUpsertBulk {
  1942. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  1943. return &AccountUpsertBulk{
  1944. create: _c,
  1945. }
  1946. }
  1947. // AccountUpsertBulk is the builder for "upsert"-ing
  1948. // a bulk of Account nodes.
  1949. type AccountUpsertBulk struct {
  1950. create *AccountCreateBulk
  1951. }
  1952. // UpdateNewValues updates the mutable fields using the new values that
  1953. // were set on create. Using this option is equivalent to using:
  1954. //
  1955. // client.Account.Create().
  1956. // OnConflict(
  1957. // sql.ResolveWithNewValues(),
  1958. // ).
  1959. // Exec(ctx)
  1960. func (u *AccountUpsertBulk) UpdateNewValues() *AccountUpsertBulk {
  1961. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1962. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1963. for _, b := range u.create.builders {
  1964. if _, exists := b.mutation.CreatedAt(); exists {
  1965. s.SetIgnore(account.FieldCreatedAt)
  1966. }
  1967. }
  1968. }))
  1969. return u
  1970. }
  1971. // Ignore sets each column to itself in case of conflict.
  1972. // Using this option is equivalent to using:
  1973. //
  1974. // client.Account.Create().
  1975. // OnConflict(sql.ResolveWithIgnore()).
  1976. // Exec(ctx)
  1977. func (u *AccountUpsertBulk) Ignore() *AccountUpsertBulk {
  1978. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1979. return u
  1980. }
  1981. // DoNothing configures the conflict_action to `DO NOTHING`.
  1982. // Supported only by SQLite and PostgreSQL.
  1983. func (u *AccountUpsertBulk) DoNothing() *AccountUpsertBulk {
  1984. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1985. return u
  1986. }
  1987. // Update allows overriding fields `UPDATE` values. See the AccountCreateBulk.OnConflict
  1988. // documentation for more info.
  1989. func (u *AccountUpsertBulk) Update(set func(*AccountUpsert)) *AccountUpsertBulk {
  1990. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1991. set(&AccountUpsert{UpdateSet: update})
  1992. }))
  1993. return u
  1994. }
  1995. // SetUpdatedAt sets the "updated_at" field.
  1996. func (u *AccountUpsertBulk) SetUpdatedAt(v time.Time) *AccountUpsertBulk {
  1997. return u.Update(func(s *AccountUpsert) {
  1998. s.SetUpdatedAt(v)
  1999. })
  2000. }
  2001. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  2002. func (u *AccountUpsertBulk) UpdateUpdatedAt() *AccountUpsertBulk {
  2003. return u.Update(func(s *AccountUpsert) {
  2004. s.UpdateUpdatedAt()
  2005. })
  2006. }
  2007. // SetDeletedAt sets the "deleted_at" field.
  2008. func (u *AccountUpsertBulk) SetDeletedAt(v time.Time) *AccountUpsertBulk {
  2009. return u.Update(func(s *AccountUpsert) {
  2010. s.SetDeletedAt(v)
  2011. })
  2012. }
  2013. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  2014. func (u *AccountUpsertBulk) UpdateDeletedAt() *AccountUpsertBulk {
  2015. return u.Update(func(s *AccountUpsert) {
  2016. s.UpdateDeletedAt()
  2017. })
  2018. }
  2019. // ClearDeletedAt clears the value of the "deleted_at" field.
  2020. func (u *AccountUpsertBulk) ClearDeletedAt() *AccountUpsertBulk {
  2021. return u.Update(func(s *AccountUpsert) {
  2022. s.ClearDeletedAt()
  2023. })
  2024. }
  2025. // SetName sets the "name" field.
  2026. func (u *AccountUpsertBulk) SetName(v string) *AccountUpsertBulk {
  2027. return u.Update(func(s *AccountUpsert) {
  2028. s.SetName(v)
  2029. })
  2030. }
  2031. // UpdateName sets the "name" field to the value that was provided on create.
  2032. func (u *AccountUpsertBulk) UpdateName() *AccountUpsertBulk {
  2033. return u.Update(func(s *AccountUpsert) {
  2034. s.UpdateName()
  2035. })
  2036. }
  2037. // SetNotes sets the "notes" field.
  2038. func (u *AccountUpsertBulk) SetNotes(v string) *AccountUpsertBulk {
  2039. return u.Update(func(s *AccountUpsert) {
  2040. s.SetNotes(v)
  2041. })
  2042. }
  2043. // UpdateNotes sets the "notes" field to the value that was provided on create.
  2044. func (u *AccountUpsertBulk) UpdateNotes() *AccountUpsertBulk {
  2045. return u.Update(func(s *AccountUpsert) {
  2046. s.UpdateNotes()
  2047. })
  2048. }
  2049. // ClearNotes clears the value of the "notes" field.
  2050. func (u *AccountUpsertBulk) ClearNotes() *AccountUpsertBulk {
  2051. return u.Update(func(s *AccountUpsert) {
  2052. s.ClearNotes()
  2053. })
  2054. }
  2055. // SetPlatform sets the "platform" field.
  2056. func (u *AccountUpsertBulk) SetPlatform(v string) *AccountUpsertBulk {
  2057. return u.Update(func(s *AccountUpsert) {
  2058. s.SetPlatform(v)
  2059. })
  2060. }
  2061. // UpdatePlatform sets the "platform" field to the value that was provided on create.
  2062. func (u *AccountUpsertBulk) UpdatePlatform() *AccountUpsertBulk {
  2063. return u.Update(func(s *AccountUpsert) {
  2064. s.UpdatePlatform()
  2065. })
  2066. }
  2067. // SetType sets the "type" field.
  2068. func (u *AccountUpsertBulk) SetType(v string) *AccountUpsertBulk {
  2069. return u.Update(func(s *AccountUpsert) {
  2070. s.SetType(v)
  2071. })
  2072. }
  2073. // UpdateType sets the "type" field to the value that was provided on create.
  2074. func (u *AccountUpsertBulk) UpdateType() *AccountUpsertBulk {
  2075. return u.Update(func(s *AccountUpsert) {
  2076. s.UpdateType()
  2077. })
  2078. }
  2079. // SetCredentials sets the "credentials" field.
  2080. func (u *AccountUpsertBulk) SetCredentials(v map[string]interface{}) *AccountUpsertBulk {
  2081. return u.Update(func(s *AccountUpsert) {
  2082. s.SetCredentials(v)
  2083. })
  2084. }
  2085. // UpdateCredentials sets the "credentials" field to the value that was provided on create.
  2086. func (u *AccountUpsertBulk) UpdateCredentials() *AccountUpsertBulk {
  2087. return u.Update(func(s *AccountUpsert) {
  2088. s.UpdateCredentials()
  2089. })
  2090. }
  2091. // SetExtra sets the "extra" field.
  2092. func (u *AccountUpsertBulk) SetExtra(v map[string]interface{}) *AccountUpsertBulk {
  2093. return u.Update(func(s *AccountUpsert) {
  2094. s.SetExtra(v)
  2095. })
  2096. }
  2097. // UpdateExtra sets the "extra" field to the value that was provided on create.
  2098. func (u *AccountUpsertBulk) UpdateExtra() *AccountUpsertBulk {
  2099. return u.Update(func(s *AccountUpsert) {
  2100. s.UpdateExtra()
  2101. })
  2102. }
  2103. // SetProxyID sets the "proxy_id" field.
  2104. func (u *AccountUpsertBulk) SetProxyID(v int64) *AccountUpsertBulk {
  2105. return u.Update(func(s *AccountUpsert) {
  2106. s.SetProxyID(v)
  2107. })
  2108. }
  2109. // UpdateProxyID sets the "proxy_id" field to the value that was provided on create.
  2110. func (u *AccountUpsertBulk) UpdateProxyID() *AccountUpsertBulk {
  2111. return u.Update(func(s *AccountUpsert) {
  2112. s.UpdateProxyID()
  2113. })
  2114. }
  2115. // ClearProxyID clears the value of the "proxy_id" field.
  2116. func (u *AccountUpsertBulk) ClearProxyID() *AccountUpsertBulk {
  2117. return u.Update(func(s *AccountUpsert) {
  2118. s.ClearProxyID()
  2119. })
  2120. }
  2121. // SetProxyFallbackOriginID sets the "proxy_fallback_origin_id" field.
  2122. func (u *AccountUpsertBulk) SetProxyFallbackOriginID(v int64) *AccountUpsertBulk {
  2123. return u.Update(func(s *AccountUpsert) {
  2124. s.SetProxyFallbackOriginID(v)
  2125. })
  2126. }
  2127. // AddProxyFallbackOriginID adds v to the "proxy_fallback_origin_id" field.
  2128. func (u *AccountUpsertBulk) AddProxyFallbackOriginID(v int64) *AccountUpsertBulk {
  2129. return u.Update(func(s *AccountUpsert) {
  2130. s.AddProxyFallbackOriginID(v)
  2131. })
  2132. }
  2133. // UpdateProxyFallbackOriginID sets the "proxy_fallback_origin_id" field to the value that was provided on create.
  2134. func (u *AccountUpsertBulk) UpdateProxyFallbackOriginID() *AccountUpsertBulk {
  2135. return u.Update(func(s *AccountUpsert) {
  2136. s.UpdateProxyFallbackOriginID()
  2137. })
  2138. }
  2139. // ClearProxyFallbackOriginID clears the value of the "proxy_fallback_origin_id" field.
  2140. func (u *AccountUpsertBulk) ClearProxyFallbackOriginID() *AccountUpsertBulk {
  2141. return u.Update(func(s *AccountUpsert) {
  2142. s.ClearProxyFallbackOriginID()
  2143. })
  2144. }
  2145. // SetConcurrency sets the "concurrency" field.
  2146. func (u *AccountUpsertBulk) SetConcurrency(v int) *AccountUpsertBulk {
  2147. return u.Update(func(s *AccountUpsert) {
  2148. s.SetConcurrency(v)
  2149. })
  2150. }
  2151. // AddConcurrency adds v to the "concurrency" field.
  2152. func (u *AccountUpsertBulk) AddConcurrency(v int) *AccountUpsertBulk {
  2153. return u.Update(func(s *AccountUpsert) {
  2154. s.AddConcurrency(v)
  2155. })
  2156. }
  2157. // UpdateConcurrency sets the "concurrency" field to the value that was provided on create.
  2158. func (u *AccountUpsertBulk) UpdateConcurrency() *AccountUpsertBulk {
  2159. return u.Update(func(s *AccountUpsert) {
  2160. s.UpdateConcurrency()
  2161. })
  2162. }
  2163. // SetLoadFactor sets the "load_factor" field.
  2164. func (u *AccountUpsertBulk) SetLoadFactor(v int) *AccountUpsertBulk {
  2165. return u.Update(func(s *AccountUpsert) {
  2166. s.SetLoadFactor(v)
  2167. })
  2168. }
  2169. // AddLoadFactor adds v to the "load_factor" field.
  2170. func (u *AccountUpsertBulk) AddLoadFactor(v int) *AccountUpsertBulk {
  2171. return u.Update(func(s *AccountUpsert) {
  2172. s.AddLoadFactor(v)
  2173. })
  2174. }
  2175. // UpdateLoadFactor sets the "load_factor" field to the value that was provided on create.
  2176. func (u *AccountUpsertBulk) UpdateLoadFactor() *AccountUpsertBulk {
  2177. return u.Update(func(s *AccountUpsert) {
  2178. s.UpdateLoadFactor()
  2179. })
  2180. }
  2181. // ClearLoadFactor clears the value of the "load_factor" field.
  2182. func (u *AccountUpsertBulk) ClearLoadFactor() *AccountUpsertBulk {
  2183. return u.Update(func(s *AccountUpsert) {
  2184. s.ClearLoadFactor()
  2185. })
  2186. }
  2187. // SetPriority sets the "priority" field.
  2188. func (u *AccountUpsertBulk) SetPriority(v int) *AccountUpsertBulk {
  2189. return u.Update(func(s *AccountUpsert) {
  2190. s.SetPriority(v)
  2191. })
  2192. }
  2193. // AddPriority adds v to the "priority" field.
  2194. func (u *AccountUpsertBulk) AddPriority(v int) *AccountUpsertBulk {
  2195. return u.Update(func(s *AccountUpsert) {
  2196. s.AddPriority(v)
  2197. })
  2198. }
  2199. // UpdatePriority sets the "priority" field to the value that was provided on create.
  2200. func (u *AccountUpsertBulk) UpdatePriority() *AccountUpsertBulk {
  2201. return u.Update(func(s *AccountUpsert) {
  2202. s.UpdatePriority()
  2203. })
  2204. }
  2205. // SetRateMultiplier sets the "rate_multiplier" field.
  2206. func (u *AccountUpsertBulk) SetRateMultiplier(v float64) *AccountUpsertBulk {
  2207. return u.Update(func(s *AccountUpsert) {
  2208. s.SetRateMultiplier(v)
  2209. })
  2210. }
  2211. // AddRateMultiplier adds v to the "rate_multiplier" field.
  2212. func (u *AccountUpsertBulk) AddRateMultiplier(v float64) *AccountUpsertBulk {
  2213. return u.Update(func(s *AccountUpsert) {
  2214. s.AddRateMultiplier(v)
  2215. })
  2216. }
  2217. // UpdateRateMultiplier sets the "rate_multiplier" field to the value that was provided on create.
  2218. func (u *AccountUpsertBulk) UpdateRateMultiplier() *AccountUpsertBulk {
  2219. return u.Update(func(s *AccountUpsert) {
  2220. s.UpdateRateMultiplier()
  2221. })
  2222. }
  2223. // SetStatus sets the "status" field.
  2224. func (u *AccountUpsertBulk) SetStatus(v string) *AccountUpsertBulk {
  2225. return u.Update(func(s *AccountUpsert) {
  2226. s.SetStatus(v)
  2227. })
  2228. }
  2229. // UpdateStatus sets the "status" field to the value that was provided on create.
  2230. func (u *AccountUpsertBulk) UpdateStatus() *AccountUpsertBulk {
  2231. return u.Update(func(s *AccountUpsert) {
  2232. s.UpdateStatus()
  2233. })
  2234. }
  2235. // SetErrorMessage sets the "error_message" field.
  2236. func (u *AccountUpsertBulk) SetErrorMessage(v string) *AccountUpsertBulk {
  2237. return u.Update(func(s *AccountUpsert) {
  2238. s.SetErrorMessage(v)
  2239. })
  2240. }
  2241. // UpdateErrorMessage sets the "error_message" field to the value that was provided on create.
  2242. func (u *AccountUpsertBulk) UpdateErrorMessage() *AccountUpsertBulk {
  2243. return u.Update(func(s *AccountUpsert) {
  2244. s.UpdateErrorMessage()
  2245. })
  2246. }
  2247. // ClearErrorMessage clears the value of the "error_message" field.
  2248. func (u *AccountUpsertBulk) ClearErrorMessage() *AccountUpsertBulk {
  2249. return u.Update(func(s *AccountUpsert) {
  2250. s.ClearErrorMessage()
  2251. })
  2252. }
  2253. // SetLastUsedAt sets the "last_used_at" field.
  2254. func (u *AccountUpsertBulk) SetLastUsedAt(v time.Time) *AccountUpsertBulk {
  2255. return u.Update(func(s *AccountUpsert) {
  2256. s.SetLastUsedAt(v)
  2257. })
  2258. }
  2259. // UpdateLastUsedAt sets the "last_used_at" field to the value that was provided on create.
  2260. func (u *AccountUpsertBulk) UpdateLastUsedAt() *AccountUpsertBulk {
  2261. return u.Update(func(s *AccountUpsert) {
  2262. s.UpdateLastUsedAt()
  2263. })
  2264. }
  2265. // ClearLastUsedAt clears the value of the "last_used_at" field.
  2266. func (u *AccountUpsertBulk) ClearLastUsedAt() *AccountUpsertBulk {
  2267. return u.Update(func(s *AccountUpsert) {
  2268. s.ClearLastUsedAt()
  2269. })
  2270. }
  2271. // SetExpiresAt sets the "expires_at" field.
  2272. func (u *AccountUpsertBulk) SetExpiresAt(v time.Time) *AccountUpsertBulk {
  2273. return u.Update(func(s *AccountUpsert) {
  2274. s.SetExpiresAt(v)
  2275. })
  2276. }
  2277. // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
  2278. func (u *AccountUpsertBulk) UpdateExpiresAt() *AccountUpsertBulk {
  2279. return u.Update(func(s *AccountUpsert) {
  2280. s.UpdateExpiresAt()
  2281. })
  2282. }
  2283. // ClearExpiresAt clears the value of the "expires_at" field.
  2284. func (u *AccountUpsertBulk) ClearExpiresAt() *AccountUpsertBulk {
  2285. return u.Update(func(s *AccountUpsert) {
  2286. s.ClearExpiresAt()
  2287. })
  2288. }
  2289. // SetAutoPauseOnExpired sets the "auto_pause_on_expired" field.
  2290. func (u *AccountUpsertBulk) SetAutoPauseOnExpired(v bool) *AccountUpsertBulk {
  2291. return u.Update(func(s *AccountUpsert) {
  2292. s.SetAutoPauseOnExpired(v)
  2293. })
  2294. }
  2295. // UpdateAutoPauseOnExpired sets the "auto_pause_on_expired" field to the value that was provided on create.
  2296. func (u *AccountUpsertBulk) UpdateAutoPauseOnExpired() *AccountUpsertBulk {
  2297. return u.Update(func(s *AccountUpsert) {
  2298. s.UpdateAutoPauseOnExpired()
  2299. })
  2300. }
  2301. // SetSchedulable sets the "schedulable" field.
  2302. func (u *AccountUpsertBulk) SetSchedulable(v bool) *AccountUpsertBulk {
  2303. return u.Update(func(s *AccountUpsert) {
  2304. s.SetSchedulable(v)
  2305. })
  2306. }
  2307. // UpdateSchedulable sets the "schedulable" field to the value that was provided on create.
  2308. func (u *AccountUpsertBulk) UpdateSchedulable() *AccountUpsertBulk {
  2309. return u.Update(func(s *AccountUpsert) {
  2310. s.UpdateSchedulable()
  2311. })
  2312. }
  2313. // SetRateLimitedAt sets the "rate_limited_at" field.
  2314. func (u *AccountUpsertBulk) SetRateLimitedAt(v time.Time) *AccountUpsertBulk {
  2315. return u.Update(func(s *AccountUpsert) {
  2316. s.SetRateLimitedAt(v)
  2317. })
  2318. }
  2319. // UpdateRateLimitedAt sets the "rate_limited_at" field to the value that was provided on create.
  2320. func (u *AccountUpsertBulk) UpdateRateLimitedAt() *AccountUpsertBulk {
  2321. return u.Update(func(s *AccountUpsert) {
  2322. s.UpdateRateLimitedAt()
  2323. })
  2324. }
  2325. // ClearRateLimitedAt clears the value of the "rate_limited_at" field.
  2326. func (u *AccountUpsertBulk) ClearRateLimitedAt() *AccountUpsertBulk {
  2327. return u.Update(func(s *AccountUpsert) {
  2328. s.ClearRateLimitedAt()
  2329. })
  2330. }
  2331. // SetRateLimitResetAt sets the "rate_limit_reset_at" field.
  2332. func (u *AccountUpsertBulk) SetRateLimitResetAt(v time.Time) *AccountUpsertBulk {
  2333. return u.Update(func(s *AccountUpsert) {
  2334. s.SetRateLimitResetAt(v)
  2335. })
  2336. }
  2337. // UpdateRateLimitResetAt sets the "rate_limit_reset_at" field to the value that was provided on create.
  2338. func (u *AccountUpsertBulk) UpdateRateLimitResetAt() *AccountUpsertBulk {
  2339. return u.Update(func(s *AccountUpsert) {
  2340. s.UpdateRateLimitResetAt()
  2341. })
  2342. }
  2343. // ClearRateLimitResetAt clears the value of the "rate_limit_reset_at" field.
  2344. func (u *AccountUpsertBulk) ClearRateLimitResetAt() *AccountUpsertBulk {
  2345. return u.Update(func(s *AccountUpsert) {
  2346. s.ClearRateLimitResetAt()
  2347. })
  2348. }
  2349. // SetOverloadUntil sets the "overload_until" field.
  2350. func (u *AccountUpsertBulk) SetOverloadUntil(v time.Time) *AccountUpsertBulk {
  2351. return u.Update(func(s *AccountUpsert) {
  2352. s.SetOverloadUntil(v)
  2353. })
  2354. }
  2355. // UpdateOverloadUntil sets the "overload_until" field to the value that was provided on create.
  2356. func (u *AccountUpsertBulk) UpdateOverloadUntil() *AccountUpsertBulk {
  2357. return u.Update(func(s *AccountUpsert) {
  2358. s.UpdateOverloadUntil()
  2359. })
  2360. }
  2361. // ClearOverloadUntil clears the value of the "overload_until" field.
  2362. func (u *AccountUpsertBulk) ClearOverloadUntil() *AccountUpsertBulk {
  2363. return u.Update(func(s *AccountUpsert) {
  2364. s.ClearOverloadUntil()
  2365. })
  2366. }
  2367. // SetTempUnschedulableUntil sets the "temp_unschedulable_until" field.
  2368. func (u *AccountUpsertBulk) SetTempUnschedulableUntil(v time.Time) *AccountUpsertBulk {
  2369. return u.Update(func(s *AccountUpsert) {
  2370. s.SetTempUnschedulableUntil(v)
  2371. })
  2372. }
  2373. // UpdateTempUnschedulableUntil sets the "temp_unschedulable_until" field to the value that was provided on create.
  2374. func (u *AccountUpsertBulk) UpdateTempUnschedulableUntil() *AccountUpsertBulk {
  2375. return u.Update(func(s *AccountUpsert) {
  2376. s.UpdateTempUnschedulableUntil()
  2377. })
  2378. }
  2379. // ClearTempUnschedulableUntil clears the value of the "temp_unschedulable_until" field.
  2380. func (u *AccountUpsertBulk) ClearTempUnschedulableUntil() *AccountUpsertBulk {
  2381. return u.Update(func(s *AccountUpsert) {
  2382. s.ClearTempUnschedulableUntil()
  2383. })
  2384. }
  2385. // SetTempUnschedulableReason sets the "temp_unschedulable_reason" field.
  2386. func (u *AccountUpsertBulk) SetTempUnschedulableReason(v string) *AccountUpsertBulk {
  2387. return u.Update(func(s *AccountUpsert) {
  2388. s.SetTempUnschedulableReason(v)
  2389. })
  2390. }
  2391. // UpdateTempUnschedulableReason sets the "temp_unschedulable_reason" field to the value that was provided on create.
  2392. func (u *AccountUpsertBulk) UpdateTempUnschedulableReason() *AccountUpsertBulk {
  2393. return u.Update(func(s *AccountUpsert) {
  2394. s.UpdateTempUnschedulableReason()
  2395. })
  2396. }
  2397. // ClearTempUnschedulableReason clears the value of the "temp_unschedulable_reason" field.
  2398. func (u *AccountUpsertBulk) ClearTempUnschedulableReason() *AccountUpsertBulk {
  2399. return u.Update(func(s *AccountUpsert) {
  2400. s.ClearTempUnschedulableReason()
  2401. })
  2402. }
  2403. // SetSessionWindowStart sets the "session_window_start" field.
  2404. func (u *AccountUpsertBulk) SetSessionWindowStart(v time.Time) *AccountUpsertBulk {
  2405. return u.Update(func(s *AccountUpsert) {
  2406. s.SetSessionWindowStart(v)
  2407. })
  2408. }
  2409. // UpdateSessionWindowStart sets the "session_window_start" field to the value that was provided on create.
  2410. func (u *AccountUpsertBulk) UpdateSessionWindowStart() *AccountUpsertBulk {
  2411. return u.Update(func(s *AccountUpsert) {
  2412. s.UpdateSessionWindowStart()
  2413. })
  2414. }
  2415. // ClearSessionWindowStart clears the value of the "session_window_start" field.
  2416. func (u *AccountUpsertBulk) ClearSessionWindowStart() *AccountUpsertBulk {
  2417. return u.Update(func(s *AccountUpsert) {
  2418. s.ClearSessionWindowStart()
  2419. })
  2420. }
  2421. // SetSessionWindowEnd sets the "session_window_end" field.
  2422. func (u *AccountUpsertBulk) SetSessionWindowEnd(v time.Time) *AccountUpsertBulk {
  2423. return u.Update(func(s *AccountUpsert) {
  2424. s.SetSessionWindowEnd(v)
  2425. })
  2426. }
  2427. // UpdateSessionWindowEnd sets the "session_window_end" field to the value that was provided on create.
  2428. func (u *AccountUpsertBulk) UpdateSessionWindowEnd() *AccountUpsertBulk {
  2429. return u.Update(func(s *AccountUpsert) {
  2430. s.UpdateSessionWindowEnd()
  2431. })
  2432. }
  2433. // ClearSessionWindowEnd clears the value of the "session_window_end" field.
  2434. func (u *AccountUpsertBulk) ClearSessionWindowEnd() *AccountUpsertBulk {
  2435. return u.Update(func(s *AccountUpsert) {
  2436. s.ClearSessionWindowEnd()
  2437. })
  2438. }
  2439. // SetSessionWindowStatus sets the "session_window_status" field.
  2440. func (u *AccountUpsertBulk) SetSessionWindowStatus(v string) *AccountUpsertBulk {
  2441. return u.Update(func(s *AccountUpsert) {
  2442. s.SetSessionWindowStatus(v)
  2443. })
  2444. }
  2445. // UpdateSessionWindowStatus sets the "session_window_status" field to the value that was provided on create.
  2446. func (u *AccountUpsertBulk) UpdateSessionWindowStatus() *AccountUpsertBulk {
  2447. return u.Update(func(s *AccountUpsert) {
  2448. s.UpdateSessionWindowStatus()
  2449. })
  2450. }
  2451. // ClearSessionWindowStatus clears the value of the "session_window_status" field.
  2452. func (u *AccountUpsertBulk) ClearSessionWindowStatus() *AccountUpsertBulk {
  2453. return u.Update(func(s *AccountUpsert) {
  2454. s.ClearSessionWindowStatus()
  2455. })
  2456. }
  2457. // SetParentAccountID sets the "parent_account_id" field.
  2458. func (u *AccountUpsertBulk) SetParentAccountID(v int64) *AccountUpsertBulk {
  2459. return u.Update(func(s *AccountUpsert) {
  2460. s.SetParentAccountID(v)
  2461. })
  2462. }
  2463. // UpdateParentAccountID sets the "parent_account_id" field to the value that was provided on create.
  2464. func (u *AccountUpsertBulk) UpdateParentAccountID() *AccountUpsertBulk {
  2465. return u.Update(func(s *AccountUpsert) {
  2466. s.UpdateParentAccountID()
  2467. })
  2468. }
  2469. // ClearParentAccountID clears the value of the "parent_account_id" field.
  2470. func (u *AccountUpsertBulk) ClearParentAccountID() *AccountUpsertBulk {
  2471. return u.Update(func(s *AccountUpsert) {
  2472. s.ClearParentAccountID()
  2473. })
  2474. }
  2475. // SetQuotaDimension sets the "quota_dimension" field.
  2476. func (u *AccountUpsertBulk) SetQuotaDimension(v account.QuotaDimension) *AccountUpsertBulk {
  2477. return u.Update(func(s *AccountUpsert) {
  2478. s.SetQuotaDimension(v)
  2479. })
  2480. }
  2481. // UpdateQuotaDimension sets the "quota_dimension" field to the value that was provided on create.
  2482. func (u *AccountUpsertBulk) UpdateQuotaDimension() *AccountUpsertBulk {
  2483. return u.Update(func(s *AccountUpsert) {
  2484. s.UpdateQuotaDimension()
  2485. })
  2486. }
  2487. // Exec executes the query.
  2488. func (u *AccountUpsertBulk) Exec(ctx context.Context) error {
  2489. if u.create.err != nil {
  2490. return u.create.err
  2491. }
  2492. for i, b := range u.create.builders {
  2493. if len(b.conflict) != 0 {
  2494. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the AccountCreateBulk instead", i)
  2495. }
  2496. }
  2497. if len(u.create.conflict) == 0 {
  2498. return errors.New("ent: missing options for AccountCreateBulk.OnConflict")
  2499. }
  2500. return u.create.Exec(ctx)
  2501. }
  2502. // ExecX is like Exec, but panics if an error occurs.
  2503. func (u *AccountUpsertBulk) ExecX(ctx context.Context) {
  2504. if err := u.create.Exec(ctx); err != nil {
  2505. panic(err)
  2506. }
  2507. }