user_update.go 108 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452
  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/announcementread"
  12. "github.com/Wei-Shaw/sub2api/ent/apikey"
  13. "github.com/Wei-Shaw/sub2api/ent/authidentity"
  14. "github.com/Wei-Shaw/sub2api/ent/group"
  15. "github.com/Wei-Shaw/sub2api/ent/paymentorder"
  16. "github.com/Wei-Shaw/sub2api/ent/pendingauthsession"
  17. "github.com/Wei-Shaw/sub2api/ent/predicate"
  18. "github.com/Wei-Shaw/sub2api/ent/promocodeusage"
  19. "github.com/Wei-Shaw/sub2api/ent/redeemcode"
  20. "github.com/Wei-Shaw/sub2api/ent/usagelog"
  21. "github.com/Wei-Shaw/sub2api/ent/user"
  22. "github.com/Wei-Shaw/sub2api/ent/userattributevalue"
  23. "github.com/Wei-Shaw/sub2api/ent/userplatformquota"
  24. "github.com/Wei-Shaw/sub2api/ent/usersubscription"
  25. )
  26. // UserUpdate is the builder for updating User entities.
  27. type UserUpdate struct {
  28. config
  29. hooks []Hook
  30. mutation *UserMutation
  31. }
  32. // Where appends a list predicates to the UserUpdate builder.
  33. func (_u *UserUpdate) Where(ps ...predicate.User) *UserUpdate {
  34. _u.mutation.Where(ps...)
  35. return _u
  36. }
  37. // SetUpdatedAt sets the "updated_at" field.
  38. func (_u *UserUpdate) SetUpdatedAt(v time.Time) *UserUpdate {
  39. _u.mutation.SetUpdatedAt(v)
  40. return _u
  41. }
  42. // SetDeletedAt sets the "deleted_at" field.
  43. func (_u *UserUpdate) SetDeletedAt(v time.Time) *UserUpdate {
  44. _u.mutation.SetDeletedAt(v)
  45. return _u
  46. }
  47. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  48. func (_u *UserUpdate) SetNillableDeletedAt(v *time.Time) *UserUpdate {
  49. if v != nil {
  50. _u.SetDeletedAt(*v)
  51. }
  52. return _u
  53. }
  54. // ClearDeletedAt clears the value of the "deleted_at" field.
  55. func (_u *UserUpdate) ClearDeletedAt() *UserUpdate {
  56. _u.mutation.ClearDeletedAt()
  57. return _u
  58. }
  59. // SetEmail sets the "email" field.
  60. func (_u *UserUpdate) SetEmail(v string) *UserUpdate {
  61. _u.mutation.SetEmail(v)
  62. return _u
  63. }
  64. // SetNillableEmail sets the "email" field if the given value is not nil.
  65. func (_u *UserUpdate) SetNillableEmail(v *string) *UserUpdate {
  66. if v != nil {
  67. _u.SetEmail(*v)
  68. }
  69. return _u
  70. }
  71. // SetPasswordHash sets the "password_hash" field.
  72. func (_u *UserUpdate) SetPasswordHash(v string) *UserUpdate {
  73. _u.mutation.SetPasswordHash(v)
  74. return _u
  75. }
  76. // SetNillablePasswordHash sets the "password_hash" field if the given value is not nil.
  77. func (_u *UserUpdate) SetNillablePasswordHash(v *string) *UserUpdate {
  78. if v != nil {
  79. _u.SetPasswordHash(*v)
  80. }
  81. return _u
  82. }
  83. // SetRole sets the "role" field.
  84. func (_u *UserUpdate) SetRole(v string) *UserUpdate {
  85. _u.mutation.SetRole(v)
  86. return _u
  87. }
  88. // SetNillableRole sets the "role" field if the given value is not nil.
  89. func (_u *UserUpdate) SetNillableRole(v *string) *UserUpdate {
  90. if v != nil {
  91. _u.SetRole(*v)
  92. }
  93. return _u
  94. }
  95. // SetBalance sets the "balance" field.
  96. func (_u *UserUpdate) SetBalance(v float64) *UserUpdate {
  97. _u.mutation.ResetBalance()
  98. _u.mutation.SetBalance(v)
  99. return _u
  100. }
  101. // SetNillableBalance sets the "balance" field if the given value is not nil.
  102. func (_u *UserUpdate) SetNillableBalance(v *float64) *UserUpdate {
  103. if v != nil {
  104. _u.SetBalance(*v)
  105. }
  106. return _u
  107. }
  108. // AddBalance adds value to the "balance" field.
  109. func (_u *UserUpdate) AddBalance(v float64) *UserUpdate {
  110. _u.mutation.AddBalance(v)
  111. return _u
  112. }
  113. // SetFrozenBalance sets the "frozen_balance" field.
  114. func (_u *UserUpdate) SetFrozenBalance(v float64) *UserUpdate {
  115. _u.mutation.ResetFrozenBalance()
  116. _u.mutation.SetFrozenBalance(v)
  117. return _u
  118. }
  119. // SetNillableFrozenBalance sets the "frozen_balance" field if the given value is not nil.
  120. func (_u *UserUpdate) SetNillableFrozenBalance(v *float64) *UserUpdate {
  121. if v != nil {
  122. _u.SetFrozenBalance(*v)
  123. }
  124. return _u
  125. }
  126. // AddFrozenBalance adds value to the "frozen_balance" field.
  127. func (_u *UserUpdate) AddFrozenBalance(v float64) *UserUpdate {
  128. _u.mutation.AddFrozenBalance(v)
  129. return _u
  130. }
  131. // SetConcurrency sets the "concurrency" field.
  132. func (_u *UserUpdate) SetConcurrency(v int) *UserUpdate {
  133. _u.mutation.ResetConcurrency()
  134. _u.mutation.SetConcurrency(v)
  135. return _u
  136. }
  137. // SetNillableConcurrency sets the "concurrency" field if the given value is not nil.
  138. func (_u *UserUpdate) SetNillableConcurrency(v *int) *UserUpdate {
  139. if v != nil {
  140. _u.SetConcurrency(*v)
  141. }
  142. return _u
  143. }
  144. // AddConcurrency adds value to the "concurrency" field.
  145. func (_u *UserUpdate) AddConcurrency(v int) *UserUpdate {
  146. _u.mutation.AddConcurrency(v)
  147. return _u
  148. }
  149. // SetStatus sets the "status" field.
  150. func (_u *UserUpdate) SetStatus(v string) *UserUpdate {
  151. _u.mutation.SetStatus(v)
  152. return _u
  153. }
  154. // SetNillableStatus sets the "status" field if the given value is not nil.
  155. func (_u *UserUpdate) SetNillableStatus(v *string) *UserUpdate {
  156. if v != nil {
  157. _u.SetStatus(*v)
  158. }
  159. return _u
  160. }
  161. // SetUsername sets the "username" field.
  162. func (_u *UserUpdate) SetUsername(v string) *UserUpdate {
  163. _u.mutation.SetUsername(v)
  164. return _u
  165. }
  166. // SetNillableUsername sets the "username" field if the given value is not nil.
  167. func (_u *UserUpdate) SetNillableUsername(v *string) *UserUpdate {
  168. if v != nil {
  169. _u.SetUsername(*v)
  170. }
  171. return _u
  172. }
  173. // SetNotes sets the "notes" field.
  174. func (_u *UserUpdate) SetNotes(v string) *UserUpdate {
  175. _u.mutation.SetNotes(v)
  176. return _u
  177. }
  178. // SetNillableNotes sets the "notes" field if the given value is not nil.
  179. func (_u *UserUpdate) SetNillableNotes(v *string) *UserUpdate {
  180. if v != nil {
  181. _u.SetNotes(*v)
  182. }
  183. return _u
  184. }
  185. // SetTotpSecretEncrypted sets the "totp_secret_encrypted" field.
  186. func (_u *UserUpdate) SetTotpSecretEncrypted(v string) *UserUpdate {
  187. _u.mutation.SetTotpSecretEncrypted(v)
  188. return _u
  189. }
  190. // SetNillableTotpSecretEncrypted sets the "totp_secret_encrypted" field if the given value is not nil.
  191. func (_u *UserUpdate) SetNillableTotpSecretEncrypted(v *string) *UserUpdate {
  192. if v != nil {
  193. _u.SetTotpSecretEncrypted(*v)
  194. }
  195. return _u
  196. }
  197. // ClearTotpSecretEncrypted clears the value of the "totp_secret_encrypted" field.
  198. func (_u *UserUpdate) ClearTotpSecretEncrypted() *UserUpdate {
  199. _u.mutation.ClearTotpSecretEncrypted()
  200. return _u
  201. }
  202. // SetTotpEnabled sets the "totp_enabled" field.
  203. func (_u *UserUpdate) SetTotpEnabled(v bool) *UserUpdate {
  204. _u.mutation.SetTotpEnabled(v)
  205. return _u
  206. }
  207. // SetNillableTotpEnabled sets the "totp_enabled" field if the given value is not nil.
  208. func (_u *UserUpdate) SetNillableTotpEnabled(v *bool) *UserUpdate {
  209. if v != nil {
  210. _u.SetTotpEnabled(*v)
  211. }
  212. return _u
  213. }
  214. // SetTotpEnabledAt sets the "totp_enabled_at" field.
  215. func (_u *UserUpdate) SetTotpEnabledAt(v time.Time) *UserUpdate {
  216. _u.mutation.SetTotpEnabledAt(v)
  217. return _u
  218. }
  219. // SetNillableTotpEnabledAt sets the "totp_enabled_at" field if the given value is not nil.
  220. func (_u *UserUpdate) SetNillableTotpEnabledAt(v *time.Time) *UserUpdate {
  221. if v != nil {
  222. _u.SetTotpEnabledAt(*v)
  223. }
  224. return _u
  225. }
  226. // ClearTotpEnabledAt clears the value of the "totp_enabled_at" field.
  227. func (_u *UserUpdate) ClearTotpEnabledAt() *UserUpdate {
  228. _u.mutation.ClearTotpEnabledAt()
  229. return _u
  230. }
  231. // SetSignupSource sets the "signup_source" field.
  232. func (_u *UserUpdate) SetSignupSource(v string) *UserUpdate {
  233. _u.mutation.SetSignupSource(v)
  234. return _u
  235. }
  236. // SetNillableSignupSource sets the "signup_source" field if the given value is not nil.
  237. func (_u *UserUpdate) SetNillableSignupSource(v *string) *UserUpdate {
  238. if v != nil {
  239. _u.SetSignupSource(*v)
  240. }
  241. return _u
  242. }
  243. // SetLastLoginAt sets the "last_login_at" field.
  244. func (_u *UserUpdate) SetLastLoginAt(v time.Time) *UserUpdate {
  245. _u.mutation.SetLastLoginAt(v)
  246. return _u
  247. }
  248. // SetNillableLastLoginAt sets the "last_login_at" field if the given value is not nil.
  249. func (_u *UserUpdate) SetNillableLastLoginAt(v *time.Time) *UserUpdate {
  250. if v != nil {
  251. _u.SetLastLoginAt(*v)
  252. }
  253. return _u
  254. }
  255. // ClearLastLoginAt clears the value of the "last_login_at" field.
  256. func (_u *UserUpdate) ClearLastLoginAt() *UserUpdate {
  257. _u.mutation.ClearLastLoginAt()
  258. return _u
  259. }
  260. // SetLastActiveAt sets the "last_active_at" field.
  261. func (_u *UserUpdate) SetLastActiveAt(v time.Time) *UserUpdate {
  262. _u.mutation.SetLastActiveAt(v)
  263. return _u
  264. }
  265. // SetNillableLastActiveAt sets the "last_active_at" field if the given value is not nil.
  266. func (_u *UserUpdate) SetNillableLastActiveAt(v *time.Time) *UserUpdate {
  267. if v != nil {
  268. _u.SetLastActiveAt(*v)
  269. }
  270. return _u
  271. }
  272. // ClearLastActiveAt clears the value of the "last_active_at" field.
  273. func (_u *UserUpdate) ClearLastActiveAt() *UserUpdate {
  274. _u.mutation.ClearLastActiveAt()
  275. return _u
  276. }
  277. // SetRestrictPublicGroups sets the "restrict_public_groups" field.
  278. func (_u *UserUpdate) SetRestrictPublicGroups(v bool) *UserUpdate {
  279. _u.mutation.SetRestrictPublicGroups(v)
  280. return _u
  281. }
  282. // SetNillableRestrictPublicGroups sets the "restrict_public_groups" field if the given value is not nil.
  283. func (_u *UserUpdate) SetNillableRestrictPublicGroups(v *bool) *UserUpdate {
  284. if v != nil {
  285. _u.SetRestrictPublicGroups(*v)
  286. }
  287. return _u
  288. }
  289. // SetBalanceNotifyEnabled sets the "balance_notify_enabled" field.
  290. func (_u *UserUpdate) SetBalanceNotifyEnabled(v bool) *UserUpdate {
  291. _u.mutation.SetBalanceNotifyEnabled(v)
  292. return _u
  293. }
  294. // SetNillableBalanceNotifyEnabled sets the "balance_notify_enabled" field if the given value is not nil.
  295. func (_u *UserUpdate) SetNillableBalanceNotifyEnabled(v *bool) *UserUpdate {
  296. if v != nil {
  297. _u.SetBalanceNotifyEnabled(*v)
  298. }
  299. return _u
  300. }
  301. // SetBalanceNotifyThresholdType sets the "balance_notify_threshold_type" field.
  302. func (_u *UserUpdate) SetBalanceNotifyThresholdType(v string) *UserUpdate {
  303. _u.mutation.SetBalanceNotifyThresholdType(v)
  304. return _u
  305. }
  306. // SetNillableBalanceNotifyThresholdType sets the "balance_notify_threshold_type" field if the given value is not nil.
  307. func (_u *UserUpdate) SetNillableBalanceNotifyThresholdType(v *string) *UserUpdate {
  308. if v != nil {
  309. _u.SetBalanceNotifyThresholdType(*v)
  310. }
  311. return _u
  312. }
  313. // SetBalanceNotifyThreshold sets the "balance_notify_threshold" field.
  314. func (_u *UserUpdate) SetBalanceNotifyThreshold(v float64) *UserUpdate {
  315. _u.mutation.ResetBalanceNotifyThreshold()
  316. _u.mutation.SetBalanceNotifyThreshold(v)
  317. return _u
  318. }
  319. // SetNillableBalanceNotifyThreshold sets the "balance_notify_threshold" field if the given value is not nil.
  320. func (_u *UserUpdate) SetNillableBalanceNotifyThreshold(v *float64) *UserUpdate {
  321. if v != nil {
  322. _u.SetBalanceNotifyThreshold(*v)
  323. }
  324. return _u
  325. }
  326. // AddBalanceNotifyThreshold adds value to the "balance_notify_threshold" field.
  327. func (_u *UserUpdate) AddBalanceNotifyThreshold(v float64) *UserUpdate {
  328. _u.mutation.AddBalanceNotifyThreshold(v)
  329. return _u
  330. }
  331. // ClearBalanceNotifyThreshold clears the value of the "balance_notify_threshold" field.
  332. func (_u *UserUpdate) ClearBalanceNotifyThreshold() *UserUpdate {
  333. _u.mutation.ClearBalanceNotifyThreshold()
  334. return _u
  335. }
  336. // SetBalanceNotifyExtraEmails sets the "balance_notify_extra_emails" field.
  337. func (_u *UserUpdate) SetBalanceNotifyExtraEmails(v string) *UserUpdate {
  338. _u.mutation.SetBalanceNotifyExtraEmails(v)
  339. return _u
  340. }
  341. // SetNillableBalanceNotifyExtraEmails sets the "balance_notify_extra_emails" field if the given value is not nil.
  342. func (_u *UserUpdate) SetNillableBalanceNotifyExtraEmails(v *string) *UserUpdate {
  343. if v != nil {
  344. _u.SetBalanceNotifyExtraEmails(*v)
  345. }
  346. return _u
  347. }
  348. // SetTotalRecharged sets the "total_recharged" field.
  349. func (_u *UserUpdate) SetTotalRecharged(v float64) *UserUpdate {
  350. _u.mutation.ResetTotalRecharged()
  351. _u.mutation.SetTotalRecharged(v)
  352. return _u
  353. }
  354. // SetNillableTotalRecharged sets the "total_recharged" field if the given value is not nil.
  355. func (_u *UserUpdate) SetNillableTotalRecharged(v *float64) *UserUpdate {
  356. if v != nil {
  357. _u.SetTotalRecharged(*v)
  358. }
  359. return _u
  360. }
  361. // AddTotalRecharged adds value to the "total_recharged" field.
  362. func (_u *UserUpdate) AddTotalRecharged(v float64) *UserUpdate {
  363. _u.mutation.AddTotalRecharged(v)
  364. return _u
  365. }
  366. // SetRpmLimit sets the "rpm_limit" field.
  367. func (_u *UserUpdate) SetRpmLimit(v int) *UserUpdate {
  368. _u.mutation.ResetRpmLimit()
  369. _u.mutation.SetRpmLimit(v)
  370. return _u
  371. }
  372. // SetNillableRpmLimit sets the "rpm_limit" field if the given value is not nil.
  373. func (_u *UserUpdate) SetNillableRpmLimit(v *int) *UserUpdate {
  374. if v != nil {
  375. _u.SetRpmLimit(*v)
  376. }
  377. return _u
  378. }
  379. // AddRpmLimit adds value to the "rpm_limit" field.
  380. func (_u *UserUpdate) AddRpmLimit(v int) *UserUpdate {
  381. _u.mutation.AddRpmLimit(v)
  382. return _u
  383. }
  384. // AddAPIKeyIDs adds the "api_keys" edge to the APIKey entity by IDs.
  385. func (_u *UserUpdate) AddAPIKeyIDs(ids ...int64) *UserUpdate {
  386. _u.mutation.AddAPIKeyIDs(ids...)
  387. return _u
  388. }
  389. // AddAPIKeys adds the "api_keys" edges to the APIKey entity.
  390. func (_u *UserUpdate) AddAPIKeys(v ...*APIKey) *UserUpdate {
  391. ids := make([]int64, len(v))
  392. for i := range v {
  393. ids[i] = v[i].ID
  394. }
  395. return _u.AddAPIKeyIDs(ids...)
  396. }
  397. // AddRedeemCodeIDs adds the "redeem_codes" edge to the RedeemCode entity by IDs.
  398. func (_u *UserUpdate) AddRedeemCodeIDs(ids ...int64) *UserUpdate {
  399. _u.mutation.AddRedeemCodeIDs(ids...)
  400. return _u
  401. }
  402. // AddRedeemCodes adds the "redeem_codes" edges to the RedeemCode entity.
  403. func (_u *UserUpdate) AddRedeemCodes(v ...*RedeemCode) *UserUpdate {
  404. ids := make([]int64, len(v))
  405. for i := range v {
  406. ids[i] = v[i].ID
  407. }
  408. return _u.AddRedeemCodeIDs(ids...)
  409. }
  410. // AddSubscriptionIDs adds the "subscriptions" edge to the UserSubscription entity by IDs.
  411. func (_u *UserUpdate) AddSubscriptionIDs(ids ...int64) *UserUpdate {
  412. _u.mutation.AddSubscriptionIDs(ids...)
  413. return _u
  414. }
  415. // AddSubscriptions adds the "subscriptions" edges to the UserSubscription entity.
  416. func (_u *UserUpdate) AddSubscriptions(v ...*UserSubscription) *UserUpdate {
  417. ids := make([]int64, len(v))
  418. for i := range v {
  419. ids[i] = v[i].ID
  420. }
  421. return _u.AddSubscriptionIDs(ids...)
  422. }
  423. // AddAssignedSubscriptionIDs adds the "assigned_subscriptions" edge to the UserSubscription entity by IDs.
  424. func (_u *UserUpdate) AddAssignedSubscriptionIDs(ids ...int64) *UserUpdate {
  425. _u.mutation.AddAssignedSubscriptionIDs(ids...)
  426. return _u
  427. }
  428. // AddAssignedSubscriptions adds the "assigned_subscriptions" edges to the UserSubscription entity.
  429. func (_u *UserUpdate) AddAssignedSubscriptions(v ...*UserSubscription) *UserUpdate {
  430. ids := make([]int64, len(v))
  431. for i := range v {
  432. ids[i] = v[i].ID
  433. }
  434. return _u.AddAssignedSubscriptionIDs(ids...)
  435. }
  436. // AddAnnouncementReadIDs adds the "announcement_reads" edge to the AnnouncementRead entity by IDs.
  437. func (_u *UserUpdate) AddAnnouncementReadIDs(ids ...int64) *UserUpdate {
  438. _u.mutation.AddAnnouncementReadIDs(ids...)
  439. return _u
  440. }
  441. // AddAnnouncementReads adds the "announcement_reads" edges to the AnnouncementRead entity.
  442. func (_u *UserUpdate) AddAnnouncementReads(v ...*AnnouncementRead) *UserUpdate {
  443. ids := make([]int64, len(v))
  444. for i := range v {
  445. ids[i] = v[i].ID
  446. }
  447. return _u.AddAnnouncementReadIDs(ids...)
  448. }
  449. // AddAllowedGroupIDs adds the "allowed_groups" edge to the Group entity by IDs.
  450. func (_u *UserUpdate) AddAllowedGroupIDs(ids ...int64) *UserUpdate {
  451. _u.mutation.AddAllowedGroupIDs(ids...)
  452. return _u
  453. }
  454. // AddAllowedGroups adds the "allowed_groups" edges to the Group entity.
  455. func (_u *UserUpdate) AddAllowedGroups(v ...*Group) *UserUpdate {
  456. ids := make([]int64, len(v))
  457. for i := range v {
  458. ids[i] = v[i].ID
  459. }
  460. return _u.AddAllowedGroupIDs(ids...)
  461. }
  462. // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by IDs.
  463. func (_u *UserUpdate) AddUsageLogIDs(ids ...int64) *UserUpdate {
  464. _u.mutation.AddUsageLogIDs(ids...)
  465. return _u
  466. }
  467. // AddUsageLogs adds the "usage_logs" edges to the UsageLog entity.
  468. func (_u *UserUpdate) AddUsageLogs(v ...*UsageLog) *UserUpdate {
  469. ids := make([]int64, len(v))
  470. for i := range v {
  471. ids[i] = v[i].ID
  472. }
  473. return _u.AddUsageLogIDs(ids...)
  474. }
  475. // AddAttributeValueIDs adds the "attribute_values" edge to the UserAttributeValue entity by IDs.
  476. func (_u *UserUpdate) AddAttributeValueIDs(ids ...int64) *UserUpdate {
  477. _u.mutation.AddAttributeValueIDs(ids...)
  478. return _u
  479. }
  480. // AddAttributeValues adds the "attribute_values" edges to the UserAttributeValue entity.
  481. func (_u *UserUpdate) AddAttributeValues(v ...*UserAttributeValue) *UserUpdate {
  482. ids := make([]int64, len(v))
  483. for i := range v {
  484. ids[i] = v[i].ID
  485. }
  486. return _u.AddAttributeValueIDs(ids...)
  487. }
  488. // AddPromoCodeUsageIDs adds the "promo_code_usages" edge to the PromoCodeUsage entity by IDs.
  489. func (_u *UserUpdate) AddPromoCodeUsageIDs(ids ...int64) *UserUpdate {
  490. _u.mutation.AddPromoCodeUsageIDs(ids...)
  491. return _u
  492. }
  493. // AddPromoCodeUsages adds the "promo_code_usages" edges to the PromoCodeUsage entity.
  494. func (_u *UserUpdate) AddPromoCodeUsages(v ...*PromoCodeUsage) *UserUpdate {
  495. ids := make([]int64, len(v))
  496. for i := range v {
  497. ids[i] = v[i].ID
  498. }
  499. return _u.AddPromoCodeUsageIDs(ids...)
  500. }
  501. // AddPaymentOrderIDs adds the "payment_orders" edge to the PaymentOrder entity by IDs.
  502. func (_u *UserUpdate) AddPaymentOrderIDs(ids ...int64) *UserUpdate {
  503. _u.mutation.AddPaymentOrderIDs(ids...)
  504. return _u
  505. }
  506. // AddPaymentOrders adds the "payment_orders" edges to the PaymentOrder entity.
  507. func (_u *UserUpdate) AddPaymentOrders(v ...*PaymentOrder) *UserUpdate {
  508. ids := make([]int64, len(v))
  509. for i := range v {
  510. ids[i] = v[i].ID
  511. }
  512. return _u.AddPaymentOrderIDs(ids...)
  513. }
  514. // AddAuthIdentityIDs adds the "auth_identities" edge to the AuthIdentity entity by IDs.
  515. func (_u *UserUpdate) AddAuthIdentityIDs(ids ...int64) *UserUpdate {
  516. _u.mutation.AddAuthIdentityIDs(ids...)
  517. return _u
  518. }
  519. // AddAuthIdentities adds the "auth_identities" edges to the AuthIdentity entity.
  520. func (_u *UserUpdate) AddAuthIdentities(v ...*AuthIdentity) *UserUpdate {
  521. ids := make([]int64, len(v))
  522. for i := range v {
  523. ids[i] = v[i].ID
  524. }
  525. return _u.AddAuthIdentityIDs(ids...)
  526. }
  527. // AddPendingAuthSessionIDs adds the "pending_auth_sessions" edge to the PendingAuthSession entity by IDs.
  528. func (_u *UserUpdate) AddPendingAuthSessionIDs(ids ...int64) *UserUpdate {
  529. _u.mutation.AddPendingAuthSessionIDs(ids...)
  530. return _u
  531. }
  532. // AddPendingAuthSessions adds the "pending_auth_sessions" edges to the PendingAuthSession entity.
  533. func (_u *UserUpdate) AddPendingAuthSessions(v ...*PendingAuthSession) *UserUpdate {
  534. ids := make([]int64, len(v))
  535. for i := range v {
  536. ids[i] = v[i].ID
  537. }
  538. return _u.AddPendingAuthSessionIDs(ids...)
  539. }
  540. // AddPlatformQuotaIDs adds the "platform_quotas" edge to the UserPlatformQuota entity by IDs.
  541. func (_u *UserUpdate) AddPlatformQuotaIDs(ids ...int64) *UserUpdate {
  542. _u.mutation.AddPlatformQuotaIDs(ids...)
  543. return _u
  544. }
  545. // AddPlatformQuotas adds the "platform_quotas" edges to the UserPlatformQuota entity.
  546. func (_u *UserUpdate) AddPlatformQuotas(v ...*UserPlatformQuota) *UserUpdate {
  547. ids := make([]int64, len(v))
  548. for i := range v {
  549. ids[i] = v[i].ID
  550. }
  551. return _u.AddPlatformQuotaIDs(ids...)
  552. }
  553. // Mutation returns the UserMutation object of the builder.
  554. func (_u *UserUpdate) Mutation() *UserMutation {
  555. return _u.mutation
  556. }
  557. // ClearAPIKeys clears all "api_keys" edges to the APIKey entity.
  558. func (_u *UserUpdate) ClearAPIKeys() *UserUpdate {
  559. _u.mutation.ClearAPIKeys()
  560. return _u
  561. }
  562. // RemoveAPIKeyIDs removes the "api_keys" edge to APIKey entities by IDs.
  563. func (_u *UserUpdate) RemoveAPIKeyIDs(ids ...int64) *UserUpdate {
  564. _u.mutation.RemoveAPIKeyIDs(ids...)
  565. return _u
  566. }
  567. // RemoveAPIKeys removes "api_keys" edges to APIKey entities.
  568. func (_u *UserUpdate) RemoveAPIKeys(v ...*APIKey) *UserUpdate {
  569. ids := make([]int64, len(v))
  570. for i := range v {
  571. ids[i] = v[i].ID
  572. }
  573. return _u.RemoveAPIKeyIDs(ids...)
  574. }
  575. // ClearRedeemCodes clears all "redeem_codes" edges to the RedeemCode entity.
  576. func (_u *UserUpdate) ClearRedeemCodes() *UserUpdate {
  577. _u.mutation.ClearRedeemCodes()
  578. return _u
  579. }
  580. // RemoveRedeemCodeIDs removes the "redeem_codes" edge to RedeemCode entities by IDs.
  581. func (_u *UserUpdate) RemoveRedeemCodeIDs(ids ...int64) *UserUpdate {
  582. _u.mutation.RemoveRedeemCodeIDs(ids...)
  583. return _u
  584. }
  585. // RemoveRedeemCodes removes "redeem_codes" edges to RedeemCode entities.
  586. func (_u *UserUpdate) RemoveRedeemCodes(v ...*RedeemCode) *UserUpdate {
  587. ids := make([]int64, len(v))
  588. for i := range v {
  589. ids[i] = v[i].ID
  590. }
  591. return _u.RemoveRedeemCodeIDs(ids...)
  592. }
  593. // ClearSubscriptions clears all "subscriptions" edges to the UserSubscription entity.
  594. func (_u *UserUpdate) ClearSubscriptions() *UserUpdate {
  595. _u.mutation.ClearSubscriptions()
  596. return _u
  597. }
  598. // RemoveSubscriptionIDs removes the "subscriptions" edge to UserSubscription entities by IDs.
  599. func (_u *UserUpdate) RemoveSubscriptionIDs(ids ...int64) *UserUpdate {
  600. _u.mutation.RemoveSubscriptionIDs(ids...)
  601. return _u
  602. }
  603. // RemoveSubscriptions removes "subscriptions" edges to UserSubscription entities.
  604. func (_u *UserUpdate) RemoveSubscriptions(v ...*UserSubscription) *UserUpdate {
  605. ids := make([]int64, len(v))
  606. for i := range v {
  607. ids[i] = v[i].ID
  608. }
  609. return _u.RemoveSubscriptionIDs(ids...)
  610. }
  611. // ClearAssignedSubscriptions clears all "assigned_subscriptions" edges to the UserSubscription entity.
  612. func (_u *UserUpdate) ClearAssignedSubscriptions() *UserUpdate {
  613. _u.mutation.ClearAssignedSubscriptions()
  614. return _u
  615. }
  616. // RemoveAssignedSubscriptionIDs removes the "assigned_subscriptions" edge to UserSubscription entities by IDs.
  617. func (_u *UserUpdate) RemoveAssignedSubscriptionIDs(ids ...int64) *UserUpdate {
  618. _u.mutation.RemoveAssignedSubscriptionIDs(ids...)
  619. return _u
  620. }
  621. // RemoveAssignedSubscriptions removes "assigned_subscriptions" edges to UserSubscription entities.
  622. func (_u *UserUpdate) RemoveAssignedSubscriptions(v ...*UserSubscription) *UserUpdate {
  623. ids := make([]int64, len(v))
  624. for i := range v {
  625. ids[i] = v[i].ID
  626. }
  627. return _u.RemoveAssignedSubscriptionIDs(ids...)
  628. }
  629. // ClearAnnouncementReads clears all "announcement_reads" edges to the AnnouncementRead entity.
  630. func (_u *UserUpdate) ClearAnnouncementReads() *UserUpdate {
  631. _u.mutation.ClearAnnouncementReads()
  632. return _u
  633. }
  634. // RemoveAnnouncementReadIDs removes the "announcement_reads" edge to AnnouncementRead entities by IDs.
  635. func (_u *UserUpdate) RemoveAnnouncementReadIDs(ids ...int64) *UserUpdate {
  636. _u.mutation.RemoveAnnouncementReadIDs(ids...)
  637. return _u
  638. }
  639. // RemoveAnnouncementReads removes "announcement_reads" edges to AnnouncementRead entities.
  640. func (_u *UserUpdate) RemoveAnnouncementReads(v ...*AnnouncementRead) *UserUpdate {
  641. ids := make([]int64, len(v))
  642. for i := range v {
  643. ids[i] = v[i].ID
  644. }
  645. return _u.RemoveAnnouncementReadIDs(ids...)
  646. }
  647. // ClearAllowedGroups clears all "allowed_groups" edges to the Group entity.
  648. func (_u *UserUpdate) ClearAllowedGroups() *UserUpdate {
  649. _u.mutation.ClearAllowedGroups()
  650. return _u
  651. }
  652. // RemoveAllowedGroupIDs removes the "allowed_groups" edge to Group entities by IDs.
  653. func (_u *UserUpdate) RemoveAllowedGroupIDs(ids ...int64) *UserUpdate {
  654. _u.mutation.RemoveAllowedGroupIDs(ids...)
  655. return _u
  656. }
  657. // RemoveAllowedGroups removes "allowed_groups" edges to Group entities.
  658. func (_u *UserUpdate) RemoveAllowedGroups(v ...*Group) *UserUpdate {
  659. ids := make([]int64, len(v))
  660. for i := range v {
  661. ids[i] = v[i].ID
  662. }
  663. return _u.RemoveAllowedGroupIDs(ids...)
  664. }
  665. // ClearUsageLogs clears all "usage_logs" edges to the UsageLog entity.
  666. func (_u *UserUpdate) ClearUsageLogs() *UserUpdate {
  667. _u.mutation.ClearUsageLogs()
  668. return _u
  669. }
  670. // RemoveUsageLogIDs removes the "usage_logs" edge to UsageLog entities by IDs.
  671. func (_u *UserUpdate) RemoveUsageLogIDs(ids ...int64) *UserUpdate {
  672. _u.mutation.RemoveUsageLogIDs(ids...)
  673. return _u
  674. }
  675. // RemoveUsageLogs removes "usage_logs" edges to UsageLog entities.
  676. func (_u *UserUpdate) RemoveUsageLogs(v ...*UsageLog) *UserUpdate {
  677. ids := make([]int64, len(v))
  678. for i := range v {
  679. ids[i] = v[i].ID
  680. }
  681. return _u.RemoveUsageLogIDs(ids...)
  682. }
  683. // ClearAttributeValues clears all "attribute_values" edges to the UserAttributeValue entity.
  684. func (_u *UserUpdate) ClearAttributeValues() *UserUpdate {
  685. _u.mutation.ClearAttributeValues()
  686. return _u
  687. }
  688. // RemoveAttributeValueIDs removes the "attribute_values" edge to UserAttributeValue entities by IDs.
  689. func (_u *UserUpdate) RemoveAttributeValueIDs(ids ...int64) *UserUpdate {
  690. _u.mutation.RemoveAttributeValueIDs(ids...)
  691. return _u
  692. }
  693. // RemoveAttributeValues removes "attribute_values" edges to UserAttributeValue entities.
  694. func (_u *UserUpdate) RemoveAttributeValues(v ...*UserAttributeValue) *UserUpdate {
  695. ids := make([]int64, len(v))
  696. for i := range v {
  697. ids[i] = v[i].ID
  698. }
  699. return _u.RemoveAttributeValueIDs(ids...)
  700. }
  701. // ClearPromoCodeUsages clears all "promo_code_usages" edges to the PromoCodeUsage entity.
  702. func (_u *UserUpdate) ClearPromoCodeUsages() *UserUpdate {
  703. _u.mutation.ClearPromoCodeUsages()
  704. return _u
  705. }
  706. // RemovePromoCodeUsageIDs removes the "promo_code_usages" edge to PromoCodeUsage entities by IDs.
  707. func (_u *UserUpdate) RemovePromoCodeUsageIDs(ids ...int64) *UserUpdate {
  708. _u.mutation.RemovePromoCodeUsageIDs(ids...)
  709. return _u
  710. }
  711. // RemovePromoCodeUsages removes "promo_code_usages" edges to PromoCodeUsage entities.
  712. func (_u *UserUpdate) RemovePromoCodeUsages(v ...*PromoCodeUsage) *UserUpdate {
  713. ids := make([]int64, len(v))
  714. for i := range v {
  715. ids[i] = v[i].ID
  716. }
  717. return _u.RemovePromoCodeUsageIDs(ids...)
  718. }
  719. // ClearPaymentOrders clears all "payment_orders" edges to the PaymentOrder entity.
  720. func (_u *UserUpdate) ClearPaymentOrders() *UserUpdate {
  721. _u.mutation.ClearPaymentOrders()
  722. return _u
  723. }
  724. // RemovePaymentOrderIDs removes the "payment_orders" edge to PaymentOrder entities by IDs.
  725. func (_u *UserUpdate) RemovePaymentOrderIDs(ids ...int64) *UserUpdate {
  726. _u.mutation.RemovePaymentOrderIDs(ids...)
  727. return _u
  728. }
  729. // RemovePaymentOrders removes "payment_orders" edges to PaymentOrder entities.
  730. func (_u *UserUpdate) RemovePaymentOrders(v ...*PaymentOrder) *UserUpdate {
  731. ids := make([]int64, len(v))
  732. for i := range v {
  733. ids[i] = v[i].ID
  734. }
  735. return _u.RemovePaymentOrderIDs(ids...)
  736. }
  737. // ClearAuthIdentities clears all "auth_identities" edges to the AuthIdentity entity.
  738. func (_u *UserUpdate) ClearAuthIdentities() *UserUpdate {
  739. _u.mutation.ClearAuthIdentities()
  740. return _u
  741. }
  742. // RemoveAuthIdentityIDs removes the "auth_identities" edge to AuthIdentity entities by IDs.
  743. func (_u *UserUpdate) RemoveAuthIdentityIDs(ids ...int64) *UserUpdate {
  744. _u.mutation.RemoveAuthIdentityIDs(ids...)
  745. return _u
  746. }
  747. // RemoveAuthIdentities removes "auth_identities" edges to AuthIdentity entities.
  748. func (_u *UserUpdate) RemoveAuthIdentities(v ...*AuthIdentity) *UserUpdate {
  749. ids := make([]int64, len(v))
  750. for i := range v {
  751. ids[i] = v[i].ID
  752. }
  753. return _u.RemoveAuthIdentityIDs(ids...)
  754. }
  755. // ClearPendingAuthSessions clears all "pending_auth_sessions" edges to the PendingAuthSession entity.
  756. func (_u *UserUpdate) ClearPendingAuthSessions() *UserUpdate {
  757. _u.mutation.ClearPendingAuthSessions()
  758. return _u
  759. }
  760. // RemovePendingAuthSessionIDs removes the "pending_auth_sessions" edge to PendingAuthSession entities by IDs.
  761. func (_u *UserUpdate) RemovePendingAuthSessionIDs(ids ...int64) *UserUpdate {
  762. _u.mutation.RemovePendingAuthSessionIDs(ids...)
  763. return _u
  764. }
  765. // RemovePendingAuthSessions removes "pending_auth_sessions" edges to PendingAuthSession entities.
  766. func (_u *UserUpdate) RemovePendingAuthSessions(v ...*PendingAuthSession) *UserUpdate {
  767. ids := make([]int64, len(v))
  768. for i := range v {
  769. ids[i] = v[i].ID
  770. }
  771. return _u.RemovePendingAuthSessionIDs(ids...)
  772. }
  773. // ClearPlatformQuotas clears all "platform_quotas" edges to the UserPlatformQuota entity.
  774. func (_u *UserUpdate) ClearPlatformQuotas() *UserUpdate {
  775. _u.mutation.ClearPlatformQuotas()
  776. return _u
  777. }
  778. // RemovePlatformQuotaIDs removes the "platform_quotas" edge to UserPlatformQuota entities by IDs.
  779. func (_u *UserUpdate) RemovePlatformQuotaIDs(ids ...int64) *UserUpdate {
  780. _u.mutation.RemovePlatformQuotaIDs(ids...)
  781. return _u
  782. }
  783. // RemovePlatformQuotas removes "platform_quotas" edges to UserPlatformQuota entities.
  784. func (_u *UserUpdate) RemovePlatformQuotas(v ...*UserPlatformQuota) *UserUpdate {
  785. ids := make([]int64, len(v))
  786. for i := range v {
  787. ids[i] = v[i].ID
  788. }
  789. return _u.RemovePlatformQuotaIDs(ids...)
  790. }
  791. // Save executes the query and returns the number of nodes affected by the update operation.
  792. func (_u *UserUpdate) Save(ctx context.Context) (int, error) {
  793. if err := _u.defaults(); err != nil {
  794. return 0, err
  795. }
  796. return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
  797. }
  798. // SaveX is like Save, but panics if an error occurs.
  799. func (_u *UserUpdate) SaveX(ctx context.Context) int {
  800. affected, err := _u.Save(ctx)
  801. if err != nil {
  802. panic(err)
  803. }
  804. return affected
  805. }
  806. // Exec executes the query.
  807. func (_u *UserUpdate) Exec(ctx context.Context) error {
  808. _, err := _u.Save(ctx)
  809. return err
  810. }
  811. // ExecX is like Exec, but panics if an error occurs.
  812. func (_u *UserUpdate) ExecX(ctx context.Context) {
  813. if err := _u.Exec(ctx); err != nil {
  814. panic(err)
  815. }
  816. }
  817. // defaults sets the default values of the builder before save.
  818. func (_u *UserUpdate) defaults() error {
  819. if _, ok := _u.mutation.UpdatedAt(); !ok {
  820. if user.UpdateDefaultUpdatedAt == nil {
  821. return fmt.Errorf("ent: uninitialized user.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  822. }
  823. v := user.UpdateDefaultUpdatedAt()
  824. _u.mutation.SetUpdatedAt(v)
  825. }
  826. return nil
  827. }
  828. // check runs all checks and user-defined validators on the builder.
  829. func (_u *UserUpdate) check() error {
  830. if v, ok := _u.mutation.Email(); ok {
  831. if err := user.EmailValidator(v); err != nil {
  832. return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)}
  833. }
  834. }
  835. if v, ok := _u.mutation.PasswordHash(); ok {
  836. if err := user.PasswordHashValidator(v); err != nil {
  837. return &ValidationError{Name: "password_hash", err: fmt.Errorf(`ent: validator failed for field "User.password_hash": %w`, err)}
  838. }
  839. }
  840. if v, ok := _u.mutation.Role(); ok {
  841. if err := user.RoleValidator(v); err != nil {
  842. return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "User.role": %w`, err)}
  843. }
  844. }
  845. if v, ok := _u.mutation.Status(); ok {
  846. if err := user.StatusValidator(v); err != nil {
  847. return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "User.status": %w`, err)}
  848. }
  849. }
  850. if v, ok := _u.mutation.Username(); ok {
  851. if err := user.UsernameValidator(v); err != nil {
  852. return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)}
  853. }
  854. }
  855. if v, ok := _u.mutation.SignupSource(); ok {
  856. if err := user.SignupSourceValidator(v); err != nil {
  857. return &ValidationError{Name: "signup_source", err: fmt.Errorf(`ent: validator failed for field "User.signup_source": %w`, err)}
  858. }
  859. }
  860. return nil
  861. }
  862. func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) {
  863. if err := _u.check(); err != nil {
  864. return _node, err
  865. }
  866. _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64))
  867. if ps := _u.mutation.predicates; len(ps) > 0 {
  868. _spec.Predicate = func(selector *sql.Selector) {
  869. for i := range ps {
  870. ps[i](selector)
  871. }
  872. }
  873. }
  874. if value, ok := _u.mutation.UpdatedAt(); ok {
  875. _spec.SetField(user.FieldUpdatedAt, field.TypeTime, value)
  876. }
  877. if value, ok := _u.mutation.DeletedAt(); ok {
  878. _spec.SetField(user.FieldDeletedAt, field.TypeTime, value)
  879. }
  880. if _u.mutation.DeletedAtCleared() {
  881. _spec.ClearField(user.FieldDeletedAt, field.TypeTime)
  882. }
  883. if value, ok := _u.mutation.Email(); ok {
  884. _spec.SetField(user.FieldEmail, field.TypeString, value)
  885. }
  886. if value, ok := _u.mutation.PasswordHash(); ok {
  887. _spec.SetField(user.FieldPasswordHash, field.TypeString, value)
  888. }
  889. if value, ok := _u.mutation.Role(); ok {
  890. _spec.SetField(user.FieldRole, field.TypeString, value)
  891. }
  892. if value, ok := _u.mutation.Balance(); ok {
  893. _spec.SetField(user.FieldBalance, field.TypeFloat64, value)
  894. }
  895. if value, ok := _u.mutation.AddedBalance(); ok {
  896. _spec.AddField(user.FieldBalance, field.TypeFloat64, value)
  897. }
  898. if value, ok := _u.mutation.FrozenBalance(); ok {
  899. _spec.SetField(user.FieldFrozenBalance, field.TypeFloat64, value)
  900. }
  901. if value, ok := _u.mutation.AddedFrozenBalance(); ok {
  902. _spec.AddField(user.FieldFrozenBalance, field.TypeFloat64, value)
  903. }
  904. if value, ok := _u.mutation.Concurrency(); ok {
  905. _spec.SetField(user.FieldConcurrency, field.TypeInt, value)
  906. }
  907. if value, ok := _u.mutation.AddedConcurrency(); ok {
  908. _spec.AddField(user.FieldConcurrency, field.TypeInt, value)
  909. }
  910. if value, ok := _u.mutation.Status(); ok {
  911. _spec.SetField(user.FieldStatus, field.TypeString, value)
  912. }
  913. if value, ok := _u.mutation.Username(); ok {
  914. _spec.SetField(user.FieldUsername, field.TypeString, value)
  915. }
  916. if value, ok := _u.mutation.Notes(); ok {
  917. _spec.SetField(user.FieldNotes, field.TypeString, value)
  918. }
  919. if value, ok := _u.mutation.TotpSecretEncrypted(); ok {
  920. _spec.SetField(user.FieldTotpSecretEncrypted, field.TypeString, value)
  921. }
  922. if _u.mutation.TotpSecretEncryptedCleared() {
  923. _spec.ClearField(user.FieldTotpSecretEncrypted, field.TypeString)
  924. }
  925. if value, ok := _u.mutation.TotpEnabled(); ok {
  926. _spec.SetField(user.FieldTotpEnabled, field.TypeBool, value)
  927. }
  928. if value, ok := _u.mutation.TotpEnabledAt(); ok {
  929. _spec.SetField(user.FieldTotpEnabledAt, field.TypeTime, value)
  930. }
  931. if _u.mutation.TotpEnabledAtCleared() {
  932. _spec.ClearField(user.FieldTotpEnabledAt, field.TypeTime)
  933. }
  934. if value, ok := _u.mutation.SignupSource(); ok {
  935. _spec.SetField(user.FieldSignupSource, field.TypeString, value)
  936. }
  937. if value, ok := _u.mutation.LastLoginAt(); ok {
  938. _spec.SetField(user.FieldLastLoginAt, field.TypeTime, value)
  939. }
  940. if _u.mutation.LastLoginAtCleared() {
  941. _spec.ClearField(user.FieldLastLoginAt, field.TypeTime)
  942. }
  943. if value, ok := _u.mutation.LastActiveAt(); ok {
  944. _spec.SetField(user.FieldLastActiveAt, field.TypeTime, value)
  945. }
  946. if _u.mutation.LastActiveAtCleared() {
  947. _spec.ClearField(user.FieldLastActiveAt, field.TypeTime)
  948. }
  949. if value, ok := _u.mutation.RestrictPublicGroups(); ok {
  950. _spec.SetField(user.FieldRestrictPublicGroups, field.TypeBool, value)
  951. }
  952. if value, ok := _u.mutation.BalanceNotifyEnabled(); ok {
  953. _spec.SetField(user.FieldBalanceNotifyEnabled, field.TypeBool, value)
  954. }
  955. if value, ok := _u.mutation.BalanceNotifyThresholdType(); ok {
  956. _spec.SetField(user.FieldBalanceNotifyThresholdType, field.TypeString, value)
  957. }
  958. if value, ok := _u.mutation.BalanceNotifyThreshold(); ok {
  959. _spec.SetField(user.FieldBalanceNotifyThreshold, field.TypeFloat64, value)
  960. }
  961. if value, ok := _u.mutation.AddedBalanceNotifyThreshold(); ok {
  962. _spec.AddField(user.FieldBalanceNotifyThreshold, field.TypeFloat64, value)
  963. }
  964. if _u.mutation.BalanceNotifyThresholdCleared() {
  965. _spec.ClearField(user.FieldBalanceNotifyThreshold, field.TypeFloat64)
  966. }
  967. if value, ok := _u.mutation.BalanceNotifyExtraEmails(); ok {
  968. _spec.SetField(user.FieldBalanceNotifyExtraEmails, field.TypeString, value)
  969. }
  970. if value, ok := _u.mutation.TotalRecharged(); ok {
  971. _spec.SetField(user.FieldTotalRecharged, field.TypeFloat64, value)
  972. }
  973. if value, ok := _u.mutation.AddedTotalRecharged(); ok {
  974. _spec.AddField(user.FieldTotalRecharged, field.TypeFloat64, value)
  975. }
  976. if value, ok := _u.mutation.RpmLimit(); ok {
  977. _spec.SetField(user.FieldRpmLimit, field.TypeInt, value)
  978. }
  979. if value, ok := _u.mutation.AddedRpmLimit(); ok {
  980. _spec.AddField(user.FieldRpmLimit, field.TypeInt, value)
  981. }
  982. if _u.mutation.APIKeysCleared() {
  983. edge := &sqlgraph.EdgeSpec{
  984. Rel: sqlgraph.O2M,
  985. Inverse: false,
  986. Table: user.APIKeysTable,
  987. Columns: []string{user.APIKeysColumn},
  988. Bidi: false,
  989. Target: &sqlgraph.EdgeTarget{
  990. IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64),
  991. },
  992. }
  993. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  994. }
  995. if nodes := _u.mutation.RemovedAPIKeysIDs(); len(nodes) > 0 && !_u.mutation.APIKeysCleared() {
  996. edge := &sqlgraph.EdgeSpec{
  997. Rel: sqlgraph.O2M,
  998. Inverse: false,
  999. Table: user.APIKeysTable,
  1000. Columns: []string{user.APIKeysColumn},
  1001. Bidi: false,
  1002. Target: &sqlgraph.EdgeTarget{
  1003. IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64),
  1004. },
  1005. }
  1006. for _, k := range nodes {
  1007. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1008. }
  1009. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1010. }
  1011. if nodes := _u.mutation.APIKeysIDs(); len(nodes) > 0 {
  1012. edge := &sqlgraph.EdgeSpec{
  1013. Rel: sqlgraph.O2M,
  1014. Inverse: false,
  1015. Table: user.APIKeysTable,
  1016. Columns: []string{user.APIKeysColumn},
  1017. Bidi: false,
  1018. Target: &sqlgraph.EdgeTarget{
  1019. IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64),
  1020. },
  1021. }
  1022. for _, k := range nodes {
  1023. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1024. }
  1025. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1026. }
  1027. if _u.mutation.RedeemCodesCleared() {
  1028. edge := &sqlgraph.EdgeSpec{
  1029. Rel: sqlgraph.O2M,
  1030. Inverse: false,
  1031. Table: user.RedeemCodesTable,
  1032. Columns: []string{user.RedeemCodesColumn},
  1033. Bidi: false,
  1034. Target: &sqlgraph.EdgeTarget{
  1035. IDSpec: sqlgraph.NewFieldSpec(redeemcode.FieldID, field.TypeInt64),
  1036. },
  1037. }
  1038. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1039. }
  1040. if nodes := _u.mutation.RemovedRedeemCodesIDs(); len(nodes) > 0 && !_u.mutation.RedeemCodesCleared() {
  1041. edge := &sqlgraph.EdgeSpec{
  1042. Rel: sqlgraph.O2M,
  1043. Inverse: false,
  1044. Table: user.RedeemCodesTable,
  1045. Columns: []string{user.RedeemCodesColumn},
  1046. Bidi: false,
  1047. Target: &sqlgraph.EdgeTarget{
  1048. IDSpec: sqlgraph.NewFieldSpec(redeemcode.FieldID, field.TypeInt64),
  1049. },
  1050. }
  1051. for _, k := range nodes {
  1052. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1053. }
  1054. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1055. }
  1056. if nodes := _u.mutation.RedeemCodesIDs(); len(nodes) > 0 {
  1057. edge := &sqlgraph.EdgeSpec{
  1058. Rel: sqlgraph.O2M,
  1059. Inverse: false,
  1060. Table: user.RedeemCodesTable,
  1061. Columns: []string{user.RedeemCodesColumn},
  1062. Bidi: false,
  1063. Target: &sqlgraph.EdgeTarget{
  1064. IDSpec: sqlgraph.NewFieldSpec(redeemcode.FieldID, field.TypeInt64),
  1065. },
  1066. }
  1067. for _, k := range nodes {
  1068. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1069. }
  1070. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1071. }
  1072. if _u.mutation.SubscriptionsCleared() {
  1073. edge := &sqlgraph.EdgeSpec{
  1074. Rel: sqlgraph.O2M,
  1075. Inverse: false,
  1076. Table: user.SubscriptionsTable,
  1077. Columns: []string{user.SubscriptionsColumn},
  1078. Bidi: false,
  1079. Target: &sqlgraph.EdgeTarget{
  1080. IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
  1081. },
  1082. }
  1083. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1084. }
  1085. if nodes := _u.mutation.RemovedSubscriptionsIDs(); len(nodes) > 0 && !_u.mutation.SubscriptionsCleared() {
  1086. edge := &sqlgraph.EdgeSpec{
  1087. Rel: sqlgraph.O2M,
  1088. Inverse: false,
  1089. Table: user.SubscriptionsTable,
  1090. Columns: []string{user.SubscriptionsColumn},
  1091. Bidi: false,
  1092. Target: &sqlgraph.EdgeTarget{
  1093. IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
  1094. },
  1095. }
  1096. for _, k := range nodes {
  1097. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1098. }
  1099. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1100. }
  1101. if nodes := _u.mutation.SubscriptionsIDs(); len(nodes) > 0 {
  1102. edge := &sqlgraph.EdgeSpec{
  1103. Rel: sqlgraph.O2M,
  1104. Inverse: false,
  1105. Table: user.SubscriptionsTable,
  1106. Columns: []string{user.SubscriptionsColumn},
  1107. Bidi: false,
  1108. Target: &sqlgraph.EdgeTarget{
  1109. IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
  1110. },
  1111. }
  1112. for _, k := range nodes {
  1113. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1114. }
  1115. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1116. }
  1117. if _u.mutation.AssignedSubscriptionsCleared() {
  1118. edge := &sqlgraph.EdgeSpec{
  1119. Rel: sqlgraph.O2M,
  1120. Inverse: false,
  1121. Table: user.AssignedSubscriptionsTable,
  1122. Columns: []string{user.AssignedSubscriptionsColumn},
  1123. Bidi: false,
  1124. Target: &sqlgraph.EdgeTarget{
  1125. IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
  1126. },
  1127. }
  1128. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1129. }
  1130. if nodes := _u.mutation.RemovedAssignedSubscriptionsIDs(); len(nodes) > 0 && !_u.mutation.AssignedSubscriptionsCleared() {
  1131. edge := &sqlgraph.EdgeSpec{
  1132. Rel: sqlgraph.O2M,
  1133. Inverse: false,
  1134. Table: user.AssignedSubscriptionsTable,
  1135. Columns: []string{user.AssignedSubscriptionsColumn},
  1136. Bidi: false,
  1137. Target: &sqlgraph.EdgeTarget{
  1138. IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
  1139. },
  1140. }
  1141. for _, k := range nodes {
  1142. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1143. }
  1144. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1145. }
  1146. if nodes := _u.mutation.AssignedSubscriptionsIDs(); len(nodes) > 0 {
  1147. edge := &sqlgraph.EdgeSpec{
  1148. Rel: sqlgraph.O2M,
  1149. Inverse: false,
  1150. Table: user.AssignedSubscriptionsTable,
  1151. Columns: []string{user.AssignedSubscriptionsColumn},
  1152. Bidi: false,
  1153. Target: &sqlgraph.EdgeTarget{
  1154. IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
  1155. },
  1156. }
  1157. for _, k := range nodes {
  1158. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1159. }
  1160. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1161. }
  1162. if _u.mutation.AnnouncementReadsCleared() {
  1163. edge := &sqlgraph.EdgeSpec{
  1164. Rel: sqlgraph.O2M,
  1165. Inverse: false,
  1166. Table: user.AnnouncementReadsTable,
  1167. Columns: []string{user.AnnouncementReadsColumn},
  1168. Bidi: false,
  1169. Target: &sqlgraph.EdgeTarget{
  1170. IDSpec: sqlgraph.NewFieldSpec(announcementread.FieldID, field.TypeInt64),
  1171. },
  1172. }
  1173. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1174. }
  1175. if nodes := _u.mutation.RemovedAnnouncementReadsIDs(); len(nodes) > 0 && !_u.mutation.AnnouncementReadsCleared() {
  1176. edge := &sqlgraph.EdgeSpec{
  1177. Rel: sqlgraph.O2M,
  1178. Inverse: false,
  1179. Table: user.AnnouncementReadsTable,
  1180. Columns: []string{user.AnnouncementReadsColumn},
  1181. Bidi: false,
  1182. Target: &sqlgraph.EdgeTarget{
  1183. IDSpec: sqlgraph.NewFieldSpec(announcementread.FieldID, field.TypeInt64),
  1184. },
  1185. }
  1186. for _, k := range nodes {
  1187. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1188. }
  1189. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1190. }
  1191. if nodes := _u.mutation.AnnouncementReadsIDs(); len(nodes) > 0 {
  1192. edge := &sqlgraph.EdgeSpec{
  1193. Rel: sqlgraph.O2M,
  1194. Inverse: false,
  1195. Table: user.AnnouncementReadsTable,
  1196. Columns: []string{user.AnnouncementReadsColumn},
  1197. Bidi: false,
  1198. Target: &sqlgraph.EdgeTarget{
  1199. IDSpec: sqlgraph.NewFieldSpec(announcementread.FieldID, field.TypeInt64),
  1200. },
  1201. }
  1202. for _, k := range nodes {
  1203. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1204. }
  1205. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1206. }
  1207. if _u.mutation.AllowedGroupsCleared() {
  1208. edge := &sqlgraph.EdgeSpec{
  1209. Rel: sqlgraph.M2M,
  1210. Inverse: false,
  1211. Table: user.AllowedGroupsTable,
  1212. Columns: user.AllowedGroupsPrimaryKey,
  1213. Bidi: false,
  1214. Target: &sqlgraph.EdgeTarget{
  1215. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  1216. },
  1217. }
  1218. createE := &UserAllowedGroupCreate{config: _u.config, mutation: newUserAllowedGroupMutation(_u.config, OpCreate)}
  1219. createE.defaults()
  1220. _, specE := createE.createSpec()
  1221. edge.Target.Fields = specE.Fields
  1222. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1223. }
  1224. if nodes := _u.mutation.RemovedAllowedGroupsIDs(); len(nodes) > 0 && !_u.mutation.AllowedGroupsCleared() {
  1225. edge := &sqlgraph.EdgeSpec{
  1226. Rel: sqlgraph.M2M,
  1227. Inverse: false,
  1228. Table: user.AllowedGroupsTable,
  1229. Columns: user.AllowedGroupsPrimaryKey,
  1230. Bidi: false,
  1231. Target: &sqlgraph.EdgeTarget{
  1232. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  1233. },
  1234. }
  1235. for _, k := range nodes {
  1236. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1237. }
  1238. createE := &UserAllowedGroupCreate{config: _u.config, mutation: newUserAllowedGroupMutation(_u.config, OpCreate)}
  1239. createE.defaults()
  1240. _, specE := createE.createSpec()
  1241. edge.Target.Fields = specE.Fields
  1242. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1243. }
  1244. if nodes := _u.mutation.AllowedGroupsIDs(); len(nodes) > 0 {
  1245. edge := &sqlgraph.EdgeSpec{
  1246. Rel: sqlgraph.M2M,
  1247. Inverse: false,
  1248. Table: user.AllowedGroupsTable,
  1249. Columns: user.AllowedGroupsPrimaryKey,
  1250. Bidi: false,
  1251. Target: &sqlgraph.EdgeTarget{
  1252. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  1253. },
  1254. }
  1255. for _, k := range nodes {
  1256. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1257. }
  1258. createE := &UserAllowedGroupCreate{config: _u.config, mutation: newUserAllowedGroupMutation(_u.config, OpCreate)}
  1259. createE.defaults()
  1260. _, specE := createE.createSpec()
  1261. edge.Target.Fields = specE.Fields
  1262. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1263. }
  1264. if _u.mutation.UsageLogsCleared() {
  1265. edge := &sqlgraph.EdgeSpec{
  1266. Rel: sqlgraph.O2M,
  1267. Inverse: false,
  1268. Table: user.UsageLogsTable,
  1269. Columns: []string{user.UsageLogsColumn},
  1270. Bidi: false,
  1271. Target: &sqlgraph.EdgeTarget{
  1272. IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
  1273. },
  1274. }
  1275. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1276. }
  1277. if nodes := _u.mutation.RemovedUsageLogsIDs(); len(nodes) > 0 && !_u.mutation.UsageLogsCleared() {
  1278. edge := &sqlgraph.EdgeSpec{
  1279. Rel: sqlgraph.O2M,
  1280. Inverse: false,
  1281. Table: user.UsageLogsTable,
  1282. Columns: []string{user.UsageLogsColumn},
  1283. Bidi: false,
  1284. Target: &sqlgraph.EdgeTarget{
  1285. IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
  1286. },
  1287. }
  1288. for _, k := range nodes {
  1289. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1290. }
  1291. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1292. }
  1293. if nodes := _u.mutation.UsageLogsIDs(); len(nodes) > 0 {
  1294. edge := &sqlgraph.EdgeSpec{
  1295. Rel: sqlgraph.O2M,
  1296. Inverse: false,
  1297. Table: user.UsageLogsTable,
  1298. Columns: []string{user.UsageLogsColumn},
  1299. Bidi: false,
  1300. Target: &sqlgraph.EdgeTarget{
  1301. IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
  1302. },
  1303. }
  1304. for _, k := range nodes {
  1305. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1306. }
  1307. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1308. }
  1309. if _u.mutation.AttributeValuesCleared() {
  1310. edge := &sqlgraph.EdgeSpec{
  1311. Rel: sqlgraph.O2M,
  1312. Inverse: false,
  1313. Table: user.AttributeValuesTable,
  1314. Columns: []string{user.AttributeValuesColumn},
  1315. Bidi: false,
  1316. Target: &sqlgraph.EdgeTarget{
  1317. IDSpec: sqlgraph.NewFieldSpec(userattributevalue.FieldID, field.TypeInt64),
  1318. },
  1319. }
  1320. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1321. }
  1322. if nodes := _u.mutation.RemovedAttributeValuesIDs(); len(nodes) > 0 && !_u.mutation.AttributeValuesCleared() {
  1323. edge := &sqlgraph.EdgeSpec{
  1324. Rel: sqlgraph.O2M,
  1325. Inverse: false,
  1326. Table: user.AttributeValuesTable,
  1327. Columns: []string{user.AttributeValuesColumn},
  1328. Bidi: false,
  1329. Target: &sqlgraph.EdgeTarget{
  1330. IDSpec: sqlgraph.NewFieldSpec(userattributevalue.FieldID, field.TypeInt64),
  1331. },
  1332. }
  1333. for _, k := range nodes {
  1334. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1335. }
  1336. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1337. }
  1338. if nodes := _u.mutation.AttributeValuesIDs(); len(nodes) > 0 {
  1339. edge := &sqlgraph.EdgeSpec{
  1340. Rel: sqlgraph.O2M,
  1341. Inverse: false,
  1342. Table: user.AttributeValuesTable,
  1343. Columns: []string{user.AttributeValuesColumn},
  1344. Bidi: false,
  1345. Target: &sqlgraph.EdgeTarget{
  1346. IDSpec: sqlgraph.NewFieldSpec(userattributevalue.FieldID, field.TypeInt64),
  1347. },
  1348. }
  1349. for _, k := range nodes {
  1350. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1351. }
  1352. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1353. }
  1354. if _u.mutation.PromoCodeUsagesCleared() {
  1355. edge := &sqlgraph.EdgeSpec{
  1356. Rel: sqlgraph.O2M,
  1357. Inverse: false,
  1358. Table: user.PromoCodeUsagesTable,
  1359. Columns: []string{user.PromoCodeUsagesColumn},
  1360. Bidi: false,
  1361. Target: &sqlgraph.EdgeTarget{
  1362. IDSpec: sqlgraph.NewFieldSpec(promocodeusage.FieldID, field.TypeInt64),
  1363. },
  1364. }
  1365. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1366. }
  1367. if nodes := _u.mutation.RemovedPromoCodeUsagesIDs(); len(nodes) > 0 && !_u.mutation.PromoCodeUsagesCleared() {
  1368. edge := &sqlgraph.EdgeSpec{
  1369. Rel: sqlgraph.O2M,
  1370. Inverse: false,
  1371. Table: user.PromoCodeUsagesTable,
  1372. Columns: []string{user.PromoCodeUsagesColumn},
  1373. Bidi: false,
  1374. Target: &sqlgraph.EdgeTarget{
  1375. IDSpec: sqlgraph.NewFieldSpec(promocodeusage.FieldID, field.TypeInt64),
  1376. },
  1377. }
  1378. for _, k := range nodes {
  1379. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1380. }
  1381. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1382. }
  1383. if nodes := _u.mutation.PromoCodeUsagesIDs(); len(nodes) > 0 {
  1384. edge := &sqlgraph.EdgeSpec{
  1385. Rel: sqlgraph.O2M,
  1386. Inverse: false,
  1387. Table: user.PromoCodeUsagesTable,
  1388. Columns: []string{user.PromoCodeUsagesColumn},
  1389. Bidi: false,
  1390. Target: &sqlgraph.EdgeTarget{
  1391. IDSpec: sqlgraph.NewFieldSpec(promocodeusage.FieldID, field.TypeInt64),
  1392. },
  1393. }
  1394. for _, k := range nodes {
  1395. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1396. }
  1397. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1398. }
  1399. if _u.mutation.PaymentOrdersCleared() {
  1400. edge := &sqlgraph.EdgeSpec{
  1401. Rel: sqlgraph.O2M,
  1402. Inverse: false,
  1403. Table: user.PaymentOrdersTable,
  1404. Columns: []string{user.PaymentOrdersColumn},
  1405. Bidi: false,
  1406. Target: &sqlgraph.EdgeTarget{
  1407. IDSpec: sqlgraph.NewFieldSpec(paymentorder.FieldID, field.TypeInt64),
  1408. },
  1409. }
  1410. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1411. }
  1412. if nodes := _u.mutation.RemovedPaymentOrdersIDs(); len(nodes) > 0 && !_u.mutation.PaymentOrdersCleared() {
  1413. edge := &sqlgraph.EdgeSpec{
  1414. Rel: sqlgraph.O2M,
  1415. Inverse: false,
  1416. Table: user.PaymentOrdersTable,
  1417. Columns: []string{user.PaymentOrdersColumn},
  1418. Bidi: false,
  1419. Target: &sqlgraph.EdgeTarget{
  1420. IDSpec: sqlgraph.NewFieldSpec(paymentorder.FieldID, field.TypeInt64),
  1421. },
  1422. }
  1423. for _, k := range nodes {
  1424. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1425. }
  1426. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1427. }
  1428. if nodes := _u.mutation.PaymentOrdersIDs(); len(nodes) > 0 {
  1429. edge := &sqlgraph.EdgeSpec{
  1430. Rel: sqlgraph.O2M,
  1431. Inverse: false,
  1432. Table: user.PaymentOrdersTable,
  1433. Columns: []string{user.PaymentOrdersColumn},
  1434. Bidi: false,
  1435. Target: &sqlgraph.EdgeTarget{
  1436. IDSpec: sqlgraph.NewFieldSpec(paymentorder.FieldID, field.TypeInt64),
  1437. },
  1438. }
  1439. for _, k := range nodes {
  1440. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1441. }
  1442. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1443. }
  1444. if _u.mutation.AuthIdentitiesCleared() {
  1445. edge := &sqlgraph.EdgeSpec{
  1446. Rel: sqlgraph.O2M,
  1447. Inverse: false,
  1448. Table: user.AuthIdentitiesTable,
  1449. Columns: []string{user.AuthIdentitiesColumn},
  1450. Bidi: false,
  1451. Target: &sqlgraph.EdgeTarget{
  1452. IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
  1453. },
  1454. }
  1455. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1456. }
  1457. if nodes := _u.mutation.RemovedAuthIdentitiesIDs(); len(nodes) > 0 && !_u.mutation.AuthIdentitiesCleared() {
  1458. edge := &sqlgraph.EdgeSpec{
  1459. Rel: sqlgraph.O2M,
  1460. Inverse: false,
  1461. Table: user.AuthIdentitiesTable,
  1462. Columns: []string{user.AuthIdentitiesColumn},
  1463. Bidi: false,
  1464. Target: &sqlgraph.EdgeTarget{
  1465. IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
  1466. },
  1467. }
  1468. for _, k := range nodes {
  1469. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1470. }
  1471. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1472. }
  1473. if nodes := _u.mutation.AuthIdentitiesIDs(); len(nodes) > 0 {
  1474. edge := &sqlgraph.EdgeSpec{
  1475. Rel: sqlgraph.O2M,
  1476. Inverse: false,
  1477. Table: user.AuthIdentitiesTable,
  1478. Columns: []string{user.AuthIdentitiesColumn},
  1479. Bidi: false,
  1480. Target: &sqlgraph.EdgeTarget{
  1481. IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
  1482. },
  1483. }
  1484. for _, k := range nodes {
  1485. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1486. }
  1487. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1488. }
  1489. if _u.mutation.PendingAuthSessionsCleared() {
  1490. edge := &sqlgraph.EdgeSpec{
  1491. Rel: sqlgraph.O2M,
  1492. Inverse: false,
  1493. Table: user.PendingAuthSessionsTable,
  1494. Columns: []string{user.PendingAuthSessionsColumn},
  1495. Bidi: false,
  1496. Target: &sqlgraph.EdgeTarget{
  1497. IDSpec: sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64),
  1498. },
  1499. }
  1500. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1501. }
  1502. if nodes := _u.mutation.RemovedPendingAuthSessionsIDs(); len(nodes) > 0 && !_u.mutation.PendingAuthSessionsCleared() {
  1503. edge := &sqlgraph.EdgeSpec{
  1504. Rel: sqlgraph.O2M,
  1505. Inverse: false,
  1506. Table: user.PendingAuthSessionsTable,
  1507. Columns: []string{user.PendingAuthSessionsColumn},
  1508. Bidi: false,
  1509. Target: &sqlgraph.EdgeTarget{
  1510. IDSpec: sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64),
  1511. },
  1512. }
  1513. for _, k := range nodes {
  1514. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1515. }
  1516. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1517. }
  1518. if nodes := _u.mutation.PendingAuthSessionsIDs(); len(nodes) > 0 {
  1519. edge := &sqlgraph.EdgeSpec{
  1520. Rel: sqlgraph.O2M,
  1521. Inverse: false,
  1522. Table: user.PendingAuthSessionsTable,
  1523. Columns: []string{user.PendingAuthSessionsColumn},
  1524. Bidi: false,
  1525. Target: &sqlgraph.EdgeTarget{
  1526. IDSpec: sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64),
  1527. },
  1528. }
  1529. for _, k := range nodes {
  1530. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1531. }
  1532. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1533. }
  1534. if _u.mutation.PlatformQuotasCleared() {
  1535. edge := &sqlgraph.EdgeSpec{
  1536. Rel: sqlgraph.O2M,
  1537. Inverse: false,
  1538. Table: user.PlatformQuotasTable,
  1539. Columns: []string{user.PlatformQuotasColumn},
  1540. Bidi: false,
  1541. Target: &sqlgraph.EdgeTarget{
  1542. IDSpec: sqlgraph.NewFieldSpec(userplatformquota.FieldID, field.TypeInt64),
  1543. },
  1544. }
  1545. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1546. }
  1547. if nodes := _u.mutation.RemovedPlatformQuotasIDs(); len(nodes) > 0 && !_u.mutation.PlatformQuotasCleared() {
  1548. edge := &sqlgraph.EdgeSpec{
  1549. Rel: sqlgraph.O2M,
  1550. Inverse: false,
  1551. Table: user.PlatformQuotasTable,
  1552. Columns: []string{user.PlatformQuotasColumn},
  1553. Bidi: false,
  1554. Target: &sqlgraph.EdgeTarget{
  1555. IDSpec: sqlgraph.NewFieldSpec(userplatformquota.FieldID, field.TypeInt64),
  1556. },
  1557. }
  1558. for _, k := range nodes {
  1559. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1560. }
  1561. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1562. }
  1563. if nodes := _u.mutation.PlatformQuotasIDs(); len(nodes) > 0 {
  1564. edge := &sqlgraph.EdgeSpec{
  1565. Rel: sqlgraph.O2M,
  1566. Inverse: false,
  1567. Table: user.PlatformQuotasTable,
  1568. Columns: []string{user.PlatformQuotasColumn},
  1569. Bidi: false,
  1570. Target: &sqlgraph.EdgeTarget{
  1571. IDSpec: sqlgraph.NewFieldSpec(userplatformquota.FieldID, field.TypeInt64),
  1572. },
  1573. }
  1574. for _, k := range nodes {
  1575. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1576. }
  1577. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1578. }
  1579. if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
  1580. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  1581. err = &NotFoundError{user.Label}
  1582. } else if sqlgraph.IsConstraintError(err) {
  1583. err = &ConstraintError{msg: err.Error(), wrap: err}
  1584. }
  1585. return 0, err
  1586. }
  1587. _u.mutation.done = true
  1588. return _node, nil
  1589. }
  1590. // UserUpdateOne is the builder for updating a single User entity.
  1591. type UserUpdateOne struct {
  1592. config
  1593. fields []string
  1594. hooks []Hook
  1595. mutation *UserMutation
  1596. }
  1597. // SetUpdatedAt sets the "updated_at" field.
  1598. func (_u *UserUpdateOne) SetUpdatedAt(v time.Time) *UserUpdateOne {
  1599. _u.mutation.SetUpdatedAt(v)
  1600. return _u
  1601. }
  1602. // SetDeletedAt sets the "deleted_at" field.
  1603. func (_u *UserUpdateOne) SetDeletedAt(v time.Time) *UserUpdateOne {
  1604. _u.mutation.SetDeletedAt(v)
  1605. return _u
  1606. }
  1607. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  1608. func (_u *UserUpdateOne) SetNillableDeletedAt(v *time.Time) *UserUpdateOne {
  1609. if v != nil {
  1610. _u.SetDeletedAt(*v)
  1611. }
  1612. return _u
  1613. }
  1614. // ClearDeletedAt clears the value of the "deleted_at" field.
  1615. func (_u *UserUpdateOne) ClearDeletedAt() *UserUpdateOne {
  1616. _u.mutation.ClearDeletedAt()
  1617. return _u
  1618. }
  1619. // SetEmail sets the "email" field.
  1620. func (_u *UserUpdateOne) SetEmail(v string) *UserUpdateOne {
  1621. _u.mutation.SetEmail(v)
  1622. return _u
  1623. }
  1624. // SetNillableEmail sets the "email" field if the given value is not nil.
  1625. func (_u *UserUpdateOne) SetNillableEmail(v *string) *UserUpdateOne {
  1626. if v != nil {
  1627. _u.SetEmail(*v)
  1628. }
  1629. return _u
  1630. }
  1631. // SetPasswordHash sets the "password_hash" field.
  1632. func (_u *UserUpdateOne) SetPasswordHash(v string) *UserUpdateOne {
  1633. _u.mutation.SetPasswordHash(v)
  1634. return _u
  1635. }
  1636. // SetNillablePasswordHash sets the "password_hash" field if the given value is not nil.
  1637. func (_u *UserUpdateOne) SetNillablePasswordHash(v *string) *UserUpdateOne {
  1638. if v != nil {
  1639. _u.SetPasswordHash(*v)
  1640. }
  1641. return _u
  1642. }
  1643. // SetRole sets the "role" field.
  1644. func (_u *UserUpdateOne) SetRole(v string) *UserUpdateOne {
  1645. _u.mutation.SetRole(v)
  1646. return _u
  1647. }
  1648. // SetNillableRole sets the "role" field if the given value is not nil.
  1649. func (_u *UserUpdateOne) SetNillableRole(v *string) *UserUpdateOne {
  1650. if v != nil {
  1651. _u.SetRole(*v)
  1652. }
  1653. return _u
  1654. }
  1655. // SetBalance sets the "balance" field.
  1656. func (_u *UserUpdateOne) SetBalance(v float64) *UserUpdateOne {
  1657. _u.mutation.ResetBalance()
  1658. _u.mutation.SetBalance(v)
  1659. return _u
  1660. }
  1661. // SetNillableBalance sets the "balance" field if the given value is not nil.
  1662. func (_u *UserUpdateOne) SetNillableBalance(v *float64) *UserUpdateOne {
  1663. if v != nil {
  1664. _u.SetBalance(*v)
  1665. }
  1666. return _u
  1667. }
  1668. // AddBalance adds value to the "balance" field.
  1669. func (_u *UserUpdateOne) AddBalance(v float64) *UserUpdateOne {
  1670. _u.mutation.AddBalance(v)
  1671. return _u
  1672. }
  1673. // SetFrozenBalance sets the "frozen_balance" field.
  1674. func (_u *UserUpdateOne) SetFrozenBalance(v float64) *UserUpdateOne {
  1675. _u.mutation.ResetFrozenBalance()
  1676. _u.mutation.SetFrozenBalance(v)
  1677. return _u
  1678. }
  1679. // SetNillableFrozenBalance sets the "frozen_balance" field if the given value is not nil.
  1680. func (_u *UserUpdateOne) SetNillableFrozenBalance(v *float64) *UserUpdateOne {
  1681. if v != nil {
  1682. _u.SetFrozenBalance(*v)
  1683. }
  1684. return _u
  1685. }
  1686. // AddFrozenBalance adds value to the "frozen_balance" field.
  1687. func (_u *UserUpdateOne) AddFrozenBalance(v float64) *UserUpdateOne {
  1688. _u.mutation.AddFrozenBalance(v)
  1689. return _u
  1690. }
  1691. // SetConcurrency sets the "concurrency" field.
  1692. func (_u *UserUpdateOne) SetConcurrency(v int) *UserUpdateOne {
  1693. _u.mutation.ResetConcurrency()
  1694. _u.mutation.SetConcurrency(v)
  1695. return _u
  1696. }
  1697. // SetNillableConcurrency sets the "concurrency" field if the given value is not nil.
  1698. func (_u *UserUpdateOne) SetNillableConcurrency(v *int) *UserUpdateOne {
  1699. if v != nil {
  1700. _u.SetConcurrency(*v)
  1701. }
  1702. return _u
  1703. }
  1704. // AddConcurrency adds value to the "concurrency" field.
  1705. func (_u *UserUpdateOne) AddConcurrency(v int) *UserUpdateOne {
  1706. _u.mutation.AddConcurrency(v)
  1707. return _u
  1708. }
  1709. // SetStatus sets the "status" field.
  1710. func (_u *UserUpdateOne) SetStatus(v string) *UserUpdateOne {
  1711. _u.mutation.SetStatus(v)
  1712. return _u
  1713. }
  1714. // SetNillableStatus sets the "status" field if the given value is not nil.
  1715. func (_u *UserUpdateOne) SetNillableStatus(v *string) *UserUpdateOne {
  1716. if v != nil {
  1717. _u.SetStatus(*v)
  1718. }
  1719. return _u
  1720. }
  1721. // SetUsername sets the "username" field.
  1722. func (_u *UserUpdateOne) SetUsername(v string) *UserUpdateOne {
  1723. _u.mutation.SetUsername(v)
  1724. return _u
  1725. }
  1726. // SetNillableUsername sets the "username" field if the given value is not nil.
  1727. func (_u *UserUpdateOne) SetNillableUsername(v *string) *UserUpdateOne {
  1728. if v != nil {
  1729. _u.SetUsername(*v)
  1730. }
  1731. return _u
  1732. }
  1733. // SetNotes sets the "notes" field.
  1734. func (_u *UserUpdateOne) SetNotes(v string) *UserUpdateOne {
  1735. _u.mutation.SetNotes(v)
  1736. return _u
  1737. }
  1738. // SetNillableNotes sets the "notes" field if the given value is not nil.
  1739. func (_u *UserUpdateOne) SetNillableNotes(v *string) *UserUpdateOne {
  1740. if v != nil {
  1741. _u.SetNotes(*v)
  1742. }
  1743. return _u
  1744. }
  1745. // SetTotpSecretEncrypted sets the "totp_secret_encrypted" field.
  1746. func (_u *UserUpdateOne) SetTotpSecretEncrypted(v string) *UserUpdateOne {
  1747. _u.mutation.SetTotpSecretEncrypted(v)
  1748. return _u
  1749. }
  1750. // SetNillableTotpSecretEncrypted sets the "totp_secret_encrypted" field if the given value is not nil.
  1751. func (_u *UserUpdateOne) SetNillableTotpSecretEncrypted(v *string) *UserUpdateOne {
  1752. if v != nil {
  1753. _u.SetTotpSecretEncrypted(*v)
  1754. }
  1755. return _u
  1756. }
  1757. // ClearTotpSecretEncrypted clears the value of the "totp_secret_encrypted" field.
  1758. func (_u *UserUpdateOne) ClearTotpSecretEncrypted() *UserUpdateOne {
  1759. _u.mutation.ClearTotpSecretEncrypted()
  1760. return _u
  1761. }
  1762. // SetTotpEnabled sets the "totp_enabled" field.
  1763. func (_u *UserUpdateOne) SetTotpEnabled(v bool) *UserUpdateOne {
  1764. _u.mutation.SetTotpEnabled(v)
  1765. return _u
  1766. }
  1767. // SetNillableTotpEnabled sets the "totp_enabled" field if the given value is not nil.
  1768. func (_u *UserUpdateOne) SetNillableTotpEnabled(v *bool) *UserUpdateOne {
  1769. if v != nil {
  1770. _u.SetTotpEnabled(*v)
  1771. }
  1772. return _u
  1773. }
  1774. // SetTotpEnabledAt sets the "totp_enabled_at" field.
  1775. func (_u *UserUpdateOne) SetTotpEnabledAt(v time.Time) *UserUpdateOne {
  1776. _u.mutation.SetTotpEnabledAt(v)
  1777. return _u
  1778. }
  1779. // SetNillableTotpEnabledAt sets the "totp_enabled_at" field if the given value is not nil.
  1780. func (_u *UserUpdateOne) SetNillableTotpEnabledAt(v *time.Time) *UserUpdateOne {
  1781. if v != nil {
  1782. _u.SetTotpEnabledAt(*v)
  1783. }
  1784. return _u
  1785. }
  1786. // ClearTotpEnabledAt clears the value of the "totp_enabled_at" field.
  1787. func (_u *UserUpdateOne) ClearTotpEnabledAt() *UserUpdateOne {
  1788. _u.mutation.ClearTotpEnabledAt()
  1789. return _u
  1790. }
  1791. // SetSignupSource sets the "signup_source" field.
  1792. func (_u *UserUpdateOne) SetSignupSource(v string) *UserUpdateOne {
  1793. _u.mutation.SetSignupSource(v)
  1794. return _u
  1795. }
  1796. // SetNillableSignupSource sets the "signup_source" field if the given value is not nil.
  1797. func (_u *UserUpdateOne) SetNillableSignupSource(v *string) *UserUpdateOne {
  1798. if v != nil {
  1799. _u.SetSignupSource(*v)
  1800. }
  1801. return _u
  1802. }
  1803. // SetLastLoginAt sets the "last_login_at" field.
  1804. func (_u *UserUpdateOne) SetLastLoginAt(v time.Time) *UserUpdateOne {
  1805. _u.mutation.SetLastLoginAt(v)
  1806. return _u
  1807. }
  1808. // SetNillableLastLoginAt sets the "last_login_at" field if the given value is not nil.
  1809. func (_u *UserUpdateOne) SetNillableLastLoginAt(v *time.Time) *UserUpdateOne {
  1810. if v != nil {
  1811. _u.SetLastLoginAt(*v)
  1812. }
  1813. return _u
  1814. }
  1815. // ClearLastLoginAt clears the value of the "last_login_at" field.
  1816. func (_u *UserUpdateOne) ClearLastLoginAt() *UserUpdateOne {
  1817. _u.mutation.ClearLastLoginAt()
  1818. return _u
  1819. }
  1820. // SetLastActiveAt sets the "last_active_at" field.
  1821. func (_u *UserUpdateOne) SetLastActiveAt(v time.Time) *UserUpdateOne {
  1822. _u.mutation.SetLastActiveAt(v)
  1823. return _u
  1824. }
  1825. // SetNillableLastActiveAt sets the "last_active_at" field if the given value is not nil.
  1826. func (_u *UserUpdateOne) SetNillableLastActiveAt(v *time.Time) *UserUpdateOne {
  1827. if v != nil {
  1828. _u.SetLastActiveAt(*v)
  1829. }
  1830. return _u
  1831. }
  1832. // ClearLastActiveAt clears the value of the "last_active_at" field.
  1833. func (_u *UserUpdateOne) ClearLastActiveAt() *UserUpdateOne {
  1834. _u.mutation.ClearLastActiveAt()
  1835. return _u
  1836. }
  1837. // SetRestrictPublicGroups sets the "restrict_public_groups" field.
  1838. func (_u *UserUpdateOne) SetRestrictPublicGroups(v bool) *UserUpdateOne {
  1839. _u.mutation.SetRestrictPublicGroups(v)
  1840. return _u
  1841. }
  1842. // SetNillableRestrictPublicGroups sets the "restrict_public_groups" field if the given value is not nil.
  1843. func (_u *UserUpdateOne) SetNillableRestrictPublicGroups(v *bool) *UserUpdateOne {
  1844. if v != nil {
  1845. _u.SetRestrictPublicGroups(*v)
  1846. }
  1847. return _u
  1848. }
  1849. // SetBalanceNotifyEnabled sets the "balance_notify_enabled" field.
  1850. func (_u *UserUpdateOne) SetBalanceNotifyEnabled(v bool) *UserUpdateOne {
  1851. _u.mutation.SetBalanceNotifyEnabled(v)
  1852. return _u
  1853. }
  1854. // SetNillableBalanceNotifyEnabled sets the "balance_notify_enabled" field if the given value is not nil.
  1855. func (_u *UserUpdateOne) SetNillableBalanceNotifyEnabled(v *bool) *UserUpdateOne {
  1856. if v != nil {
  1857. _u.SetBalanceNotifyEnabled(*v)
  1858. }
  1859. return _u
  1860. }
  1861. // SetBalanceNotifyThresholdType sets the "balance_notify_threshold_type" field.
  1862. func (_u *UserUpdateOne) SetBalanceNotifyThresholdType(v string) *UserUpdateOne {
  1863. _u.mutation.SetBalanceNotifyThresholdType(v)
  1864. return _u
  1865. }
  1866. // SetNillableBalanceNotifyThresholdType sets the "balance_notify_threshold_type" field if the given value is not nil.
  1867. func (_u *UserUpdateOne) SetNillableBalanceNotifyThresholdType(v *string) *UserUpdateOne {
  1868. if v != nil {
  1869. _u.SetBalanceNotifyThresholdType(*v)
  1870. }
  1871. return _u
  1872. }
  1873. // SetBalanceNotifyThreshold sets the "balance_notify_threshold" field.
  1874. func (_u *UserUpdateOne) SetBalanceNotifyThreshold(v float64) *UserUpdateOne {
  1875. _u.mutation.ResetBalanceNotifyThreshold()
  1876. _u.mutation.SetBalanceNotifyThreshold(v)
  1877. return _u
  1878. }
  1879. // SetNillableBalanceNotifyThreshold sets the "balance_notify_threshold" field if the given value is not nil.
  1880. func (_u *UserUpdateOne) SetNillableBalanceNotifyThreshold(v *float64) *UserUpdateOne {
  1881. if v != nil {
  1882. _u.SetBalanceNotifyThreshold(*v)
  1883. }
  1884. return _u
  1885. }
  1886. // AddBalanceNotifyThreshold adds value to the "balance_notify_threshold" field.
  1887. func (_u *UserUpdateOne) AddBalanceNotifyThreshold(v float64) *UserUpdateOne {
  1888. _u.mutation.AddBalanceNotifyThreshold(v)
  1889. return _u
  1890. }
  1891. // ClearBalanceNotifyThreshold clears the value of the "balance_notify_threshold" field.
  1892. func (_u *UserUpdateOne) ClearBalanceNotifyThreshold() *UserUpdateOne {
  1893. _u.mutation.ClearBalanceNotifyThreshold()
  1894. return _u
  1895. }
  1896. // SetBalanceNotifyExtraEmails sets the "balance_notify_extra_emails" field.
  1897. func (_u *UserUpdateOne) SetBalanceNotifyExtraEmails(v string) *UserUpdateOne {
  1898. _u.mutation.SetBalanceNotifyExtraEmails(v)
  1899. return _u
  1900. }
  1901. // SetNillableBalanceNotifyExtraEmails sets the "balance_notify_extra_emails" field if the given value is not nil.
  1902. func (_u *UserUpdateOne) SetNillableBalanceNotifyExtraEmails(v *string) *UserUpdateOne {
  1903. if v != nil {
  1904. _u.SetBalanceNotifyExtraEmails(*v)
  1905. }
  1906. return _u
  1907. }
  1908. // SetTotalRecharged sets the "total_recharged" field.
  1909. func (_u *UserUpdateOne) SetTotalRecharged(v float64) *UserUpdateOne {
  1910. _u.mutation.ResetTotalRecharged()
  1911. _u.mutation.SetTotalRecharged(v)
  1912. return _u
  1913. }
  1914. // SetNillableTotalRecharged sets the "total_recharged" field if the given value is not nil.
  1915. func (_u *UserUpdateOne) SetNillableTotalRecharged(v *float64) *UserUpdateOne {
  1916. if v != nil {
  1917. _u.SetTotalRecharged(*v)
  1918. }
  1919. return _u
  1920. }
  1921. // AddTotalRecharged adds value to the "total_recharged" field.
  1922. func (_u *UserUpdateOne) AddTotalRecharged(v float64) *UserUpdateOne {
  1923. _u.mutation.AddTotalRecharged(v)
  1924. return _u
  1925. }
  1926. // SetRpmLimit sets the "rpm_limit" field.
  1927. func (_u *UserUpdateOne) SetRpmLimit(v int) *UserUpdateOne {
  1928. _u.mutation.ResetRpmLimit()
  1929. _u.mutation.SetRpmLimit(v)
  1930. return _u
  1931. }
  1932. // SetNillableRpmLimit sets the "rpm_limit" field if the given value is not nil.
  1933. func (_u *UserUpdateOne) SetNillableRpmLimit(v *int) *UserUpdateOne {
  1934. if v != nil {
  1935. _u.SetRpmLimit(*v)
  1936. }
  1937. return _u
  1938. }
  1939. // AddRpmLimit adds value to the "rpm_limit" field.
  1940. func (_u *UserUpdateOne) AddRpmLimit(v int) *UserUpdateOne {
  1941. _u.mutation.AddRpmLimit(v)
  1942. return _u
  1943. }
  1944. // AddAPIKeyIDs adds the "api_keys" edge to the APIKey entity by IDs.
  1945. func (_u *UserUpdateOne) AddAPIKeyIDs(ids ...int64) *UserUpdateOne {
  1946. _u.mutation.AddAPIKeyIDs(ids...)
  1947. return _u
  1948. }
  1949. // AddAPIKeys adds the "api_keys" edges to the APIKey entity.
  1950. func (_u *UserUpdateOne) AddAPIKeys(v ...*APIKey) *UserUpdateOne {
  1951. ids := make([]int64, len(v))
  1952. for i := range v {
  1953. ids[i] = v[i].ID
  1954. }
  1955. return _u.AddAPIKeyIDs(ids...)
  1956. }
  1957. // AddRedeemCodeIDs adds the "redeem_codes" edge to the RedeemCode entity by IDs.
  1958. func (_u *UserUpdateOne) AddRedeemCodeIDs(ids ...int64) *UserUpdateOne {
  1959. _u.mutation.AddRedeemCodeIDs(ids...)
  1960. return _u
  1961. }
  1962. // AddRedeemCodes adds the "redeem_codes" edges to the RedeemCode entity.
  1963. func (_u *UserUpdateOne) AddRedeemCodes(v ...*RedeemCode) *UserUpdateOne {
  1964. ids := make([]int64, len(v))
  1965. for i := range v {
  1966. ids[i] = v[i].ID
  1967. }
  1968. return _u.AddRedeemCodeIDs(ids...)
  1969. }
  1970. // AddSubscriptionIDs adds the "subscriptions" edge to the UserSubscription entity by IDs.
  1971. func (_u *UserUpdateOne) AddSubscriptionIDs(ids ...int64) *UserUpdateOne {
  1972. _u.mutation.AddSubscriptionIDs(ids...)
  1973. return _u
  1974. }
  1975. // AddSubscriptions adds the "subscriptions" edges to the UserSubscription entity.
  1976. func (_u *UserUpdateOne) AddSubscriptions(v ...*UserSubscription) *UserUpdateOne {
  1977. ids := make([]int64, len(v))
  1978. for i := range v {
  1979. ids[i] = v[i].ID
  1980. }
  1981. return _u.AddSubscriptionIDs(ids...)
  1982. }
  1983. // AddAssignedSubscriptionIDs adds the "assigned_subscriptions" edge to the UserSubscription entity by IDs.
  1984. func (_u *UserUpdateOne) AddAssignedSubscriptionIDs(ids ...int64) *UserUpdateOne {
  1985. _u.mutation.AddAssignedSubscriptionIDs(ids...)
  1986. return _u
  1987. }
  1988. // AddAssignedSubscriptions adds the "assigned_subscriptions" edges to the UserSubscription entity.
  1989. func (_u *UserUpdateOne) AddAssignedSubscriptions(v ...*UserSubscription) *UserUpdateOne {
  1990. ids := make([]int64, len(v))
  1991. for i := range v {
  1992. ids[i] = v[i].ID
  1993. }
  1994. return _u.AddAssignedSubscriptionIDs(ids...)
  1995. }
  1996. // AddAnnouncementReadIDs adds the "announcement_reads" edge to the AnnouncementRead entity by IDs.
  1997. func (_u *UserUpdateOne) AddAnnouncementReadIDs(ids ...int64) *UserUpdateOne {
  1998. _u.mutation.AddAnnouncementReadIDs(ids...)
  1999. return _u
  2000. }
  2001. // AddAnnouncementReads adds the "announcement_reads" edges to the AnnouncementRead entity.
  2002. func (_u *UserUpdateOne) AddAnnouncementReads(v ...*AnnouncementRead) *UserUpdateOne {
  2003. ids := make([]int64, len(v))
  2004. for i := range v {
  2005. ids[i] = v[i].ID
  2006. }
  2007. return _u.AddAnnouncementReadIDs(ids...)
  2008. }
  2009. // AddAllowedGroupIDs adds the "allowed_groups" edge to the Group entity by IDs.
  2010. func (_u *UserUpdateOne) AddAllowedGroupIDs(ids ...int64) *UserUpdateOne {
  2011. _u.mutation.AddAllowedGroupIDs(ids...)
  2012. return _u
  2013. }
  2014. // AddAllowedGroups adds the "allowed_groups" edges to the Group entity.
  2015. func (_u *UserUpdateOne) AddAllowedGroups(v ...*Group) *UserUpdateOne {
  2016. ids := make([]int64, len(v))
  2017. for i := range v {
  2018. ids[i] = v[i].ID
  2019. }
  2020. return _u.AddAllowedGroupIDs(ids...)
  2021. }
  2022. // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by IDs.
  2023. func (_u *UserUpdateOne) AddUsageLogIDs(ids ...int64) *UserUpdateOne {
  2024. _u.mutation.AddUsageLogIDs(ids...)
  2025. return _u
  2026. }
  2027. // AddUsageLogs adds the "usage_logs" edges to the UsageLog entity.
  2028. func (_u *UserUpdateOne) AddUsageLogs(v ...*UsageLog) *UserUpdateOne {
  2029. ids := make([]int64, len(v))
  2030. for i := range v {
  2031. ids[i] = v[i].ID
  2032. }
  2033. return _u.AddUsageLogIDs(ids...)
  2034. }
  2035. // AddAttributeValueIDs adds the "attribute_values" edge to the UserAttributeValue entity by IDs.
  2036. func (_u *UserUpdateOne) AddAttributeValueIDs(ids ...int64) *UserUpdateOne {
  2037. _u.mutation.AddAttributeValueIDs(ids...)
  2038. return _u
  2039. }
  2040. // AddAttributeValues adds the "attribute_values" edges to the UserAttributeValue entity.
  2041. func (_u *UserUpdateOne) AddAttributeValues(v ...*UserAttributeValue) *UserUpdateOne {
  2042. ids := make([]int64, len(v))
  2043. for i := range v {
  2044. ids[i] = v[i].ID
  2045. }
  2046. return _u.AddAttributeValueIDs(ids...)
  2047. }
  2048. // AddPromoCodeUsageIDs adds the "promo_code_usages" edge to the PromoCodeUsage entity by IDs.
  2049. func (_u *UserUpdateOne) AddPromoCodeUsageIDs(ids ...int64) *UserUpdateOne {
  2050. _u.mutation.AddPromoCodeUsageIDs(ids...)
  2051. return _u
  2052. }
  2053. // AddPromoCodeUsages adds the "promo_code_usages" edges to the PromoCodeUsage entity.
  2054. func (_u *UserUpdateOne) AddPromoCodeUsages(v ...*PromoCodeUsage) *UserUpdateOne {
  2055. ids := make([]int64, len(v))
  2056. for i := range v {
  2057. ids[i] = v[i].ID
  2058. }
  2059. return _u.AddPromoCodeUsageIDs(ids...)
  2060. }
  2061. // AddPaymentOrderIDs adds the "payment_orders" edge to the PaymentOrder entity by IDs.
  2062. func (_u *UserUpdateOne) AddPaymentOrderIDs(ids ...int64) *UserUpdateOne {
  2063. _u.mutation.AddPaymentOrderIDs(ids...)
  2064. return _u
  2065. }
  2066. // AddPaymentOrders adds the "payment_orders" edges to the PaymentOrder entity.
  2067. func (_u *UserUpdateOne) AddPaymentOrders(v ...*PaymentOrder) *UserUpdateOne {
  2068. ids := make([]int64, len(v))
  2069. for i := range v {
  2070. ids[i] = v[i].ID
  2071. }
  2072. return _u.AddPaymentOrderIDs(ids...)
  2073. }
  2074. // AddAuthIdentityIDs adds the "auth_identities" edge to the AuthIdentity entity by IDs.
  2075. func (_u *UserUpdateOne) AddAuthIdentityIDs(ids ...int64) *UserUpdateOne {
  2076. _u.mutation.AddAuthIdentityIDs(ids...)
  2077. return _u
  2078. }
  2079. // AddAuthIdentities adds the "auth_identities" edges to the AuthIdentity entity.
  2080. func (_u *UserUpdateOne) AddAuthIdentities(v ...*AuthIdentity) *UserUpdateOne {
  2081. ids := make([]int64, len(v))
  2082. for i := range v {
  2083. ids[i] = v[i].ID
  2084. }
  2085. return _u.AddAuthIdentityIDs(ids...)
  2086. }
  2087. // AddPendingAuthSessionIDs adds the "pending_auth_sessions" edge to the PendingAuthSession entity by IDs.
  2088. func (_u *UserUpdateOne) AddPendingAuthSessionIDs(ids ...int64) *UserUpdateOne {
  2089. _u.mutation.AddPendingAuthSessionIDs(ids...)
  2090. return _u
  2091. }
  2092. // AddPendingAuthSessions adds the "pending_auth_sessions" edges to the PendingAuthSession entity.
  2093. func (_u *UserUpdateOne) AddPendingAuthSessions(v ...*PendingAuthSession) *UserUpdateOne {
  2094. ids := make([]int64, len(v))
  2095. for i := range v {
  2096. ids[i] = v[i].ID
  2097. }
  2098. return _u.AddPendingAuthSessionIDs(ids...)
  2099. }
  2100. // AddPlatformQuotaIDs adds the "platform_quotas" edge to the UserPlatformQuota entity by IDs.
  2101. func (_u *UserUpdateOne) AddPlatformQuotaIDs(ids ...int64) *UserUpdateOne {
  2102. _u.mutation.AddPlatformQuotaIDs(ids...)
  2103. return _u
  2104. }
  2105. // AddPlatformQuotas adds the "platform_quotas" edges to the UserPlatformQuota entity.
  2106. func (_u *UserUpdateOne) AddPlatformQuotas(v ...*UserPlatformQuota) *UserUpdateOne {
  2107. ids := make([]int64, len(v))
  2108. for i := range v {
  2109. ids[i] = v[i].ID
  2110. }
  2111. return _u.AddPlatformQuotaIDs(ids...)
  2112. }
  2113. // Mutation returns the UserMutation object of the builder.
  2114. func (_u *UserUpdateOne) Mutation() *UserMutation {
  2115. return _u.mutation
  2116. }
  2117. // ClearAPIKeys clears all "api_keys" edges to the APIKey entity.
  2118. func (_u *UserUpdateOne) ClearAPIKeys() *UserUpdateOne {
  2119. _u.mutation.ClearAPIKeys()
  2120. return _u
  2121. }
  2122. // RemoveAPIKeyIDs removes the "api_keys" edge to APIKey entities by IDs.
  2123. func (_u *UserUpdateOne) RemoveAPIKeyIDs(ids ...int64) *UserUpdateOne {
  2124. _u.mutation.RemoveAPIKeyIDs(ids...)
  2125. return _u
  2126. }
  2127. // RemoveAPIKeys removes "api_keys" edges to APIKey entities.
  2128. func (_u *UserUpdateOne) RemoveAPIKeys(v ...*APIKey) *UserUpdateOne {
  2129. ids := make([]int64, len(v))
  2130. for i := range v {
  2131. ids[i] = v[i].ID
  2132. }
  2133. return _u.RemoveAPIKeyIDs(ids...)
  2134. }
  2135. // ClearRedeemCodes clears all "redeem_codes" edges to the RedeemCode entity.
  2136. func (_u *UserUpdateOne) ClearRedeemCodes() *UserUpdateOne {
  2137. _u.mutation.ClearRedeemCodes()
  2138. return _u
  2139. }
  2140. // RemoveRedeemCodeIDs removes the "redeem_codes" edge to RedeemCode entities by IDs.
  2141. func (_u *UserUpdateOne) RemoveRedeemCodeIDs(ids ...int64) *UserUpdateOne {
  2142. _u.mutation.RemoveRedeemCodeIDs(ids...)
  2143. return _u
  2144. }
  2145. // RemoveRedeemCodes removes "redeem_codes" edges to RedeemCode entities.
  2146. func (_u *UserUpdateOne) RemoveRedeemCodes(v ...*RedeemCode) *UserUpdateOne {
  2147. ids := make([]int64, len(v))
  2148. for i := range v {
  2149. ids[i] = v[i].ID
  2150. }
  2151. return _u.RemoveRedeemCodeIDs(ids...)
  2152. }
  2153. // ClearSubscriptions clears all "subscriptions" edges to the UserSubscription entity.
  2154. func (_u *UserUpdateOne) ClearSubscriptions() *UserUpdateOne {
  2155. _u.mutation.ClearSubscriptions()
  2156. return _u
  2157. }
  2158. // RemoveSubscriptionIDs removes the "subscriptions" edge to UserSubscription entities by IDs.
  2159. func (_u *UserUpdateOne) RemoveSubscriptionIDs(ids ...int64) *UserUpdateOne {
  2160. _u.mutation.RemoveSubscriptionIDs(ids...)
  2161. return _u
  2162. }
  2163. // RemoveSubscriptions removes "subscriptions" edges to UserSubscription entities.
  2164. func (_u *UserUpdateOne) RemoveSubscriptions(v ...*UserSubscription) *UserUpdateOne {
  2165. ids := make([]int64, len(v))
  2166. for i := range v {
  2167. ids[i] = v[i].ID
  2168. }
  2169. return _u.RemoveSubscriptionIDs(ids...)
  2170. }
  2171. // ClearAssignedSubscriptions clears all "assigned_subscriptions" edges to the UserSubscription entity.
  2172. func (_u *UserUpdateOne) ClearAssignedSubscriptions() *UserUpdateOne {
  2173. _u.mutation.ClearAssignedSubscriptions()
  2174. return _u
  2175. }
  2176. // RemoveAssignedSubscriptionIDs removes the "assigned_subscriptions" edge to UserSubscription entities by IDs.
  2177. func (_u *UserUpdateOne) RemoveAssignedSubscriptionIDs(ids ...int64) *UserUpdateOne {
  2178. _u.mutation.RemoveAssignedSubscriptionIDs(ids...)
  2179. return _u
  2180. }
  2181. // RemoveAssignedSubscriptions removes "assigned_subscriptions" edges to UserSubscription entities.
  2182. func (_u *UserUpdateOne) RemoveAssignedSubscriptions(v ...*UserSubscription) *UserUpdateOne {
  2183. ids := make([]int64, len(v))
  2184. for i := range v {
  2185. ids[i] = v[i].ID
  2186. }
  2187. return _u.RemoveAssignedSubscriptionIDs(ids...)
  2188. }
  2189. // ClearAnnouncementReads clears all "announcement_reads" edges to the AnnouncementRead entity.
  2190. func (_u *UserUpdateOne) ClearAnnouncementReads() *UserUpdateOne {
  2191. _u.mutation.ClearAnnouncementReads()
  2192. return _u
  2193. }
  2194. // RemoveAnnouncementReadIDs removes the "announcement_reads" edge to AnnouncementRead entities by IDs.
  2195. func (_u *UserUpdateOne) RemoveAnnouncementReadIDs(ids ...int64) *UserUpdateOne {
  2196. _u.mutation.RemoveAnnouncementReadIDs(ids...)
  2197. return _u
  2198. }
  2199. // RemoveAnnouncementReads removes "announcement_reads" edges to AnnouncementRead entities.
  2200. func (_u *UserUpdateOne) RemoveAnnouncementReads(v ...*AnnouncementRead) *UserUpdateOne {
  2201. ids := make([]int64, len(v))
  2202. for i := range v {
  2203. ids[i] = v[i].ID
  2204. }
  2205. return _u.RemoveAnnouncementReadIDs(ids...)
  2206. }
  2207. // ClearAllowedGroups clears all "allowed_groups" edges to the Group entity.
  2208. func (_u *UserUpdateOne) ClearAllowedGroups() *UserUpdateOne {
  2209. _u.mutation.ClearAllowedGroups()
  2210. return _u
  2211. }
  2212. // RemoveAllowedGroupIDs removes the "allowed_groups" edge to Group entities by IDs.
  2213. func (_u *UserUpdateOne) RemoveAllowedGroupIDs(ids ...int64) *UserUpdateOne {
  2214. _u.mutation.RemoveAllowedGroupIDs(ids...)
  2215. return _u
  2216. }
  2217. // RemoveAllowedGroups removes "allowed_groups" edges to Group entities.
  2218. func (_u *UserUpdateOne) RemoveAllowedGroups(v ...*Group) *UserUpdateOne {
  2219. ids := make([]int64, len(v))
  2220. for i := range v {
  2221. ids[i] = v[i].ID
  2222. }
  2223. return _u.RemoveAllowedGroupIDs(ids...)
  2224. }
  2225. // ClearUsageLogs clears all "usage_logs" edges to the UsageLog entity.
  2226. func (_u *UserUpdateOne) ClearUsageLogs() *UserUpdateOne {
  2227. _u.mutation.ClearUsageLogs()
  2228. return _u
  2229. }
  2230. // RemoveUsageLogIDs removes the "usage_logs" edge to UsageLog entities by IDs.
  2231. func (_u *UserUpdateOne) RemoveUsageLogIDs(ids ...int64) *UserUpdateOne {
  2232. _u.mutation.RemoveUsageLogIDs(ids...)
  2233. return _u
  2234. }
  2235. // RemoveUsageLogs removes "usage_logs" edges to UsageLog entities.
  2236. func (_u *UserUpdateOne) RemoveUsageLogs(v ...*UsageLog) *UserUpdateOne {
  2237. ids := make([]int64, len(v))
  2238. for i := range v {
  2239. ids[i] = v[i].ID
  2240. }
  2241. return _u.RemoveUsageLogIDs(ids...)
  2242. }
  2243. // ClearAttributeValues clears all "attribute_values" edges to the UserAttributeValue entity.
  2244. func (_u *UserUpdateOne) ClearAttributeValues() *UserUpdateOne {
  2245. _u.mutation.ClearAttributeValues()
  2246. return _u
  2247. }
  2248. // RemoveAttributeValueIDs removes the "attribute_values" edge to UserAttributeValue entities by IDs.
  2249. func (_u *UserUpdateOne) RemoveAttributeValueIDs(ids ...int64) *UserUpdateOne {
  2250. _u.mutation.RemoveAttributeValueIDs(ids...)
  2251. return _u
  2252. }
  2253. // RemoveAttributeValues removes "attribute_values" edges to UserAttributeValue entities.
  2254. func (_u *UserUpdateOne) RemoveAttributeValues(v ...*UserAttributeValue) *UserUpdateOne {
  2255. ids := make([]int64, len(v))
  2256. for i := range v {
  2257. ids[i] = v[i].ID
  2258. }
  2259. return _u.RemoveAttributeValueIDs(ids...)
  2260. }
  2261. // ClearPromoCodeUsages clears all "promo_code_usages" edges to the PromoCodeUsage entity.
  2262. func (_u *UserUpdateOne) ClearPromoCodeUsages() *UserUpdateOne {
  2263. _u.mutation.ClearPromoCodeUsages()
  2264. return _u
  2265. }
  2266. // RemovePromoCodeUsageIDs removes the "promo_code_usages" edge to PromoCodeUsage entities by IDs.
  2267. func (_u *UserUpdateOne) RemovePromoCodeUsageIDs(ids ...int64) *UserUpdateOne {
  2268. _u.mutation.RemovePromoCodeUsageIDs(ids...)
  2269. return _u
  2270. }
  2271. // RemovePromoCodeUsages removes "promo_code_usages" edges to PromoCodeUsage entities.
  2272. func (_u *UserUpdateOne) RemovePromoCodeUsages(v ...*PromoCodeUsage) *UserUpdateOne {
  2273. ids := make([]int64, len(v))
  2274. for i := range v {
  2275. ids[i] = v[i].ID
  2276. }
  2277. return _u.RemovePromoCodeUsageIDs(ids...)
  2278. }
  2279. // ClearPaymentOrders clears all "payment_orders" edges to the PaymentOrder entity.
  2280. func (_u *UserUpdateOne) ClearPaymentOrders() *UserUpdateOne {
  2281. _u.mutation.ClearPaymentOrders()
  2282. return _u
  2283. }
  2284. // RemovePaymentOrderIDs removes the "payment_orders" edge to PaymentOrder entities by IDs.
  2285. func (_u *UserUpdateOne) RemovePaymentOrderIDs(ids ...int64) *UserUpdateOne {
  2286. _u.mutation.RemovePaymentOrderIDs(ids...)
  2287. return _u
  2288. }
  2289. // RemovePaymentOrders removes "payment_orders" edges to PaymentOrder entities.
  2290. func (_u *UserUpdateOne) RemovePaymentOrders(v ...*PaymentOrder) *UserUpdateOne {
  2291. ids := make([]int64, len(v))
  2292. for i := range v {
  2293. ids[i] = v[i].ID
  2294. }
  2295. return _u.RemovePaymentOrderIDs(ids...)
  2296. }
  2297. // ClearAuthIdentities clears all "auth_identities" edges to the AuthIdentity entity.
  2298. func (_u *UserUpdateOne) ClearAuthIdentities() *UserUpdateOne {
  2299. _u.mutation.ClearAuthIdentities()
  2300. return _u
  2301. }
  2302. // RemoveAuthIdentityIDs removes the "auth_identities" edge to AuthIdentity entities by IDs.
  2303. func (_u *UserUpdateOne) RemoveAuthIdentityIDs(ids ...int64) *UserUpdateOne {
  2304. _u.mutation.RemoveAuthIdentityIDs(ids...)
  2305. return _u
  2306. }
  2307. // RemoveAuthIdentities removes "auth_identities" edges to AuthIdentity entities.
  2308. func (_u *UserUpdateOne) RemoveAuthIdentities(v ...*AuthIdentity) *UserUpdateOne {
  2309. ids := make([]int64, len(v))
  2310. for i := range v {
  2311. ids[i] = v[i].ID
  2312. }
  2313. return _u.RemoveAuthIdentityIDs(ids...)
  2314. }
  2315. // ClearPendingAuthSessions clears all "pending_auth_sessions" edges to the PendingAuthSession entity.
  2316. func (_u *UserUpdateOne) ClearPendingAuthSessions() *UserUpdateOne {
  2317. _u.mutation.ClearPendingAuthSessions()
  2318. return _u
  2319. }
  2320. // RemovePendingAuthSessionIDs removes the "pending_auth_sessions" edge to PendingAuthSession entities by IDs.
  2321. func (_u *UserUpdateOne) RemovePendingAuthSessionIDs(ids ...int64) *UserUpdateOne {
  2322. _u.mutation.RemovePendingAuthSessionIDs(ids...)
  2323. return _u
  2324. }
  2325. // RemovePendingAuthSessions removes "pending_auth_sessions" edges to PendingAuthSession entities.
  2326. func (_u *UserUpdateOne) RemovePendingAuthSessions(v ...*PendingAuthSession) *UserUpdateOne {
  2327. ids := make([]int64, len(v))
  2328. for i := range v {
  2329. ids[i] = v[i].ID
  2330. }
  2331. return _u.RemovePendingAuthSessionIDs(ids...)
  2332. }
  2333. // ClearPlatformQuotas clears all "platform_quotas" edges to the UserPlatformQuota entity.
  2334. func (_u *UserUpdateOne) ClearPlatformQuotas() *UserUpdateOne {
  2335. _u.mutation.ClearPlatformQuotas()
  2336. return _u
  2337. }
  2338. // RemovePlatformQuotaIDs removes the "platform_quotas" edge to UserPlatformQuota entities by IDs.
  2339. func (_u *UserUpdateOne) RemovePlatformQuotaIDs(ids ...int64) *UserUpdateOne {
  2340. _u.mutation.RemovePlatformQuotaIDs(ids...)
  2341. return _u
  2342. }
  2343. // RemovePlatformQuotas removes "platform_quotas" edges to UserPlatformQuota entities.
  2344. func (_u *UserUpdateOne) RemovePlatformQuotas(v ...*UserPlatformQuota) *UserUpdateOne {
  2345. ids := make([]int64, len(v))
  2346. for i := range v {
  2347. ids[i] = v[i].ID
  2348. }
  2349. return _u.RemovePlatformQuotaIDs(ids...)
  2350. }
  2351. // Where appends a list predicates to the UserUpdate builder.
  2352. func (_u *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne {
  2353. _u.mutation.Where(ps...)
  2354. return _u
  2355. }
  2356. // Select allows selecting one or more fields (columns) of the returned entity.
  2357. // The default is selecting all fields defined in the entity schema.
  2358. func (_u *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne {
  2359. _u.fields = append([]string{field}, fields...)
  2360. return _u
  2361. }
  2362. // Save executes the query and returns the updated User entity.
  2363. func (_u *UserUpdateOne) Save(ctx context.Context) (*User, error) {
  2364. if err := _u.defaults(); err != nil {
  2365. return nil, err
  2366. }
  2367. return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
  2368. }
  2369. // SaveX is like Save, but panics if an error occurs.
  2370. func (_u *UserUpdateOne) SaveX(ctx context.Context) *User {
  2371. node, err := _u.Save(ctx)
  2372. if err != nil {
  2373. panic(err)
  2374. }
  2375. return node
  2376. }
  2377. // Exec executes the query on the entity.
  2378. func (_u *UserUpdateOne) Exec(ctx context.Context) error {
  2379. _, err := _u.Save(ctx)
  2380. return err
  2381. }
  2382. // ExecX is like Exec, but panics if an error occurs.
  2383. func (_u *UserUpdateOne) ExecX(ctx context.Context) {
  2384. if err := _u.Exec(ctx); err != nil {
  2385. panic(err)
  2386. }
  2387. }
  2388. // defaults sets the default values of the builder before save.
  2389. func (_u *UserUpdateOne) defaults() error {
  2390. if _, ok := _u.mutation.UpdatedAt(); !ok {
  2391. if user.UpdateDefaultUpdatedAt == nil {
  2392. return fmt.Errorf("ent: uninitialized user.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  2393. }
  2394. v := user.UpdateDefaultUpdatedAt()
  2395. _u.mutation.SetUpdatedAt(v)
  2396. }
  2397. return nil
  2398. }
  2399. // check runs all checks and user-defined validators on the builder.
  2400. func (_u *UserUpdateOne) check() error {
  2401. if v, ok := _u.mutation.Email(); ok {
  2402. if err := user.EmailValidator(v); err != nil {
  2403. return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)}
  2404. }
  2405. }
  2406. if v, ok := _u.mutation.PasswordHash(); ok {
  2407. if err := user.PasswordHashValidator(v); err != nil {
  2408. return &ValidationError{Name: "password_hash", err: fmt.Errorf(`ent: validator failed for field "User.password_hash": %w`, err)}
  2409. }
  2410. }
  2411. if v, ok := _u.mutation.Role(); ok {
  2412. if err := user.RoleValidator(v); err != nil {
  2413. return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "User.role": %w`, err)}
  2414. }
  2415. }
  2416. if v, ok := _u.mutation.Status(); ok {
  2417. if err := user.StatusValidator(v); err != nil {
  2418. return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "User.status": %w`, err)}
  2419. }
  2420. }
  2421. if v, ok := _u.mutation.Username(); ok {
  2422. if err := user.UsernameValidator(v); err != nil {
  2423. return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)}
  2424. }
  2425. }
  2426. if v, ok := _u.mutation.SignupSource(); ok {
  2427. if err := user.SignupSourceValidator(v); err != nil {
  2428. return &ValidationError{Name: "signup_source", err: fmt.Errorf(`ent: validator failed for field "User.signup_source": %w`, err)}
  2429. }
  2430. }
  2431. return nil
  2432. }
  2433. func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) {
  2434. if err := _u.check(); err != nil {
  2435. return _node, err
  2436. }
  2437. _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64))
  2438. id, ok := _u.mutation.ID()
  2439. if !ok {
  2440. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "User.id" for update`)}
  2441. }
  2442. _spec.Node.ID.Value = id
  2443. if fields := _u.fields; len(fields) > 0 {
  2444. _spec.Node.Columns = make([]string, 0, len(fields))
  2445. _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID)
  2446. for _, f := range fields {
  2447. if !user.ValidColumn(f) {
  2448. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  2449. }
  2450. if f != user.FieldID {
  2451. _spec.Node.Columns = append(_spec.Node.Columns, f)
  2452. }
  2453. }
  2454. }
  2455. if ps := _u.mutation.predicates; len(ps) > 0 {
  2456. _spec.Predicate = func(selector *sql.Selector) {
  2457. for i := range ps {
  2458. ps[i](selector)
  2459. }
  2460. }
  2461. }
  2462. if value, ok := _u.mutation.UpdatedAt(); ok {
  2463. _spec.SetField(user.FieldUpdatedAt, field.TypeTime, value)
  2464. }
  2465. if value, ok := _u.mutation.DeletedAt(); ok {
  2466. _spec.SetField(user.FieldDeletedAt, field.TypeTime, value)
  2467. }
  2468. if _u.mutation.DeletedAtCleared() {
  2469. _spec.ClearField(user.FieldDeletedAt, field.TypeTime)
  2470. }
  2471. if value, ok := _u.mutation.Email(); ok {
  2472. _spec.SetField(user.FieldEmail, field.TypeString, value)
  2473. }
  2474. if value, ok := _u.mutation.PasswordHash(); ok {
  2475. _spec.SetField(user.FieldPasswordHash, field.TypeString, value)
  2476. }
  2477. if value, ok := _u.mutation.Role(); ok {
  2478. _spec.SetField(user.FieldRole, field.TypeString, value)
  2479. }
  2480. if value, ok := _u.mutation.Balance(); ok {
  2481. _spec.SetField(user.FieldBalance, field.TypeFloat64, value)
  2482. }
  2483. if value, ok := _u.mutation.AddedBalance(); ok {
  2484. _spec.AddField(user.FieldBalance, field.TypeFloat64, value)
  2485. }
  2486. if value, ok := _u.mutation.FrozenBalance(); ok {
  2487. _spec.SetField(user.FieldFrozenBalance, field.TypeFloat64, value)
  2488. }
  2489. if value, ok := _u.mutation.AddedFrozenBalance(); ok {
  2490. _spec.AddField(user.FieldFrozenBalance, field.TypeFloat64, value)
  2491. }
  2492. if value, ok := _u.mutation.Concurrency(); ok {
  2493. _spec.SetField(user.FieldConcurrency, field.TypeInt, value)
  2494. }
  2495. if value, ok := _u.mutation.AddedConcurrency(); ok {
  2496. _spec.AddField(user.FieldConcurrency, field.TypeInt, value)
  2497. }
  2498. if value, ok := _u.mutation.Status(); ok {
  2499. _spec.SetField(user.FieldStatus, field.TypeString, value)
  2500. }
  2501. if value, ok := _u.mutation.Username(); ok {
  2502. _spec.SetField(user.FieldUsername, field.TypeString, value)
  2503. }
  2504. if value, ok := _u.mutation.Notes(); ok {
  2505. _spec.SetField(user.FieldNotes, field.TypeString, value)
  2506. }
  2507. if value, ok := _u.mutation.TotpSecretEncrypted(); ok {
  2508. _spec.SetField(user.FieldTotpSecretEncrypted, field.TypeString, value)
  2509. }
  2510. if _u.mutation.TotpSecretEncryptedCleared() {
  2511. _spec.ClearField(user.FieldTotpSecretEncrypted, field.TypeString)
  2512. }
  2513. if value, ok := _u.mutation.TotpEnabled(); ok {
  2514. _spec.SetField(user.FieldTotpEnabled, field.TypeBool, value)
  2515. }
  2516. if value, ok := _u.mutation.TotpEnabledAt(); ok {
  2517. _spec.SetField(user.FieldTotpEnabledAt, field.TypeTime, value)
  2518. }
  2519. if _u.mutation.TotpEnabledAtCleared() {
  2520. _spec.ClearField(user.FieldTotpEnabledAt, field.TypeTime)
  2521. }
  2522. if value, ok := _u.mutation.SignupSource(); ok {
  2523. _spec.SetField(user.FieldSignupSource, field.TypeString, value)
  2524. }
  2525. if value, ok := _u.mutation.LastLoginAt(); ok {
  2526. _spec.SetField(user.FieldLastLoginAt, field.TypeTime, value)
  2527. }
  2528. if _u.mutation.LastLoginAtCleared() {
  2529. _spec.ClearField(user.FieldLastLoginAt, field.TypeTime)
  2530. }
  2531. if value, ok := _u.mutation.LastActiveAt(); ok {
  2532. _spec.SetField(user.FieldLastActiveAt, field.TypeTime, value)
  2533. }
  2534. if _u.mutation.LastActiveAtCleared() {
  2535. _spec.ClearField(user.FieldLastActiveAt, field.TypeTime)
  2536. }
  2537. if value, ok := _u.mutation.RestrictPublicGroups(); ok {
  2538. _spec.SetField(user.FieldRestrictPublicGroups, field.TypeBool, value)
  2539. }
  2540. if value, ok := _u.mutation.BalanceNotifyEnabled(); ok {
  2541. _spec.SetField(user.FieldBalanceNotifyEnabled, field.TypeBool, value)
  2542. }
  2543. if value, ok := _u.mutation.BalanceNotifyThresholdType(); ok {
  2544. _spec.SetField(user.FieldBalanceNotifyThresholdType, field.TypeString, value)
  2545. }
  2546. if value, ok := _u.mutation.BalanceNotifyThreshold(); ok {
  2547. _spec.SetField(user.FieldBalanceNotifyThreshold, field.TypeFloat64, value)
  2548. }
  2549. if value, ok := _u.mutation.AddedBalanceNotifyThreshold(); ok {
  2550. _spec.AddField(user.FieldBalanceNotifyThreshold, field.TypeFloat64, value)
  2551. }
  2552. if _u.mutation.BalanceNotifyThresholdCleared() {
  2553. _spec.ClearField(user.FieldBalanceNotifyThreshold, field.TypeFloat64)
  2554. }
  2555. if value, ok := _u.mutation.BalanceNotifyExtraEmails(); ok {
  2556. _spec.SetField(user.FieldBalanceNotifyExtraEmails, field.TypeString, value)
  2557. }
  2558. if value, ok := _u.mutation.TotalRecharged(); ok {
  2559. _spec.SetField(user.FieldTotalRecharged, field.TypeFloat64, value)
  2560. }
  2561. if value, ok := _u.mutation.AddedTotalRecharged(); ok {
  2562. _spec.AddField(user.FieldTotalRecharged, field.TypeFloat64, value)
  2563. }
  2564. if value, ok := _u.mutation.RpmLimit(); ok {
  2565. _spec.SetField(user.FieldRpmLimit, field.TypeInt, value)
  2566. }
  2567. if value, ok := _u.mutation.AddedRpmLimit(); ok {
  2568. _spec.AddField(user.FieldRpmLimit, field.TypeInt, value)
  2569. }
  2570. if _u.mutation.APIKeysCleared() {
  2571. edge := &sqlgraph.EdgeSpec{
  2572. Rel: sqlgraph.O2M,
  2573. Inverse: false,
  2574. Table: user.APIKeysTable,
  2575. Columns: []string{user.APIKeysColumn},
  2576. Bidi: false,
  2577. Target: &sqlgraph.EdgeTarget{
  2578. IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64),
  2579. },
  2580. }
  2581. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2582. }
  2583. if nodes := _u.mutation.RemovedAPIKeysIDs(); len(nodes) > 0 && !_u.mutation.APIKeysCleared() {
  2584. edge := &sqlgraph.EdgeSpec{
  2585. Rel: sqlgraph.O2M,
  2586. Inverse: false,
  2587. Table: user.APIKeysTable,
  2588. Columns: []string{user.APIKeysColumn},
  2589. Bidi: false,
  2590. Target: &sqlgraph.EdgeTarget{
  2591. IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64),
  2592. },
  2593. }
  2594. for _, k := range nodes {
  2595. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2596. }
  2597. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2598. }
  2599. if nodes := _u.mutation.APIKeysIDs(); len(nodes) > 0 {
  2600. edge := &sqlgraph.EdgeSpec{
  2601. Rel: sqlgraph.O2M,
  2602. Inverse: false,
  2603. Table: user.APIKeysTable,
  2604. Columns: []string{user.APIKeysColumn},
  2605. Bidi: false,
  2606. Target: &sqlgraph.EdgeTarget{
  2607. IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64),
  2608. },
  2609. }
  2610. for _, k := range nodes {
  2611. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2612. }
  2613. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  2614. }
  2615. if _u.mutation.RedeemCodesCleared() {
  2616. edge := &sqlgraph.EdgeSpec{
  2617. Rel: sqlgraph.O2M,
  2618. Inverse: false,
  2619. Table: user.RedeemCodesTable,
  2620. Columns: []string{user.RedeemCodesColumn},
  2621. Bidi: false,
  2622. Target: &sqlgraph.EdgeTarget{
  2623. IDSpec: sqlgraph.NewFieldSpec(redeemcode.FieldID, field.TypeInt64),
  2624. },
  2625. }
  2626. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2627. }
  2628. if nodes := _u.mutation.RemovedRedeemCodesIDs(); len(nodes) > 0 && !_u.mutation.RedeemCodesCleared() {
  2629. edge := &sqlgraph.EdgeSpec{
  2630. Rel: sqlgraph.O2M,
  2631. Inverse: false,
  2632. Table: user.RedeemCodesTable,
  2633. Columns: []string{user.RedeemCodesColumn},
  2634. Bidi: false,
  2635. Target: &sqlgraph.EdgeTarget{
  2636. IDSpec: sqlgraph.NewFieldSpec(redeemcode.FieldID, field.TypeInt64),
  2637. },
  2638. }
  2639. for _, k := range nodes {
  2640. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2641. }
  2642. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2643. }
  2644. if nodes := _u.mutation.RedeemCodesIDs(); len(nodes) > 0 {
  2645. edge := &sqlgraph.EdgeSpec{
  2646. Rel: sqlgraph.O2M,
  2647. Inverse: false,
  2648. Table: user.RedeemCodesTable,
  2649. Columns: []string{user.RedeemCodesColumn},
  2650. Bidi: false,
  2651. Target: &sqlgraph.EdgeTarget{
  2652. IDSpec: sqlgraph.NewFieldSpec(redeemcode.FieldID, field.TypeInt64),
  2653. },
  2654. }
  2655. for _, k := range nodes {
  2656. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2657. }
  2658. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  2659. }
  2660. if _u.mutation.SubscriptionsCleared() {
  2661. edge := &sqlgraph.EdgeSpec{
  2662. Rel: sqlgraph.O2M,
  2663. Inverse: false,
  2664. Table: user.SubscriptionsTable,
  2665. Columns: []string{user.SubscriptionsColumn},
  2666. Bidi: false,
  2667. Target: &sqlgraph.EdgeTarget{
  2668. IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
  2669. },
  2670. }
  2671. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2672. }
  2673. if nodes := _u.mutation.RemovedSubscriptionsIDs(); len(nodes) > 0 && !_u.mutation.SubscriptionsCleared() {
  2674. edge := &sqlgraph.EdgeSpec{
  2675. Rel: sqlgraph.O2M,
  2676. Inverse: false,
  2677. Table: user.SubscriptionsTable,
  2678. Columns: []string{user.SubscriptionsColumn},
  2679. Bidi: false,
  2680. Target: &sqlgraph.EdgeTarget{
  2681. IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
  2682. },
  2683. }
  2684. for _, k := range nodes {
  2685. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2686. }
  2687. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2688. }
  2689. if nodes := _u.mutation.SubscriptionsIDs(); len(nodes) > 0 {
  2690. edge := &sqlgraph.EdgeSpec{
  2691. Rel: sqlgraph.O2M,
  2692. Inverse: false,
  2693. Table: user.SubscriptionsTable,
  2694. Columns: []string{user.SubscriptionsColumn},
  2695. Bidi: false,
  2696. Target: &sqlgraph.EdgeTarget{
  2697. IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
  2698. },
  2699. }
  2700. for _, k := range nodes {
  2701. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2702. }
  2703. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  2704. }
  2705. if _u.mutation.AssignedSubscriptionsCleared() {
  2706. edge := &sqlgraph.EdgeSpec{
  2707. Rel: sqlgraph.O2M,
  2708. Inverse: false,
  2709. Table: user.AssignedSubscriptionsTable,
  2710. Columns: []string{user.AssignedSubscriptionsColumn},
  2711. Bidi: false,
  2712. Target: &sqlgraph.EdgeTarget{
  2713. IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
  2714. },
  2715. }
  2716. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2717. }
  2718. if nodes := _u.mutation.RemovedAssignedSubscriptionsIDs(); len(nodes) > 0 && !_u.mutation.AssignedSubscriptionsCleared() {
  2719. edge := &sqlgraph.EdgeSpec{
  2720. Rel: sqlgraph.O2M,
  2721. Inverse: false,
  2722. Table: user.AssignedSubscriptionsTable,
  2723. Columns: []string{user.AssignedSubscriptionsColumn},
  2724. Bidi: false,
  2725. Target: &sqlgraph.EdgeTarget{
  2726. IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
  2727. },
  2728. }
  2729. for _, k := range nodes {
  2730. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2731. }
  2732. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2733. }
  2734. if nodes := _u.mutation.AssignedSubscriptionsIDs(); len(nodes) > 0 {
  2735. edge := &sqlgraph.EdgeSpec{
  2736. Rel: sqlgraph.O2M,
  2737. Inverse: false,
  2738. Table: user.AssignedSubscriptionsTable,
  2739. Columns: []string{user.AssignedSubscriptionsColumn},
  2740. Bidi: false,
  2741. Target: &sqlgraph.EdgeTarget{
  2742. IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
  2743. },
  2744. }
  2745. for _, k := range nodes {
  2746. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2747. }
  2748. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  2749. }
  2750. if _u.mutation.AnnouncementReadsCleared() {
  2751. edge := &sqlgraph.EdgeSpec{
  2752. Rel: sqlgraph.O2M,
  2753. Inverse: false,
  2754. Table: user.AnnouncementReadsTable,
  2755. Columns: []string{user.AnnouncementReadsColumn},
  2756. Bidi: false,
  2757. Target: &sqlgraph.EdgeTarget{
  2758. IDSpec: sqlgraph.NewFieldSpec(announcementread.FieldID, field.TypeInt64),
  2759. },
  2760. }
  2761. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2762. }
  2763. if nodes := _u.mutation.RemovedAnnouncementReadsIDs(); len(nodes) > 0 && !_u.mutation.AnnouncementReadsCleared() {
  2764. edge := &sqlgraph.EdgeSpec{
  2765. Rel: sqlgraph.O2M,
  2766. Inverse: false,
  2767. Table: user.AnnouncementReadsTable,
  2768. Columns: []string{user.AnnouncementReadsColumn},
  2769. Bidi: false,
  2770. Target: &sqlgraph.EdgeTarget{
  2771. IDSpec: sqlgraph.NewFieldSpec(announcementread.FieldID, field.TypeInt64),
  2772. },
  2773. }
  2774. for _, k := range nodes {
  2775. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2776. }
  2777. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2778. }
  2779. if nodes := _u.mutation.AnnouncementReadsIDs(); len(nodes) > 0 {
  2780. edge := &sqlgraph.EdgeSpec{
  2781. Rel: sqlgraph.O2M,
  2782. Inverse: false,
  2783. Table: user.AnnouncementReadsTable,
  2784. Columns: []string{user.AnnouncementReadsColumn},
  2785. Bidi: false,
  2786. Target: &sqlgraph.EdgeTarget{
  2787. IDSpec: sqlgraph.NewFieldSpec(announcementread.FieldID, field.TypeInt64),
  2788. },
  2789. }
  2790. for _, k := range nodes {
  2791. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2792. }
  2793. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  2794. }
  2795. if _u.mutation.AllowedGroupsCleared() {
  2796. edge := &sqlgraph.EdgeSpec{
  2797. Rel: sqlgraph.M2M,
  2798. Inverse: false,
  2799. Table: user.AllowedGroupsTable,
  2800. Columns: user.AllowedGroupsPrimaryKey,
  2801. Bidi: false,
  2802. Target: &sqlgraph.EdgeTarget{
  2803. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  2804. },
  2805. }
  2806. createE := &UserAllowedGroupCreate{config: _u.config, mutation: newUserAllowedGroupMutation(_u.config, OpCreate)}
  2807. createE.defaults()
  2808. _, specE := createE.createSpec()
  2809. edge.Target.Fields = specE.Fields
  2810. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2811. }
  2812. if nodes := _u.mutation.RemovedAllowedGroupsIDs(); len(nodes) > 0 && !_u.mutation.AllowedGroupsCleared() {
  2813. edge := &sqlgraph.EdgeSpec{
  2814. Rel: sqlgraph.M2M,
  2815. Inverse: false,
  2816. Table: user.AllowedGroupsTable,
  2817. Columns: user.AllowedGroupsPrimaryKey,
  2818. Bidi: false,
  2819. Target: &sqlgraph.EdgeTarget{
  2820. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  2821. },
  2822. }
  2823. for _, k := range nodes {
  2824. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2825. }
  2826. createE := &UserAllowedGroupCreate{config: _u.config, mutation: newUserAllowedGroupMutation(_u.config, OpCreate)}
  2827. createE.defaults()
  2828. _, specE := createE.createSpec()
  2829. edge.Target.Fields = specE.Fields
  2830. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2831. }
  2832. if nodes := _u.mutation.AllowedGroupsIDs(); len(nodes) > 0 {
  2833. edge := &sqlgraph.EdgeSpec{
  2834. Rel: sqlgraph.M2M,
  2835. Inverse: false,
  2836. Table: user.AllowedGroupsTable,
  2837. Columns: user.AllowedGroupsPrimaryKey,
  2838. Bidi: false,
  2839. Target: &sqlgraph.EdgeTarget{
  2840. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  2841. },
  2842. }
  2843. for _, k := range nodes {
  2844. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2845. }
  2846. createE := &UserAllowedGroupCreate{config: _u.config, mutation: newUserAllowedGroupMutation(_u.config, OpCreate)}
  2847. createE.defaults()
  2848. _, specE := createE.createSpec()
  2849. edge.Target.Fields = specE.Fields
  2850. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  2851. }
  2852. if _u.mutation.UsageLogsCleared() {
  2853. edge := &sqlgraph.EdgeSpec{
  2854. Rel: sqlgraph.O2M,
  2855. Inverse: false,
  2856. Table: user.UsageLogsTable,
  2857. Columns: []string{user.UsageLogsColumn},
  2858. Bidi: false,
  2859. Target: &sqlgraph.EdgeTarget{
  2860. IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
  2861. },
  2862. }
  2863. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2864. }
  2865. if nodes := _u.mutation.RemovedUsageLogsIDs(); len(nodes) > 0 && !_u.mutation.UsageLogsCleared() {
  2866. edge := &sqlgraph.EdgeSpec{
  2867. Rel: sqlgraph.O2M,
  2868. Inverse: false,
  2869. Table: user.UsageLogsTable,
  2870. Columns: []string{user.UsageLogsColumn},
  2871. Bidi: false,
  2872. Target: &sqlgraph.EdgeTarget{
  2873. IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
  2874. },
  2875. }
  2876. for _, k := range nodes {
  2877. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2878. }
  2879. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2880. }
  2881. if nodes := _u.mutation.UsageLogsIDs(); len(nodes) > 0 {
  2882. edge := &sqlgraph.EdgeSpec{
  2883. Rel: sqlgraph.O2M,
  2884. Inverse: false,
  2885. Table: user.UsageLogsTable,
  2886. Columns: []string{user.UsageLogsColumn},
  2887. Bidi: false,
  2888. Target: &sqlgraph.EdgeTarget{
  2889. IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
  2890. },
  2891. }
  2892. for _, k := range nodes {
  2893. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2894. }
  2895. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  2896. }
  2897. if _u.mutation.AttributeValuesCleared() {
  2898. edge := &sqlgraph.EdgeSpec{
  2899. Rel: sqlgraph.O2M,
  2900. Inverse: false,
  2901. Table: user.AttributeValuesTable,
  2902. Columns: []string{user.AttributeValuesColumn},
  2903. Bidi: false,
  2904. Target: &sqlgraph.EdgeTarget{
  2905. IDSpec: sqlgraph.NewFieldSpec(userattributevalue.FieldID, field.TypeInt64),
  2906. },
  2907. }
  2908. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2909. }
  2910. if nodes := _u.mutation.RemovedAttributeValuesIDs(); len(nodes) > 0 && !_u.mutation.AttributeValuesCleared() {
  2911. edge := &sqlgraph.EdgeSpec{
  2912. Rel: sqlgraph.O2M,
  2913. Inverse: false,
  2914. Table: user.AttributeValuesTable,
  2915. Columns: []string{user.AttributeValuesColumn},
  2916. Bidi: false,
  2917. Target: &sqlgraph.EdgeTarget{
  2918. IDSpec: sqlgraph.NewFieldSpec(userattributevalue.FieldID, field.TypeInt64),
  2919. },
  2920. }
  2921. for _, k := range nodes {
  2922. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2923. }
  2924. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2925. }
  2926. if nodes := _u.mutation.AttributeValuesIDs(); len(nodes) > 0 {
  2927. edge := &sqlgraph.EdgeSpec{
  2928. Rel: sqlgraph.O2M,
  2929. Inverse: false,
  2930. Table: user.AttributeValuesTable,
  2931. Columns: []string{user.AttributeValuesColumn},
  2932. Bidi: false,
  2933. Target: &sqlgraph.EdgeTarget{
  2934. IDSpec: sqlgraph.NewFieldSpec(userattributevalue.FieldID, field.TypeInt64),
  2935. },
  2936. }
  2937. for _, k := range nodes {
  2938. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2939. }
  2940. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  2941. }
  2942. if _u.mutation.PromoCodeUsagesCleared() {
  2943. edge := &sqlgraph.EdgeSpec{
  2944. Rel: sqlgraph.O2M,
  2945. Inverse: false,
  2946. Table: user.PromoCodeUsagesTable,
  2947. Columns: []string{user.PromoCodeUsagesColumn},
  2948. Bidi: false,
  2949. Target: &sqlgraph.EdgeTarget{
  2950. IDSpec: sqlgraph.NewFieldSpec(promocodeusage.FieldID, field.TypeInt64),
  2951. },
  2952. }
  2953. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2954. }
  2955. if nodes := _u.mutation.RemovedPromoCodeUsagesIDs(); len(nodes) > 0 && !_u.mutation.PromoCodeUsagesCleared() {
  2956. edge := &sqlgraph.EdgeSpec{
  2957. Rel: sqlgraph.O2M,
  2958. Inverse: false,
  2959. Table: user.PromoCodeUsagesTable,
  2960. Columns: []string{user.PromoCodeUsagesColumn},
  2961. Bidi: false,
  2962. Target: &sqlgraph.EdgeTarget{
  2963. IDSpec: sqlgraph.NewFieldSpec(promocodeusage.FieldID, field.TypeInt64),
  2964. },
  2965. }
  2966. for _, k := range nodes {
  2967. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2968. }
  2969. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2970. }
  2971. if nodes := _u.mutation.PromoCodeUsagesIDs(); len(nodes) > 0 {
  2972. edge := &sqlgraph.EdgeSpec{
  2973. Rel: sqlgraph.O2M,
  2974. Inverse: false,
  2975. Table: user.PromoCodeUsagesTable,
  2976. Columns: []string{user.PromoCodeUsagesColumn},
  2977. Bidi: false,
  2978. Target: &sqlgraph.EdgeTarget{
  2979. IDSpec: sqlgraph.NewFieldSpec(promocodeusage.FieldID, field.TypeInt64),
  2980. },
  2981. }
  2982. for _, k := range nodes {
  2983. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2984. }
  2985. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  2986. }
  2987. if _u.mutation.PaymentOrdersCleared() {
  2988. edge := &sqlgraph.EdgeSpec{
  2989. Rel: sqlgraph.O2M,
  2990. Inverse: false,
  2991. Table: user.PaymentOrdersTable,
  2992. Columns: []string{user.PaymentOrdersColumn},
  2993. Bidi: false,
  2994. Target: &sqlgraph.EdgeTarget{
  2995. IDSpec: sqlgraph.NewFieldSpec(paymentorder.FieldID, field.TypeInt64),
  2996. },
  2997. }
  2998. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2999. }
  3000. if nodes := _u.mutation.RemovedPaymentOrdersIDs(); len(nodes) > 0 && !_u.mutation.PaymentOrdersCleared() {
  3001. edge := &sqlgraph.EdgeSpec{
  3002. Rel: sqlgraph.O2M,
  3003. Inverse: false,
  3004. Table: user.PaymentOrdersTable,
  3005. Columns: []string{user.PaymentOrdersColumn},
  3006. Bidi: false,
  3007. Target: &sqlgraph.EdgeTarget{
  3008. IDSpec: sqlgraph.NewFieldSpec(paymentorder.FieldID, field.TypeInt64),
  3009. },
  3010. }
  3011. for _, k := range nodes {
  3012. edge.Target.Nodes = append(edge.Target.Nodes, k)
  3013. }
  3014. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  3015. }
  3016. if nodes := _u.mutation.PaymentOrdersIDs(); len(nodes) > 0 {
  3017. edge := &sqlgraph.EdgeSpec{
  3018. Rel: sqlgraph.O2M,
  3019. Inverse: false,
  3020. Table: user.PaymentOrdersTable,
  3021. Columns: []string{user.PaymentOrdersColumn},
  3022. Bidi: false,
  3023. Target: &sqlgraph.EdgeTarget{
  3024. IDSpec: sqlgraph.NewFieldSpec(paymentorder.FieldID, field.TypeInt64),
  3025. },
  3026. }
  3027. for _, k := range nodes {
  3028. edge.Target.Nodes = append(edge.Target.Nodes, k)
  3029. }
  3030. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  3031. }
  3032. if _u.mutation.AuthIdentitiesCleared() {
  3033. edge := &sqlgraph.EdgeSpec{
  3034. Rel: sqlgraph.O2M,
  3035. Inverse: false,
  3036. Table: user.AuthIdentitiesTable,
  3037. Columns: []string{user.AuthIdentitiesColumn},
  3038. Bidi: false,
  3039. Target: &sqlgraph.EdgeTarget{
  3040. IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
  3041. },
  3042. }
  3043. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  3044. }
  3045. if nodes := _u.mutation.RemovedAuthIdentitiesIDs(); len(nodes) > 0 && !_u.mutation.AuthIdentitiesCleared() {
  3046. edge := &sqlgraph.EdgeSpec{
  3047. Rel: sqlgraph.O2M,
  3048. Inverse: false,
  3049. Table: user.AuthIdentitiesTable,
  3050. Columns: []string{user.AuthIdentitiesColumn},
  3051. Bidi: false,
  3052. Target: &sqlgraph.EdgeTarget{
  3053. IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
  3054. },
  3055. }
  3056. for _, k := range nodes {
  3057. edge.Target.Nodes = append(edge.Target.Nodes, k)
  3058. }
  3059. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  3060. }
  3061. if nodes := _u.mutation.AuthIdentitiesIDs(); len(nodes) > 0 {
  3062. edge := &sqlgraph.EdgeSpec{
  3063. Rel: sqlgraph.O2M,
  3064. Inverse: false,
  3065. Table: user.AuthIdentitiesTable,
  3066. Columns: []string{user.AuthIdentitiesColumn},
  3067. Bidi: false,
  3068. Target: &sqlgraph.EdgeTarget{
  3069. IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
  3070. },
  3071. }
  3072. for _, k := range nodes {
  3073. edge.Target.Nodes = append(edge.Target.Nodes, k)
  3074. }
  3075. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  3076. }
  3077. if _u.mutation.PendingAuthSessionsCleared() {
  3078. edge := &sqlgraph.EdgeSpec{
  3079. Rel: sqlgraph.O2M,
  3080. Inverse: false,
  3081. Table: user.PendingAuthSessionsTable,
  3082. Columns: []string{user.PendingAuthSessionsColumn},
  3083. Bidi: false,
  3084. Target: &sqlgraph.EdgeTarget{
  3085. IDSpec: sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64),
  3086. },
  3087. }
  3088. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  3089. }
  3090. if nodes := _u.mutation.RemovedPendingAuthSessionsIDs(); len(nodes) > 0 && !_u.mutation.PendingAuthSessionsCleared() {
  3091. edge := &sqlgraph.EdgeSpec{
  3092. Rel: sqlgraph.O2M,
  3093. Inverse: false,
  3094. Table: user.PendingAuthSessionsTable,
  3095. Columns: []string{user.PendingAuthSessionsColumn},
  3096. Bidi: false,
  3097. Target: &sqlgraph.EdgeTarget{
  3098. IDSpec: sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64),
  3099. },
  3100. }
  3101. for _, k := range nodes {
  3102. edge.Target.Nodes = append(edge.Target.Nodes, k)
  3103. }
  3104. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  3105. }
  3106. if nodes := _u.mutation.PendingAuthSessionsIDs(); len(nodes) > 0 {
  3107. edge := &sqlgraph.EdgeSpec{
  3108. Rel: sqlgraph.O2M,
  3109. Inverse: false,
  3110. Table: user.PendingAuthSessionsTable,
  3111. Columns: []string{user.PendingAuthSessionsColumn},
  3112. Bidi: false,
  3113. Target: &sqlgraph.EdgeTarget{
  3114. IDSpec: sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64),
  3115. },
  3116. }
  3117. for _, k := range nodes {
  3118. edge.Target.Nodes = append(edge.Target.Nodes, k)
  3119. }
  3120. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  3121. }
  3122. if _u.mutation.PlatformQuotasCleared() {
  3123. edge := &sqlgraph.EdgeSpec{
  3124. Rel: sqlgraph.O2M,
  3125. Inverse: false,
  3126. Table: user.PlatformQuotasTable,
  3127. Columns: []string{user.PlatformQuotasColumn},
  3128. Bidi: false,
  3129. Target: &sqlgraph.EdgeTarget{
  3130. IDSpec: sqlgraph.NewFieldSpec(userplatformquota.FieldID, field.TypeInt64),
  3131. },
  3132. }
  3133. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  3134. }
  3135. if nodes := _u.mutation.RemovedPlatformQuotasIDs(); len(nodes) > 0 && !_u.mutation.PlatformQuotasCleared() {
  3136. edge := &sqlgraph.EdgeSpec{
  3137. Rel: sqlgraph.O2M,
  3138. Inverse: false,
  3139. Table: user.PlatformQuotasTable,
  3140. Columns: []string{user.PlatformQuotasColumn},
  3141. Bidi: false,
  3142. Target: &sqlgraph.EdgeTarget{
  3143. IDSpec: sqlgraph.NewFieldSpec(userplatformquota.FieldID, field.TypeInt64),
  3144. },
  3145. }
  3146. for _, k := range nodes {
  3147. edge.Target.Nodes = append(edge.Target.Nodes, k)
  3148. }
  3149. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  3150. }
  3151. if nodes := _u.mutation.PlatformQuotasIDs(); len(nodes) > 0 {
  3152. edge := &sqlgraph.EdgeSpec{
  3153. Rel: sqlgraph.O2M,
  3154. Inverse: false,
  3155. Table: user.PlatformQuotasTable,
  3156. Columns: []string{user.PlatformQuotasColumn},
  3157. Bidi: false,
  3158. Target: &sqlgraph.EdgeTarget{
  3159. IDSpec: sqlgraph.NewFieldSpec(userplatformquota.FieldID, field.TypeInt64),
  3160. },
  3161. }
  3162. for _, k := range nodes {
  3163. edge.Target.Nodes = append(edge.Target.Nodes, k)
  3164. }
  3165. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  3166. }
  3167. _node = &User{config: _u.config}
  3168. _spec.Assign = _node.assignValues
  3169. _spec.ScanValues = _node.scanValues
  3170. if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
  3171. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  3172. err = &NotFoundError{user.Label}
  3173. } else if sqlgraph.IsConstraintError(err) {
  3174. err = &ConstraintError{msg: err.Error(), wrap: err}
  3175. }
  3176. return nil, err
  3177. }
  3178. _u.mutation.done = true
  3179. return _node, nil
  3180. }