usagelog_update.go 98 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "entgo.io/ent/dialect/sql"
  8. "entgo.io/ent/dialect/sql/sqlgraph"
  9. "entgo.io/ent/schema/field"
  10. "github.com/Wei-Shaw/sub2api/ent/account"
  11. "github.com/Wei-Shaw/sub2api/ent/apikey"
  12. "github.com/Wei-Shaw/sub2api/ent/group"
  13. "github.com/Wei-Shaw/sub2api/ent/predicate"
  14. "github.com/Wei-Shaw/sub2api/ent/usagelog"
  15. "github.com/Wei-Shaw/sub2api/ent/user"
  16. "github.com/Wei-Shaw/sub2api/ent/usersubscription"
  17. )
  18. // UsageLogUpdate is the builder for updating UsageLog entities.
  19. type UsageLogUpdate struct {
  20. config
  21. hooks []Hook
  22. mutation *UsageLogMutation
  23. }
  24. // Where appends a list predicates to the UsageLogUpdate builder.
  25. func (_u *UsageLogUpdate) Where(ps ...predicate.UsageLog) *UsageLogUpdate {
  26. _u.mutation.Where(ps...)
  27. return _u
  28. }
  29. // SetUserID sets the "user_id" field.
  30. func (_u *UsageLogUpdate) SetUserID(v int64) *UsageLogUpdate {
  31. _u.mutation.SetUserID(v)
  32. return _u
  33. }
  34. // SetNillableUserID sets the "user_id" field if the given value is not nil.
  35. func (_u *UsageLogUpdate) SetNillableUserID(v *int64) *UsageLogUpdate {
  36. if v != nil {
  37. _u.SetUserID(*v)
  38. }
  39. return _u
  40. }
  41. // SetAPIKeyID sets the "api_key_id" field.
  42. func (_u *UsageLogUpdate) SetAPIKeyID(v int64) *UsageLogUpdate {
  43. _u.mutation.SetAPIKeyID(v)
  44. return _u
  45. }
  46. // SetNillableAPIKeyID sets the "api_key_id" field if the given value is not nil.
  47. func (_u *UsageLogUpdate) SetNillableAPIKeyID(v *int64) *UsageLogUpdate {
  48. if v != nil {
  49. _u.SetAPIKeyID(*v)
  50. }
  51. return _u
  52. }
  53. // SetAccountID sets the "account_id" field.
  54. func (_u *UsageLogUpdate) SetAccountID(v int64) *UsageLogUpdate {
  55. _u.mutation.SetAccountID(v)
  56. return _u
  57. }
  58. // SetNillableAccountID sets the "account_id" field if the given value is not nil.
  59. func (_u *UsageLogUpdate) SetNillableAccountID(v *int64) *UsageLogUpdate {
  60. if v != nil {
  61. _u.SetAccountID(*v)
  62. }
  63. return _u
  64. }
  65. // SetRequestID sets the "request_id" field.
  66. func (_u *UsageLogUpdate) SetRequestID(v string) *UsageLogUpdate {
  67. _u.mutation.SetRequestID(v)
  68. return _u
  69. }
  70. // SetNillableRequestID sets the "request_id" field if the given value is not nil.
  71. func (_u *UsageLogUpdate) SetNillableRequestID(v *string) *UsageLogUpdate {
  72. if v != nil {
  73. _u.SetRequestID(*v)
  74. }
  75. return _u
  76. }
  77. // SetModel sets the "model" field.
  78. func (_u *UsageLogUpdate) SetModel(v string) *UsageLogUpdate {
  79. _u.mutation.SetModel(v)
  80. return _u
  81. }
  82. // SetNillableModel sets the "model" field if the given value is not nil.
  83. func (_u *UsageLogUpdate) SetNillableModel(v *string) *UsageLogUpdate {
  84. if v != nil {
  85. _u.SetModel(*v)
  86. }
  87. return _u
  88. }
  89. // SetRequestedModel sets the "requested_model" field.
  90. func (_u *UsageLogUpdate) SetRequestedModel(v string) *UsageLogUpdate {
  91. _u.mutation.SetRequestedModel(v)
  92. return _u
  93. }
  94. // SetNillableRequestedModel sets the "requested_model" field if the given value is not nil.
  95. func (_u *UsageLogUpdate) SetNillableRequestedModel(v *string) *UsageLogUpdate {
  96. if v != nil {
  97. _u.SetRequestedModel(*v)
  98. }
  99. return _u
  100. }
  101. // ClearRequestedModel clears the value of the "requested_model" field.
  102. func (_u *UsageLogUpdate) ClearRequestedModel() *UsageLogUpdate {
  103. _u.mutation.ClearRequestedModel()
  104. return _u
  105. }
  106. // SetUpstreamModel sets the "upstream_model" field.
  107. func (_u *UsageLogUpdate) SetUpstreamModel(v string) *UsageLogUpdate {
  108. _u.mutation.SetUpstreamModel(v)
  109. return _u
  110. }
  111. // SetNillableUpstreamModel sets the "upstream_model" field if the given value is not nil.
  112. func (_u *UsageLogUpdate) SetNillableUpstreamModel(v *string) *UsageLogUpdate {
  113. if v != nil {
  114. _u.SetUpstreamModel(*v)
  115. }
  116. return _u
  117. }
  118. // ClearUpstreamModel clears the value of the "upstream_model" field.
  119. func (_u *UsageLogUpdate) ClearUpstreamModel() *UsageLogUpdate {
  120. _u.mutation.ClearUpstreamModel()
  121. return _u
  122. }
  123. // SetUpstreamResponseModel sets the "upstream_response_model" field.
  124. func (_u *UsageLogUpdate) SetUpstreamResponseModel(v string) *UsageLogUpdate {
  125. _u.mutation.SetUpstreamResponseModel(v)
  126. return _u
  127. }
  128. // SetNillableUpstreamResponseModel sets the "upstream_response_model" field if the given value is not nil.
  129. func (_u *UsageLogUpdate) SetNillableUpstreamResponseModel(v *string) *UsageLogUpdate {
  130. if v != nil {
  131. _u.SetUpstreamResponseModel(*v)
  132. }
  133. return _u
  134. }
  135. // ClearUpstreamResponseModel clears the value of the "upstream_response_model" field.
  136. func (_u *UsageLogUpdate) ClearUpstreamResponseModel() *UsageLogUpdate {
  137. _u.mutation.ClearUpstreamResponseModel()
  138. return _u
  139. }
  140. // SetUpstreamModelMismatch sets the "upstream_model_mismatch" field.
  141. func (_u *UsageLogUpdate) SetUpstreamModelMismatch(v bool) *UsageLogUpdate {
  142. _u.mutation.SetUpstreamModelMismatch(v)
  143. return _u
  144. }
  145. // SetNillableUpstreamModelMismatch sets the "upstream_model_mismatch" field if the given value is not nil.
  146. func (_u *UsageLogUpdate) SetNillableUpstreamModelMismatch(v *bool) *UsageLogUpdate {
  147. if v != nil {
  148. _u.SetUpstreamModelMismatch(*v)
  149. }
  150. return _u
  151. }
  152. // ClearUpstreamModelMismatch clears the value of the "upstream_model_mismatch" field.
  153. func (_u *UsageLogUpdate) ClearUpstreamModelMismatch() *UsageLogUpdate {
  154. _u.mutation.ClearUpstreamModelMismatch()
  155. return _u
  156. }
  157. // SetChannelID sets the "channel_id" field.
  158. func (_u *UsageLogUpdate) SetChannelID(v int64) *UsageLogUpdate {
  159. _u.mutation.ResetChannelID()
  160. _u.mutation.SetChannelID(v)
  161. return _u
  162. }
  163. // SetNillableChannelID sets the "channel_id" field if the given value is not nil.
  164. func (_u *UsageLogUpdate) SetNillableChannelID(v *int64) *UsageLogUpdate {
  165. if v != nil {
  166. _u.SetChannelID(*v)
  167. }
  168. return _u
  169. }
  170. // AddChannelID adds value to the "channel_id" field.
  171. func (_u *UsageLogUpdate) AddChannelID(v int64) *UsageLogUpdate {
  172. _u.mutation.AddChannelID(v)
  173. return _u
  174. }
  175. // ClearChannelID clears the value of the "channel_id" field.
  176. func (_u *UsageLogUpdate) ClearChannelID() *UsageLogUpdate {
  177. _u.mutation.ClearChannelID()
  178. return _u
  179. }
  180. // SetModelMappingChain sets the "model_mapping_chain" field.
  181. func (_u *UsageLogUpdate) SetModelMappingChain(v string) *UsageLogUpdate {
  182. _u.mutation.SetModelMappingChain(v)
  183. return _u
  184. }
  185. // SetNillableModelMappingChain sets the "model_mapping_chain" field if the given value is not nil.
  186. func (_u *UsageLogUpdate) SetNillableModelMappingChain(v *string) *UsageLogUpdate {
  187. if v != nil {
  188. _u.SetModelMappingChain(*v)
  189. }
  190. return _u
  191. }
  192. // ClearModelMappingChain clears the value of the "model_mapping_chain" field.
  193. func (_u *UsageLogUpdate) ClearModelMappingChain() *UsageLogUpdate {
  194. _u.mutation.ClearModelMappingChain()
  195. return _u
  196. }
  197. // SetBillingTier sets the "billing_tier" field.
  198. func (_u *UsageLogUpdate) SetBillingTier(v string) *UsageLogUpdate {
  199. _u.mutation.SetBillingTier(v)
  200. return _u
  201. }
  202. // SetNillableBillingTier sets the "billing_tier" field if the given value is not nil.
  203. func (_u *UsageLogUpdate) SetNillableBillingTier(v *string) *UsageLogUpdate {
  204. if v != nil {
  205. _u.SetBillingTier(*v)
  206. }
  207. return _u
  208. }
  209. // ClearBillingTier clears the value of the "billing_tier" field.
  210. func (_u *UsageLogUpdate) ClearBillingTier() *UsageLogUpdate {
  211. _u.mutation.ClearBillingTier()
  212. return _u
  213. }
  214. // SetBillingMode sets the "billing_mode" field.
  215. func (_u *UsageLogUpdate) SetBillingMode(v string) *UsageLogUpdate {
  216. _u.mutation.SetBillingMode(v)
  217. return _u
  218. }
  219. // SetNillableBillingMode sets the "billing_mode" field if the given value is not nil.
  220. func (_u *UsageLogUpdate) SetNillableBillingMode(v *string) *UsageLogUpdate {
  221. if v != nil {
  222. _u.SetBillingMode(*v)
  223. }
  224. return _u
  225. }
  226. // ClearBillingMode clears the value of the "billing_mode" field.
  227. func (_u *UsageLogUpdate) ClearBillingMode() *UsageLogUpdate {
  228. _u.mutation.ClearBillingMode()
  229. return _u
  230. }
  231. // SetGroupID sets the "group_id" field.
  232. func (_u *UsageLogUpdate) SetGroupID(v int64) *UsageLogUpdate {
  233. _u.mutation.SetGroupID(v)
  234. return _u
  235. }
  236. // SetNillableGroupID sets the "group_id" field if the given value is not nil.
  237. func (_u *UsageLogUpdate) SetNillableGroupID(v *int64) *UsageLogUpdate {
  238. if v != nil {
  239. _u.SetGroupID(*v)
  240. }
  241. return _u
  242. }
  243. // ClearGroupID clears the value of the "group_id" field.
  244. func (_u *UsageLogUpdate) ClearGroupID() *UsageLogUpdate {
  245. _u.mutation.ClearGroupID()
  246. return _u
  247. }
  248. // SetSubscriptionID sets the "subscription_id" field.
  249. func (_u *UsageLogUpdate) SetSubscriptionID(v int64) *UsageLogUpdate {
  250. _u.mutation.SetSubscriptionID(v)
  251. return _u
  252. }
  253. // SetNillableSubscriptionID sets the "subscription_id" field if the given value is not nil.
  254. func (_u *UsageLogUpdate) SetNillableSubscriptionID(v *int64) *UsageLogUpdate {
  255. if v != nil {
  256. _u.SetSubscriptionID(*v)
  257. }
  258. return _u
  259. }
  260. // ClearSubscriptionID clears the value of the "subscription_id" field.
  261. func (_u *UsageLogUpdate) ClearSubscriptionID() *UsageLogUpdate {
  262. _u.mutation.ClearSubscriptionID()
  263. return _u
  264. }
  265. // SetInputTokens sets the "input_tokens" field.
  266. func (_u *UsageLogUpdate) SetInputTokens(v int) *UsageLogUpdate {
  267. _u.mutation.ResetInputTokens()
  268. _u.mutation.SetInputTokens(v)
  269. return _u
  270. }
  271. // SetNillableInputTokens sets the "input_tokens" field if the given value is not nil.
  272. func (_u *UsageLogUpdate) SetNillableInputTokens(v *int) *UsageLogUpdate {
  273. if v != nil {
  274. _u.SetInputTokens(*v)
  275. }
  276. return _u
  277. }
  278. // AddInputTokens adds value to the "input_tokens" field.
  279. func (_u *UsageLogUpdate) AddInputTokens(v int) *UsageLogUpdate {
  280. _u.mutation.AddInputTokens(v)
  281. return _u
  282. }
  283. // SetOutputTokens sets the "output_tokens" field.
  284. func (_u *UsageLogUpdate) SetOutputTokens(v int) *UsageLogUpdate {
  285. _u.mutation.ResetOutputTokens()
  286. _u.mutation.SetOutputTokens(v)
  287. return _u
  288. }
  289. // SetNillableOutputTokens sets the "output_tokens" field if the given value is not nil.
  290. func (_u *UsageLogUpdate) SetNillableOutputTokens(v *int) *UsageLogUpdate {
  291. if v != nil {
  292. _u.SetOutputTokens(*v)
  293. }
  294. return _u
  295. }
  296. // AddOutputTokens adds value to the "output_tokens" field.
  297. func (_u *UsageLogUpdate) AddOutputTokens(v int) *UsageLogUpdate {
  298. _u.mutation.AddOutputTokens(v)
  299. return _u
  300. }
  301. // SetCacheCreationTokens sets the "cache_creation_tokens" field.
  302. func (_u *UsageLogUpdate) SetCacheCreationTokens(v int) *UsageLogUpdate {
  303. _u.mutation.ResetCacheCreationTokens()
  304. _u.mutation.SetCacheCreationTokens(v)
  305. return _u
  306. }
  307. // SetNillableCacheCreationTokens sets the "cache_creation_tokens" field if the given value is not nil.
  308. func (_u *UsageLogUpdate) SetNillableCacheCreationTokens(v *int) *UsageLogUpdate {
  309. if v != nil {
  310. _u.SetCacheCreationTokens(*v)
  311. }
  312. return _u
  313. }
  314. // AddCacheCreationTokens adds value to the "cache_creation_tokens" field.
  315. func (_u *UsageLogUpdate) AddCacheCreationTokens(v int) *UsageLogUpdate {
  316. _u.mutation.AddCacheCreationTokens(v)
  317. return _u
  318. }
  319. // SetCacheReadTokens sets the "cache_read_tokens" field.
  320. func (_u *UsageLogUpdate) SetCacheReadTokens(v int) *UsageLogUpdate {
  321. _u.mutation.ResetCacheReadTokens()
  322. _u.mutation.SetCacheReadTokens(v)
  323. return _u
  324. }
  325. // SetNillableCacheReadTokens sets the "cache_read_tokens" field if the given value is not nil.
  326. func (_u *UsageLogUpdate) SetNillableCacheReadTokens(v *int) *UsageLogUpdate {
  327. if v != nil {
  328. _u.SetCacheReadTokens(*v)
  329. }
  330. return _u
  331. }
  332. // AddCacheReadTokens adds value to the "cache_read_tokens" field.
  333. func (_u *UsageLogUpdate) AddCacheReadTokens(v int) *UsageLogUpdate {
  334. _u.mutation.AddCacheReadTokens(v)
  335. return _u
  336. }
  337. // SetCacheCreation5mTokens sets the "cache_creation_5m_tokens" field.
  338. func (_u *UsageLogUpdate) SetCacheCreation5mTokens(v int) *UsageLogUpdate {
  339. _u.mutation.ResetCacheCreation5mTokens()
  340. _u.mutation.SetCacheCreation5mTokens(v)
  341. return _u
  342. }
  343. // SetNillableCacheCreation5mTokens sets the "cache_creation_5m_tokens" field if the given value is not nil.
  344. func (_u *UsageLogUpdate) SetNillableCacheCreation5mTokens(v *int) *UsageLogUpdate {
  345. if v != nil {
  346. _u.SetCacheCreation5mTokens(*v)
  347. }
  348. return _u
  349. }
  350. // AddCacheCreation5mTokens adds value to the "cache_creation_5m_tokens" field.
  351. func (_u *UsageLogUpdate) AddCacheCreation5mTokens(v int) *UsageLogUpdate {
  352. _u.mutation.AddCacheCreation5mTokens(v)
  353. return _u
  354. }
  355. // SetCacheCreation1hTokens sets the "cache_creation_1h_tokens" field.
  356. func (_u *UsageLogUpdate) SetCacheCreation1hTokens(v int) *UsageLogUpdate {
  357. _u.mutation.ResetCacheCreation1hTokens()
  358. _u.mutation.SetCacheCreation1hTokens(v)
  359. return _u
  360. }
  361. // SetNillableCacheCreation1hTokens sets the "cache_creation_1h_tokens" field if the given value is not nil.
  362. func (_u *UsageLogUpdate) SetNillableCacheCreation1hTokens(v *int) *UsageLogUpdate {
  363. if v != nil {
  364. _u.SetCacheCreation1hTokens(*v)
  365. }
  366. return _u
  367. }
  368. // AddCacheCreation1hTokens adds value to the "cache_creation_1h_tokens" field.
  369. func (_u *UsageLogUpdate) AddCacheCreation1hTokens(v int) *UsageLogUpdate {
  370. _u.mutation.AddCacheCreation1hTokens(v)
  371. return _u
  372. }
  373. // SetInputCost sets the "input_cost" field.
  374. func (_u *UsageLogUpdate) SetInputCost(v float64) *UsageLogUpdate {
  375. _u.mutation.ResetInputCost()
  376. _u.mutation.SetInputCost(v)
  377. return _u
  378. }
  379. // SetNillableInputCost sets the "input_cost" field if the given value is not nil.
  380. func (_u *UsageLogUpdate) SetNillableInputCost(v *float64) *UsageLogUpdate {
  381. if v != nil {
  382. _u.SetInputCost(*v)
  383. }
  384. return _u
  385. }
  386. // AddInputCost adds value to the "input_cost" field.
  387. func (_u *UsageLogUpdate) AddInputCost(v float64) *UsageLogUpdate {
  388. _u.mutation.AddInputCost(v)
  389. return _u
  390. }
  391. // SetOutputCost sets the "output_cost" field.
  392. func (_u *UsageLogUpdate) SetOutputCost(v float64) *UsageLogUpdate {
  393. _u.mutation.ResetOutputCost()
  394. _u.mutation.SetOutputCost(v)
  395. return _u
  396. }
  397. // SetNillableOutputCost sets the "output_cost" field if the given value is not nil.
  398. func (_u *UsageLogUpdate) SetNillableOutputCost(v *float64) *UsageLogUpdate {
  399. if v != nil {
  400. _u.SetOutputCost(*v)
  401. }
  402. return _u
  403. }
  404. // AddOutputCost adds value to the "output_cost" field.
  405. func (_u *UsageLogUpdate) AddOutputCost(v float64) *UsageLogUpdate {
  406. _u.mutation.AddOutputCost(v)
  407. return _u
  408. }
  409. // SetCacheCreationCost sets the "cache_creation_cost" field.
  410. func (_u *UsageLogUpdate) SetCacheCreationCost(v float64) *UsageLogUpdate {
  411. _u.mutation.ResetCacheCreationCost()
  412. _u.mutation.SetCacheCreationCost(v)
  413. return _u
  414. }
  415. // SetNillableCacheCreationCost sets the "cache_creation_cost" field if the given value is not nil.
  416. func (_u *UsageLogUpdate) SetNillableCacheCreationCost(v *float64) *UsageLogUpdate {
  417. if v != nil {
  418. _u.SetCacheCreationCost(*v)
  419. }
  420. return _u
  421. }
  422. // AddCacheCreationCost adds value to the "cache_creation_cost" field.
  423. func (_u *UsageLogUpdate) AddCacheCreationCost(v float64) *UsageLogUpdate {
  424. _u.mutation.AddCacheCreationCost(v)
  425. return _u
  426. }
  427. // SetCacheReadCost sets the "cache_read_cost" field.
  428. func (_u *UsageLogUpdate) SetCacheReadCost(v float64) *UsageLogUpdate {
  429. _u.mutation.ResetCacheReadCost()
  430. _u.mutation.SetCacheReadCost(v)
  431. return _u
  432. }
  433. // SetNillableCacheReadCost sets the "cache_read_cost" field if the given value is not nil.
  434. func (_u *UsageLogUpdate) SetNillableCacheReadCost(v *float64) *UsageLogUpdate {
  435. if v != nil {
  436. _u.SetCacheReadCost(*v)
  437. }
  438. return _u
  439. }
  440. // AddCacheReadCost adds value to the "cache_read_cost" field.
  441. func (_u *UsageLogUpdate) AddCacheReadCost(v float64) *UsageLogUpdate {
  442. _u.mutation.AddCacheReadCost(v)
  443. return _u
  444. }
  445. // SetTotalCost sets the "total_cost" field.
  446. func (_u *UsageLogUpdate) SetTotalCost(v float64) *UsageLogUpdate {
  447. _u.mutation.ResetTotalCost()
  448. _u.mutation.SetTotalCost(v)
  449. return _u
  450. }
  451. // SetNillableTotalCost sets the "total_cost" field if the given value is not nil.
  452. func (_u *UsageLogUpdate) SetNillableTotalCost(v *float64) *UsageLogUpdate {
  453. if v != nil {
  454. _u.SetTotalCost(*v)
  455. }
  456. return _u
  457. }
  458. // AddTotalCost adds value to the "total_cost" field.
  459. func (_u *UsageLogUpdate) AddTotalCost(v float64) *UsageLogUpdate {
  460. _u.mutation.AddTotalCost(v)
  461. return _u
  462. }
  463. // SetActualCost sets the "actual_cost" field.
  464. func (_u *UsageLogUpdate) SetActualCost(v float64) *UsageLogUpdate {
  465. _u.mutation.ResetActualCost()
  466. _u.mutation.SetActualCost(v)
  467. return _u
  468. }
  469. // SetNillableActualCost sets the "actual_cost" field if the given value is not nil.
  470. func (_u *UsageLogUpdate) SetNillableActualCost(v *float64) *UsageLogUpdate {
  471. if v != nil {
  472. _u.SetActualCost(*v)
  473. }
  474. return _u
  475. }
  476. // AddActualCost adds value to the "actual_cost" field.
  477. func (_u *UsageLogUpdate) AddActualCost(v float64) *UsageLogUpdate {
  478. _u.mutation.AddActualCost(v)
  479. return _u
  480. }
  481. // SetRateMultiplier sets the "rate_multiplier" field.
  482. func (_u *UsageLogUpdate) SetRateMultiplier(v float64) *UsageLogUpdate {
  483. _u.mutation.ResetRateMultiplier()
  484. _u.mutation.SetRateMultiplier(v)
  485. return _u
  486. }
  487. // SetNillableRateMultiplier sets the "rate_multiplier" field if the given value is not nil.
  488. func (_u *UsageLogUpdate) SetNillableRateMultiplier(v *float64) *UsageLogUpdate {
  489. if v != nil {
  490. _u.SetRateMultiplier(*v)
  491. }
  492. return _u
  493. }
  494. // AddRateMultiplier adds value to the "rate_multiplier" field.
  495. func (_u *UsageLogUpdate) AddRateMultiplier(v float64) *UsageLogUpdate {
  496. _u.mutation.AddRateMultiplier(v)
  497. return _u
  498. }
  499. // SetLongContextBillingApplied sets the "long_context_billing_applied" field.
  500. func (_u *UsageLogUpdate) SetLongContextBillingApplied(v bool) *UsageLogUpdate {
  501. _u.mutation.SetLongContextBillingApplied(v)
  502. return _u
  503. }
  504. // SetNillableLongContextBillingApplied sets the "long_context_billing_applied" field if the given value is not nil.
  505. func (_u *UsageLogUpdate) SetNillableLongContextBillingApplied(v *bool) *UsageLogUpdate {
  506. if v != nil {
  507. _u.SetLongContextBillingApplied(*v)
  508. }
  509. return _u
  510. }
  511. // SetAccountRateMultiplier sets the "account_rate_multiplier" field.
  512. func (_u *UsageLogUpdate) SetAccountRateMultiplier(v float64) *UsageLogUpdate {
  513. _u.mutation.ResetAccountRateMultiplier()
  514. _u.mutation.SetAccountRateMultiplier(v)
  515. return _u
  516. }
  517. // SetNillableAccountRateMultiplier sets the "account_rate_multiplier" field if the given value is not nil.
  518. func (_u *UsageLogUpdate) SetNillableAccountRateMultiplier(v *float64) *UsageLogUpdate {
  519. if v != nil {
  520. _u.SetAccountRateMultiplier(*v)
  521. }
  522. return _u
  523. }
  524. // AddAccountRateMultiplier adds value to the "account_rate_multiplier" field.
  525. func (_u *UsageLogUpdate) AddAccountRateMultiplier(v float64) *UsageLogUpdate {
  526. _u.mutation.AddAccountRateMultiplier(v)
  527. return _u
  528. }
  529. // ClearAccountRateMultiplier clears the value of the "account_rate_multiplier" field.
  530. func (_u *UsageLogUpdate) ClearAccountRateMultiplier() *UsageLogUpdate {
  531. _u.mutation.ClearAccountRateMultiplier()
  532. return _u
  533. }
  534. // SetBillingType sets the "billing_type" field.
  535. func (_u *UsageLogUpdate) SetBillingType(v int8) *UsageLogUpdate {
  536. _u.mutation.ResetBillingType()
  537. _u.mutation.SetBillingType(v)
  538. return _u
  539. }
  540. // SetNillableBillingType sets the "billing_type" field if the given value is not nil.
  541. func (_u *UsageLogUpdate) SetNillableBillingType(v *int8) *UsageLogUpdate {
  542. if v != nil {
  543. _u.SetBillingType(*v)
  544. }
  545. return _u
  546. }
  547. // AddBillingType adds value to the "billing_type" field.
  548. func (_u *UsageLogUpdate) AddBillingType(v int8) *UsageLogUpdate {
  549. _u.mutation.AddBillingType(v)
  550. return _u
  551. }
  552. // SetStream sets the "stream" field.
  553. func (_u *UsageLogUpdate) SetStream(v bool) *UsageLogUpdate {
  554. _u.mutation.SetStream(v)
  555. return _u
  556. }
  557. // SetNillableStream sets the "stream" field if the given value is not nil.
  558. func (_u *UsageLogUpdate) SetNillableStream(v *bool) *UsageLogUpdate {
  559. if v != nil {
  560. _u.SetStream(*v)
  561. }
  562. return _u
  563. }
  564. // SetDurationMs sets the "duration_ms" field.
  565. func (_u *UsageLogUpdate) SetDurationMs(v int) *UsageLogUpdate {
  566. _u.mutation.ResetDurationMs()
  567. _u.mutation.SetDurationMs(v)
  568. return _u
  569. }
  570. // SetNillableDurationMs sets the "duration_ms" field if the given value is not nil.
  571. func (_u *UsageLogUpdate) SetNillableDurationMs(v *int) *UsageLogUpdate {
  572. if v != nil {
  573. _u.SetDurationMs(*v)
  574. }
  575. return _u
  576. }
  577. // AddDurationMs adds value to the "duration_ms" field.
  578. func (_u *UsageLogUpdate) AddDurationMs(v int) *UsageLogUpdate {
  579. _u.mutation.AddDurationMs(v)
  580. return _u
  581. }
  582. // ClearDurationMs clears the value of the "duration_ms" field.
  583. func (_u *UsageLogUpdate) ClearDurationMs() *UsageLogUpdate {
  584. _u.mutation.ClearDurationMs()
  585. return _u
  586. }
  587. // SetFirstTokenMs sets the "first_token_ms" field.
  588. func (_u *UsageLogUpdate) SetFirstTokenMs(v int) *UsageLogUpdate {
  589. _u.mutation.ResetFirstTokenMs()
  590. _u.mutation.SetFirstTokenMs(v)
  591. return _u
  592. }
  593. // SetNillableFirstTokenMs sets the "first_token_ms" field if the given value is not nil.
  594. func (_u *UsageLogUpdate) SetNillableFirstTokenMs(v *int) *UsageLogUpdate {
  595. if v != nil {
  596. _u.SetFirstTokenMs(*v)
  597. }
  598. return _u
  599. }
  600. // AddFirstTokenMs adds value to the "first_token_ms" field.
  601. func (_u *UsageLogUpdate) AddFirstTokenMs(v int) *UsageLogUpdate {
  602. _u.mutation.AddFirstTokenMs(v)
  603. return _u
  604. }
  605. // ClearFirstTokenMs clears the value of the "first_token_ms" field.
  606. func (_u *UsageLogUpdate) ClearFirstTokenMs() *UsageLogUpdate {
  607. _u.mutation.ClearFirstTokenMs()
  608. return _u
  609. }
  610. // SetUserAgent sets the "user_agent" field.
  611. func (_u *UsageLogUpdate) SetUserAgent(v string) *UsageLogUpdate {
  612. _u.mutation.SetUserAgent(v)
  613. return _u
  614. }
  615. // SetNillableUserAgent sets the "user_agent" field if the given value is not nil.
  616. func (_u *UsageLogUpdate) SetNillableUserAgent(v *string) *UsageLogUpdate {
  617. if v != nil {
  618. _u.SetUserAgent(*v)
  619. }
  620. return _u
  621. }
  622. // ClearUserAgent clears the value of the "user_agent" field.
  623. func (_u *UsageLogUpdate) ClearUserAgent() *UsageLogUpdate {
  624. _u.mutation.ClearUserAgent()
  625. return _u
  626. }
  627. // SetIPAddress sets the "ip_address" field.
  628. func (_u *UsageLogUpdate) SetIPAddress(v string) *UsageLogUpdate {
  629. _u.mutation.SetIPAddress(v)
  630. return _u
  631. }
  632. // SetNillableIPAddress sets the "ip_address" field if the given value is not nil.
  633. func (_u *UsageLogUpdate) SetNillableIPAddress(v *string) *UsageLogUpdate {
  634. if v != nil {
  635. _u.SetIPAddress(*v)
  636. }
  637. return _u
  638. }
  639. // ClearIPAddress clears the value of the "ip_address" field.
  640. func (_u *UsageLogUpdate) ClearIPAddress() *UsageLogUpdate {
  641. _u.mutation.ClearIPAddress()
  642. return _u
  643. }
  644. // SetImageCount sets the "image_count" field.
  645. func (_u *UsageLogUpdate) SetImageCount(v int) *UsageLogUpdate {
  646. _u.mutation.ResetImageCount()
  647. _u.mutation.SetImageCount(v)
  648. return _u
  649. }
  650. // SetNillableImageCount sets the "image_count" field if the given value is not nil.
  651. func (_u *UsageLogUpdate) SetNillableImageCount(v *int) *UsageLogUpdate {
  652. if v != nil {
  653. _u.SetImageCount(*v)
  654. }
  655. return _u
  656. }
  657. // AddImageCount adds value to the "image_count" field.
  658. func (_u *UsageLogUpdate) AddImageCount(v int) *UsageLogUpdate {
  659. _u.mutation.AddImageCount(v)
  660. return _u
  661. }
  662. // SetImageSize sets the "image_size" field.
  663. func (_u *UsageLogUpdate) SetImageSize(v string) *UsageLogUpdate {
  664. _u.mutation.SetImageSize(v)
  665. return _u
  666. }
  667. // SetNillableImageSize sets the "image_size" field if the given value is not nil.
  668. func (_u *UsageLogUpdate) SetNillableImageSize(v *string) *UsageLogUpdate {
  669. if v != nil {
  670. _u.SetImageSize(*v)
  671. }
  672. return _u
  673. }
  674. // ClearImageSize clears the value of the "image_size" field.
  675. func (_u *UsageLogUpdate) ClearImageSize() *UsageLogUpdate {
  676. _u.mutation.ClearImageSize()
  677. return _u
  678. }
  679. // SetImageInputSize sets the "image_input_size" field.
  680. func (_u *UsageLogUpdate) SetImageInputSize(v string) *UsageLogUpdate {
  681. _u.mutation.SetImageInputSize(v)
  682. return _u
  683. }
  684. // SetNillableImageInputSize sets the "image_input_size" field if the given value is not nil.
  685. func (_u *UsageLogUpdate) SetNillableImageInputSize(v *string) *UsageLogUpdate {
  686. if v != nil {
  687. _u.SetImageInputSize(*v)
  688. }
  689. return _u
  690. }
  691. // ClearImageInputSize clears the value of the "image_input_size" field.
  692. func (_u *UsageLogUpdate) ClearImageInputSize() *UsageLogUpdate {
  693. _u.mutation.ClearImageInputSize()
  694. return _u
  695. }
  696. // SetImageOutputSize sets the "image_output_size" field.
  697. func (_u *UsageLogUpdate) SetImageOutputSize(v string) *UsageLogUpdate {
  698. _u.mutation.SetImageOutputSize(v)
  699. return _u
  700. }
  701. // SetNillableImageOutputSize sets the "image_output_size" field if the given value is not nil.
  702. func (_u *UsageLogUpdate) SetNillableImageOutputSize(v *string) *UsageLogUpdate {
  703. if v != nil {
  704. _u.SetImageOutputSize(*v)
  705. }
  706. return _u
  707. }
  708. // ClearImageOutputSize clears the value of the "image_output_size" field.
  709. func (_u *UsageLogUpdate) ClearImageOutputSize() *UsageLogUpdate {
  710. _u.mutation.ClearImageOutputSize()
  711. return _u
  712. }
  713. // SetImageSizeSource sets the "image_size_source" field.
  714. func (_u *UsageLogUpdate) SetImageSizeSource(v string) *UsageLogUpdate {
  715. _u.mutation.SetImageSizeSource(v)
  716. return _u
  717. }
  718. // SetNillableImageSizeSource sets the "image_size_source" field if the given value is not nil.
  719. func (_u *UsageLogUpdate) SetNillableImageSizeSource(v *string) *UsageLogUpdate {
  720. if v != nil {
  721. _u.SetImageSizeSource(*v)
  722. }
  723. return _u
  724. }
  725. // ClearImageSizeSource clears the value of the "image_size_source" field.
  726. func (_u *UsageLogUpdate) ClearImageSizeSource() *UsageLogUpdate {
  727. _u.mutation.ClearImageSizeSource()
  728. return _u
  729. }
  730. // SetImageSizeBreakdown sets the "image_size_breakdown" field.
  731. func (_u *UsageLogUpdate) SetImageSizeBreakdown(v map[string]int) *UsageLogUpdate {
  732. _u.mutation.SetImageSizeBreakdown(v)
  733. return _u
  734. }
  735. // ClearImageSizeBreakdown clears the value of the "image_size_breakdown" field.
  736. func (_u *UsageLogUpdate) ClearImageSizeBreakdown() *UsageLogUpdate {
  737. _u.mutation.ClearImageSizeBreakdown()
  738. return _u
  739. }
  740. // SetVideoCount sets the "video_count" field.
  741. func (_u *UsageLogUpdate) SetVideoCount(v int) *UsageLogUpdate {
  742. _u.mutation.ResetVideoCount()
  743. _u.mutation.SetVideoCount(v)
  744. return _u
  745. }
  746. // SetNillableVideoCount sets the "video_count" field if the given value is not nil.
  747. func (_u *UsageLogUpdate) SetNillableVideoCount(v *int) *UsageLogUpdate {
  748. if v != nil {
  749. _u.SetVideoCount(*v)
  750. }
  751. return _u
  752. }
  753. // AddVideoCount adds value to the "video_count" field.
  754. func (_u *UsageLogUpdate) AddVideoCount(v int) *UsageLogUpdate {
  755. _u.mutation.AddVideoCount(v)
  756. return _u
  757. }
  758. // SetVideoResolution sets the "video_resolution" field.
  759. func (_u *UsageLogUpdate) SetVideoResolution(v string) *UsageLogUpdate {
  760. _u.mutation.SetVideoResolution(v)
  761. return _u
  762. }
  763. // SetNillableVideoResolution sets the "video_resolution" field if the given value is not nil.
  764. func (_u *UsageLogUpdate) SetNillableVideoResolution(v *string) *UsageLogUpdate {
  765. if v != nil {
  766. _u.SetVideoResolution(*v)
  767. }
  768. return _u
  769. }
  770. // ClearVideoResolution clears the value of the "video_resolution" field.
  771. func (_u *UsageLogUpdate) ClearVideoResolution() *UsageLogUpdate {
  772. _u.mutation.ClearVideoResolution()
  773. return _u
  774. }
  775. // SetVideoDurationSeconds sets the "video_duration_seconds" field.
  776. func (_u *UsageLogUpdate) SetVideoDurationSeconds(v int) *UsageLogUpdate {
  777. _u.mutation.ResetVideoDurationSeconds()
  778. _u.mutation.SetVideoDurationSeconds(v)
  779. return _u
  780. }
  781. // SetNillableVideoDurationSeconds sets the "video_duration_seconds" field if the given value is not nil.
  782. func (_u *UsageLogUpdate) SetNillableVideoDurationSeconds(v *int) *UsageLogUpdate {
  783. if v != nil {
  784. _u.SetVideoDurationSeconds(*v)
  785. }
  786. return _u
  787. }
  788. // AddVideoDurationSeconds adds value to the "video_duration_seconds" field.
  789. func (_u *UsageLogUpdate) AddVideoDurationSeconds(v int) *UsageLogUpdate {
  790. _u.mutation.AddVideoDurationSeconds(v)
  791. return _u
  792. }
  793. // ClearVideoDurationSeconds clears the value of the "video_duration_seconds" field.
  794. func (_u *UsageLogUpdate) ClearVideoDurationSeconds() *UsageLogUpdate {
  795. _u.mutation.ClearVideoDurationSeconds()
  796. return _u
  797. }
  798. // SetCacheTTLOverridden sets the "cache_ttl_overridden" field.
  799. func (_u *UsageLogUpdate) SetCacheTTLOverridden(v bool) *UsageLogUpdate {
  800. _u.mutation.SetCacheTTLOverridden(v)
  801. return _u
  802. }
  803. // SetNillableCacheTTLOverridden sets the "cache_ttl_overridden" field if the given value is not nil.
  804. func (_u *UsageLogUpdate) SetNillableCacheTTLOverridden(v *bool) *UsageLogUpdate {
  805. if v != nil {
  806. _u.SetCacheTTLOverridden(*v)
  807. }
  808. return _u
  809. }
  810. // SetUser sets the "user" edge to the User entity.
  811. func (_u *UsageLogUpdate) SetUser(v *User) *UsageLogUpdate {
  812. return _u.SetUserID(v.ID)
  813. }
  814. // SetAPIKey sets the "api_key" edge to the APIKey entity.
  815. func (_u *UsageLogUpdate) SetAPIKey(v *APIKey) *UsageLogUpdate {
  816. return _u.SetAPIKeyID(v.ID)
  817. }
  818. // SetAccount sets the "account" edge to the Account entity.
  819. func (_u *UsageLogUpdate) SetAccount(v *Account) *UsageLogUpdate {
  820. return _u.SetAccountID(v.ID)
  821. }
  822. // SetGroup sets the "group" edge to the Group entity.
  823. func (_u *UsageLogUpdate) SetGroup(v *Group) *UsageLogUpdate {
  824. return _u.SetGroupID(v.ID)
  825. }
  826. // SetSubscription sets the "subscription" edge to the UserSubscription entity.
  827. func (_u *UsageLogUpdate) SetSubscription(v *UserSubscription) *UsageLogUpdate {
  828. return _u.SetSubscriptionID(v.ID)
  829. }
  830. // Mutation returns the UsageLogMutation object of the builder.
  831. func (_u *UsageLogUpdate) Mutation() *UsageLogMutation {
  832. return _u.mutation
  833. }
  834. // ClearUser clears the "user" edge to the User entity.
  835. func (_u *UsageLogUpdate) ClearUser() *UsageLogUpdate {
  836. _u.mutation.ClearUser()
  837. return _u
  838. }
  839. // ClearAPIKey clears the "api_key" edge to the APIKey entity.
  840. func (_u *UsageLogUpdate) ClearAPIKey() *UsageLogUpdate {
  841. _u.mutation.ClearAPIKey()
  842. return _u
  843. }
  844. // ClearAccount clears the "account" edge to the Account entity.
  845. func (_u *UsageLogUpdate) ClearAccount() *UsageLogUpdate {
  846. _u.mutation.ClearAccount()
  847. return _u
  848. }
  849. // ClearGroup clears the "group" edge to the Group entity.
  850. func (_u *UsageLogUpdate) ClearGroup() *UsageLogUpdate {
  851. _u.mutation.ClearGroup()
  852. return _u
  853. }
  854. // ClearSubscription clears the "subscription" edge to the UserSubscription entity.
  855. func (_u *UsageLogUpdate) ClearSubscription() *UsageLogUpdate {
  856. _u.mutation.ClearSubscription()
  857. return _u
  858. }
  859. // Save executes the query and returns the number of nodes affected by the update operation.
  860. func (_u *UsageLogUpdate) Save(ctx context.Context) (int, error) {
  861. return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
  862. }
  863. // SaveX is like Save, but panics if an error occurs.
  864. func (_u *UsageLogUpdate) SaveX(ctx context.Context) int {
  865. affected, err := _u.Save(ctx)
  866. if err != nil {
  867. panic(err)
  868. }
  869. return affected
  870. }
  871. // Exec executes the query.
  872. func (_u *UsageLogUpdate) Exec(ctx context.Context) error {
  873. _, err := _u.Save(ctx)
  874. return err
  875. }
  876. // ExecX is like Exec, but panics if an error occurs.
  877. func (_u *UsageLogUpdate) ExecX(ctx context.Context) {
  878. if err := _u.Exec(ctx); err != nil {
  879. panic(err)
  880. }
  881. }
  882. // check runs all checks and user-defined validators on the builder.
  883. func (_u *UsageLogUpdate) check() error {
  884. if v, ok := _u.mutation.RequestID(); ok {
  885. if err := usagelog.RequestIDValidator(v); err != nil {
  886. return &ValidationError{Name: "request_id", err: fmt.Errorf(`ent: validator failed for field "UsageLog.request_id": %w`, err)}
  887. }
  888. }
  889. if v, ok := _u.mutation.Model(); ok {
  890. if err := usagelog.ModelValidator(v); err != nil {
  891. return &ValidationError{Name: "model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.model": %w`, err)}
  892. }
  893. }
  894. if v, ok := _u.mutation.RequestedModel(); ok {
  895. if err := usagelog.RequestedModelValidator(v); err != nil {
  896. return &ValidationError{Name: "requested_model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.requested_model": %w`, err)}
  897. }
  898. }
  899. if v, ok := _u.mutation.UpstreamModel(); ok {
  900. if err := usagelog.UpstreamModelValidator(v); err != nil {
  901. return &ValidationError{Name: "upstream_model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.upstream_model": %w`, err)}
  902. }
  903. }
  904. if v, ok := _u.mutation.UpstreamResponseModel(); ok {
  905. if err := usagelog.UpstreamResponseModelValidator(v); err != nil {
  906. return &ValidationError{Name: "upstream_response_model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.upstream_response_model": %w`, err)}
  907. }
  908. }
  909. if v, ok := _u.mutation.ModelMappingChain(); ok {
  910. if err := usagelog.ModelMappingChainValidator(v); err != nil {
  911. return &ValidationError{Name: "model_mapping_chain", err: fmt.Errorf(`ent: validator failed for field "UsageLog.model_mapping_chain": %w`, err)}
  912. }
  913. }
  914. if v, ok := _u.mutation.BillingTier(); ok {
  915. if err := usagelog.BillingTierValidator(v); err != nil {
  916. return &ValidationError{Name: "billing_tier", err: fmt.Errorf(`ent: validator failed for field "UsageLog.billing_tier": %w`, err)}
  917. }
  918. }
  919. if v, ok := _u.mutation.BillingMode(); ok {
  920. if err := usagelog.BillingModeValidator(v); err != nil {
  921. return &ValidationError{Name: "billing_mode", err: fmt.Errorf(`ent: validator failed for field "UsageLog.billing_mode": %w`, err)}
  922. }
  923. }
  924. if v, ok := _u.mutation.UserAgent(); ok {
  925. if err := usagelog.UserAgentValidator(v); err != nil {
  926. return &ValidationError{Name: "user_agent", err: fmt.Errorf(`ent: validator failed for field "UsageLog.user_agent": %w`, err)}
  927. }
  928. }
  929. if v, ok := _u.mutation.IPAddress(); ok {
  930. if err := usagelog.IPAddressValidator(v); err != nil {
  931. return &ValidationError{Name: "ip_address", err: fmt.Errorf(`ent: validator failed for field "UsageLog.ip_address": %w`, err)}
  932. }
  933. }
  934. if v, ok := _u.mutation.ImageSize(); ok {
  935. if err := usagelog.ImageSizeValidator(v); err != nil {
  936. return &ValidationError{Name: "image_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_size": %w`, err)}
  937. }
  938. }
  939. if v, ok := _u.mutation.ImageInputSize(); ok {
  940. if err := usagelog.ImageInputSizeValidator(v); err != nil {
  941. return &ValidationError{Name: "image_input_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_input_size": %w`, err)}
  942. }
  943. }
  944. if v, ok := _u.mutation.ImageOutputSize(); ok {
  945. if err := usagelog.ImageOutputSizeValidator(v); err != nil {
  946. return &ValidationError{Name: "image_output_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_output_size": %w`, err)}
  947. }
  948. }
  949. if v, ok := _u.mutation.ImageSizeSource(); ok {
  950. if err := usagelog.ImageSizeSourceValidator(v); err != nil {
  951. return &ValidationError{Name: "image_size_source", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_size_source": %w`, err)}
  952. }
  953. }
  954. if v, ok := _u.mutation.VideoResolution(); ok {
  955. if err := usagelog.VideoResolutionValidator(v); err != nil {
  956. return &ValidationError{Name: "video_resolution", err: fmt.Errorf(`ent: validator failed for field "UsageLog.video_resolution": %w`, err)}
  957. }
  958. }
  959. if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
  960. return errors.New(`ent: clearing a required unique edge "UsageLog.user"`)
  961. }
  962. if _u.mutation.APIKeyCleared() && len(_u.mutation.APIKeyIDs()) > 0 {
  963. return errors.New(`ent: clearing a required unique edge "UsageLog.api_key"`)
  964. }
  965. if _u.mutation.AccountCleared() && len(_u.mutation.AccountIDs()) > 0 {
  966. return errors.New(`ent: clearing a required unique edge "UsageLog.account"`)
  967. }
  968. return nil
  969. }
  970. func (_u *UsageLogUpdate) sqlSave(ctx context.Context) (_node int, err error) {
  971. if err := _u.check(); err != nil {
  972. return _node, err
  973. }
  974. _spec := sqlgraph.NewUpdateSpec(usagelog.Table, usagelog.Columns, sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64))
  975. if ps := _u.mutation.predicates; len(ps) > 0 {
  976. _spec.Predicate = func(selector *sql.Selector) {
  977. for i := range ps {
  978. ps[i](selector)
  979. }
  980. }
  981. }
  982. if value, ok := _u.mutation.RequestID(); ok {
  983. _spec.SetField(usagelog.FieldRequestID, field.TypeString, value)
  984. }
  985. if value, ok := _u.mutation.Model(); ok {
  986. _spec.SetField(usagelog.FieldModel, field.TypeString, value)
  987. }
  988. if value, ok := _u.mutation.RequestedModel(); ok {
  989. _spec.SetField(usagelog.FieldRequestedModel, field.TypeString, value)
  990. }
  991. if _u.mutation.RequestedModelCleared() {
  992. _spec.ClearField(usagelog.FieldRequestedModel, field.TypeString)
  993. }
  994. if value, ok := _u.mutation.UpstreamModel(); ok {
  995. _spec.SetField(usagelog.FieldUpstreamModel, field.TypeString, value)
  996. }
  997. if _u.mutation.UpstreamModelCleared() {
  998. _spec.ClearField(usagelog.FieldUpstreamModel, field.TypeString)
  999. }
  1000. if value, ok := _u.mutation.UpstreamResponseModel(); ok {
  1001. _spec.SetField(usagelog.FieldUpstreamResponseModel, field.TypeString, value)
  1002. }
  1003. if _u.mutation.UpstreamResponseModelCleared() {
  1004. _spec.ClearField(usagelog.FieldUpstreamResponseModel, field.TypeString)
  1005. }
  1006. if value, ok := _u.mutation.UpstreamModelMismatch(); ok {
  1007. _spec.SetField(usagelog.FieldUpstreamModelMismatch, field.TypeBool, value)
  1008. }
  1009. if _u.mutation.UpstreamModelMismatchCleared() {
  1010. _spec.ClearField(usagelog.FieldUpstreamModelMismatch, field.TypeBool)
  1011. }
  1012. if value, ok := _u.mutation.ChannelID(); ok {
  1013. _spec.SetField(usagelog.FieldChannelID, field.TypeInt64, value)
  1014. }
  1015. if value, ok := _u.mutation.AddedChannelID(); ok {
  1016. _spec.AddField(usagelog.FieldChannelID, field.TypeInt64, value)
  1017. }
  1018. if _u.mutation.ChannelIDCleared() {
  1019. _spec.ClearField(usagelog.FieldChannelID, field.TypeInt64)
  1020. }
  1021. if value, ok := _u.mutation.ModelMappingChain(); ok {
  1022. _spec.SetField(usagelog.FieldModelMappingChain, field.TypeString, value)
  1023. }
  1024. if _u.mutation.ModelMappingChainCleared() {
  1025. _spec.ClearField(usagelog.FieldModelMappingChain, field.TypeString)
  1026. }
  1027. if value, ok := _u.mutation.BillingTier(); ok {
  1028. _spec.SetField(usagelog.FieldBillingTier, field.TypeString, value)
  1029. }
  1030. if _u.mutation.BillingTierCleared() {
  1031. _spec.ClearField(usagelog.FieldBillingTier, field.TypeString)
  1032. }
  1033. if value, ok := _u.mutation.BillingMode(); ok {
  1034. _spec.SetField(usagelog.FieldBillingMode, field.TypeString, value)
  1035. }
  1036. if _u.mutation.BillingModeCleared() {
  1037. _spec.ClearField(usagelog.FieldBillingMode, field.TypeString)
  1038. }
  1039. if value, ok := _u.mutation.InputTokens(); ok {
  1040. _spec.SetField(usagelog.FieldInputTokens, field.TypeInt, value)
  1041. }
  1042. if value, ok := _u.mutation.AddedInputTokens(); ok {
  1043. _spec.AddField(usagelog.FieldInputTokens, field.TypeInt, value)
  1044. }
  1045. if value, ok := _u.mutation.OutputTokens(); ok {
  1046. _spec.SetField(usagelog.FieldOutputTokens, field.TypeInt, value)
  1047. }
  1048. if value, ok := _u.mutation.AddedOutputTokens(); ok {
  1049. _spec.AddField(usagelog.FieldOutputTokens, field.TypeInt, value)
  1050. }
  1051. if value, ok := _u.mutation.CacheCreationTokens(); ok {
  1052. _spec.SetField(usagelog.FieldCacheCreationTokens, field.TypeInt, value)
  1053. }
  1054. if value, ok := _u.mutation.AddedCacheCreationTokens(); ok {
  1055. _spec.AddField(usagelog.FieldCacheCreationTokens, field.TypeInt, value)
  1056. }
  1057. if value, ok := _u.mutation.CacheReadTokens(); ok {
  1058. _spec.SetField(usagelog.FieldCacheReadTokens, field.TypeInt, value)
  1059. }
  1060. if value, ok := _u.mutation.AddedCacheReadTokens(); ok {
  1061. _spec.AddField(usagelog.FieldCacheReadTokens, field.TypeInt, value)
  1062. }
  1063. if value, ok := _u.mutation.CacheCreation5mTokens(); ok {
  1064. _spec.SetField(usagelog.FieldCacheCreation5mTokens, field.TypeInt, value)
  1065. }
  1066. if value, ok := _u.mutation.AddedCacheCreation5mTokens(); ok {
  1067. _spec.AddField(usagelog.FieldCacheCreation5mTokens, field.TypeInt, value)
  1068. }
  1069. if value, ok := _u.mutation.CacheCreation1hTokens(); ok {
  1070. _spec.SetField(usagelog.FieldCacheCreation1hTokens, field.TypeInt, value)
  1071. }
  1072. if value, ok := _u.mutation.AddedCacheCreation1hTokens(); ok {
  1073. _spec.AddField(usagelog.FieldCacheCreation1hTokens, field.TypeInt, value)
  1074. }
  1075. if value, ok := _u.mutation.InputCost(); ok {
  1076. _spec.SetField(usagelog.FieldInputCost, field.TypeFloat64, value)
  1077. }
  1078. if value, ok := _u.mutation.AddedInputCost(); ok {
  1079. _spec.AddField(usagelog.FieldInputCost, field.TypeFloat64, value)
  1080. }
  1081. if value, ok := _u.mutation.OutputCost(); ok {
  1082. _spec.SetField(usagelog.FieldOutputCost, field.TypeFloat64, value)
  1083. }
  1084. if value, ok := _u.mutation.AddedOutputCost(); ok {
  1085. _spec.AddField(usagelog.FieldOutputCost, field.TypeFloat64, value)
  1086. }
  1087. if value, ok := _u.mutation.CacheCreationCost(); ok {
  1088. _spec.SetField(usagelog.FieldCacheCreationCost, field.TypeFloat64, value)
  1089. }
  1090. if value, ok := _u.mutation.AddedCacheCreationCost(); ok {
  1091. _spec.AddField(usagelog.FieldCacheCreationCost, field.TypeFloat64, value)
  1092. }
  1093. if value, ok := _u.mutation.CacheReadCost(); ok {
  1094. _spec.SetField(usagelog.FieldCacheReadCost, field.TypeFloat64, value)
  1095. }
  1096. if value, ok := _u.mutation.AddedCacheReadCost(); ok {
  1097. _spec.AddField(usagelog.FieldCacheReadCost, field.TypeFloat64, value)
  1098. }
  1099. if value, ok := _u.mutation.TotalCost(); ok {
  1100. _spec.SetField(usagelog.FieldTotalCost, field.TypeFloat64, value)
  1101. }
  1102. if value, ok := _u.mutation.AddedTotalCost(); ok {
  1103. _spec.AddField(usagelog.FieldTotalCost, field.TypeFloat64, value)
  1104. }
  1105. if value, ok := _u.mutation.ActualCost(); ok {
  1106. _spec.SetField(usagelog.FieldActualCost, field.TypeFloat64, value)
  1107. }
  1108. if value, ok := _u.mutation.AddedActualCost(); ok {
  1109. _spec.AddField(usagelog.FieldActualCost, field.TypeFloat64, value)
  1110. }
  1111. if value, ok := _u.mutation.RateMultiplier(); ok {
  1112. _spec.SetField(usagelog.FieldRateMultiplier, field.TypeFloat64, value)
  1113. }
  1114. if value, ok := _u.mutation.AddedRateMultiplier(); ok {
  1115. _spec.AddField(usagelog.FieldRateMultiplier, field.TypeFloat64, value)
  1116. }
  1117. if value, ok := _u.mutation.LongContextBillingApplied(); ok {
  1118. _spec.SetField(usagelog.FieldLongContextBillingApplied, field.TypeBool, value)
  1119. }
  1120. if value, ok := _u.mutation.AccountRateMultiplier(); ok {
  1121. _spec.SetField(usagelog.FieldAccountRateMultiplier, field.TypeFloat64, value)
  1122. }
  1123. if value, ok := _u.mutation.AddedAccountRateMultiplier(); ok {
  1124. _spec.AddField(usagelog.FieldAccountRateMultiplier, field.TypeFloat64, value)
  1125. }
  1126. if _u.mutation.AccountRateMultiplierCleared() {
  1127. _spec.ClearField(usagelog.FieldAccountRateMultiplier, field.TypeFloat64)
  1128. }
  1129. if value, ok := _u.mutation.BillingType(); ok {
  1130. _spec.SetField(usagelog.FieldBillingType, field.TypeInt8, value)
  1131. }
  1132. if value, ok := _u.mutation.AddedBillingType(); ok {
  1133. _spec.AddField(usagelog.FieldBillingType, field.TypeInt8, value)
  1134. }
  1135. if value, ok := _u.mutation.Stream(); ok {
  1136. _spec.SetField(usagelog.FieldStream, field.TypeBool, value)
  1137. }
  1138. if value, ok := _u.mutation.DurationMs(); ok {
  1139. _spec.SetField(usagelog.FieldDurationMs, field.TypeInt, value)
  1140. }
  1141. if value, ok := _u.mutation.AddedDurationMs(); ok {
  1142. _spec.AddField(usagelog.FieldDurationMs, field.TypeInt, value)
  1143. }
  1144. if _u.mutation.DurationMsCleared() {
  1145. _spec.ClearField(usagelog.FieldDurationMs, field.TypeInt)
  1146. }
  1147. if value, ok := _u.mutation.FirstTokenMs(); ok {
  1148. _spec.SetField(usagelog.FieldFirstTokenMs, field.TypeInt, value)
  1149. }
  1150. if value, ok := _u.mutation.AddedFirstTokenMs(); ok {
  1151. _spec.AddField(usagelog.FieldFirstTokenMs, field.TypeInt, value)
  1152. }
  1153. if _u.mutation.FirstTokenMsCleared() {
  1154. _spec.ClearField(usagelog.FieldFirstTokenMs, field.TypeInt)
  1155. }
  1156. if value, ok := _u.mutation.UserAgent(); ok {
  1157. _spec.SetField(usagelog.FieldUserAgent, field.TypeString, value)
  1158. }
  1159. if _u.mutation.UserAgentCleared() {
  1160. _spec.ClearField(usagelog.FieldUserAgent, field.TypeString)
  1161. }
  1162. if value, ok := _u.mutation.IPAddress(); ok {
  1163. _spec.SetField(usagelog.FieldIPAddress, field.TypeString, value)
  1164. }
  1165. if _u.mutation.IPAddressCleared() {
  1166. _spec.ClearField(usagelog.FieldIPAddress, field.TypeString)
  1167. }
  1168. if value, ok := _u.mutation.ImageCount(); ok {
  1169. _spec.SetField(usagelog.FieldImageCount, field.TypeInt, value)
  1170. }
  1171. if value, ok := _u.mutation.AddedImageCount(); ok {
  1172. _spec.AddField(usagelog.FieldImageCount, field.TypeInt, value)
  1173. }
  1174. if value, ok := _u.mutation.ImageSize(); ok {
  1175. _spec.SetField(usagelog.FieldImageSize, field.TypeString, value)
  1176. }
  1177. if _u.mutation.ImageSizeCleared() {
  1178. _spec.ClearField(usagelog.FieldImageSize, field.TypeString)
  1179. }
  1180. if value, ok := _u.mutation.ImageInputSize(); ok {
  1181. _spec.SetField(usagelog.FieldImageInputSize, field.TypeString, value)
  1182. }
  1183. if _u.mutation.ImageInputSizeCleared() {
  1184. _spec.ClearField(usagelog.FieldImageInputSize, field.TypeString)
  1185. }
  1186. if value, ok := _u.mutation.ImageOutputSize(); ok {
  1187. _spec.SetField(usagelog.FieldImageOutputSize, field.TypeString, value)
  1188. }
  1189. if _u.mutation.ImageOutputSizeCleared() {
  1190. _spec.ClearField(usagelog.FieldImageOutputSize, field.TypeString)
  1191. }
  1192. if value, ok := _u.mutation.ImageSizeSource(); ok {
  1193. _spec.SetField(usagelog.FieldImageSizeSource, field.TypeString, value)
  1194. }
  1195. if _u.mutation.ImageSizeSourceCleared() {
  1196. _spec.ClearField(usagelog.FieldImageSizeSource, field.TypeString)
  1197. }
  1198. if value, ok := _u.mutation.ImageSizeBreakdown(); ok {
  1199. _spec.SetField(usagelog.FieldImageSizeBreakdown, field.TypeJSON, value)
  1200. }
  1201. if _u.mutation.ImageSizeBreakdownCleared() {
  1202. _spec.ClearField(usagelog.FieldImageSizeBreakdown, field.TypeJSON)
  1203. }
  1204. if value, ok := _u.mutation.VideoCount(); ok {
  1205. _spec.SetField(usagelog.FieldVideoCount, field.TypeInt, value)
  1206. }
  1207. if value, ok := _u.mutation.AddedVideoCount(); ok {
  1208. _spec.AddField(usagelog.FieldVideoCount, field.TypeInt, value)
  1209. }
  1210. if value, ok := _u.mutation.VideoResolution(); ok {
  1211. _spec.SetField(usagelog.FieldVideoResolution, field.TypeString, value)
  1212. }
  1213. if _u.mutation.VideoResolutionCleared() {
  1214. _spec.ClearField(usagelog.FieldVideoResolution, field.TypeString)
  1215. }
  1216. if value, ok := _u.mutation.VideoDurationSeconds(); ok {
  1217. _spec.SetField(usagelog.FieldVideoDurationSeconds, field.TypeInt, value)
  1218. }
  1219. if value, ok := _u.mutation.AddedVideoDurationSeconds(); ok {
  1220. _spec.AddField(usagelog.FieldVideoDurationSeconds, field.TypeInt, value)
  1221. }
  1222. if _u.mutation.VideoDurationSecondsCleared() {
  1223. _spec.ClearField(usagelog.FieldVideoDurationSeconds, field.TypeInt)
  1224. }
  1225. if value, ok := _u.mutation.CacheTTLOverridden(); ok {
  1226. _spec.SetField(usagelog.FieldCacheTTLOverridden, field.TypeBool, value)
  1227. }
  1228. if _u.mutation.UserCleared() {
  1229. edge := &sqlgraph.EdgeSpec{
  1230. Rel: sqlgraph.M2O,
  1231. Inverse: true,
  1232. Table: usagelog.UserTable,
  1233. Columns: []string{usagelog.UserColumn},
  1234. Bidi: false,
  1235. Target: &sqlgraph.EdgeTarget{
  1236. IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
  1237. },
  1238. }
  1239. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1240. }
  1241. if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
  1242. edge := &sqlgraph.EdgeSpec{
  1243. Rel: sqlgraph.M2O,
  1244. Inverse: true,
  1245. Table: usagelog.UserTable,
  1246. Columns: []string{usagelog.UserColumn},
  1247. Bidi: false,
  1248. Target: &sqlgraph.EdgeTarget{
  1249. IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
  1250. },
  1251. }
  1252. for _, k := range nodes {
  1253. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1254. }
  1255. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1256. }
  1257. if _u.mutation.APIKeyCleared() {
  1258. edge := &sqlgraph.EdgeSpec{
  1259. Rel: sqlgraph.M2O,
  1260. Inverse: true,
  1261. Table: usagelog.APIKeyTable,
  1262. Columns: []string{usagelog.APIKeyColumn},
  1263. Bidi: false,
  1264. Target: &sqlgraph.EdgeTarget{
  1265. IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64),
  1266. },
  1267. }
  1268. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1269. }
  1270. if nodes := _u.mutation.APIKeyIDs(); len(nodes) > 0 {
  1271. edge := &sqlgraph.EdgeSpec{
  1272. Rel: sqlgraph.M2O,
  1273. Inverse: true,
  1274. Table: usagelog.APIKeyTable,
  1275. Columns: []string{usagelog.APIKeyColumn},
  1276. Bidi: false,
  1277. Target: &sqlgraph.EdgeTarget{
  1278. IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64),
  1279. },
  1280. }
  1281. for _, k := range nodes {
  1282. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1283. }
  1284. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1285. }
  1286. if _u.mutation.AccountCleared() {
  1287. edge := &sqlgraph.EdgeSpec{
  1288. Rel: sqlgraph.M2O,
  1289. Inverse: true,
  1290. Table: usagelog.AccountTable,
  1291. Columns: []string{usagelog.AccountColumn},
  1292. Bidi: false,
  1293. Target: &sqlgraph.EdgeTarget{
  1294. IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
  1295. },
  1296. }
  1297. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1298. }
  1299. if nodes := _u.mutation.AccountIDs(); len(nodes) > 0 {
  1300. edge := &sqlgraph.EdgeSpec{
  1301. Rel: sqlgraph.M2O,
  1302. Inverse: true,
  1303. Table: usagelog.AccountTable,
  1304. Columns: []string{usagelog.AccountColumn},
  1305. Bidi: false,
  1306. Target: &sqlgraph.EdgeTarget{
  1307. IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
  1308. },
  1309. }
  1310. for _, k := range nodes {
  1311. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1312. }
  1313. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1314. }
  1315. if _u.mutation.GroupCleared() {
  1316. edge := &sqlgraph.EdgeSpec{
  1317. Rel: sqlgraph.M2O,
  1318. Inverse: true,
  1319. Table: usagelog.GroupTable,
  1320. Columns: []string{usagelog.GroupColumn},
  1321. Bidi: false,
  1322. Target: &sqlgraph.EdgeTarget{
  1323. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  1324. },
  1325. }
  1326. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1327. }
  1328. if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
  1329. edge := &sqlgraph.EdgeSpec{
  1330. Rel: sqlgraph.M2O,
  1331. Inverse: true,
  1332. Table: usagelog.GroupTable,
  1333. Columns: []string{usagelog.GroupColumn},
  1334. Bidi: false,
  1335. Target: &sqlgraph.EdgeTarget{
  1336. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  1337. },
  1338. }
  1339. for _, k := range nodes {
  1340. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1341. }
  1342. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1343. }
  1344. if _u.mutation.SubscriptionCleared() {
  1345. edge := &sqlgraph.EdgeSpec{
  1346. Rel: sqlgraph.M2O,
  1347. Inverse: true,
  1348. Table: usagelog.SubscriptionTable,
  1349. Columns: []string{usagelog.SubscriptionColumn},
  1350. Bidi: false,
  1351. Target: &sqlgraph.EdgeTarget{
  1352. IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
  1353. },
  1354. }
  1355. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1356. }
  1357. if nodes := _u.mutation.SubscriptionIDs(); len(nodes) > 0 {
  1358. edge := &sqlgraph.EdgeSpec{
  1359. Rel: sqlgraph.M2O,
  1360. Inverse: true,
  1361. Table: usagelog.SubscriptionTable,
  1362. Columns: []string{usagelog.SubscriptionColumn},
  1363. Bidi: false,
  1364. Target: &sqlgraph.EdgeTarget{
  1365. IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
  1366. },
  1367. }
  1368. for _, k := range nodes {
  1369. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1370. }
  1371. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1372. }
  1373. if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
  1374. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  1375. err = &NotFoundError{usagelog.Label}
  1376. } else if sqlgraph.IsConstraintError(err) {
  1377. err = &ConstraintError{msg: err.Error(), wrap: err}
  1378. }
  1379. return 0, err
  1380. }
  1381. _u.mutation.done = true
  1382. return _node, nil
  1383. }
  1384. // UsageLogUpdateOne is the builder for updating a single UsageLog entity.
  1385. type UsageLogUpdateOne struct {
  1386. config
  1387. fields []string
  1388. hooks []Hook
  1389. mutation *UsageLogMutation
  1390. }
  1391. // SetUserID sets the "user_id" field.
  1392. func (_u *UsageLogUpdateOne) SetUserID(v int64) *UsageLogUpdateOne {
  1393. _u.mutation.SetUserID(v)
  1394. return _u
  1395. }
  1396. // SetNillableUserID sets the "user_id" field if the given value is not nil.
  1397. func (_u *UsageLogUpdateOne) SetNillableUserID(v *int64) *UsageLogUpdateOne {
  1398. if v != nil {
  1399. _u.SetUserID(*v)
  1400. }
  1401. return _u
  1402. }
  1403. // SetAPIKeyID sets the "api_key_id" field.
  1404. func (_u *UsageLogUpdateOne) SetAPIKeyID(v int64) *UsageLogUpdateOne {
  1405. _u.mutation.SetAPIKeyID(v)
  1406. return _u
  1407. }
  1408. // SetNillableAPIKeyID sets the "api_key_id" field if the given value is not nil.
  1409. func (_u *UsageLogUpdateOne) SetNillableAPIKeyID(v *int64) *UsageLogUpdateOne {
  1410. if v != nil {
  1411. _u.SetAPIKeyID(*v)
  1412. }
  1413. return _u
  1414. }
  1415. // SetAccountID sets the "account_id" field.
  1416. func (_u *UsageLogUpdateOne) SetAccountID(v int64) *UsageLogUpdateOne {
  1417. _u.mutation.SetAccountID(v)
  1418. return _u
  1419. }
  1420. // SetNillableAccountID sets the "account_id" field if the given value is not nil.
  1421. func (_u *UsageLogUpdateOne) SetNillableAccountID(v *int64) *UsageLogUpdateOne {
  1422. if v != nil {
  1423. _u.SetAccountID(*v)
  1424. }
  1425. return _u
  1426. }
  1427. // SetRequestID sets the "request_id" field.
  1428. func (_u *UsageLogUpdateOne) SetRequestID(v string) *UsageLogUpdateOne {
  1429. _u.mutation.SetRequestID(v)
  1430. return _u
  1431. }
  1432. // SetNillableRequestID sets the "request_id" field if the given value is not nil.
  1433. func (_u *UsageLogUpdateOne) SetNillableRequestID(v *string) *UsageLogUpdateOne {
  1434. if v != nil {
  1435. _u.SetRequestID(*v)
  1436. }
  1437. return _u
  1438. }
  1439. // SetModel sets the "model" field.
  1440. func (_u *UsageLogUpdateOne) SetModel(v string) *UsageLogUpdateOne {
  1441. _u.mutation.SetModel(v)
  1442. return _u
  1443. }
  1444. // SetNillableModel sets the "model" field if the given value is not nil.
  1445. func (_u *UsageLogUpdateOne) SetNillableModel(v *string) *UsageLogUpdateOne {
  1446. if v != nil {
  1447. _u.SetModel(*v)
  1448. }
  1449. return _u
  1450. }
  1451. // SetRequestedModel sets the "requested_model" field.
  1452. func (_u *UsageLogUpdateOne) SetRequestedModel(v string) *UsageLogUpdateOne {
  1453. _u.mutation.SetRequestedModel(v)
  1454. return _u
  1455. }
  1456. // SetNillableRequestedModel sets the "requested_model" field if the given value is not nil.
  1457. func (_u *UsageLogUpdateOne) SetNillableRequestedModel(v *string) *UsageLogUpdateOne {
  1458. if v != nil {
  1459. _u.SetRequestedModel(*v)
  1460. }
  1461. return _u
  1462. }
  1463. // ClearRequestedModel clears the value of the "requested_model" field.
  1464. func (_u *UsageLogUpdateOne) ClearRequestedModel() *UsageLogUpdateOne {
  1465. _u.mutation.ClearRequestedModel()
  1466. return _u
  1467. }
  1468. // SetUpstreamModel sets the "upstream_model" field.
  1469. func (_u *UsageLogUpdateOne) SetUpstreamModel(v string) *UsageLogUpdateOne {
  1470. _u.mutation.SetUpstreamModel(v)
  1471. return _u
  1472. }
  1473. // SetNillableUpstreamModel sets the "upstream_model" field if the given value is not nil.
  1474. func (_u *UsageLogUpdateOne) SetNillableUpstreamModel(v *string) *UsageLogUpdateOne {
  1475. if v != nil {
  1476. _u.SetUpstreamModel(*v)
  1477. }
  1478. return _u
  1479. }
  1480. // ClearUpstreamModel clears the value of the "upstream_model" field.
  1481. func (_u *UsageLogUpdateOne) ClearUpstreamModel() *UsageLogUpdateOne {
  1482. _u.mutation.ClearUpstreamModel()
  1483. return _u
  1484. }
  1485. // SetUpstreamResponseModel sets the "upstream_response_model" field.
  1486. func (_u *UsageLogUpdateOne) SetUpstreamResponseModel(v string) *UsageLogUpdateOne {
  1487. _u.mutation.SetUpstreamResponseModel(v)
  1488. return _u
  1489. }
  1490. // SetNillableUpstreamResponseModel sets the "upstream_response_model" field if the given value is not nil.
  1491. func (_u *UsageLogUpdateOne) SetNillableUpstreamResponseModel(v *string) *UsageLogUpdateOne {
  1492. if v != nil {
  1493. _u.SetUpstreamResponseModel(*v)
  1494. }
  1495. return _u
  1496. }
  1497. // ClearUpstreamResponseModel clears the value of the "upstream_response_model" field.
  1498. func (_u *UsageLogUpdateOne) ClearUpstreamResponseModel() *UsageLogUpdateOne {
  1499. _u.mutation.ClearUpstreamResponseModel()
  1500. return _u
  1501. }
  1502. // SetUpstreamModelMismatch sets the "upstream_model_mismatch" field.
  1503. func (_u *UsageLogUpdateOne) SetUpstreamModelMismatch(v bool) *UsageLogUpdateOne {
  1504. _u.mutation.SetUpstreamModelMismatch(v)
  1505. return _u
  1506. }
  1507. // SetNillableUpstreamModelMismatch sets the "upstream_model_mismatch" field if the given value is not nil.
  1508. func (_u *UsageLogUpdateOne) SetNillableUpstreamModelMismatch(v *bool) *UsageLogUpdateOne {
  1509. if v != nil {
  1510. _u.SetUpstreamModelMismatch(*v)
  1511. }
  1512. return _u
  1513. }
  1514. // ClearUpstreamModelMismatch clears the value of the "upstream_model_mismatch" field.
  1515. func (_u *UsageLogUpdateOne) ClearUpstreamModelMismatch() *UsageLogUpdateOne {
  1516. _u.mutation.ClearUpstreamModelMismatch()
  1517. return _u
  1518. }
  1519. // SetChannelID sets the "channel_id" field.
  1520. func (_u *UsageLogUpdateOne) SetChannelID(v int64) *UsageLogUpdateOne {
  1521. _u.mutation.ResetChannelID()
  1522. _u.mutation.SetChannelID(v)
  1523. return _u
  1524. }
  1525. // SetNillableChannelID sets the "channel_id" field if the given value is not nil.
  1526. func (_u *UsageLogUpdateOne) SetNillableChannelID(v *int64) *UsageLogUpdateOne {
  1527. if v != nil {
  1528. _u.SetChannelID(*v)
  1529. }
  1530. return _u
  1531. }
  1532. // AddChannelID adds value to the "channel_id" field.
  1533. func (_u *UsageLogUpdateOne) AddChannelID(v int64) *UsageLogUpdateOne {
  1534. _u.mutation.AddChannelID(v)
  1535. return _u
  1536. }
  1537. // ClearChannelID clears the value of the "channel_id" field.
  1538. func (_u *UsageLogUpdateOne) ClearChannelID() *UsageLogUpdateOne {
  1539. _u.mutation.ClearChannelID()
  1540. return _u
  1541. }
  1542. // SetModelMappingChain sets the "model_mapping_chain" field.
  1543. func (_u *UsageLogUpdateOne) SetModelMappingChain(v string) *UsageLogUpdateOne {
  1544. _u.mutation.SetModelMappingChain(v)
  1545. return _u
  1546. }
  1547. // SetNillableModelMappingChain sets the "model_mapping_chain" field if the given value is not nil.
  1548. func (_u *UsageLogUpdateOne) SetNillableModelMappingChain(v *string) *UsageLogUpdateOne {
  1549. if v != nil {
  1550. _u.SetModelMappingChain(*v)
  1551. }
  1552. return _u
  1553. }
  1554. // ClearModelMappingChain clears the value of the "model_mapping_chain" field.
  1555. func (_u *UsageLogUpdateOne) ClearModelMappingChain() *UsageLogUpdateOne {
  1556. _u.mutation.ClearModelMappingChain()
  1557. return _u
  1558. }
  1559. // SetBillingTier sets the "billing_tier" field.
  1560. func (_u *UsageLogUpdateOne) SetBillingTier(v string) *UsageLogUpdateOne {
  1561. _u.mutation.SetBillingTier(v)
  1562. return _u
  1563. }
  1564. // SetNillableBillingTier sets the "billing_tier" field if the given value is not nil.
  1565. func (_u *UsageLogUpdateOne) SetNillableBillingTier(v *string) *UsageLogUpdateOne {
  1566. if v != nil {
  1567. _u.SetBillingTier(*v)
  1568. }
  1569. return _u
  1570. }
  1571. // ClearBillingTier clears the value of the "billing_tier" field.
  1572. func (_u *UsageLogUpdateOne) ClearBillingTier() *UsageLogUpdateOne {
  1573. _u.mutation.ClearBillingTier()
  1574. return _u
  1575. }
  1576. // SetBillingMode sets the "billing_mode" field.
  1577. func (_u *UsageLogUpdateOne) SetBillingMode(v string) *UsageLogUpdateOne {
  1578. _u.mutation.SetBillingMode(v)
  1579. return _u
  1580. }
  1581. // SetNillableBillingMode sets the "billing_mode" field if the given value is not nil.
  1582. func (_u *UsageLogUpdateOne) SetNillableBillingMode(v *string) *UsageLogUpdateOne {
  1583. if v != nil {
  1584. _u.SetBillingMode(*v)
  1585. }
  1586. return _u
  1587. }
  1588. // ClearBillingMode clears the value of the "billing_mode" field.
  1589. func (_u *UsageLogUpdateOne) ClearBillingMode() *UsageLogUpdateOne {
  1590. _u.mutation.ClearBillingMode()
  1591. return _u
  1592. }
  1593. // SetGroupID sets the "group_id" field.
  1594. func (_u *UsageLogUpdateOne) SetGroupID(v int64) *UsageLogUpdateOne {
  1595. _u.mutation.SetGroupID(v)
  1596. return _u
  1597. }
  1598. // SetNillableGroupID sets the "group_id" field if the given value is not nil.
  1599. func (_u *UsageLogUpdateOne) SetNillableGroupID(v *int64) *UsageLogUpdateOne {
  1600. if v != nil {
  1601. _u.SetGroupID(*v)
  1602. }
  1603. return _u
  1604. }
  1605. // ClearGroupID clears the value of the "group_id" field.
  1606. func (_u *UsageLogUpdateOne) ClearGroupID() *UsageLogUpdateOne {
  1607. _u.mutation.ClearGroupID()
  1608. return _u
  1609. }
  1610. // SetSubscriptionID sets the "subscription_id" field.
  1611. func (_u *UsageLogUpdateOne) SetSubscriptionID(v int64) *UsageLogUpdateOne {
  1612. _u.mutation.SetSubscriptionID(v)
  1613. return _u
  1614. }
  1615. // SetNillableSubscriptionID sets the "subscription_id" field if the given value is not nil.
  1616. func (_u *UsageLogUpdateOne) SetNillableSubscriptionID(v *int64) *UsageLogUpdateOne {
  1617. if v != nil {
  1618. _u.SetSubscriptionID(*v)
  1619. }
  1620. return _u
  1621. }
  1622. // ClearSubscriptionID clears the value of the "subscription_id" field.
  1623. func (_u *UsageLogUpdateOne) ClearSubscriptionID() *UsageLogUpdateOne {
  1624. _u.mutation.ClearSubscriptionID()
  1625. return _u
  1626. }
  1627. // SetInputTokens sets the "input_tokens" field.
  1628. func (_u *UsageLogUpdateOne) SetInputTokens(v int) *UsageLogUpdateOne {
  1629. _u.mutation.ResetInputTokens()
  1630. _u.mutation.SetInputTokens(v)
  1631. return _u
  1632. }
  1633. // SetNillableInputTokens sets the "input_tokens" field if the given value is not nil.
  1634. func (_u *UsageLogUpdateOne) SetNillableInputTokens(v *int) *UsageLogUpdateOne {
  1635. if v != nil {
  1636. _u.SetInputTokens(*v)
  1637. }
  1638. return _u
  1639. }
  1640. // AddInputTokens adds value to the "input_tokens" field.
  1641. func (_u *UsageLogUpdateOne) AddInputTokens(v int) *UsageLogUpdateOne {
  1642. _u.mutation.AddInputTokens(v)
  1643. return _u
  1644. }
  1645. // SetOutputTokens sets the "output_tokens" field.
  1646. func (_u *UsageLogUpdateOne) SetOutputTokens(v int) *UsageLogUpdateOne {
  1647. _u.mutation.ResetOutputTokens()
  1648. _u.mutation.SetOutputTokens(v)
  1649. return _u
  1650. }
  1651. // SetNillableOutputTokens sets the "output_tokens" field if the given value is not nil.
  1652. func (_u *UsageLogUpdateOne) SetNillableOutputTokens(v *int) *UsageLogUpdateOne {
  1653. if v != nil {
  1654. _u.SetOutputTokens(*v)
  1655. }
  1656. return _u
  1657. }
  1658. // AddOutputTokens adds value to the "output_tokens" field.
  1659. func (_u *UsageLogUpdateOne) AddOutputTokens(v int) *UsageLogUpdateOne {
  1660. _u.mutation.AddOutputTokens(v)
  1661. return _u
  1662. }
  1663. // SetCacheCreationTokens sets the "cache_creation_tokens" field.
  1664. func (_u *UsageLogUpdateOne) SetCacheCreationTokens(v int) *UsageLogUpdateOne {
  1665. _u.mutation.ResetCacheCreationTokens()
  1666. _u.mutation.SetCacheCreationTokens(v)
  1667. return _u
  1668. }
  1669. // SetNillableCacheCreationTokens sets the "cache_creation_tokens" field if the given value is not nil.
  1670. func (_u *UsageLogUpdateOne) SetNillableCacheCreationTokens(v *int) *UsageLogUpdateOne {
  1671. if v != nil {
  1672. _u.SetCacheCreationTokens(*v)
  1673. }
  1674. return _u
  1675. }
  1676. // AddCacheCreationTokens adds value to the "cache_creation_tokens" field.
  1677. func (_u *UsageLogUpdateOne) AddCacheCreationTokens(v int) *UsageLogUpdateOne {
  1678. _u.mutation.AddCacheCreationTokens(v)
  1679. return _u
  1680. }
  1681. // SetCacheReadTokens sets the "cache_read_tokens" field.
  1682. func (_u *UsageLogUpdateOne) SetCacheReadTokens(v int) *UsageLogUpdateOne {
  1683. _u.mutation.ResetCacheReadTokens()
  1684. _u.mutation.SetCacheReadTokens(v)
  1685. return _u
  1686. }
  1687. // SetNillableCacheReadTokens sets the "cache_read_tokens" field if the given value is not nil.
  1688. func (_u *UsageLogUpdateOne) SetNillableCacheReadTokens(v *int) *UsageLogUpdateOne {
  1689. if v != nil {
  1690. _u.SetCacheReadTokens(*v)
  1691. }
  1692. return _u
  1693. }
  1694. // AddCacheReadTokens adds value to the "cache_read_tokens" field.
  1695. func (_u *UsageLogUpdateOne) AddCacheReadTokens(v int) *UsageLogUpdateOne {
  1696. _u.mutation.AddCacheReadTokens(v)
  1697. return _u
  1698. }
  1699. // SetCacheCreation5mTokens sets the "cache_creation_5m_tokens" field.
  1700. func (_u *UsageLogUpdateOne) SetCacheCreation5mTokens(v int) *UsageLogUpdateOne {
  1701. _u.mutation.ResetCacheCreation5mTokens()
  1702. _u.mutation.SetCacheCreation5mTokens(v)
  1703. return _u
  1704. }
  1705. // SetNillableCacheCreation5mTokens sets the "cache_creation_5m_tokens" field if the given value is not nil.
  1706. func (_u *UsageLogUpdateOne) SetNillableCacheCreation5mTokens(v *int) *UsageLogUpdateOne {
  1707. if v != nil {
  1708. _u.SetCacheCreation5mTokens(*v)
  1709. }
  1710. return _u
  1711. }
  1712. // AddCacheCreation5mTokens adds value to the "cache_creation_5m_tokens" field.
  1713. func (_u *UsageLogUpdateOne) AddCacheCreation5mTokens(v int) *UsageLogUpdateOne {
  1714. _u.mutation.AddCacheCreation5mTokens(v)
  1715. return _u
  1716. }
  1717. // SetCacheCreation1hTokens sets the "cache_creation_1h_tokens" field.
  1718. func (_u *UsageLogUpdateOne) SetCacheCreation1hTokens(v int) *UsageLogUpdateOne {
  1719. _u.mutation.ResetCacheCreation1hTokens()
  1720. _u.mutation.SetCacheCreation1hTokens(v)
  1721. return _u
  1722. }
  1723. // SetNillableCacheCreation1hTokens sets the "cache_creation_1h_tokens" field if the given value is not nil.
  1724. func (_u *UsageLogUpdateOne) SetNillableCacheCreation1hTokens(v *int) *UsageLogUpdateOne {
  1725. if v != nil {
  1726. _u.SetCacheCreation1hTokens(*v)
  1727. }
  1728. return _u
  1729. }
  1730. // AddCacheCreation1hTokens adds value to the "cache_creation_1h_tokens" field.
  1731. func (_u *UsageLogUpdateOne) AddCacheCreation1hTokens(v int) *UsageLogUpdateOne {
  1732. _u.mutation.AddCacheCreation1hTokens(v)
  1733. return _u
  1734. }
  1735. // SetInputCost sets the "input_cost" field.
  1736. func (_u *UsageLogUpdateOne) SetInputCost(v float64) *UsageLogUpdateOne {
  1737. _u.mutation.ResetInputCost()
  1738. _u.mutation.SetInputCost(v)
  1739. return _u
  1740. }
  1741. // SetNillableInputCost sets the "input_cost" field if the given value is not nil.
  1742. func (_u *UsageLogUpdateOne) SetNillableInputCost(v *float64) *UsageLogUpdateOne {
  1743. if v != nil {
  1744. _u.SetInputCost(*v)
  1745. }
  1746. return _u
  1747. }
  1748. // AddInputCost adds value to the "input_cost" field.
  1749. func (_u *UsageLogUpdateOne) AddInputCost(v float64) *UsageLogUpdateOne {
  1750. _u.mutation.AddInputCost(v)
  1751. return _u
  1752. }
  1753. // SetOutputCost sets the "output_cost" field.
  1754. func (_u *UsageLogUpdateOne) SetOutputCost(v float64) *UsageLogUpdateOne {
  1755. _u.mutation.ResetOutputCost()
  1756. _u.mutation.SetOutputCost(v)
  1757. return _u
  1758. }
  1759. // SetNillableOutputCost sets the "output_cost" field if the given value is not nil.
  1760. func (_u *UsageLogUpdateOne) SetNillableOutputCost(v *float64) *UsageLogUpdateOne {
  1761. if v != nil {
  1762. _u.SetOutputCost(*v)
  1763. }
  1764. return _u
  1765. }
  1766. // AddOutputCost adds value to the "output_cost" field.
  1767. func (_u *UsageLogUpdateOne) AddOutputCost(v float64) *UsageLogUpdateOne {
  1768. _u.mutation.AddOutputCost(v)
  1769. return _u
  1770. }
  1771. // SetCacheCreationCost sets the "cache_creation_cost" field.
  1772. func (_u *UsageLogUpdateOne) SetCacheCreationCost(v float64) *UsageLogUpdateOne {
  1773. _u.mutation.ResetCacheCreationCost()
  1774. _u.mutation.SetCacheCreationCost(v)
  1775. return _u
  1776. }
  1777. // SetNillableCacheCreationCost sets the "cache_creation_cost" field if the given value is not nil.
  1778. func (_u *UsageLogUpdateOne) SetNillableCacheCreationCost(v *float64) *UsageLogUpdateOne {
  1779. if v != nil {
  1780. _u.SetCacheCreationCost(*v)
  1781. }
  1782. return _u
  1783. }
  1784. // AddCacheCreationCost adds value to the "cache_creation_cost" field.
  1785. func (_u *UsageLogUpdateOne) AddCacheCreationCost(v float64) *UsageLogUpdateOne {
  1786. _u.mutation.AddCacheCreationCost(v)
  1787. return _u
  1788. }
  1789. // SetCacheReadCost sets the "cache_read_cost" field.
  1790. func (_u *UsageLogUpdateOne) SetCacheReadCost(v float64) *UsageLogUpdateOne {
  1791. _u.mutation.ResetCacheReadCost()
  1792. _u.mutation.SetCacheReadCost(v)
  1793. return _u
  1794. }
  1795. // SetNillableCacheReadCost sets the "cache_read_cost" field if the given value is not nil.
  1796. func (_u *UsageLogUpdateOne) SetNillableCacheReadCost(v *float64) *UsageLogUpdateOne {
  1797. if v != nil {
  1798. _u.SetCacheReadCost(*v)
  1799. }
  1800. return _u
  1801. }
  1802. // AddCacheReadCost adds value to the "cache_read_cost" field.
  1803. func (_u *UsageLogUpdateOne) AddCacheReadCost(v float64) *UsageLogUpdateOne {
  1804. _u.mutation.AddCacheReadCost(v)
  1805. return _u
  1806. }
  1807. // SetTotalCost sets the "total_cost" field.
  1808. func (_u *UsageLogUpdateOne) SetTotalCost(v float64) *UsageLogUpdateOne {
  1809. _u.mutation.ResetTotalCost()
  1810. _u.mutation.SetTotalCost(v)
  1811. return _u
  1812. }
  1813. // SetNillableTotalCost sets the "total_cost" field if the given value is not nil.
  1814. func (_u *UsageLogUpdateOne) SetNillableTotalCost(v *float64) *UsageLogUpdateOne {
  1815. if v != nil {
  1816. _u.SetTotalCost(*v)
  1817. }
  1818. return _u
  1819. }
  1820. // AddTotalCost adds value to the "total_cost" field.
  1821. func (_u *UsageLogUpdateOne) AddTotalCost(v float64) *UsageLogUpdateOne {
  1822. _u.mutation.AddTotalCost(v)
  1823. return _u
  1824. }
  1825. // SetActualCost sets the "actual_cost" field.
  1826. func (_u *UsageLogUpdateOne) SetActualCost(v float64) *UsageLogUpdateOne {
  1827. _u.mutation.ResetActualCost()
  1828. _u.mutation.SetActualCost(v)
  1829. return _u
  1830. }
  1831. // SetNillableActualCost sets the "actual_cost" field if the given value is not nil.
  1832. func (_u *UsageLogUpdateOne) SetNillableActualCost(v *float64) *UsageLogUpdateOne {
  1833. if v != nil {
  1834. _u.SetActualCost(*v)
  1835. }
  1836. return _u
  1837. }
  1838. // AddActualCost adds value to the "actual_cost" field.
  1839. func (_u *UsageLogUpdateOne) AddActualCost(v float64) *UsageLogUpdateOne {
  1840. _u.mutation.AddActualCost(v)
  1841. return _u
  1842. }
  1843. // SetRateMultiplier sets the "rate_multiplier" field.
  1844. func (_u *UsageLogUpdateOne) SetRateMultiplier(v float64) *UsageLogUpdateOne {
  1845. _u.mutation.ResetRateMultiplier()
  1846. _u.mutation.SetRateMultiplier(v)
  1847. return _u
  1848. }
  1849. // SetNillableRateMultiplier sets the "rate_multiplier" field if the given value is not nil.
  1850. func (_u *UsageLogUpdateOne) SetNillableRateMultiplier(v *float64) *UsageLogUpdateOne {
  1851. if v != nil {
  1852. _u.SetRateMultiplier(*v)
  1853. }
  1854. return _u
  1855. }
  1856. // AddRateMultiplier adds value to the "rate_multiplier" field.
  1857. func (_u *UsageLogUpdateOne) AddRateMultiplier(v float64) *UsageLogUpdateOne {
  1858. _u.mutation.AddRateMultiplier(v)
  1859. return _u
  1860. }
  1861. // SetLongContextBillingApplied sets the "long_context_billing_applied" field.
  1862. func (_u *UsageLogUpdateOne) SetLongContextBillingApplied(v bool) *UsageLogUpdateOne {
  1863. _u.mutation.SetLongContextBillingApplied(v)
  1864. return _u
  1865. }
  1866. // SetNillableLongContextBillingApplied sets the "long_context_billing_applied" field if the given value is not nil.
  1867. func (_u *UsageLogUpdateOne) SetNillableLongContextBillingApplied(v *bool) *UsageLogUpdateOne {
  1868. if v != nil {
  1869. _u.SetLongContextBillingApplied(*v)
  1870. }
  1871. return _u
  1872. }
  1873. // SetAccountRateMultiplier sets the "account_rate_multiplier" field.
  1874. func (_u *UsageLogUpdateOne) SetAccountRateMultiplier(v float64) *UsageLogUpdateOne {
  1875. _u.mutation.ResetAccountRateMultiplier()
  1876. _u.mutation.SetAccountRateMultiplier(v)
  1877. return _u
  1878. }
  1879. // SetNillableAccountRateMultiplier sets the "account_rate_multiplier" field if the given value is not nil.
  1880. func (_u *UsageLogUpdateOne) SetNillableAccountRateMultiplier(v *float64) *UsageLogUpdateOne {
  1881. if v != nil {
  1882. _u.SetAccountRateMultiplier(*v)
  1883. }
  1884. return _u
  1885. }
  1886. // AddAccountRateMultiplier adds value to the "account_rate_multiplier" field.
  1887. func (_u *UsageLogUpdateOne) AddAccountRateMultiplier(v float64) *UsageLogUpdateOne {
  1888. _u.mutation.AddAccountRateMultiplier(v)
  1889. return _u
  1890. }
  1891. // ClearAccountRateMultiplier clears the value of the "account_rate_multiplier" field.
  1892. func (_u *UsageLogUpdateOne) ClearAccountRateMultiplier() *UsageLogUpdateOne {
  1893. _u.mutation.ClearAccountRateMultiplier()
  1894. return _u
  1895. }
  1896. // SetBillingType sets the "billing_type" field.
  1897. func (_u *UsageLogUpdateOne) SetBillingType(v int8) *UsageLogUpdateOne {
  1898. _u.mutation.ResetBillingType()
  1899. _u.mutation.SetBillingType(v)
  1900. return _u
  1901. }
  1902. // SetNillableBillingType sets the "billing_type" field if the given value is not nil.
  1903. func (_u *UsageLogUpdateOne) SetNillableBillingType(v *int8) *UsageLogUpdateOne {
  1904. if v != nil {
  1905. _u.SetBillingType(*v)
  1906. }
  1907. return _u
  1908. }
  1909. // AddBillingType adds value to the "billing_type" field.
  1910. func (_u *UsageLogUpdateOne) AddBillingType(v int8) *UsageLogUpdateOne {
  1911. _u.mutation.AddBillingType(v)
  1912. return _u
  1913. }
  1914. // SetStream sets the "stream" field.
  1915. func (_u *UsageLogUpdateOne) SetStream(v bool) *UsageLogUpdateOne {
  1916. _u.mutation.SetStream(v)
  1917. return _u
  1918. }
  1919. // SetNillableStream sets the "stream" field if the given value is not nil.
  1920. func (_u *UsageLogUpdateOne) SetNillableStream(v *bool) *UsageLogUpdateOne {
  1921. if v != nil {
  1922. _u.SetStream(*v)
  1923. }
  1924. return _u
  1925. }
  1926. // SetDurationMs sets the "duration_ms" field.
  1927. func (_u *UsageLogUpdateOne) SetDurationMs(v int) *UsageLogUpdateOne {
  1928. _u.mutation.ResetDurationMs()
  1929. _u.mutation.SetDurationMs(v)
  1930. return _u
  1931. }
  1932. // SetNillableDurationMs sets the "duration_ms" field if the given value is not nil.
  1933. func (_u *UsageLogUpdateOne) SetNillableDurationMs(v *int) *UsageLogUpdateOne {
  1934. if v != nil {
  1935. _u.SetDurationMs(*v)
  1936. }
  1937. return _u
  1938. }
  1939. // AddDurationMs adds value to the "duration_ms" field.
  1940. func (_u *UsageLogUpdateOne) AddDurationMs(v int) *UsageLogUpdateOne {
  1941. _u.mutation.AddDurationMs(v)
  1942. return _u
  1943. }
  1944. // ClearDurationMs clears the value of the "duration_ms" field.
  1945. func (_u *UsageLogUpdateOne) ClearDurationMs() *UsageLogUpdateOne {
  1946. _u.mutation.ClearDurationMs()
  1947. return _u
  1948. }
  1949. // SetFirstTokenMs sets the "first_token_ms" field.
  1950. func (_u *UsageLogUpdateOne) SetFirstTokenMs(v int) *UsageLogUpdateOne {
  1951. _u.mutation.ResetFirstTokenMs()
  1952. _u.mutation.SetFirstTokenMs(v)
  1953. return _u
  1954. }
  1955. // SetNillableFirstTokenMs sets the "first_token_ms" field if the given value is not nil.
  1956. func (_u *UsageLogUpdateOne) SetNillableFirstTokenMs(v *int) *UsageLogUpdateOne {
  1957. if v != nil {
  1958. _u.SetFirstTokenMs(*v)
  1959. }
  1960. return _u
  1961. }
  1962. // AddFirstTokenMs adds value to the "first_token_ms" field.
  1963. func (_u *UsageLogUpdateOne) AddFirstTokenMs(v int) *UsageLogUpdateOne {
  1964. _u.mutation.AddFirstTokenMs(v)
  1965. return _u
  1966. }
  1967. // ClearFirstTokenMs clears the value of the "first_token_ms" field.
  1968. func (_u *UsageLogUpdateOne) ClearFirstTokenMs() *UsageLogUpdateOne {
  1969. _u.mutation.ClearFirstTokenMs()
  1970. return _u
  1971. }
  1972. // SetUserAgent sets the "user_agent" field.
  1973. func (_u *UsageLogUpdateOne) SetUserAgent(v string) *UsageLogUpdateOne {
  1974. _u.mutation.SetUserAgent(v)
  1975. return _u
  1976. }
  1977. // SetNillableUserAgent sets the "user_agent" field if the given value is not nil.
  1978. func (_u *UsageLogUpdateOne) SetNillableUserAgent(v *string) *UsageLogUpdateOne {
  1979. if v != nil {
  1980. _u.SetUserAgent(*v)
  1981. }
  1982. return _u
  1983. }
  1984. // ClearUserAgent clears the value of the "user_agent" field.
  1985. func (_u *UsageLogUpdateOne) ClearUserAgent() *UsageLogUpdateOne {
  1986. _u.mutation.ClearUserAgent()
  1987. return _u
  1988. }
  1989. // SetIPAddress sets the "ip_address" field.
  1990. func (_u *UsageLogUpdateOne) SetIPAddress(v string) *UsageLogUpdateOne {
  1991. _u.mutation.SetIPAddress(v)
  1992. return _u
  1993. }
  1994. // SetNillableIPAddress sets the "ip_address" field if the given value is not nil.
  1995. func (_u *UsageLogUpdateOne) SetNillableIPAddress(v *string) *UsageLogUpdateOne {
  1996. if v != nil {
  1997. _u.SetIPAddress(*v)
  1998. }
  1999. return _u
  2000. }
  2001. // ClearIPAddress clears the value of the "ip_address" field.
  2002. func (_u *UsageLogUpdateOne) ClearIPAddress() *UsageLogUpdateOne {
  2003. _u.mutation.ClearIPAddress()
  2004. return _u
  2005. }
  2006. // SetImageCount sets the "image_count" field.
  2007. func (_u *UsageLogUpdateOne) SetImageCount(v int) *UsageLogUpdateOne {
  2008. _u.mutation.ResetImageCount()
  2009. _u.mutation.SetImageCount(v)
  2010. return _u
  2011. }
  2012. // SetNillableImageCount sets the "image_count" field if the given value is not nil.
  2013. func (_u *UsageLogUpdateOne) SetNillableImageCount(v *int) *UsageLogUpdateOne {
  2014. if v != nil {
  2015. _u.SetImageCount(*v)
  2016. }
  2017. return _u
  2018. }
  2019. // AddImageCount adds value to the "image_count" field.
  2020. func (_u *UsageLogUpdateOne) AddImageCount(v int) *UsageLogUpdateOne {
  2021. _u.mutation.AddImageCount(v)
  2022. return _u
  2023. }
  2024. // SetImageSize sets the "image_size" field.
  2025. func (_u *UsageLogUpdateOne) SetImageSize(v string) *UsageLogUpdateOne {
  2026. _u.mutation.SetImageSize(v)
  2027. return _u
  2028. }
  2029. // SetNillableImageSize sets the "image_size" field if the given value is not nil.
  2030. func (_u *UsageLogUpdateOne) SetNillableImageSize(v *string) *UsageLogUpdateOne {
  2031. if v != nil {
  2032. _u.SetImageSize(*v)
  2033. }
  2034. return _u
  2035. }
  2036. // ClearImageSize clears the value of the "image_size" field.
  2037. func (_u *UsageLogUpdateOne) ClearImageSize() *UsageLogUpdateOne {
  2038. _u.mutation.ClearImageSize()
  2039. return _u
  2040. }
  2041. // SetImageInputSize sets the "image_input_size" field.
  2042. func (_u *UsageLogUpdateOne) SetImageInputSize(v string) *UsageLogUpdateOne {
  2043. _u.mutation.SetImageInputSize(v)
  2044. return _u
  2045. }
  2046. // SetNillableImageInputSize sets the "image_input_size" field if the given value is not nil.
  2047. func (_u *UsageLogUpdateOne) SetNillableImageInputSize(v *string) *UsageLogUpdateOne {
  2048. if v != nil {
  2049. _u.SetImageInputSize(*v)
  2050. }
  2051. return _u
  2052. }
  2053. // ClearImageInputSize clears the value of the "image_input_size" field.
  2054. func (_u *UsageLogUpdateOne) ClearImageInputSize() *UsageLogUpdateOne {
  2055. _u.mutation.ClearImageInputSize()
  2056. return _u
  2057. }
  2058. // SetImageOutputSize sets the "image_output_size" field.
  2059. func (_u *UsageLogUpdateOne) SetImageOutputSize(v string) *UsageLogUpdateOne {
  2060. _u.mutation.SetImageOutputSize(v)
  2061. return _u
  2062. }
  2063. // SetNillableImageOutputSize sets the "image_output_size" field if the given value is not nil.
  2064. func (_u *UsageLogUpdateOne) SetNillableImageOutputSize(v *string) *UsageLogUpdateOne {
  2065. if v != nil {
  2066. _u.SetImageOutputSize(*v)
  2067. }
  2068. return _u
  2069. }
  2070. // ClearImageOutputSize clears the value of the "image_output_size" field.
  2071. func (_u *UsageLogUpdateOne) ClearImageOutputSize() *UsageLogUpdateOne {
  2072. _u.mutation.ClearImageOutputSize()
  2073. return _u
  2074. }
  2075. // SetImageSizeSource sets the "image_size_source" field.
  2076. func (_u *UsageLogUpdateOne) SetImageSizeSource(v string) *UsageLogUpdateOne {
  2077. _u.mutation.SetImageSizeSource(v)
  2078. return _u
  2079. }
  2080. // SetNillableImageSizeSource sets the "image_size_source" field if the given value is not nil.
  2081. func (_u *UsageLogUpdateOne) SetNillableImageSizeSource(v *string) *UsageLogUpdateOne {
  2082. if v != nil {
  2083. _u.SetImageSizeSource(*v)
  2084. }
  2085. return _u
  2086. }
  2087. // ClearImageSizeSource clears the value of the "image_size_source" field.
  2088. func (_u *UsageLogUpdateOne) ClearImageSizeSource() *UsageLogUpdateOne {
  2089. _u.mutation.ClearImageSizeSource()
  2090. return _u
  2091. }
  2092. // SetImageSizeBreakdown sets the "image_size_breakdown" field.
  2093. func (_u *UsageLogUpdateOne) SetImageSizeBreakdown(v map[string]int) *UsageLogUpdateOne {
  2094. _u.mutation.SetImageSizeBreakdown(v)
  2095. return _u
  2096. }
  2097. // ClearImageSizeBreakdown clears the value of the "image_size_breakdown" field.
  2098. func (_u *UsageLogUpdateOne) ClearImageSizeBreakdown() *UsageLogUpdateOne {
  2099. _u.mutation.ClearImageSizeBreakdown()
  2100. return _u
  2101. }
  2102. // SetVideoCount sets the "video_count" field.
  2103. func (_u *UsageLogUpdateOne) SetVideoCount(v int) *UsageLogUpdateOne {
  2104. _u.mutation.ResetVideoCount()
  2105. _u.mutation.SetVideoCount(v)
  2106. return _u
  2107. }
  2108. // SetNillableVideoCount sets the "video_count" field if the given value is not nil.
  2109. func (_u *UsageLogUpdateOne) SetNillableVideoCount(v *int) *UsageLogUpdateOne {
  2110. if v != nil {
  2111. _u.SetVideoCount(*v)
  2112. }
  2113. return _u
  2114. }
  2115. // AddVideoCount adds value to the "video_count" field.
  2116. func (_u *UsageLogUpdateOne) AddVideoCount(v int) *UsageLogUpdateOne {
  2117. _u.mutation.AddVideoCount(v)
  2118. return _u
  2119. }
  2120. // SetVideoResolution sets the "video_resolution" field.
  2121. func (_u *UsageLogUpdateOne) SetVideoResolution(v string) *UsageLogUpdateOne {
  2122. _u.mutation.SetVideoResolution(v)
  2123. return _u
  2124. }
  2125. // SetNillableVideoResolution sets the "video_resolution" field if the given value is not nil.
  2126. func (_u *UsageLogUpdateOne) SetNillableVideoResolution(v *string) *UsageLogUpdateOne {
  2127. if v != nil {
  2128. _u.SetVideoResolution(*v)
  2129. }
  2130. return _u
  2131. }
  2132. // ClearVideoResolution clears the value of the "video_resolution" field.
  2133. func (_u *UsageLogUpdateOne) ClearVideoResolution() *UsageLogUpdateOne {
  2134. _u.mutation.ClearVideoResolution()
  2135. return _u
  2136. }
  2137. // SetVideoDurationSeconds sets the "video_duration_seconds" field.
  2138. func (_u *UsageLogUpdateOne) SetVideoDurationSeconds(v int) *UsageLogUpdateOne {
  2139. _u.mutation.ResetVideoDurationSeconds()
  2140. _u.mutation.SetVideoDurationSeconds(v)
  2141. return _u
  2142. }
  2143. // SetNillableVideoDurationSeconds sets the "video_duration_seconds" field if the given value is not nil.
  2144. func (_u *UsageLogUpdateOne) SetNillableVideoDurationSeconds(v *int) *UsageLogUpdateOne {
  2145. if v != nil {
  2146. _u.SetVideoDurationSeconds(*v)
  2147. }
  2148. return _u
  2149. }
  2150. // AddVideoDurationSeconds adds value to the "video_duration_seconds" field.
  2151. func (_u *UsageLogUpdateOne) AddVideoDurationSeconds(v int) *UsageLogUpdateOne {
  2152. _u.mutation.AddVideoDurationSeconds(v)
  2153. return _u
  2154. }
  2155. // ClearVideoDurationSeconds clears the value of the "video_duration_seconds" field.
  2156. func (_u *UsageLogUpdateOne) ClearVideoDurationSeconds() *UsageLogUpdateOne {
  2157. _u.mutation.ClearVideoDurationSeconds()
  2158. return _u
  2159. }
  2160. // SetCacheTTLOverridden sets the "cache_ttl_overridden" field.
  2161. func (_u *UsageLogUpdateOne) SetCacheTTLOverridden(v bool) *UsageLogUpdateOne {
  2162. _u.mutation.SetCacheTTLOverridden(v)
  2163. return _u
  2164. }
  2165. // SetNillableCacheTTLOverridden sets the "cache_ttl_overridden" field if the given value is not nil.
  2166. func (_u *UsageLogUpdateOne) SetNillableCacheTTLOverridden(v *bool) *UsageLogUpdateOne {
  2167. if v != nil {
  2168. _u.SetCacheTTLOverridden(*v)
  2169. }
  2170. return _u
  2171. }
  2172. // SetUser sets the "user" edge to the User entity.
  2173. func (_u *UsageLogUpdateOne) SetUser(v *User) *UsageLogUpdateOne {
  2174. return _u.SetUserID(v.ID)
  2175. }
  2176. // SetAPIKey sets the "api_key" edge to the APIKey entity.
  2177. func (_u *UsageLogUpdateOne) SetAPIKey(v *APIKey) *UsageLogUpdateOne {
  2178. return _u.SetAPIKeyID(v.ID)
  2179. }
  2180. // SetAccount sets the "account" edge to the Account entity.
  2181. func (_u *UsageLogUpdateOne) SetAccount(v *Account) *UsageLogUpdateOne {
  2182. return _u.SetAccountID(v.ID)
  2183. }
  2184. // SetGroup sets the "group" edge to the Group entity.
  2185. func (_u *UsageLogUpdateOne) SetGroup(v *Group) *UsageLogUpdateOne {
  2186. return _u.SetGroupID(v.ID)
  2187. }
  2188. // SetSubscription sets the "subscription" edge to the UserSubscription entity.
  2189. func (_u *UsageLogUpdateOne) SetSubscription(v *UserSubscription) *UsageLogUpdateOne {
  2190. return _u.SetSubscriptionID(v.ID)
  2191. }
  2192. // Mutation returns the UsageLogMutation object of the builder.
  2193. func (_u *UsageLogUpdateOne) Mutation() *UsageLogMutation {
  2194. return _u.mutation
  2195. }
  2196. // ClearUser clears the "user" edge to the User entity.
  2197. func (_u *UsageLogUpdateOne) ClearUser() *UsageLogUpdateOne {
  2198. _u.mutation.ClearUser()
  2199. return _u
  2200. }
  2201. // ClearAPIKey clears the "api_key" edge to the APIKey entity.
  2202. func (_u *UsageLogUpdateOne) ClearAPIKey() *UsageLogUpdateOne {
  2203. _u.mutation.ClearAPIKey()
  2204. return _u
  2205. }
  2206. // ClearAccount clears the "account" edge to the Account entity.
  2207. func (_u *UsageLogUpdateOne) ClearAccount() *UsageLogUpdateOne {
  2208. _u.mutation.ClearAccount()
  2209. return _u
  2210. }
  2211. // ClearGroup clears the "group" edge to the Group entity.
  2212. func (_u *UsageLogUpdateOne) ClearGroup() *UsageLogUpdateOne {
  2213. _u.mutation.ClearGroup()
  2214. return _u
  2215. }
  2216. // ClearSubscription clears the "subscription" edge to the UserSubscription entity.
  2217. func (_u *UsageLogUpdateOne) ClearSubscription() *UsageLogUpdateOne {
  2218. _u.mutation.ClearSubscription()
  2219. return _u
  2220. }
  2221. // Where appends a list predicates to the UsageLogUpdate builder.
  2222. func (_u *UsageLogUpdateOne) Where(ps ...predicate.UsageLog) *UsageLogUpdateOne {
  2223. _u.mutation.Where(ps...)
  2224. return _u
  2225. }
  2226. // Select allows selecting one or more fields (columns) of the returned entity.
  2227. // The default is selecting all fields defined in the entity schema.
  2228. func (_u *UsageLogUpdateOne) Select(field string, fields ...string) *UsageLogUpdateOne {
  2229. _u.fields = append([]string{field}, fields...)
  2230. return _u
  2231. }
  2232. // Save executes the query and returns the updated UsageLog entity.
  2233. func (_u *UsageLogUpdateOne) Save(ctx context.Context) (*UsageLog, error) {
  2234. return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
  2235. }
  2236. // SaveX is like Save, but panics if an error occurs.
  2237. func (_u *UsageLogUpdateOne) SaveX(ctx context.Context) *UsageLog {
  2238. node, err := _u.Save(ctx)
  2239. if err != nil {
  2240. panic(err)
  2241. }
  2242. return node
  2243. }
  2244. // Exec executes the query on the entity.
  2245. func (_u *UsageLogUpdateOne) Exec(ctx context.Context) error {
  2246. _, err := _u.Save(ctx)
  2247. return err
  2248. }
  2249. // ExecX is like Exec, but panics if an error occurs.
  2250. func (_u *UsageLogUpdateOne) ExecX(ctx context.Context) {
  2251. if err := _u.Exec(ctx); err != nil {
  2252. panic(err)
  2253. }
  2254. }
  2255. // check runs all checks and user-defined validators on the builder.
  2256. func (_u *UsageLogUpdateOne) check() error {
  2257. if v, ok := _u.mutation.RequestID(); ok {
  2258. if err := usagelog.RequestIDValidator(v); err != nil {
  2259. return &ValidationError{Name: "request_id", err: fmt.Errorf(`ent: validator failed for field "UsageLog.request_id": %w`, err)}
  2260. }
  2261. }
  2262. if v, ok := _u.mutation.Model(); ok {
  2263. if err := usagelog.ModelValidator(v); err != nil {
  2264. return &ValidationError{Name: "model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.model": %w`, err)}
  2265. }
  2266. }
  2267. if v, ok := _u.mutation.RequestedModel(); ok {
  2268. if err := usagelog.RequestedModelValidator(v); err != nil {
  2269. return &ValidationError{Name: "requested_model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.requested_model": %w`, err)}
  2270. }
  2271. }
  2272. if v, ok := _u.mutation.UpstreamModel(); ok {
  2273. if err := usagelog.UpstreamModelValidator(v); err != nil {
  2274. return &ValidationError{Name: "upstream_model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.upstream_model": %w`, err)}
  2275. }
  2276. }
  2277. if v, ok := _u.mutation.UpstreamResponseModel(); ok {
  2278. if err := usagelog.UpstreamResponseModelValidator(v); err != nil {
  2279. return &ValidationError{Name: "upstream_response_model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.upstream_response_model": %w`, err)}
  2280. }
  2281. }
  2282. if v, ok := _u.mutation.ModelMappingChain(); ok {
  2283. if err := usagelog.ModelMappingChainValidator(v); err != nil {
  2284. return &ValidationError{Name: "model_mapping_chain", err: fmt.Errorf(`ent: validator failed for field "UsageLog.model_mapping_chain": %w`, err)}
  2285. }
  2286. }
  2287. if v, ok := _u.mutation.BillingTier(); ok {
  2288. if err := usagelog.BillingTierValidator(v); err != nil {
  2289. return &ValidationError{Name: "billing_tier", err: fmt.Errorf(`ent: validator failed for field "UsageLog.billing_tier": %w`, err)}
  2290. }
  2291. }
  2292. if v, ok := _u.mutation.BillingMode(); ok {
  2293. if err := usagelog.BillingModeValidator(v); err != nil {
  2294. return &ValidationError{Name: "billing_mode", err: fmt.Errorf(`ent: validator failed for field "UsageLog.billing_mode": %w`, err)}
  2295. }
  2296. }
  2297. if v, ok := _u.mutation.UserAgent(); ok {
  2298. if err := usagelog.UserAgentValidator(v); err != nil {
  2299. return &ValidationError{Name: "user_agent", err: fmt.Errorf(`ent: validator failed for field "UsageLog.user_agent": %w`, err)}
  2300. }
  2301. }
  2302. if v, ok := _u.mutation.IPAddress(); ok {
  2303. if err := usagelog.IPAddressValidator(v); err != nil {
  2304. return &ValidationError{Name: "ip_address", err: fmt.Errorf(`ent: validator failed for field "UsageLog.ip_address": %w`, err)}
  2305. }
  2306. }
  2307. if v, ok := _u.mutation.ImageSize(); ok {
  2308. if err := usagelog.ImageSizeValidator(v); err != nil {
  2309. return &ValidationError{Name: "image_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_size": %w`, err)}
  2310. }
  2311. }
  2312. if v, ok := _u.mutation.ImageInputSize(); ok {
  2313. if err := usagelog.ImageInputSizeValidator(v); err != nil {
  2314. return &ValidationError{Name: "image_input_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_input_size": %w`, err)}
  2315. }
  2316. }
  2317. if v, ok := _u.mutation.ImageOutputSize(); ok {
  2318. if err := usagelog.ImageOutputSizeValidator(v); err != nil {
  2319. return &ValidationError{Name: "image_output_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_output_size": %w`, err)}
  2320. }
  2321. }
  2322. if v, ok := _u.mutation.ImageSizeSource(); ok {
  2323. if err := usagelog.ImageSizeSourceValidator(v); err != nil {
  2324. return &ValidationError{Name: "image_size_source", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_size_source": %w`, err)}
  2325. }
  2326. }
  2327. if v, ok := _u.mutation.VideoResolution(); ok {
  2328. if err := usagelog.VideoResolutionValidator(v); err != nil {
  2329. return &ValidationError{Name: "video_resolution", err: fmt.Errorf(`ent: validator failed for field "UsageLog.video_resolution": %w`, err)}
  2330. }
  2331. }
  2332. if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
  2333. return errors.New(`ent: clearing a required unique edge "UsageLog.user"`)
  2334. }
  2335. if _u.mutation.APIKeyCleared() && len(_u.mutation.APIKeyIDs()) > 0 {
  2336. return errors.New(`ent: clearing a required unique edge "UsageLog.api_key"`)
  2337. }
  2338. if _u.mutation.AccountCleared() && len(_u.mutation.AccountIDs()) > 0 {
  2339. return errors.New(`ent: clearing a required unique edge "UsageLog.account"`)
  2340. }
  2341. return nil
  2342. }
  2343. func (_u *UsageLogUpdateOne) sqlSave(ctx context.Context) (_node *UsageLog, err error) {
  2344. if err := _u.check(); err != nil {
  2345. return _node, err
  2346. }
  2347. _spec := sqlgraph.NewUpdateSpec(usagelog.Table, usagelog.Columns, sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64))
  2348. id, ok := _u.mutation.ID()
  2349. if !ok {
  2350. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "UsageLog.id" for update`)}
  2351. }
  2352. _spec.Node.ID.Value = id
  2353. if fields := _u.fields; len(fields) > 0 {
  2354. _spec.Node.Columns = make([]string, 0, len(fields))
  2355. _spec.Node.Columns = append(_spec.Node.Columns, usagelog.FieldID)
  2356. for _, f := range fields {
  2357. if !usagelog.ValidColumn(f) {
  2358. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  2359. }
  2360. if f != usagelog.FieldID {
  2361. _spec.Node.Columns = append(_spec.Node.Columns, f)
  2362. }
  2363. }
  2364. }
  2365. if ps := _u.mutation.predicates; len(ps) > 0 {
  2366. _spec.Predicate = func(selector *sql.Selector) {
  2367. for i := range ps {
  2368. ps[i](selector)
  2369. }
  2370. }
  2371. }
  2372. if value, ok := _u.mutation.RequestID(); ok {
  2373. _spec.SetField(usagelog.FieldRequestID, field.TypeString, value)
  2374. }
  2375. if value, ok := _u.mutation.Model(); ok {
  2376. _spec.SetField(usagelog.FieldModel, field.TypeString, value)
  2377. }
  2378. if value, ok := _u.mutation.RequestedModel(); ok {
  2379. _spec.SetField(usagelog.FieldRequestedModel, field.TypeString, value)
  2380. }
  2381. if _u.mutation.RequestedModelCleared() {
  2382. _spec.ClearField(usagelog.FieldRequestedModel, field.TypeString)
  2383. }
  2384. if value, ok := _u.mutation.UpstreamModel(); ok {
  2385. _spec.SetField(usagelog.FieldUpstreamModel, field.TypeString, value)
  2386. }
  2387. if _u.mutation.UpstreamModelCleared() {
  2388. _spec.ClearField(usagelog.FieldUpstreamModel, field.TypeString)
  2389. }
  2390. if value, ok := _u.mutation.UpstreamResponseModel(); ok {
  2391. _spec.SetField(usagelog.FieldUpstreamResponseModel, field.TypeString, value)
  2392. }
  2393. if _u.mutation.UpstreamResponseModelCleared() {
  2394. _spec.ClearField(usagelog.FieldUpstreamResponseModel, field.TypeString)
  2395. }
  2396. if value, ok := _u.mutation.UpstreamModelMismatch(); ok {
  2397. _spec.SetField(usagelog.FieldUpstreamModelMismatch, field.TypeBool, value)
  2398. }
  2399. if _u.mutation.UpstreamModelMismatchCleared() {
  2400. _spec.ClearField(usagelog.FieldUpstreamModelMismatch, field.TypeBool)
  2401. }
  2402. if value, ok := _u.mutation.ChannelID(); ok {
  2403. _spec.SetField(usagelog.FieldChannelID, field.TypeInt64, value)
  2404. }
  2405. if value, ok := _u.mutation.AddedChannelID(); ok {
  2406. _spec.AddField(usagelog.FieldChannelID, field.TypeInt64, value)
  2407. }
  2408. if _u.mutation.ChannelIDCleared() {
  2409. _spec.ClearField(usagelog.FieldChannelID, field.TypeInt64)
  2410. }
  2411. if value, ok := _u.mutation.ModelMappingChain(); ok {
  2412. _spec.SetField(usagelog.FieldModelMappingChain, field.TypeString, value)
  2413. }
  2414. if _u.mutation.ModelMappingChainCleared() {
  2415. _spec.ClearField(usagelog.FieldModelMappingChain, field.TypeString)
  2416. }
  2417. if value, ok := _u.mutation.BillingTier(); ok {
  2418. _spec.SetField(usagelog.FieldBillingTier, field.TypeString, value)
  2419. }
  2420. if _u.mutation.BillingTierCleared() {
  2421. _spec.ClearField(usagelog.FieldBillingTier, field.TypeString)
  2422. }
  2423. if value, ok := _u.mutation.BillingMode(); ok {
  2424. _spec.SetField(usagelog.FieldBillingMode, field.TypeString, value)
  2425. }
  2426. if _u.mutation.BillingModeCleared() {
  2427. _spec.ClearField(usagelog.FieldBillingMode, field.TypeString)
  2428. }
  2429. if value, ok := _u.mutation.InputTokens(); ok {
  2430. _spec.SetField(usagelog.FieldInputTokens, field.TypeInt, value)
  2431. }
  2432. if value, ok := _u.mutation.AddedInputTokens(); ok {
  2433. _spec.AddField(usagelog.FieldInputTokens, field.TypeInt, value)
  2434. }
  2435. if value, ok := _u.mutation.OutputTokens(); ok {
  2436. _spec.SetField(usagelog.FieldOutputTokens, field.TypeInt, value)
  2437. }
  2438. if value, ok := _u.mutation.AddedOutputTokens(); ok {
  2439. _spec.AddField(usagelog.FieldOutputTokens, field.TypeInt, value)
  2440. }
  2441. if value, ok := _u.mutation.CacheCreationTokens(); ok {
  2442. _spec.SetField(usagelog.FieldCacheCreationTokens, field.TypeInt, value)
  2443. }
  2444. if value, ok := _u.mutation.AddedCacheCreationTokens(); ok {
  2445. _spec.AddField(usagelog.FieldCacheCreationTokens, field.TypeInt, value)
  2446. }
  2447. if value, ok := _u.mutation.CacheReadTokens(); ok {
  2448. _spec.SetField(usagelog.FieldCacheReadTokens, field.TypeInt, value)
  2449. }
  2450. if value, ok := _u.mutation.AddedCacheReadTokens(); ok {
  2451. _spec.AddField(usagelog.FieldCacheReadTokens, field.TypeInt, value)
  2452. }
  2453. if value, ok := _u.mutation.CacheCreation5mTokens(); ok {
  2454. _spec.SetField(usagelog.FieldCacheCreation5mTokens, field.TypeInt, value)
  2455. }
  2456. if value, ok := _u.mutation.AddedCacheCreation5mTokens(); ok {
  2457. _spec.AddField(usagelog.FieldCacheCreation5mTokens, field.TypeInt, value)
  2458. }
  2459. if value, ok := _u.mutation.CacheCreation1hTokens(); ok {
  2460. _spec.SetField(usagelog.FieldCacheCreation1hTokens, field.TypeInt, value)
  2461. }
  2462. if value, ok := _u.mutation.AddedCacheCreation1hTokens(); ok {
  2463. _spec.AddField(usagelog.FieldCacheCreation1hTokens, field.TypeInt, value)
  2464. }
  2465. if value, ok := _u.mutation.InputCost(); ok {
  2466. _spec.SetField(usagelog.FieldInputCost, field.TypeFloat64, value)
  2467. }
  2468. if value, ok := _u.mutation.AddedInputCost(); ok {
  2469. _spec.AddField(usagelog.FieldInputCost, field.TypeFloat64, value)
  2470. }
  2471. if value, ok := _u.mutation.OutputCost(); ok {
  2472. _spec.SetField(usagelog.FieldOutputCost, field.TypeFloat64, value)
  2473. }
  2474. if value, ok := _u.mutation.AddedOutputCost(); ok {
  2475. _spec.AddField(usagelog.FieldOutputCost, field.TypeFloat64, value)
  2476. }
  2477. if value, ok := _u.mutation.CacheCreationCost(); ok {
  2478. _spec.SetField(usagelog.FieldCacheCreationCost, field.TypeFloat64, value)
  2479. }
  2480. if value, ok := _u.mutation.AddedCacheCreationCost(); ok {
  2481. _spec.AddField(usagelog.FieldCacheCreationCost, field.TypeFloat64, value)
  2482. }
  2483. if value, ok := _u.mutation.CacheReadCost(); ok {
  2484. _spec.SetField(usagelog.FieldCacheReadCost, field.TypeFloat64, value)
  2485. }
  2486. if value, ok := _u.mutation.AddedCacheReadCost(); ok {
  2487. _spec.AddField(usagelog.FieldCacheReadCost, field.TypeFloat64, value)
  2488. }
  2489. if value, ok := _u.mutation.TotalCost(); ok {
  2490. _spec.SetField(usagelog.FieldTotalCost, field.TypeFloat64, value)
  2491. }
  2492. if value, ok := _u.mutation.AddedTotalCost(); ok {
  2493. _spec.AddField(usagelog.FieldTotalCost, field.TypeFloat64, value)
  2494. }
  2495. if value, ok := _u.mutation.ActualCost(); ok {
  2496. _spec.SetField(usagelog.FieldActualCost, field.TypeFloat64, value)
  2497. }
  2498. if value, ok := _u.mutation.AddedActualCost(); ok {
  2499. _spec.AddField(usagelog.FieldActualCost, field.TypeFloat64, value)
  2500. }
  2501. if value, ok := _u.mutation.RateMultiplier(); ok {
  2502. _spec.SetField(usagelog.FieldRateMultiplier, field.TypeFloat64, value)
  2503. }
  2504. if value, ok := _u.mutation.AddedRateMultiplier(); ok {
  2505. _spec.AddField(usagelog.FieldRateMultiplier, field.TypeFloat64, value)
  2506. }
  2507. if value, ok := _u.mutation.LongContextBillingApplied(); ok {
  2508. _spec.SetField(usagelog.FieldLongContextBillingApplied, field.TypeBool, value)
  2509. }
  2510. if value, ok := _u.mutation.AccountRateMultiplier(); ok {
  2511. _spec.SetField(usagelog.FieldAccountRateMultiplier, field.TypeFloat64, value)
  2512. }
  2513. if value, ok := _u.mutation.AddedAccountRateMultiplier(); ok {
  2514. _spec.AddField(usagelog.FieldAccountRateMultiplier, field.TypeFloat64, value)
  2515. }
  2516. if _u.mutation.AccountRateMultiplierCleared() {
  2517. _spec.ClearField(usagelog.FieldAccountRateMultiplier, field.TypeFloat64)
  2518. }
  2519. if value, ok := _u.mutation.BillingType(); ok {
  2520. _spec.SetField(usagelog.FieldBillingType, field.TypeInt8, value)
  2521. }
  2522. if value, ok := _u.mutation.AddedBillingType(); ok {
  2523. _spec.AddField(usagelog.FieldBillingType, field.TypeInt8, value)
  2524. }
  2525. if value, ok := _u.mutation.Stream(); ok {
  2526. _spec.SetField(usagelog.FieldStream, field.TypeBool, value)
  2527. }
  2528. if value, ok := _u.mutation.DurationMs(); ok {
  2529. _spec.SetField(usagelog.FieldDurationMs, field.TypeInt, value)
  2530. }
  2531. if value, ok := _u.mutation.AddedDurationMs(); ok {
  2532. _spec.AddField(usagelog.FieldDurationMs, field.TypeInt, value)
  2533. }
  2534. if _u.mutation.DurationMsCleared() {
  2535. _spec.ClearField(usagelog.FieldDurationMs, field.TypeInt)
  2536. }
  2537. if value, ok := _u.mutation.FirstTokenMs(); ok {
  2538. _spec.SetField(usagelog.FieldFirstTokenMs, field.TypeInt, value)
  2539. }
  2540. if value, ok := _u.mutation.AddedFirstTokenMs(); ok {
  2541. _spec.AddField(usagelog.FieldFirstTokenMs, field.TypeInt, value)
  2542. }
  2543. if _u.mutation.FirstTokenMsCleared() {
  2544. _spec.ClearField(usagelog.FieldFirstTokenMs, field.TypeInt)
  2545. }
  2546. if value, ok := _u.mutation.UserAgent(); ok {
  2547. _spec.SetField(usagelog.FieldUserAgent, field.TypeString, value)
  2548. }
  2549. if _u.mutation.UserAgentCleared() {
  2550. _spec.ClearField(usagelog.FieldUserAgent, field.TypeString)
  2551. }
  2552. if value, ok := _u.mutation.IPAddress(); ok {
  2553. _spec.SetField(usagelog.FieldIPAddress, field.TypeString, value)
  2554. }
  2555. if _u.mutation.IPAddressCleared() {
  2556. _spec.ClearField(usagelog.FieldIPAddress, field.TypeString)
  2557. }
  2558. if value, ok := _u.mutation.ImageCount(); ok {
  2559. _spec.SetField(usagelog.FieldImageCount, field.TypeInt, value)
  2560. }
  2561. if value, ok := _u.mutation.AddedImageCount(); ok {
  2562. _spec.AddField(usagelog.FieldImageCount, field.TypeInt, value)
  2563. }
  2564. if value, ok := _u.mutation.ImageSize(); ok {
  2565. _spec.SetField(usagelog.FieldImageSize, field.TypeString, value)
  2566. }
  2567. if _u.mutation.ImageSizeCleared() {
  2568. _spec.ClearField(usagelog.FieldImageSize, field.TypeString)
  2569. }
  2570. if value, ok := _u.mutation.ImageInputSize(); ok {
  2571. _spec.SetField(usagelog.FieldImageInputSize, field.TypeString, value)
  2572. }
  2573. if _u.mutation.ImageInputSizeCleared() {
  2574. _spec.ClearField(usagelog.FieldImageInputSize, field.TypeString)
  2575. }
  2576. if value, ok := _u.mutation.ImageOutputSize(); ok {
  2577. _spec.SetField(usagelog.FieldImageOutputSize, field.TypeString, value)
  2578. }
  2579. if _u.mutation.ImageOutputSizeCleared() {
  2580. _spec.ClearField(usagelog.FieldImageOutputSize, field.TypeString)
  2581. }
  2582. if value, ok := _u.mutation.ImageSizeSource(); ok {
  2583. _spec.SetField(usagelog.FieldImageSizeSource, field.TypeString, value)
  2584. }
  2585. if _u.mutation.ImageSizeSourceCleared() {
  2586. _spec.ClearField(usagelog.FieldImageSizeSource, field.TypeString)
  2587. }
  2588. if value, ok := _u.mutation.ImageSizeBreakdown(); ok {
  2589. _spec.SetField(usagelog.FieldImageSizeBreakdown, field.TypeJSON, value)
  2590. }
  2591. if _u.mutation.ImageSizeBreakdownCleared() {
  2592. _spec.ClearField(usagelog.FieldImageSizeBreakdown, field.TypeJSON)
  2593. }
  2594. if value, ok := _u.mutation.VideoCount(); ok {
  2595. _spec.SetField(usagelog.FieldVideoCount, field.TypeInt, value)
  2596. }
  2597. if value, ok := _u.mutation.AddedVideoCount(); ok {
  2598. _spec.AddField(usagelog.FieldVideoCount, field.TypeInt, value)
  2599. }
  2600. if value, ok := _u.mutation.VideoResolution(); ok {
  2601. _spec.SetField(usagelog.FieldVideoResolution, field.TypeString, value)
  2602. }
  2603. if _u.mutation.VideoResolutionCleared() {
  2604. _spec.ClearField(usagelog.FieldVideoResolution, field.TypeString)
  2605. }
  2606. if value, ok := _u.mutation.VideoDurationSeconds(); ok {
  2607. _spec.SetField(usagelog.FieldVideoDurationSeconds, field.TypeInt, value)
  2608. }
  2609. if value, ok := _u.mutation.AddedVideoDurationSeconds(); ok {
  2610. _spec.AddField(usagelog.FieldVideoDurationSeconds, field.TypeInt, value)
  2611. }
  2612. if _u.mutation.VideoDurationSecondsCleared() {
  2613. _spec.ClearField(usagelog.FieldVideoDurationSeconds, field.TypeInt)
  2614. }
  2615. if value, ok := _u.mutation.CacheTTLOverridden(); ok {
  2616. _spec.SetField(usagelog.FieldCacheTTLOverridden, field.TypeBool, value)
  2617. }
  2618. if _u.mutation.UserCleared() {
  2619. edge := &sqlgraph.EdgeSpec{
  2620. Rel: sqlgraph.M2O,
  2621. Inverse: true,
  2622. Table: usagelog.UserTable,
  2623. Columns: []string{usagelog.UserColumn},
  2624. Bidi: false,
  2625. Target: &sqlgraph.EdgeTarget{
  2626. IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
  2627. },
  2628. }
  2629. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2630. }
  2631. if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
  2632. edge := &sqlgraph.EdgeSpec{
  2633. Rel: sqlgraph.M2O,
  2634. Inverse: true,
  2635. Table: usagelog.UserTable,
  2636. Columns: []string{usagelog.UserColumn},
  2637. Bidi: false,
  2638. Target: &sqlgraph.EdgeTarget{
  2639. IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
  2640. },
  2641. }
  2642. for _, k := range nodes {
  2643. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2644. }
  2645. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  2646. }
  2647. if _u.mutation.APIKeyCleared() {
  2648. edge := &sqlgraph.EdgeSpec{
  2649. Rel: sqlgraph.M2O,
  2650. Inverse: true,
  2651. Table: usagelog.APIKeyTable,
  2652. Columns: []string{usagelog.APIKeyColumn},
  2653. Bidi: false,
  2654. Target: &sqlgraph.EdgeTarget{
  2655. IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64),
  2656. },
  2657. }
  2658. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2659. }
  2660. if nodes := _u.mutation.APIKeyIDs(); len(nodes) > 0 {
  2661. edge := &sqlgraph.EdgeSpec{
  2662. Rel: sqlgraph.M2O,
  2663. Inverse: true,
  2664. Table: usagelog.APIKeyTable,
  2665. Columns: []string{usagelog.APIKeyColumn},
  2666. Bidi: false,
  2667. Target: &sqlgraph.EdgeTarget{
  2668. IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64),
  2669. },
  2670. }
  2671. for _, k := range nodes {
  2672. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2673. }
  2674. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  2675. }
  2676. if _u.mutation.AccountCleared() {
  2677. edge := &sqlgraph.EdgeSpec{
  2678. Rel: sqlgraph.M2O,
  2679. Inverse: true,
  2680. Table: usagelog.AccountTable,
  2681. Columns: []string{usagelog.AccountColumn},
  2682. Bidi: false,
  2683. Target: &sqlgraph.EdgeTarget{
  2684. IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
  2685. },
  2686. }
  2687. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2688. }
  2689. if nodes := _u.mutation.AccountIDs(); len(nodes) > 0 {
  2690. edge := &sqlgraph.EdgeSpec{
  2691. Rel: sqlgraph.M2O,
  2692. Inverse: true,
  2693. Table: usagelog.AccountTable,
  2694. Columns: []string{usagelog.AccountColumn},
  2695. Bidi: false,
  2696. Target: &sqlgraph.EdgeTarget{
  2697. IDSpec: sqlgraph.NewFieldSpec(account.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.GroupCleared() {
  2706. edge := &sqlgraph.EdgeSpec{
  2707. Rel: sqlgraph.M2O,
  2708. Inverse: true,
  2709. Table: usagelog.GroupTable,
  2710. Columns: []string{usagelog.GroupColumn},
  2711. Bidi: false,
  2712. Target: &sqlgraph.EdgeTarget{
  2713. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  2714. },
  2715. }
  2716. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2717. }
  2718. if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
  2719. edge := &sqlgraph.EdgeSpec{
  2720. Rel: sqlgraph.M2O,
  2721. Inverse: true,
  2722. Table: usagelog.GroupTable,
  2723. Columns: []string{usagelog.GroupColumn},
  2724. Bidi: false,
  2725. Target: &sqlgraph.EdgeTarget{
  2726. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  2727. },
  2728. }
  2729. for _, k := range nodes {
  2730. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2731. }
  2732. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  2733. }
  2734. if _u.mutation.SubscriptionCleared() {
  2735. edge := &sqlgraph.EdgeSpec{
  2736. Rel: sqlgraph.M2O,
  2737. Inverse: true,
  2738. Table: usagelog.SubscriptionTable,
  2739. Columns: []string{usagelog.SubscriptionColumn},
  2740. Bidi: false,
  2741. Target: &sqlgraph.EdgeTarget{
  2742. IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
  2743. },
  2744. }
  2745. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2746. }
  2747. if nodes := _u.mutation.SubscriptionIDs(); len(nodes) > 0 {
  2748. edge := &sqlgraph.EdgeSpec{
  2749. Rel: sqlgraph.M2O,
  2750. Inverse: true,
  2751. Table: usagelog.SubscriptionTable,
  2752. Columns: []string{usagelog.SubscriptionColumn},
  2753. Bidi: false,
  2754. Target: &sqlgraph.EdgeTarget{
  2755. IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
  2756. },
  2757. }
  2758. for _, k := range nodes {
  2759. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2760. }
  2761. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  2762. }
  2763. _node = &UsageLog{config: _u.config}
  2764. _spec.Assign = _node.assignValues
  2765. _spec.ScanValues = _node.scanValues
  2766. if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
  2767. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  2768. err = &NotFoundError{usagelog.Label}
  2769. } else if sqlgraph.IsConstraintError(err) {
  2770. err = &ConstraintError{msg: err.Error(), wrap: err}
  2771. }
  2772. return nil, err
  2773. }
  2774. _u.mutation.done = true
  2775. return _node, nil
  2776. }