userplatformquota_create.go 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "time"
  8. "entgo.io/ent/dialect/sql"
  9. "entgo.io/ent/dialect/sql/sqlgraph"
  10. "entgo.io/ent/schema/field"
  11. "github.com/Wei-Shaw/sub2api/ent/user"
  12. "github.com/Wei-Shaw/sub2api/ent/userplatformquota"
  13. )
  14. // UserPlatformQuotaCreate is the builder for creating a UserPlatformQuota entity.
  15. type UserPlatformQuotaCreate struct {
  16. config
  17. mutation *UserPlatformQuotaMutation
  18. hooks []Hook
  19. conflict []sql.ConflictOption
  20. }
  21. // SetCreatedAt sets the "created_at" field.
  22. func (_c *UserPlatformQuotaCreate) SetCreatedAt(v time.Time) *UserPlatformQuotaCreate {
  23. _c.mutation.SetCreatedAt(v)
  24. return _c
  25. }
  26. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  27. func (_c *UserPlatformQuotaCreate) SetNillableCreatedAt(v *time.Time) *UserPlatformQuotaCreate {
  28. if v != nil {
  29. _c.SetCreatedAt(*v)
  30. }
  31. return _c
  32. }
  33. // SetUpdatedAt sets the "updated_at" field.
  34. func (_c *UserPlatformQuotaCreate) SetUpdatedAt(v time.Time) *UserPlatformQuotaCreate {
  35. _c.mutation.SetUpdatedAt(v)
  36. return _c
  37. }
  38. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  39. func (_c *UserPlatformQuotaCreate) SetNillableUpdatedAt(v *time.Time) *UserPlatformQuotaCreate {
  40. if v != nil {
  41. _c.SetUpdatedAt(*v)
  42. }
  43. return _c
  44. }
  45. // SetDeletedAt sets the "deleted_at" field.
  46. func (_c *UserPlatformQuotaCreate) SetDeletedAt(v time.Time) *UserPlatformQuotaCreate {
  47. _c.mutation.SetDeletedAt(v)
  48. return _c
  49. }
  50. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  51. func (_c *UserPlatformQuotaCreate) SetNillableDeletedAt(v *time.Time) *UserPlatformQuotaCreate {
  52. if v != nil {
  53. _c.SetDeletedAt(*v)
  54. }
  55. return _c
  56. }
  57. // SetUserID sets the "user_id" field.
  58. func (_c *UserPlatformQuotaCreate) SetUserID(v int64) *UserPlatformQuotaCreate {
  59. _c.mutation.SetUserID(v)
  60. return _c
  61. }
  62. // SetPlatform sets the "platform" field.
  63. func (_c *UserPlatformQuotaCreate) SetPlatform(v string) *UserPlatformQuotaCreate {
  64. _c.mutation.SetPlatform(v)
  65. return _c
  66. }
  67. // SetDailyLimitUsd sets the "daily_limit_usd" field.
  68. func (_c *UserPlatformQuotaCreate) SetDailyLimitUsd(v float64) *UserPlatformQuotaCreate {
  69. _c.mutation.SetDailyLimitUsd(v)
  70. return _c
  71. }
  72. // SetNillableDailyLimitUsd sets the "daily_limit_usd" field if the given value is not nil.
  73. func (_c *UserPlatformQuotaCreate) SetNillableDailyLimitUsd(v *float64) *UserPlatformQuotaCreate {
  74. if v != nil {
  75. _c.SetDailyLimitUsd(*v)
  76. }
  77. return _c
  78. }
  79. // SetWeeklyLimitUsd sets the "weekly_limit_usd" field.
  80. func (_c *UserPlatformQuotaCreate) SetWeeklyLimitUsd(v float64) *UserPlatformQuotaCreate {
  81. _c.mutation.SetWeeklyLimitUsd(v)
  82. return _c
  83. }
  84. // SetNillableWeeklyLimitUsd sets the "weekly_limit_usd" field if the given value is not nil.
  85. func (_c *UserPlatformQuotaCreate) SetNillableWeeklyLimitUsd(v *float64) *UserPlatformQuotaCreate {
  86. if v != nil {
  87. _c.SetWeeklyLimitUsd(*v)
  88. }
  89. return _c
  90. }
  91. // SetMonthlyLimitUsd sets the "monthly_limit_usd" field.
  92. func (_c *UserPlatformQuotaCreate) SetMonthlyLimitUsd(v float64) *UserPlatformQuotaCreate {
  93. _c.mutation.SetMonthlyLimitUsd(v)
  94. return _c
  95. }
  96. // SetNillableMonthlyLimitUsd sets the "monthly_limit_usd" field if the given value is not nil.
  97. func (_c *UserPlatformQuotaCreate) SetNillableMonthlyLimitUsd(v *float64) *UserPlatformQuotaCreate {
  98. if v != nil {
  99. _c.SetMonthlyLimitUsd(*v)
  100. }
  101. return _c
  102. }
  103. // SetDailyUsageUsd sets the "daily_usage_usd" field.
  104. func (_c *UserPlatformQuotaCreate) SetDailyUsageUsd(v float64) *UserPlatformQuotaCreate {
  105. _c.mutation.SetDailyUsageUsd(v)
  106. return _c
  107. }
  108. // SetNillableDailyUsageUsd sets the "daily_usage_usd" field if the given value is not nil.
  109. func (_c *UserPlatformQuotaCreate) SetNillableDailyUsageUsd(v *float64) *UserPlatformQuotaCreate {
  110. if v != nil {
  111. _c.SetDailyUsageUsd(*v)
  112. }
  113. return _c
  114. }
  115. // SetWeeklyUsageUsd sets the "weekly_usage_usd" field.
  116. func (_c *UserPlatformQuotaCreate) SetWeeklyUsageUsd(v float64) *UserPlatformQuotaCreate {
  117. _c.mutation.SetWeeklyUsageUsd(v)
  118. return _c
  119. }
  120. // SetNillableWeeklyUsageUsd sets the "weekly_usage_usd" field if the given value is not nil.
  121. func (_c *UserPlatformQuotaCreate) SetNillableWeeklyUsageUsd(v *float64) *UserPlatformQuotaCreate {
  122. if v != nil {
  123. _c.SetWeeklyUsageUsd(*v)
  124. }
  125. return _c
  126. }
  127. // SetMonthlyUsageUsd sets the "monthly_usage_usd" field.
  128. func (_c *UserPlatformQuotaCreate) SetMonthlyUsageUsd(v float64) *UserPlatformQuotaCreate {
  129. _c.mutation.SetMonthlyUsageUsd(v)
  130. return _c
  131. }
  132. // SetNillableMonthlyUsageUsd sets the "monthly_usage_usd" field if the given value is not nil.
  133. func (_c *UserPlatformQuotaCreate) SetNillableMonthlyUsageUsd(v *float64) *UserPlatformQuotaCreate {
  134. if v != nil {
  135. _c.SetMonthlyUsageUsd(*v)
  136. }
  137. return _c
  138. }
  139. // SetDailyWindowStart sets the "daily_window_start" field.
  140. func (_c *UserPlatformQuotaCreate) SetDailyWindowStart(v time.Time) *UserPlatformQuotaCreate {
  141. _c.mutation.SetDailyWindowStart(v)
  142. return _c
  143. }
  144. // SetNillableDailyWindowStart sets the "daily_window_start" field if the given value is not nil.
  145. func (_c *UserPlatformQuotaCreate) SetNillableDailyWindowStart(v *time.Time) *UserPlatformQuotaCreate {
  146. if v != nil {
  147. _c.SetDailyWindowStart(*v)
  148. }
  149. return _c
  150. }
  151. // SetWeeklyWindowStart sets the "weekly_window_start" field.
  152. func (_c *UserPlatformQuotaCreate) SetWeeklyWindowStart(v time.Time) *UserPlatformQuotaCreate {
  153. _c.mutation.SetWeeklyWindowStart(v)
  154. return _c
  155. }
  156. // SetNillableWeeklyWindowStart sets the "weekly_window_start" field if the given value is not nil.
  157. func (_c *UserPlatformQuotaCreate) SetNillableWeeklyWindowStart(v *time.Time) *UserPlatformQuotaCreate {
  158. if v != nil {
  159. _c.SetWeeklyWindowStart(*v)
  160. }
  161. return _c
  162. }
  163. // SetMonthlyWindowStart sets the "monthly_window_start" field.
  164. func (_c *UserPlatformQuotaCreate) SetMonthlyWindowStart(v time.Time) *UserPlatformQuotaCreate {
  165. _c.mutation.SetMonthlyWindowStart(v)
  166. return _c
  167. }
  168. // SetNillableMonthlyWindowStart sets the "monthly_window_start" field if the given value is not nil.
  169. func (_c *UserPlatformQuotaCreate) SetNillableMonthlyWindowStart(v *time.Time) *UserPlatformQuotaCreate {
  170. if v != nil {
  171. _c.SetMonthlyWindowStart(*v)
  172. }
  173. return _c
  174. }
  175. // SetUser sets the "user" edge to the User entity.
  176. func (_c *UserPlatformQuotaCreate) SetUser(v *User) *UserPlatformQuotaCreate {
  177. return _c.SetUserID(v.ID)
  178. }
  179. // Mutation returns the UserPlatformQuotaMutation object of the builder.
  180. func (_c *UserPlatformQuotaCreate) Mutation() *UserPlatformQuotaMutation {
  181. return _c.mutation
  182. }
  183. // Save creates the UserPlatformQuota in the database.
  184. func (_c *UserPlatformQuotaCreate) Save(ctx context.Context) (*UserPlatformQuota, error) {
  185. if err := _c.defaults(); err != nil {
  186. return nil, err
  187. }
  188. return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
  189. }
  190. // SaveX calls Save and panics if Save returns an error.
  191. func (_c *UserPlatformQuotaCreate) SaveX(ctx context.Context) *UserPlatformQuota {
  192. v, err := _c.Save(ctx)
  193. if err != nil {
  194. panic(err)
  195. }
  196. return v
  197. }
  198. // Exec executes the query.
  199. func (_c *UserPlatformQuotaCreate) Exec(ctx context.Context) error {
  200. _, err := _c.Save(ctx)
  201. return err
  202. }
  203. // ExecX is like Exec, but panics if an error occurs.
  204. func (_c *UserPlatformQuotaCreate) ExecX(ctx context.Context) {
  205. if err := _c.Exec(ctx); err != nil {
  206. panic(err)
  207. }
  208. }
  209. // defaults sets the default values of the builder before save.
  210. func (_c *UserPlatformQuotaCreate) defaults() error {
  211. if _, ok := _c.mutation.CreatedAt(); !ok {
  212. if userplatformquota.DefaultCreatedAt == nil {
  213. return fmt.Errorf("ent: uninitialized userplatformquota.DefaultCreatedAt (forgotten import ent/runtime?)")
  214. }
  215. v := userplatformquota.DefaultCreatedAt()
  216. _c.mutation.SetCreatedAt(v)
  217. }
  218. if _, ok := _c.mutation.UpdatedAt(); !ok {
  219. if userplatformquota.DefaultUpdatedAt == nil {
  220. return fmt.Errorf("ent: uninitialized userplatformquota.DefaultUpdatedAt (forgotten import ent/runtime?)")
  221. }
  222. v := userplatformquota.DefaultUpdatedAt()
  223. _c.mutation.SetUpdatedAt(v)
  224. }
  225. if _, ok := _c.mutation.DailyUsageUsd(); !ok {
  226. v := userplatformquota.DefaultDailyUsageUsd
  227. _c.mutation.SetDailyUsageUsd(v)
  228. }
  229. if _, ok := _c.mutation.WeeklyUsageUsd(); !ok {
  230. v := userplatformquota.DefaultWeeklyUsageUsd
  231. _c.mutation.SetWeeklyUsageUsd(v)
  232. }
  233. if _, ok := _c.mutation.MonthlyUsageUsd(); !ok {
  234. v := userplatformquota.DefaultMonthlyUsageUsd
  235. _c.mutation.SetMonthlyUsageUsd(v)
  236. }
  237. return nil
  238. }
  239. // check runs all checks and user-defined validators on the builder.
  240. func (_c *UserPlatformQuotaCreate) check() error {
  241. if _, ok := _c.mutation.CreatedAt(); !ok {
  242. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "UserPlatformQuota.created_at"`)}
  243. }
  244. if _, ok := _c.mutation.UpdatedAt(); !ok {
  245. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "UserPlatformQuota.updated_at"`)}
  246. }
  247. if _, ok := _c.mutation.UserID(); !ok {
  248. return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "UserPlatformQuota.user_id"`)}
  249. }
  250. if _, ok := _c.mutation.Platform(); !ok {
  251. return &ValidationError{Name: "platform", err: errors.New(`ent: missing required field "UserPlatformQuota.platform"`)}
  252. }
  253. if v, ok := _c.mutation.Platform(); ok {
  254. if err := userplatformquota.PlatformValidator(v); err != nil {
  255. return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "UserPlatformQuota.platform": %w`, err)}
  256. }
  257. }
  258. if _, ok := _c.mutation.DailyUsageUsd(); !ok {
  259. return &ValidationError{Name: "daily_usage_usd", err: errors.New(`ent: missing required field "UserPlatformQuota.daily_usage_usd"`)}
  260. }
  261. if _, ok := _c.mutation.WeeklyUsageUsd(); !ok {
  262. return &ValidationError{Name: "weekly_usage_usd", err: errors.New(`ent: missing required field "UserPlatformQuota.weekly_usage_usd"`)}
  263. }
  264. if _, ok := _c.mutation.MonthlyUsageUsd(); !ok {
  265. return &ValidationError{Name: "monthly_usage_usd", err: errors.New(`ent: missing required field "UserPlatformQuota.monthly_usage_usd"`)}
  266. }
  267. if len(_c.mutation.UserIDs()) == 0 {
  268. return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "UserPlatformQuota.user"`)}
  269. }
  270. return nil
  271. }
  272. func (_c *UserPlatformQuotaCreate) sqlSave(ctx context.Context) (*UserPlatformQuota, error) {
  273. if err := _c.check(); err != nil {
  274. return nil, err
  275. }
  276. _node, _spec := _c.createSpec()
  277. if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
  278. if sqlgraph.IsConstraintError(err) {
  279. err = &ConstraintError{msg: err.Error(), wrap: err}
  280. }
  281. return nil, err
  282. }
  283. id := _spec.ID.Value.(int64)
  284. _node.ID = int64(id)
  285. _c.mutation.id = &_node.ID
  286. _c.mutation.done = true
  287. return _node, nil
  288. }
  289. func (_c *UserPlatformQuotaCreate) createSpec() (*UserPlatformQuota, *sqlgraph.CreateSpec) {
  290. var (
  291. _node = &UserPlatformQuota{config: _c.config}
  292. _spec = sqlgraph.NewCreateSpec(userplatformquota.Table, sqlgraph.NewFieldSpec(userplatformquota.FieldID, field.TypeInt64))
  293. )
  294. _spec.OnConflict = _c.conflict
  295. if value, ok := _c.mutation.CreatedAt(); ok {
  296. _spec.SetField(userplatformquota.FieldCreatedAt, field.TypeTime, value)
  297. _node.CreatedAt = value
  298. }
  299. if value, ok := _c.mutation.UpdatedAt(); ok {
  300. _spec.SetField(userplatformquota.FieldUpdatedAt, field.TypeTime, value)
  301. _node.UpdatedAt = value
  302. }
  303. if value, ok := _c.mutation.DeletedAt(); ok {
  304. _spec.SetField(userplatformquota.FieldDeletedAt, field.TypeTime, value)
  305. _node.DeletedAt = &value
  306. }
  307. if value, ok := _c.mutation.Platform(); ok {
  308. _spec.SetField(userplatformquota.FieldPlatform, field.TypeString, value)
  309. _node.Platform = value
  310. }
  311. if value, ok := _c.mutation.DailyLimitUsd(); ok {
  312. _spec.SetField(userplatformquota.FieldDailyLimitUsd, field.TypeFloat64, value)
  313. _node.DailyLimitUsd = &value
  314. }
  315. if value, ok := _c.mutation.WeeklyLimitUsd(); ok {
  316. _spec.SetField(userplatformquota.FieldWeeklyLimitUsd, field.TypeFloat64, value)
  317. _node.WeeklyLimitUsd = &value
  318. }
  319. if value, ok := _c.mutation.MonthlyLimitUsd(); ok {
  320. _spec.SetField(userplatformquota.FieldMonthlyLimitUsd, field.TypeFloat64, value)
  321. _node.MonthlyLimitUsd = &value
  322. }
  323. if value, ok := _c.mutation.DailyUsageUsd(); ok {
  324. _spec.SetField(userplatformquota.FieldDailyUsageUsd, field.TypeFloat64, value)
  325. _node.DailyUsageUsd = value
  326. }
  327. if value, ok := _c.mutation.WeeklyUsageUsd(); ok {
  328. _spec.SetField(userplatformquota.FieldWeeklyUsageUsd, field.TypeFloat64, value)
  329. _node.WeeklyUsageUsd = value
  330. }
  331. if value, ok := _c.mutation.MonthlyUsageUsd(); ok {
  332. _spec.SetField(userplatformquota.FieldMonthlyUsageUsd, field.TypeFloat64, value)
  333. _node.MonthlyUsageUsd = value
  334. }
  335. if value, ok := _c.mutation.DailyWindowStart(); ok {
  336. _spec.SetField(userplatformquota.FieldDailyWindowStart, field.TypeTime, value)
  337. _node.DailyWindowStart = &value
  338. }
  339. if value, ok := _c.mutation.WeeklyWindowStart(); ok {
  340. _spec.SetField(userplatformquota.FieldWeeklyWindowStart, field.TypeTime, value)
  341. _node.WeeklyWindowStart = &value
  342. }
  343. if value, ok := _c.mutation.MonthlyWindowStart(); ok {
  344. _spec.SetField(userplatformquota.FieldMonthlyWindowStart, field.TypeTime, value)
  345. _node.MonthlyWindowStart = &value
  346. }
  347. if nodes := _c.mutation.UserIDs(); len(nodes) > 0 {
  348. edge := &sqlgraph.EdgeSpec{
  349. Rel: sqlgraph.M2O,
  350. Inverse: true,
  351. Table: userplatformquota.UserTable,
  352. Columns: []string{userplatformquota.UserColumn},
  353. Bidi: false,
  354. Target: &sqlgraph.EdgeTarget{
  355. IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
  356. },
  357. }
  358. for _, k := range nodes {
  359. edge.Target.Nodes = append(edge.Target.Nodes, k)
  360. }
  361. _node.UserID = nodes[0]
  362. _spec.Edges = append(_spec.Edges, edge)
  363. }
  364. return _node, _spec
  365. }
  366. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  367. // of the `INSERT` statement. For example:
  368. //
  369. // client.UserPlatformQuota.Create().
  370. // SetCreatedAt(v).
  371. // OnConflict(
  372. // // Update the row with the new values
  373. // // the was proposed for insertion.
  374. // sql.ResolveWithNewValues(),
  375. // ).
  376. // // Override some of the fields with custom
  377. // // update values.
  378. // Update(func(u *ent.UserPlatformQuotaUpsert) {
  379. // SetCreatedAt(v+v).
  380. // }).
  381. // Exec(ctx)
  382. func (_c *UserPlatformQuotaCreate) OnConflict(opts ...sql.ConflictOption) *UserPlatformQuotaUpsertOne {
  383. _c.conflict = opts
  384. return &UserPlatformQuotaUpsertOne{
  385. create: _c,
  386. }
  387. }
  388. // OnConflictColumns calls `OnConflict` and configures the columns
  389. // as conflict target. Using this option is equivalent to using:
  390. //
  391. // client.UserPlatformQuota.Create().
  392. // OnConflict(sql.ConflictColumns(columns...)).
  393. // Exec(ctx)
  394. func (_c *UserPlatformQuotaCreate) OnConflictColumns(columns ...string) *UserPlatformQuotaUpsertOne {
  395. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  396. return &UserPlatformQuotaUpsertOne{
  397. create: _c,
  398. }
  399. }
  400. type (
  401. // UserPlatformQuotaUpsertOne is the builder for "upsert"-ing
  402. // one UserPlatformQuota node.
  403. UserPlatformQuotaUpsertOne struct {
  404. create *UserPlatformQuotaCreate
  405. }
  406. // UserPlatformQuotaUpsert is the "OnConflict" setter.
  407. UserPlatformQuotaUpsert struct {
  408. *sql.UpdateSet
  409. }
  410. )
  411. // SetUpdatedAt sets the "updated_at" field.
  412. func (u *UserPlatformQuotaUpsert) SetUpdatedAt(v time.Time) *UserPlatformQuotaUpsert {
  413. u.Set(userplatformquota.FieldUpdatedAt, v)
  414. return u
  415. }
  416. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  417. func (u *UserPlatformQuotaUpsert) UpdateUpdatedAt() *UserPlatformQuotaUpsert {
  418. u.SetExcluded(userplatformquota.FieldUpdatedAt)
  419. return u
  420. }
  421. // SetDeletedAt sets the "deleted_at" field.
  422. func (u *UserPlatformQuotaUpsert) SetDeletedAt(v time.Time) *UserPlatformQuotaUpsert {
  423. u.Set(userplatformquota.FieldDeletedAt, v)
  424. return u
  425. }
  426. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  427. func (u *UserPlatformQuotaUpsert) UpdateDeletedAt() *UserPlatformQuotaUpsert {
  428. u.SetExcluded(userplatformquota.FieldDeletedAt)
  429. return u
  430. }
  431. // ClearDeletedAt clears the value of the "deleted_at" field.
  432. func (u *UserPlatformQuotaUpsert) ClearDeletedAt() *UserPlatformQuotaUpsert {
  433. u.SetNull(userplatformquota.FieldDeletedAt)
  434. return u
  435. }
  436. // SetUserID sets the "user_id" field.
  437. func (u *UserPlatformQuotaUpsert) SetUserID(v int64) *UserPlatformQuotaUpsert {
  438. u.Set(userplatformquota.FieldUserID, v)
  439. return u
  440. }
  441. // UpdateUserID sets the "user_id" field to the value that was provided on create.
  442. func (u *UserPlatformQuotaUpsert) UpdateUserID() *UserPlatformQuotaUpsert {
  443. u.SetExcluded(userplatformquota.FieldUserID)
  444. return u
  445. }
  446. // SetPlatform sets the "platform" field.
  447. func (u *UserPlatformQuotaUpsert) SetPlatform(v string) *UserPlatformQuotaUpsert {
  448. u.Set(userplatformquota.FieldPlatform, v)
  449. return u
  450. }
  451. // UpdatePlatform sets the "platform" field to the value that was provided on create.
  452. func (u *UserPlatformQuotaUpsert) UpdatePlatform() *UserPlatformQuotaUpsert {
  453. u.SetExcluded(userplatformquota.FieldPlatform)
  454. return u
  455. }
  456. // SetDailyLimitUsd sets the "daily_limit_usd" field.
  457. func (u *UserPlatformQuotaUpsert) SetDailyLimitUsd(v float64) *UserPlatformQuotaUpsert {
  458. u.Set(userplatformquota.FieldDailyLimitUsd, v)
  459. return u
  460. }
  461. // UpdateDailyLimitUsd sets the "daily_limit_usd" field to the value that was provided on create.
  462. func (u *UserPlatformQuotaUpsert) UpdateDailyLimitUsd() *UserPlatformQuotaUpsert {
  463. u.SetExcluded(userplatformquota.FieldDailyLimitUsd)
  464. return u
  465. }
  466. // AddDailyLimitUsd adds v to the "daily_limit_usd" field.
  467. func (u *UserPlatformQuotaUpsert) AddDailyLimitUsd(v float64) *UserPlatformQuotaUpsert {
  468. u.Add(userplatformquota.FieldDailyLimitUsd, v)
  469. return u
  470. }
  471. // ClearDailyLimitUsd clears the value of the "daily_limit_usd" field.
  472. func (u *UserPlatformQuotaUpsert) ClearDailyLimitUsd() *UserPlatformQuotaUpsert {
  473. u.SetNull(userplatformquota.FieldDailyLimitUsd)
  474. return u
  475. }
  476. // SetWeeklyLimitUsd sets the "weekly_limit_usd" field.
  477. func (u *UserPlatformQuotaUpsert) SetWeeklyLimitUsd(v float64) *UserPlatformQuotaUpsert {
  478. u.Set(userplatformquota.FieldWeeklyLimitUsd, v)
  479. return u
  480. }
  481. // UpdateWeeklyLimitUsd sets the "weekly_limit_usd" field to the value that was provided on create.
  482. func (u *UserPlatformQuotaUpsert) UpdateWeeklyLimitUsd() *UserPlatformQuotaUpsert {
  483. u.SetExcluded(userplatformquota.FieldWeeklyLimitUsd)
  484. return u
  485. }
  486. // AddWeeklyLimitUsd adds v to the "weekly_limit_usd" field.
  487. func (u *UserPlatformQuotaUpsert) AddWeeklyLimitUsd(v float64) *UserPlatformQuotaUpsert {
  488. u.Add(userplatformquota.FieldWeeklyLimitUsd, v)
  489. return u
  490. }
  491. // ClearWeeklyLimitUsd clears the value of the "weekly_limit_usd" field.
  492. func (u *UserPlatformQuotaUpsert) ClearWeeklyLimitUsd() *UserPlatformQuotaUpsert {
  493. u.SetNull(userplatformquota.FieldWeeklyLimitUsd)
  494. return u
  495. }
  496. // SetMonthlyLimitUsd sets the "monthly_limit_usd" field.
  497. func (u *UserPlatformQuotaUpsert) SetMonthlyLimitUsd(v float64) *UserPlatformQuotaUpsert {
  498. u.Set(userplatformquota.FieldMonthlyLimitUsd, v)
  499. return u
  500. }
  501. // UpdateMonthlyLimitUsd sets the "monthly_limit_usd" field to the value that was provided on create.
  502. func (u *UserPlatformQuotaUpsert) UpdateMonthlyLimitUsd() *UserPlatformQuotaUpsert {
  503. u.SetExcluded(userplatformquota.FieldMonthlyLimitUsd)
  504. return u
  505. }
  506. // AddMonthlyLimitUsd adds v to the "monthly_limit_usd" field.
  507. func (u *UserPlatformQuotaUpsert) AddMonthlyLimitUsd(v float64) *UserPlatformQuotaUpsert {
  508. u.Add(userplatformquota.FieldMonthlyLimitUsd, v)
  509. return u
  510. }
  511. // ClearMonthlyLimitUsd clears the value of the "monthly_limit_usd" field.
  512. func (u *UserPlatformQuotaUpsert) ClearMonthlyLimitUsd() *UserPlatformQuotaUpsert {
  513. u.SetNull(userplatformquota.FieldMonthlyLimitUsd)
  514. return u
  515. }
  516. // SetDailyUsageUsd sets the "daily_usage_usd" field.
  517. func (u *UserPlatformQuotaUpsert) SetDailyUsageUsd(v float64) *UserPlatformQuotaUpsert {
  518. u.Set(userplatformquota.FieldDailyUsageUsd, v)
  519. return u
  520. }
  521. // UpdateDailyUsageUsd sets the "daily_usage_usd" field to the value that was provided on create.
  522. func (u *UserPlatformQuotaUpsert) UpdateDailyUsageUsd() *UserPlatformQuotaUpsert {
  523. u.SetExcluded(userplatformquota.FieldDailyUsageUsd)
  524. return u
  525. }
  526. // AddDailyUsageUsd adds v to the "daily_usage_usd" field.
  527. func (u *UserPlatformQuotaUpsert) AddDailyUsageUsd(v float64) *UserPlatformQuotaUpsert {
  528. u.Add(userplatformquota.FieldDailyUsageUsd, v)
  529. return u
  530. }
  531. // SetWeeklyUsageUsd sets the "weekly_usage_usd" field.
  532. func (u *UserPlatformQuotaUpsert) SetWeeklyUsageUsd(v float64) *UserPlatformQuotaUpsert {
  533. u.Set(userplatformquota.FieldWeeklyUsageUsd, v)
  534. return u
  535. }
  536. // UpdateWeeklyUsageUsd sets the "weekly_usage_usd" field to the value that was provided on create.
  537. func (u *UserPlatformQuotaUpsert) UpdateWeeklyUsageUsd() *UserPlatformQuotaUpsert {
  538. u.SetExcluded(userplatformquota.FieldWeeklyUsageUsd)
  539. return u
  540. }
  541. // AddWeeklyUsageUsd adds v to the "weekly_usage_usd" field.
  542. func (u *UserPlatformQuotaUpsert) AddWeeklyUsageUsd(v float64) *UserPlatformQuotaUpsert {
  543. u.Add(userplatformquota.FieldWeeklyUsageUsd, v)
  544. return u
  545. }
  546. // SetMonthlyUsageUsd sets the "monthly_usage_usd" field.
  547. func (u *UserPlatformQuotaUpsert) SetMonthlyUsageUsd(v float64) *UserPlatformQuotaUpsert {
  548. u.Set(userplatformquota.FieldMonthlyUsageUsd, v)
  549. return u
  550. }
  551. // UpdateMonthlyUsageUsd sets the "monthly_usage_usd" field to the value that was provided on create.
  552. func (u *UserPlatformQuotaUpsert) UpdateMonthlyUsageUsd() *UserPlatformQuotaUpsert {
  553. u.SetExcluded(userplatformquota.FieldMonthlyUsageUsd)
  554. return u
  555. }
  556. // AddMonthlyUsageUsd adds v to the "monthly_usage_usd" field.
  557. func (u *UserPlatformQuotaUpsert) AddMonthlyUsageUsd(v float64) *UserPlatformQuotaUpsert {
  558. u.Add(userplatformquota.FieldMonthlyUsageUsd, v)
  559. return u
  560. }
  561. // SetDailyWindowStart sets the "daily_window_start" field.
  562. func (u *UserPlatformQuotaUpsert) SetDailyWindowStart(v time.Time) *UserPlatformQuotaUpsert {
  563. u.Set(userplatformquota.FieldDailyWindowStart, v)
  564. return u
  565. }
  566. // UpdateDailyWindowStart sets the "daily_window_start" field to the value that was provided on create.
  567. func (u *UserPlatformQuotaUpsert) UpdateDailyWindowStart() *UserPlatformQuotaUpsert {
  568. u.SetExcluded(userplatformquota.FieldDailyWindowStart)
  569. return u
  570. }
  571. // ClearDailyWindowStart clears the value of the "daily_window_start" field.
  572. func (u *UserPlatformQuotaUpsert) ClearDailyWindowStart() *UserPlatformQuotaUpsert {
  573. u.SetNull(userplatformquota.FieldDailyWindowStart)
  574. return u
  575. }
  576. // SetWeeklyWindowStart sets the "weekly_window_start" field.
  577. func (u *UserPlatformQuotaUpsert) SetWeeklyWindowStart(v time.Time) *UserPlatformQuotaUpsert {
  578. u.Set(userplatformquota.FieldWeeklyWindowStart, v)
  579. return u
  580. }
  581. // UpdateWeeklyWindowStart sets the "weekly_window_start" field to the value that was provided on create.
  582. func (u *UserPlatformQuotaUpsert) UpdateWeeklyWindowStart() *UserPlatformQuotaUpsert {
  583. u.SetExcluded(userplatformquota.FieldWeeklyWindowStart)
  584. return u
  585. }
  586. // ClearWeeklyWindowStart clears the value of the "weekly_window_start" field.
  587. func (u *UserPlatformQuotaUpsert) ClearWeeklyWindowStart() *UserPlatformQuotaUpsert {
  588. u.SetNull(userplatformquota.FieldWeeklyWindowStart)
  589. return u
  590. }
  591. // SetMonthlyWindowStart sets the "monthly_window_start" field.
  592. func (u *UserPlatformQuotaUpsert) SetMonthlyWindowStart(v time.Time) *UserPlatformQuotaUpsert {
  593. u.Set(userplatformquota.FieldMonthlyWindowStart, v)
  594. return u
  595. }
  596. // UpdateMonthlyWindowStart sets the "monthly_window_start" field to the value that was provided on create.
  597. func (u *UserPlatformQuotaUpsert) UpdateMonthlyWindowStart() *UserPlatformQuotaUpsert {
  598. u.SetExcluded(userplatformquota.FieldMonthlyWindowStart)
  599. return u
  600. }
  601. // ClearMonthlyWindowStart clears the value of the "monthly_window_start" field.
  602. func (u *UserPlatformQuotaUpsert) ClearMonthlyWindowStart() *UserPlatformQuotaUpsert {
  603. u.SetNull(userplatformquota.FieldMonthlyWindowStart)
  604. return u
  605. }
  606. // UpdateNewValues updates the mutable fields using the new values that were set on create.
  607. // Using this option is equivalent to using:
  608. //
  609. // client.UserPlatformQuota.Create().
  610. // OnConflict(
  611. // sql.ResolveWithNewValues(),
  612. // ).
  613. // Exec(ctx)
  614. func (u *UserPlatformQuotaUpsertOne) UpdateNewValues() *UserPlatformQuotaUpsertOne {
  615. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  616. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  617. if _, exists := u.create.mutation.CreatedAt(); exists {
  618. s.SetIgnore(userplatformquota.FieldCreatedAt)
  619. }
  620. }))
  621. return u
  622. }
  623. // Ignore sets each column to itself in case of conflict.
  624. // Using this option is equivalent to using:
  625. //
  626. // client.UserPlatformQuota.Create().
  627. // OnConflict(sql.ResolveWithIgnore()).
  628. // Exec(ctx)
  629. func (u *UserPlatformQuotaUpsertOne) Ignore() *UserPlatformQuotaUpsertOne {
  630. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  631. return u
  632. }
  633. // DoNothing configures the conflict_action to `DO NOTHING`.
  634. // Supported only by SQLite and PostgreSQL.
  635. func (u *UserPlatformQuotaUpsertOne) DoNothing() *UserPlatformQuotaUpsertOne {
  636. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  637. return u
  638. }
  639. // Update allows overriding fields `UPDATE` values. See the UserPlatformQuotaCreate.OnConflict
  640. // documentation for more info.
  641. func (u *UserPlatformQuotaUpsertOne) Update(set func(*UserPlatformQuotaUpsert)) *UserPlatformQuotaUpsertOne {
  642. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  643. set(&UserPlatformQuotaUpsert{UpdateSet: update})
  644. }))
  645. return u
  646. }
  647. // SetUpdatedAt sets the "updated_at" field.
  648. func (u *UserPlatformQuotaUpsertOne) SetUpdatedAt(v time.Time) *UserPlatformQuotaUpsertOne {
  649. return u.Update(func(s *UserPlatformQuotaUpsert) {
  650. s.SetUpdatedAt(v)
  651. })
  652. }
  653. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  654. func (u *UserPlatformQuotaUpsertOne) UpdateUpdatedAt() *UserPlatformQuotaUpsertOne {
  655. return u.Update(func(s *UserPlatformQuotaUpsert) {
  656. s.UpdateUpdatedAt()
  657. })
  658. }
  659. // SetDeletedAt sets the "deleted_at" field.
  660. func (u *UserPlatformQuotaUpsertOne) SetDeletedAt(v time.Time) *UserPlatformQuotaUpsertOne {
  661. return u.Update(func(s *UserPlatformQuotaUpsert) {
  662. s.SetDeletedAt(v)
  663. })
  664. }
  665. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  666. func (u *UserPlatformQuotaUpsertOne) UpdateDeletedAt() *UserPlatformQuotaUpsertOne {
  667. return u.Update(func(s *UserPlatformQuotaUpsert) {
  668. s.UpdateDeletedAt()
  669. })
  670. }
  671. // ClearDeletedAt clears the value of the "deleted_at" field.
  672. func (u *UserPlatformQuotaUpsertOne) ClearDeletedAt() *UserPlatformQuotaUpsertOne {
  673. return u.Update(func(s *UserPlatformQuotaUpsert) {
  674. s.ClearDeletedAt()
  675. })
  676. }
  677. // SetUserID sets the "user_id" field.
  678. func (u *UserPlatformQuotaUpsertOne) SetUserID(v int64) *UserPlatformQuotaUpsertOne {
  679. return u.Update(func(s *UserPlatformQuotaUpsert) {
  680. s.SetUserID(v)
  681. })
  682. }
  683. // UpdateUserID sets the "user_id" field to the value that was provided on create.
  684. func (u *UserPlatformQuotaUpsertOne) UpdateUserID() *UserPlatformQuotaUpsertOne {
  685. return u.Update(func(s *UserPlatformQuotaUpsert) {
  686. s.UpdateUserID()
  687. })
  688. }
  689. // SetPlatform sets the "platform" field.
  690. func (u *UserPlatformQuotaUpsertOne) SetPlatform(v string) *UserPlatformQuotaUpsertOne {
  691. return u.Update(func(s *UserPlatformQuotaUpsert) {
  692. s.SetPlatform(v)
  693. })
  694. }
  695. // UpdatePlatform sets the "platform" field to the value that was provided on create.
  696. func (u *UserPlatformQuotaUpsertOne) UpdatePlatform() *UserPlatformQuotaUpsertOne {
  697. return u.Update(func(s *UserPlatformQuotaUpsert) {
  698. s.UpdatePlatform()
  699. })
  700. }
  701. // SetDailyLimitUsd sets the "daily_limit_usd" field.
  702. func (u *UserPlatformQuotaUpsertOne) SetDailyLimitUsd(v float64) *UserPlatformQuotaUpsertOne {
  703. return u.Update(func(s *UserPlatformQuotaUpsert) {
  704. s.SetDailyLimitUsd(v)
  705. })
  706. }
  707. // AddDailyLimitUsd adds v to the "daily_limit_usd" field.
  708. func (u *UserPlatformQuotaUpsertOne) AddDailyLimitUsd(v float64) *UserPlatformQuotaUpsertOne {
  709. return u.Update(func(s *UserPlatformQuotaUpsert) {
  710. s.AddDailyLimitUsd(v)
  711. })
  712. }
  713. // UpdateDailyLimitUsd sets the "daily_limit_usd" field to the value that was provided on create.
  714. func (u *UserPlatformQuotaUpsertOne) UpdateDailyLimitUsd() *UserPlatformQuotaUpsertOne {
  715. return u.Update(func(s *UserPlatformQuotaUpsert) {
  716. s.UpdateDailyLimitUsd()
  717. })
  718. }
  719. // ClearDailyLimitUsd clears the value of the "daily_limit_usd" field.
  720. func (u *UserPlatformQuotaUpsertOne) ClearDailyLimitUsd() *UserPlatformQuotaUpsertOne {
  721. return u.Update(func(s *UserPlatformQuotaUpsert) {
  722. s.ClearDailyLimitUsd()
  723. })
  724. }
  725. // SetWeeklyLimitUsd sets the "weekly_limit_usd" field.
  726. func (u *UserPlatformQuotaUpsertOne) SetWeeklyLimitUsd(v float64) *UserPlatformQuotaUpsertOne {
  727. return u.Update(func(s *UserPlatformQuotaUpsert) {
  728. s.SetWeeklyLimitUsd(v)
  729. })
  730. }
  731. // AddWeeklyLimitUsd adds v to the "weekly_limit_usd" field.
  732. func (u *UserPlatformQuotaUpsertOne) AddWeeklyLimitUsd(v float64) *UserPlatformQuotaUpsertOne {
  733. return u.Update(func(s *UserPlatformQuotaUpsert) {
  734. s.AddWeeklyLimitUsd(v)
  735. })
  736. }
  737. // UpdateWeeklyLimitUsd sets the "weekly_limit_usd" field to the value that was provided on create.
  738. func (u *UserPlatformQuotaUpsertOne) UpdateWeeklyLimitUsd() *UserPlatformQuotaUpsertOne {
  739. return u.Update(func(s *UserPlatformQuotaUpsert) {
  740. s.UpdateWeeklyLimitUsd()
  741. })
  742. }
  743. // ClearWeeklyLimitUsd clears the value of the "weekly_limit_usd" field.
  744. func (u *UserPlatformQuotaUpsertOne) ClearWeeklyLimitUsd() *UserPlatformQuotaUpsertOne {
  745. return u.Update(func(s *UserPlatformQuotaUpsert) {
  746. s.ClearWeeklyLimitUsd()
  747. })
  748. }
  749. // SetMonthlyLimitUsd sets the "monthly_limit_usd" field.
  750. func (u *UserPlatformQuotaUpsertOne) SetMonthlyLimitUsd(v float64) *UserPlatformQuotaUpsertOne {
  751. return u.Update(func(s *UserPlatformQuotaUpsert) {
  752. s.SetMonthlyLimitUsd(v)
  753. })
  754. }
  755. // AddMonthlyLimitUsd adds v to the "monthly_limit_usd" field.
  756. func (u *UserPlatformQuotaUpsertOne) AddMonthlyLimitUsd(v float64) *UserPlatformQuotaUpsertOne {
  757. return u.Update(func(s *UserPlatformQuotaUpsert) {
  758. s.AddMonthlyLimitUsd(v)
  759. })
  760. }
  761. // UpdateMonthlyLimitUsd sets the "monthly_limit_usd" field to the value that was provided on create.
  762. func (u *UserPlatformQuotaUpsertOne) UpdateMonthlyLimitUsd() *UserPlatformQuotaUpsertOne {
  763. return u.Update(func(s *UserPlatformQuotaUpsert) {
  764. s.UpdateMonthlyLimitUsd()
  765. })
  766. }
  767. // ClearMonthlyLimitUsd clears the value of the "monthly_limit_usd" field.
  768. func (u *UserPlatformQuotaUpsertOne) ClearMonthlyLimitUsd() *UserPlatformQuotaUpsertOne {
  769. return u.Update(func(s *UserPlatformQuotaUpsert) {
  770. s.ClearMonthlyLimitUsd()
  771. })
  772. }
  773. // SetDailyUsageUsd sets the "daily_usage_usd" field.
  774. func (u *UserPlatformQuotaUpsertOne) SetDailyUsageUsd(v float64) *UserPlatformQuotaUpsertOne {
  775. return u.Update(func(s *UserPlatformQuotaUpsert) {
  776. s.SetDailyUsageUsd(v)
  777. })
  778. }
  779. // AddDailyUsageUsd adds v to the "daily_usage_usd" field.
  780. func (u *UserPlatformQuotaUpsertOne) AddDailyUsageUsd(v float64) *UserPlatformQuotaUpsertOne {
  781. return u.Update(func(s *UserPlatformQuotaUpsert) {
  782. s.AddDailyUsageUsd(v)
  783. })
  784. }
  785. // UpdateDailyUsageUsd sets the "daily_usage_usd" field to the value that was provided on create.
  786. func (u *UserPlatformQuotaUpsertOne) UpdateDailyUsageUsd() *UserPlatformQuotaUpsertOne {
  787. return u.Update(func(s *UserPlatformQuotaUpsert) {
  788. s.UpdateDailyUsageUsd()
  789. })
  790. }
  791. // SetWeeklyUsageUsd sets the "weekly_usage_usd" field.
  792. func (u *UserPlatformQuotaUpsertOne) SetWeeklyUsageUsd(v float64) *UserPlatformQuotaUpsertOne {
  793. return u.Update(func(s *UserPlatformQuotaUpsert) {
  794. s.SetWeeklyUsageUsd(v)
  795. })
  796. }
  797. // AddWeeklyUsageUsd adds v to the "weekly_usage_usd" field.
  798. func (u *UserPlatformQuotaUpsertOne) AddWeeklyUsageUsd(v float64) *UserPlatformQuotaUpsertOne {
  799. return u.Update(func(s *UserPlatformQuotaUpsert) {
  800. s.AddWeeklyUsageUsd(v)
  801. })
  802. }
  803. // UpdateWeeklyUsageUsd sets the "weekly_usage_usd" field to the value that was provided on create.
  804. func (u *UserPlatformQuotaUpsertOne) UpdateWeeklyUsageUsd() *UserPlatformQuotaUpsertOne {
  805. return u.Update(func(s *UserPlatformQuotaUpsert) {
  806. s.UpdateWeeklyUsageUsd()
  807. })
  808. }
  809. // SetMonthlyUsageUsd sets the "monthly_usage_usd" field.
  810. func (u *UserPlatformQuotaUpsertOne) SetMonthlyUsageUsd(v float64) *UserPlatformQuotaUpsertOne {
  811. return u.Update(func(s *UserPlatformQuotaUpsert) {
  812. s.SetMonthlyUsageUsd(v)
  813. })
  814. }
  815. // AddMonthlyUsageUsd adds v to the "monthly_usage_usd" field.
  816. func (u *UserPlatformQuotaUpsertOne) AddMonthlyUsageUsd(v float64) *UserPlatformQuotaUpsertOne {
  817. return u.Update(func(s *UserPlatformQuotaUpsert) {
  818. s.AddMonthlyUsageUsd(v)
  819. })
  820. }
  821. // UpdateMonthlyUsageUsd sets the "monthly_usage_usd" field to the value that was provided on create.
  822. func (u *UserPlatformQuotaUpsertOne) UpdateMonthlyUsageUsd() *UserPlatformQuotaUpsertOne {
  823. return u.Update(func(s *UserPlatformQuotaUpsert) {
  824. s.UpdateMonthlyUsageUsd()
  825. })
  826. }
  827. // SetDailyWindowStart sets the "daily_window_start" field.
  828. func (u *UserPlatformQuotaUpsertOne) SetDailyWindowStart(v time.Time) *UserPlatformQuotaUpsertOne {
  829. return u.Update(func(s *UserPlatformQuotaUpsert) {
  830. s.SetDailyWindowStart(v)
  831. })
  832. }
  833. // UpdateDailyWindowStart sets the "daily_window_start" field to the value that was provided on create.
  834. func (u *UserPlatformQuotaUpsertOne) UpdateDailyWindowStart() *UserPlatformQuotaUpsertOne {
  835. return u.Update(func(s *UserPlatformQuotaUpsert) {
  836. s.UpdateDailyWindowStart()
  837. })
  838. }
  839. // ClearDailyWindowStart clears the value of the "daily_window_start" field.
  840. func (u *UserPlatformQuotaUpsertOne) ClearDailyWindowStart() *UserPlatformQuotaUpsertOne {
  841. return u.Update(func(s *UserPlatformQuotaUpsert) {
  842. s.ClearDailyWindowStart()
  843. })
  844. }
  845. // SetWeeklyWindowStart sets the "weekly_window_start" field.
  846. func (u *UserPlatformQuotaUpsertOne) SetWeeklyWindowStart(v time.Time) *UserPlatformQuotaUpsertOne {
  847. return u.Update(func(s *UserPlatformQuotaUpsert) {
  848. s.SetWeeklyWindowStart(v)
  849. })
  850. }
  851. // UpdateWeeklyWindowStart sets the "weekly_window_start" field to the value that was provided on create.
  852. func (u *UserPlatformQuotaUpsertOne) UpdateWeeklyWindowStart() *UserPlatformQuotaUpsertOne {
  853. return u.Update(func(s *UserPlatformQuotaUpsert) {
  854. s.UpdateWeeklyWindowStart()
  855. })
  856. }
  857. // ClearWeeklyWindowStart clears the value of the "weekly_window_start" field.
  858. func (u *UserPlatformQuotaUpsertOne) ClearWeeklyWindowStart() *UserPlatformQuotaUpsertOne {
  859. return u.Update(func(s *UserPlatformQuotaUpsert) {
  860. s.ClearWeeklyWindowStart()
  861. })
  862. }
  863. // SetMonthlyWindowStart sets the "monthly_window_start" field.
  864. func (u *UserPlatformQuotaUpsertOne) SetMonthlyWindowStart(v time.Time) *UserPlatformQuotaUpsertOne {
  865. return u.Update(func(s *UserPlatformQuotaUpsert) {
  866. s.SetMonthlyWindowStart(v)
  867. })
  868. }
  869. // UpdateMonthlyWindowStart sets the "monthly_window_start" field to the value that was provided on create.
  870. func (u *UserPlatformQuotaUpsertOne) UpdateMonthlyWindowStart() *UserPlatformQuotaUpsertOne {
  871. return u.Update(func(s *UserPlatformQuotaUpsert) {
  872. s.UpdateMonthlyWindowStart()
  873. })
  874. }
  875. // ClearMonthlyWindowStart clears the value of the "monthly_window_start" field.
  876. func (u *UserPlatformQuotaUpsertOne) ClearMonthlyWindowStart() *UserPlatformQuotaUpsertOne {
  877. return u.Update(func(s *UserPlatformQuotaUpsert) {
  878. s.ClearMonthlyWindowStart()
  879. })
  880. }
  881. // Exec executes the query.
  882. func (u *UserPlatformQuotaUpsertOne) Exec(ctx context.Context) error {
  883. if len(u.create.conflict) == 0 {
  884. return errors.New("ent: missing options for UserPlatformQuotaCreate.OnConflict")
  885. }
  886. return u.create.Exec(ctx)
  887. }
  888. // ExecX is like Exec, but panics if an error occurs.
  889. func (u *UserPlatformQuotaUpsertOne) ExecX(ctx context.Context) {
  890. if err := u.create.Exec(ctx); err != nil {
  891. panic(err)
  892. }
  893. }
  894. // Exec executes the UPSERT query and returns the inserted/updated ID.
  895. func (u *UserPlatformQuotaUpsertOne) ID(ctx context.Context) (id int64, err error) {
  896. node, err := u.create.Save(ctx)
  897. if err != nil {
  898. return id, err
  899. }
  900. return node.ID, nil
  901. }
  902. // IDX is like ID, but panics if an error occurs.
  903. func (u *UserPlatformQuotaUpsertOne) IDX(ctx context.Context) int64 {
  904. id, err := u.ID(ctx)
  905. if err != nil {
  906. panic(err)
  907. }
  908. return id
  909. }
  910. // UserPlatformQuotaCreateBulk is the builder for creating many UserPlatformQuota entities in bulk.
  911. type UserPlatformQuotaCreateBulk struct {
  912. config
  913. err error
  914. builders []*UserPlatformQuotaCreate
  915. conflict []sql.ConflictOption
  916. }
  917. // Save creates the UserPlatformQuota entities in the database.
  918. func (_c *UserPlatformQuotaCreateBulk) Save(ctx context.Context) ([]*UserPlatformQuota, error) {
  919. if _c.err != nil {
  920. return nil, _c.err
  921. }
  922. specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
  923. nodes := make([]*UserPlatformQuota, len(_c.builders))
  924. mutators := make([]Mutator, len(_c.builders))
  925. for i := range _c.builders {
  926. func(i int, root context.Context) {
  927. builder := _c.builders[i]
  928. builder.defaults()
  929. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  930. mutation, ok := m.(*UserPlatformQuotaMutation)
  931. if !ok {
  932. return nil, fmt.Errorf("unexpected mutation type %T", m)
  933. }
  934. if err := builder.check(); err != nil {
  935. return nil, err
  936. }
  937. builder.mutation = mutation
  938. var err error
  939. nodes[i], specs[i] = builder.createSpec()
  940. if i < len(mutators)-1 {
  941. _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
  942. } else {
  943. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  944. spec.OnConflict = _c.conflict
  945. // Invoke the actual operation on the latest mutation in the chain.
  946. if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
  947. if sqlgraph.IsConstraintError(err) {
  948. err = &ConstraintError{msg: err.Error(), wrap: err}
  949. }
  950. }
  951. }
  952. if err != nil {
  953. return nil, err
  954. }
  955. mutation.id = &nodes[i].ID
  956. if specs[i].ID.Value != nil {
  957. id := specs[i].ID.Value.(int64)
  958. nodes[i].ID = int64(id)
  959. }
  960. mutation.done = true
  961. return nodes[i], nil
  962. })
  963. for i := len(builder.hooks) - 1; i >= 0; i-- {
  964. mut = builder.hooks[i](mut)
  965. }
  966. mutators[i] = mut
  967. }(i, ctx)
  968. }
  969. if len(mutators) > 0 {
  970. if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
  971. return nil, err
  972. }
  973. }
  974. return nodes, nil
  975. }
  976. // SaveX is like Save, but panics if an error occurs.
  977. func (_c *UserPlatformQuotaCreateBulk) SaveX(ctx context.Context) []*UserPlatformQuota {
  978. v, err := _c.Save(ctx)
  979. if err != nil {
  980. panic(err)
  981. }
  982. return v
  983. }
  984. // Exec executes the query.
  985. func (_c *UserPlatformQuotaCreateBulk) Exec(ctx context.Context) error {
  986. _, err := _c.Save(ctx)
  987. return err
  988. }
  989. // ExecX is like Exec, but panics if an error occurs.
  990. func (_c *UserPlatformQuotaCreateBulk) ExecX(ctx context.Context) {
  991. if err := _c.Exec(ctx); err != nil {
  992. panic(err)
  993. }
  994. }
  995. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  996. // of the `INSERT` statement. For example:
  997. //
  998. // client.UserPlatformQuota.CreateBulk(builders...).
  999. // OnConflict(
  1000. // // Update the row with the new values
  1001. // // the was proposed for insertion.
  1002. // sql.ResolveWithNewValues(),
  1003. // ).
  1004. // // Override some of the fields with custom
  1005. // // update values.
  1006. // Update(func(u *ent.UserPlatformQuotaUpsert) {
  1007. // SetCreatedAt(v+v).
  1008. // }).
  1009. // Exec(ctx)
  1010. func (_c *UserPlatformQuotaCreateBulk) OnConflict(opts ...sql.ConflictOption) *UserPlatformQuotaUpsertBulk {
  1011. _c.conflict = opts
  1012. return &UserPlatformQuotaUpsertBulk{
  1013. create: _c,
  1014. }
  1015. }
  1016. // OnConflictColumns calls `OnConflict` and configures the columns
  1017. // as conflict target. Using this option is equivalent to using:
  1018. //
  1019. // client.UserPlatformQuota.Create().
  1020. // OnConflict(sql.ConflictColumns(columns...)).
  1021. // Exec(ctx)
  1022. func (_c *UserPlatformQuotaCreateBulk) OnConflictColumns(columns ...string) *UserPlatformQuotaUpsertBulk {
  1023. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  1024. return &UserPlatformQuotaUpsertBulk{
  1025. create: _c,
  1026. }
  1027. }
  1028. // UserPlatformQuotaUpsertBulk is the builder for "upsert"-ing
  1029. // a bulk of UserPlatformQuota nodes.
  1030. type UserPlatformQuotaUpsertBulk struct {
  1031. create *UserPlatformQuotaCreateBulk
  1032. }
  1033. // UpdateNewValues updates the mutable fields using the new values that
  1034. // were set on create. Using this option is equivalent to using:
  1035. //
  1036. // client.UserPlatformQuota.Create().
  1037. // OnConflict(
  1038. // sql.ResolveWithNewValues(),
  1039. // ).
  1040. // Exec(ctx)
  1041. func (u *UserPlatformQuotaUpsertBulk) UpdateNewValues() *UserPlatformQuotaUpsertBulk {
  1042. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1043. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1044. for _, b := range u.create.builders {
  1045. if _, exists := b.mutation.CreatedAt(); exists {
  1046. s.SetIgnore(userplatformquota.FieldCreatedAt)
  1047. }
  1048. }
  1049. }))
  1050. return u
  1051. }
  1052. // Ignore sets each column to itself in case of conflict.
  1053. // Using this option is equivalent to using:
  1054. //
  1055. // client.UserPlatformQuota.Create().
  1056. // OnConflict(sql.ResolveWithIgnore()).
  1057. // Exec(ctx)
  1058. func (u *UserPlatformQuotaUpsertBulk) Ignore() *UserPlatformQuotaUpsertBulk {
  1059. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1060. return u
  1061. }
  1062. // DoNothing configures the conflict_action to `DO NOTHING`.
  1063. // Supported only by SQLite and PostgreSQL.
  1064. func (u *UserPlatformQuotaUpsertBulk) DoNothing() *UserPlatformQuotaUpsertBulk {
  1065. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1066. return u
  1067. }
  1068. // Update allows overriding fields `UPDATE` values. See the UserPlatformQuotaCreateBulk.OnConflict
  1069. // documentation for more info.
  1070. func (u *UserPlatformQuotaUpsertBulk) Update(set func(*UserPlatformQuotaUpsert)) *UserPlatformQuotaUpsertBulk {
  1071. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1072. set(&UserPlatformQuotaUpsert{UpdateSet: update})
  1073. }))
  1074. return u
  1075. }
  1076. // SetUpdatedAt sets the "updated_at" field.
  1077. func (u *UserPlatformQuotaUpsertBulk) SetUpdatedAt(v time.Time) *UserPlatformQuotaUpsertBulk {
  1078. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1079. s.SetUpdatedAt(v)
  1080. })
  1081. }
  1082. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1083. func (u *UserPlatformQuotaUpsertBulk) UpdateUpdatedAt() *UserPlatformQuotaUpsertBulk {
  1084. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1085. s.UpdateUpdatedAt()
  1086. })
  1087. }
  1088. // SetDeletedAt sets the "deleted_at" field.
  1089. func (u *UserPlatformQuotaUpsertBulk) SetDeletedAt(v time.Time) *UserPlatformQuotaUpsertBulk {
  1090. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1091. s.SetDeletedAt(v)
  1092. })
  1093. }
  1094. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  1095. func (u *UserPlatformQuotaUpsertBulk) UpdateDeletedAt() *UserPlatformQuotaUpsertBulk {
  1096. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1097. s.UpdateDeletedAt()
  1098. })
  1099. }
  1100. // ClearDeletedAt clears the value of the "deleted_at" field.
  1101. func (u *UserPlatformQuotaUpsertBulk) ClearDeletedAt() *UserPlatformQuotaUpsertBulk {
  1102. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1103. s.ClearDeletedAt()
  1104. })
  1105. }
  1106. // SetUserID sets the "user_id" field.
  1107. func (u *UserPlatformQuotaUpsertBulk) SetUserID(v int64) *UserPlatformQuotaUpsertBulk {
  1108. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1109. s.SetUserID(v)
  1110. })
  1111. }
  1112. // UpdateUserID sets the "user_id" field to the value that was provided on create.
  1113. func (u *UserPlatformQuotaUpsertBulk) UpdateUserID() *UserPlatformQuotaUpsertBulk {
  1114. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1115. s.UpdateUserID()
  1116. })
  1117. }
  1118. // SetPlatform sets the "platform" field.
  1119. func (u *UserPlatformQuotaUpsertBulk) SetPlatform(v string) *UserPlatformQuotaUpsertBulk {
  1120. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1121. s.SetPlatform(v)
  1122. })
  1123. }
  1124. // UpdatePlatform sets the "platform" field to the value that was provided on create.
  1125. func (u *UserPlatformQuotaUpsertBulk) UpdatePlatform() *UserPlatformQuotaUpsertBulk {
  1126. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1127. s.UpdatePlatform()
  1128. })
  1129. }
  1130. // SetDailyLimitUsd sets the "daily_limit_usd" field.
  1131. func (u *UserPlatformQuotaUpsertBulk) SetDailyLimitUsd(v float64) *UserPlatformQuotaUpsertBulk {
  1132. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1133. s.SetDailyLimitUsd(v)
  1134. })
  1135. }
  1136. // AddDailyLimitUsd adds v to the "daily_limit_usd" field.
  1137. func (u *UserPlatformQuotaUpsertBulk) AddDailyLimitUsd(v float64) *UserPlatformQuotaUpsertBulk {
  1138. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1139. s.AddDailyLimitUsd(v)
  1140. })
  1141. }
  1142. // UpdateDailyLimitUsd sets the "daily_limit_usd" field to the value that was provided on create.
  1143. func (u *UserPlatformQuotaUpsertBulk) UpdateDailyLimitUsd() *UserPlatformQuotaUpsertBulk {
  1144. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1145. s.UpdateDailyLimitUsd()
  1146. })
  1147. }
  1148. // ClearDailyLimitUsd clears the value of the "daily_limit_usd" field.
  1149. func (u *UserPlatformQuotaUpsertBulk) ClearDailyLimitUsd() *UserPlatformQuotaUpsertBulk {
  1150. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1151. s.ClearDailyLimitUsd()
  1152. })
  1153. }
  1154. // SetWeeklyLimitUsd sets the "weekly_limit_usd" field.
  1155. func (u *UserPlatformQuotaUpsertBulk) SetWeeklyLimitUsd(v float64) *UserPlatformQuotaUpsertBulk {
  1156. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1157. s.SetWeeklyLimitUsd(v)
  1158. })
  1159. }
  1160. // AddWeeklyLimitUsd adds v to the "weekly_limit_usd" field.
  1161. func (u *UserPlatformQuotaUpsertBulk) AddWeeklyLimitUsd(v float64) *UserPlatformQuotaUpsertBulk {
  1162. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1163. s.AddWeeklyLimitUsd(v)
  1164. })
  1165. }
  1166. // UpdateWeeklyLimitUsd sets the "weekly_limit_usd" field to the value that was provided on create.
  1167. func (u *UserPlatformQuotaUpsertBulk) UpdateWeeklyLimitUsd() *UserPlatformQuotaUpsertBulk {
  1168. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1169. s.UpdateWeeklyLimitUsd()
  1170. })
  1171. }
  1172. // ClearWeeklyLimitUsd clears the value of the "weekly_limit_usd" field.
  1173. func (u *UserPlatformQuotaUpsertBulk) ClearWeeklyLimitUsd() *UserPlatformQuotaUpsertBulk {
  1174. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1175. s.ClearWeeklyLimitUsd()
  1176. })
  1177. }
  1178. // SetMonthlyLimitUsd sets the "monthly_limit_usd" field.
  1179. func (u *UserPlatformQuotaUpsertBulk) SetMonthlyLimitUsd(v float64) *UserPlatformQuotaUpsertBulk {
  1180. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1181. s.SetMonthlyLimitUsd(v)
  1182. })
  1183. }
  1184. // AddMonthlyLimitUsd adds v to the "monthly_limit_usd" field.
  1185. func (u *UserPlatformQuotaUpsertBulk) AddMonthlyLimitUsd(v float64) *UserPlatformQuotaUpsertBulk {
  1186. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1187. s.AddMonthlyLimitUsd(v)
  1188. })
  1189. }
  1190. // UpdateMonthlyLimitUsd sets the "monthly_limit_usd" field to the value that was provided on create.
  1191. func (u *UserPlatformQuotaUpsertBulk) UpdateMonthlyLimitUsd() *UserPlatformQuotaUpsertBulk {
  1192. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1193. s.UpdateMonthlyLimitUsd()
  1194. })
  1195. }
  1196. // ClearMonthlyLimitUsd clears the value of the "monthly_limit_usd" field.
  1197. func (u *UserPlatformQuotaUpsertBulk) ClearMonthlyLimitUsd() *UserPlatformQuotaUpsertBulk {
  1198. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1199. s.ClearMonthlyLimitUsd()
  1200. })
  1201. }
  1202. // SetDailyUsageUsd sets the "daily_usage_usd" field.
  1203. func (u *UserPlatformQuotaUpsertBulk) SetDailyUsageUsd(v float64) *UserPlatformQuotaUpsertBulk {
  1204. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1205. s.SetDailyUsageUsd(v)
  1206. })
  1207. }
  1208. // AddDailyUsageUsd adds v to the "daily_usage_usd" field.
  1209. func (u *UserPlatformQuotaUpsertBulk) AddDailyUsageUsd(v float64) *UserPlatformQuotaUpsertBulk {
  1210. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1211. s.AddDailyUsageUsd(v)
  1212. })
  1213. }
  1214. // UpdateDailyUsageUsd sets the "daily_usage_usd" field to the value that was provided on create.
  1215. func (u *UserPlatformQuotaUpsertBulk) UpdateDailyUsageUsd() *UserPlatformQuotaUpsertBulk {
  1216. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1217. s.UpdateDailyUsageUsd()
  1218. })
  1219. }
  1220. // SetWeeklyUsageUsd sets the "weekly_usage_usd" field.
  1221. func (u *UserPlatformQuotaUpsertBulk) SetWeeklyUsageUsd(v float64) *UserPlatformQuotaUpsertBulk {
  1222. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1223. s.SetWeeklyUsageUsd(v)
  1224. })
  1225. }
  1226. // AddWeeklyUsageUsd adds v to the "weekly_usage_usd" field.
  1227. func (u *UserPlatformQuotaUpsertBulk) AddWeeklyUsageUsd(v float64) *UserPlatformQuotaUpsertBulk {
  1228. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1229. s.AddWeeklyUsageUsd(v)
  1230. })
  1231. }
  1232. // UpdateWeeklyUsageUsd sets the "weekly_usage_usd" field to the value that was provided on create.
  1233. func (u *UserPlatformQuotaUpsertBulk) UpdateWeeklyUsageUsd() *UserPlatformQuotaUpsertBulk {
  1234. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1235. s.UpdateWeeklyUsageUsd()
  1236. })
  1237. }
  1238. // SetMonthlyUsageUsd sets the "monthly_usage_usd" field.
  1239. func (u *UserPlatformQuotaUpsertBulk) SetMonthlyUsageUsd(v float64) *UserPlatformQuotaUpsertBulk {
  1240. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1241. s.SetMonthlyUsageUsd(v)
  1242. })
  1243. }
  1244. // AddMonthlyUsageUsd adds v to the "monthly_usage_usd" field.
  1245. func (u *UserPlatformQuotaUpsertBulk) AddMonthlyUsageUsd(v float64) *UserPlatformQuotaUpsertBulk {
  1246. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1247. s.AddMonthlyUsageUsd(v)
  1248. })
  1249. }
  1250. // UpdateMonthlyUsageUsd sets the "monthly_usage_usd" field to the value that was provided on create.
  1251. func (u *UserPlatformQuotaUpsertBulk) UpdateMonthlyUsageUsd() *UserPlatformQuotaUpsertBulk {
  1252. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1253. s.UpdateMonthlyUsageUsd()
  1254. })
  1255. }
  1256. // SetDailyWindowStart sets the "daily_window_start" field.
  1257. func (u *UserPlatformQuotaUpsertBulk) SetDailyWindowStart(v time.Time) *UserPlatformQuotaUpsertBulk {
  1258. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1259. s.SetDailyWindowStart(v)
  1260. })
  1261. }
  1262. // UpdateDailyWindowStart sets the "daily_window_start" field to the value that was provided on create.
  1263. func (u *UserPlatformQuotaUpsertBulk) UpdateDailyWindowStart() *UserPlatformQuotaUpsertBulk {
  1264. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1265. s.UpdateDailyWindowStart()
  1266. })
  1267. }
  1268. // ClearDailyWindowStart clears the value of the "daily_window_start" field.
  1269. func (u *UserPlatformQuotaUpsertBulk) ClearDailyWindowStart() *UserPlatformQuotaUpsertBulk {
  1270. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1271. s.ClearDailyWindowStart()
  1272. })
  1273. }
  1274. // SetWeeklyWindowStart sets the "weekly_window_start" field.
  1275. func (u *UserPlatformQuotaUpsertBulk) SetWeeklyWindowStart(v time.Time) *UserPlatformQuotaUpsertBulk {
  1276. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1277. s.SetWeeklyWindowStart(v)
  1278. })
  1279. }
  1280. // UpdateWeeklyWindowStart sets the "weekly_window_start" field to the value that was provided on create.
  1281. func (u *UserPlatformQuotaUpsertBulk) UpdateWeeklyWindowStart() *UserPlatformQuotaUpsertBulk {
  1282. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1283. s.UpdateWeeklyWindowStart()
  1284. })
  1285. }
  1286. // ClearWeeklyWindowStart clears the value of the "weekly_window_start" field.
  1287. func (u *UserPlatformQuotaUpsertBulk) ClearWeeklyWindowStart() *UserPlatformQuotaUpsertBulk {
  1288. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1289. s.ClearWeeklyWindowStart()
  1290. })
  1291. }
  1292. // SetMonthlyWindowStart sets the "monthly_window_start" field.
  1293. func (u *UserPlatformQuotaUpsertBulk) SetMonthlyWindowStart(v time.Time) *UserPlatformQuotaUpsertBulk {
  1294. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1295. s.SetMonthlyWindowStart(v)
  1296. })
  1297. }
  1298. // UpdateMonthlyWindowStart sets the "monthly_window_start" field to the value that was provided on create.
  1299. func (u *UserPlatformQuotaUpsertBulk) UpdateMonthlyWindowStart() *UserPlatformQuotaUpsertBulk {
  1300. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1301. s.UpdateMonthlyWindowStart()
  1302. })
  1303. }
  1304. // ClearMonthlyWindowStart clears the value of the "monthly_window_start" field.
  1305. func (u *UserPlatformQuotaUpsertBulk) ClearMonthlyWindowStart() *UserPlatformQuotaUpsertBulk {
  1306. return u.Update(func(s *UserPlatformQuotaUpsert) {
  1307. s.ClearMonthlyWindowStart()
  1308. })
  1309. }
  1310. // Exec executes the query.
  1311. func (u *UserPlatformQuotaUpsertBulk) Exec(ctx context.Context) error {
  1312. if u.create.err != nil {
  1313. return u.create.err
  1314. }
  1315. for i, b := range u.create.builders {
  1316. if len(b.conflict) != 0 {
  1317. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the UserPlatformQuotaCreateBulk instead", i)
  1318. }
  1319. }
  1320. if len(u.create.conflict) == 0 {
  1321. return errors.New("ent: missing options for UserPlatformQuotaCreateBulk.OnConflict")
  1322. }
  1323. return u.create.Exec(ctx)
  1324. }
  1325. // ExecX is like Exec, but panics if an error occurs.
  1326. func (u *UserPlatformQuotaUpsertBulk) ExecX(ctx context.Context) {
  1327. if err := u.create.Exec(ctx); err != nil {
  1328. panic(err)
  1329. }
  1330. }