| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- "github.com/Wei-Shaw/sub2api/ent/user"
- "github.com/Wei-Shaw/sub2api/ent/userplatformquota"
- )
- // UserPlatformQuotaCreate is the builder for creating a UserPlatformQuota entity.
- type UserPlatformQuotaCreate struct {
- config
- mutation *UserPlatformQuotaMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetCreatedAt sets the "created_at" field.
- func (_c *UserPlatformQuotaCreate) SetCreatedAt(v time.Time) *UserPlatformQuotaCreate {
- _c.mutation.SetCreatedAt(v)
- return _c
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (_c *UserPlatformQuotaCreate) SetNillableCreatedAt(v *time.Time) *UserPlatformQuotaCreate {
- if v != nil {
- _c.SetCreatedAt(*v)
- }
- return _c
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (_c *UserPlatformQuotaCreate) SetUpdatedAt(v time.Time) *UserPlatformQuotaCreate {
- _c.mutation.SetUpdatedAt(v)
- return _c
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (_c *UserPlatformQuotaCreate) SetNillableUpdatedAt(v *time.Time) *UserPlatformQuotaCreate {
- if v != nil {
- _c.SetUpdatedAt(*v)
- }
- return _c
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (_c *UserPlatformQuotaCreate) SetDeletedAt(v time.Time) *UserPlatformQuotaCreate {
- _c.mutation.SetDeletedAt(v)
- return _c
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (_c *UserPlatformQuotaCreate) SetNillableDeletedAt(v *time.Time) *UserPlatformQuotaCreate {
- if v != nil {
- _c.SetDeletedAt(*v)
- }
- return _c
- }
- // SetUserID sets the "user_id" field.
- func (_c *UserPlatformQuotaCreate) SetUserID(v int64) *UserPlatformQuotaCreate {
- _c.mutation.SetUserID(v)
- return _c
- }
- // SetPlatform sets the "platform" field.
- func (_c *UserPlatformQuotaCreate) SetPlatform(v string) *UserPlatformQuotaCreate {
- _c.mutation.SetPlatform(v)
- return _c
- }
- // SetDailyLimitUsd sets the "daily_limit_usd" field.
- func (_c *UserPlatformQuotaCreate) SetDailyLimitUsd(v float64) *UserPlatformQuotaCreate {
- _c.mutation.SetDailyLimitUsd(v)
- return _c
- }
- // SetNillableDailyLimitUsd sets the "daily_limit_usd" field if the given value is not nil.
- func (_c *UserPlatformQuotaCreate) SetNillableDailyLimitUsd(v *float64) *UserPlatformQuotaCreate {
- if v != nil {
- _c.SetDailyLimitUsd(*v)
- }
- return _c
- }
- // SetWeeklyLimitUsd sets the "weekly_limit_usd" field.
- func (_c *UserPlatformQuotaCreate) SetWeeklyLimitUsd(v float64) *UserPlatformQuotaCreate {
- _c.mutation.SetWeeklyLimitUsd(v)
- return _c
- }
- // SetNillableWeeklyLimitUsd sets the "weekly_limit_usd" field if the given value is not nil.
- func (_c *UserPlatformQuotaCreate) SetNillableWeeklyLimitUsd(v *float64) *UserPlatformQuotaCreate {
- if v != nil {
- _c.SetWeeklyLimitUsd(*v)
- }
- return _c
- }
- // SetMonthlyLimitUsd sets the "monthly_limit_usd" field.
- func (_c *UserPlatformQuotaCreate) SetMonthlyLimitUsd(v float64) *UserPlatformQuotaCreate {
- _c.mutation.SetMonthlyLimitUsd(v)
- return _c
- }
- // SetNillableMonthlyLimitUsd sets the "monthly_limit_usd" field if the given value is not nil.
- func (_c *UserPlatformQuotaCreate) SetNillableMonthlyLimitUsd(v *float64) *UserPlatformQuotaCreate {
- if v != nil {
- _c.SetMonthlyLimitUsd(*v)
- }
- return _c
- }
- // SetDailyUsageUsd sets the "daily_usage_usd" field.
- func (_c *UserPlatformQuotaCreate) SetDailyUsageUsd(v float64) *UserPlatformQuotaCreate {
- _c.mutation.SetDailyUsageUsd(v)
- return _c
- }
- // SetNillableDailyUsageUsd sets the "daily_usage_usd" field if the given value is not nil.
- func (_c *UserPlatformQuotaCreate) SetNillableDailyUsageUsd(v *float64) *UserPlatformQuotaCreate {
- if v != nil {
- _c.SetDailyUsageUsd(*v)
- }
- return _c
- }
- // SetWeeklyUsageUsd sets the "weekly_usage_usd" field.
- func (_c *UserPlatformQuotaCreate) SetWeeklyUsageUsd(v float64) *UserPlatformQuotaCreate {
- _c.mutation.SetWeeklyUsageUsd(v)
- return _c
- }
- // SetNillableWeeklyUsageUsd sets the "weekly_usage_usd" field if the given value is not nil.
- func (_c *UserPlatformQuotaCreate) SetNillableWeeklyUsageUsd(v *float64) *UserPlatformQuotaCreate {
- if v != nil {
- _c.SetWeeklyUsageUsd(*v)
- }
- return _c
- }
- // SetMonthlyUsageUsd sets the "monthly_usage_usd" field.
- func (_c *UserPlatformQuotaCreate) SetMonthlyUsageUsd(v float64) *UserPlatformQuotaCreate {
- _c.mutation.SetMonthlyUsageUsd(v)
- return _c
- }
- // SetNillableMonthlyUsageUsd sets the "monthly_usage_usd" field if the given value is not nil.
- func (_c *UserPlatformQuotaCreate) SetNillableMonthlyUsageUsd(v *float64) *UserPlatformQuotaCreate {
- if v != nil {
- _c.SetMonthlyUsageUsd(*v)
- }
- return _c
- }
- // SetDailyWindowStart sets the "daily_window_start" field.
- func (_c *UserPlatformQuotaCreate) SetDailyWindowStart(v time.Time) *UserPlatformQuotaCreate {
- _c.mutation.SetDailyWindowStart(v)
- return _c
- }
- // SetNillableDailyWindowStart sets the "daily_window_start" field if the given value is not nil.
- func (_c *UserPlatformQuotaCreate) SetNillableDailyWindowStart(v *time.Time) *UserPlatformQuotaCreate {
- if v != nil {
- _c.SetDailyWindowStart(*v)
- }
- return _c
- }
- // SetWeeklyWindowStart sets the "weekly_window_start" field.
- func (_c *UserPlatformQuotaCreate) SetWeeklyWindowStart(v time.Time) *UserPlatformQuotaCreate {
- _c.mutation.SetWeeklyWindowStart(v)
- return _c
- }
- // SetNillableWeeklyWindowStart sets the "weekly_window_start" field if the given value is not nil.
- func (_c *UserPlatformQuotaCreate) SetNillableWeeklyWindowStart(v *time.Time) *UserPlatformQuotaCreate {
- if v != nil {
- _c.SetWeeklyWindowStart(*v)
- }
- return _c
- }
- // SetMonthlyWindowStart sets the "monthly_window_start" field.
- func (_c *UserPlatformQuotaCreate) SetMonthlyWindowStart(v time.Time) *UserPlatformQuotaCreate {
- _c.mutation.SetMonthlyWindowStart(v)
- return _c
- }
- // SetNillableMonthlyWindowStart sets the "monthly_window_start" field if the given value is not nil.
- func (_c *UserPlatformQuotaCreate) SetNillableMonthlyWindowStart(v *time.Time) *UserPlatformQuotaCreate {
- if v != nil {
- _c.SetMonthlyWindowStart(*v)
- }
- return _c
- }
- // SetUser sets the "user" edge to the User entity.
- func (_c *UserPlatformQuotaCreate) SetUser(v *User) *UserPlatformQuotaCreate {
- return _c.SetUserID(v.ID)
- }
- // Mutation returns the UserPlatformQuotaMutation object of the builder.
- func (_c *UserPlatformQuotaCreate) Mutation() *UserPlatformQuotaMutation {
- return _c.mutation
- }
- // Save creates the UserPlatformQuota in the database.
- func (_c *UserPlatformQuotaCreate) Save(ctx context.Context) (*UserPlatformQuota, error) {
- if err := _c.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (_c *UserPlatformQuotaCreate) SaveX(ctx context.Context) *UserPlatformQuota {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *UserPlatformQuotaCreate) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *UserPlatformQuotaCreate) ExecX(ctx context.Context) {
- if err := _c.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (_c *UserPlatformQuotaCreate) defaults() error {
- if _, ok := _c.mutation.CreatedAt(); !ok {
- if userplatformquota.DefaultCreatedAt == nil {
- return fmt.Errorf("ent: uninitialized userplatformquota.DefaultCreatedAt (forgotten import ent/runtime?)")
- }
- v := userplatformquota.DefaultCreatedAt()
- _c.mutation.SetCreatedAt(v)
- }
- if _, ok := _c.mutation.UpdatedAt(); !ok {
- if userplatformquota.DefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized userplatformquota.DefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := userplatformquota.DefaultUpdatedAt()
- _c.mutation.SetUpdatedAt(v)
- }
- if _, ok := _c.mutation.DailyUsageUsd(); !ok {
- v := userplatformquota.DefaultDailyUsageUsd
- _c.mutation.SetDailyUsageUsd(v)
- }
- if _, ok := _c.mutation.WeeklyUsageUsd(); !ok {
- v := userplatformquota.DefaultWeeklyUsageUsd
- _c.mutation.SetWeeklyUsageUsd(v)
- }
- if _, ok := _c.mutation.MonthlyUsageUsd(); !ok {
- v := userplatformquota.DefaultMonthlyUsageUsd
- _c.mutation.SetMonthlyUsageUsd(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (_c *UserPlatformQuotaCreate) check() error {
- if _, ok := _c.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "UserPlatformQuota.created_at"`)}
- }
- if _, ok := _c.mutation.UpdatedAt(); !ok {
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "UserPlatformQuota.updated_at"`)}
- }
- if _, ok := _c.mutation.UserID(); !ok {
- return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "UserPlatformQuota.user_id"`)}
- }
- if _, ok := _c.mutation.Platform(); !ok {
- return &ValidationError{Name: "platform", err: errors.New(`ent: missing required field "UserPlatformQuota.platform"`)}
- }
- if v, ok := _c.mutation.Platform(); ok {
- if err := userplatformquota.PlatformValidator(v); err != nil {
- return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "UserPlatformQuota.platform": %w`, err)}
- }
- }
- if _, ok := _c.mutation.DailyUsageUsd(); !ok {
- return &ValidationError{Name: "daily_usage_usd", err: errors.New(`ent: missing required field "UserPlatformQuota.daily_usage_usd"`)}
- }
- if _, ok := _c.mutation.WeeklyUsageUsd(); !ok {
- return &ValidationError{Name: "weekly_usage_usd", err: errors.New(`ent: missing required field "UserPlatformQuota.weekly_usage_usd"`)}
- }
- if _, ok := _c.mutation.MonthlyUsageUsd(); !ok {
- return &ValidationError{Name: "monthly_usage_usd", err: errors.New(`ent: missing required field "UserPlatformQuota.monthly_usage_usd"`)}
- }
- if len(_c.mutation.UserIDs()) == 0 {
- return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "UserPlatformQuota.user"`)}
- }
- return nil
- }
- func (_c *UserPlatformQuotaCreate) sqlSave(ctx context.Context) (*UserPlatformQuota, error) {
- if err := _c.check(); err != nil {
- return nil, err
- }
- _node, _spec := _c.createSpec()
- if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
- if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- id := _spec.ID.Value.(int64)
- _node.ID = int64(id)
- _c.mutation.id = &_node.ID
- _c.mutation.done = true
- return _node, nil
- }
- func (_c *UserPlatformQuotaCreate) createSpec() (*UserPlatformQuota, *sqlgraph.CreateSpec) {
- var (
- _node = &UserPlatformQuota{config: _c.config}
- _spec = sqlgraph.NewCreateSpec(userplatformquota.Table, sqlgraph.NewFieldSpec(userplatformquota.FieldID, field.TypeInt64))
- )
- _spec.OnConflict = _c.conflict
- if value, ok := _c.mutation.CreatedAt(); ok {
- _spec.SetField(userplatformquota.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if value, ok := _c.mutation.UpdatedAt(); ok {
- _spec.SetField(userplatformquota.FieldUpdatedAt, field.TypeTime, value)
- _node.UpdatedAt = value
- }
- if value, ok := _c.mutation.DeletedAt(); ok {
- _spec.SetField(userplatformquota.FieldDeletedAt, field.TypeTime, value)
- _node.DeletedAt = &value
- }
- if value, ok := _c.mutation.Platform(); ok {
- _spec.SetField(userplatformquota.FieldPlatform, field.TypeString, value)
- _node.Platform = value
- }
- if value, ok := _c.mutation.DailyLimitUsd(); ok {
- _spec.SetField(userplatformquota.FieldDailyLimitUsd, field.TypeFloat64, value)
- _node.DailyLimitUsd = &value
- }
- if value, ok := _c.mutation.WeeklyLimitUsd(); ok {
- _spec.SetField(userplatformquota.FieldWeeklyLimitUsd, field.TypeFloat64, value)
- _node.WeeklyLimitUsd = &value
- }
- if value, ok := _c.mutation.MonthlyLimitUsd(); ok {
- _spec.SetField(userplatformquota.FieldMonthlyLimitUsd, field.TypeFloat64, value)
- _node.MonthlyLimitUsd = &value
- }
- if value, ok := _c.mutation.DailyUsageUsd(); ok {
- _spec.SetField(userplatformquota.FieldDailyUsageUsd, field.TypeFloat64, value)
- _node.DailyUsageUsd = value
- }
- if value, ok := _c.mutation.WeeklyUsageUsd(); ok {
- _spec.SetField(userplatformquota.FieldWeeklyUsageUsd, field.TypeFloat64, value)
- _node.WeeklyUsageUsd = value
- }
- if value, ok := _c.mutation.MonthlyUsageUsd(); ok {
- _spec.SetField(userplatformquota.FieldMonthlyUsageUsd, field.TypeFloat64, value)
- _node.MonthlyUsageUsd = value
- }
- if value, ok := _c.mutation.DailyWindowStart(); ok {
- _spec.SetField(userplatformquota.FieldDailyWindowStart, field.TypeTime, value)
- _node.DailyWindowStart = &value
- }
- if value, ok := _c.mutation.WeeklyWindowStart(); ok {
- _spec.SetField(userplatformquota.FieldWeeklyWindowStart, field.TypeTime, value)
- _node.WeeklyWindowStart = &value
- }
- if value, ok := _c.mutation.MonthlyWindowStart(); ok {
- _spec.SetField(userplatformquota.FieldMonthlyWindowStart, field.TypeTime, value)
- _node.MonthlyWindowStart = &value
- }
- if nodes := _c.mutation.UserIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: userplatformquota.UserTable,
- Columns: []string{userplatformquota.UserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _node.UserID = nodes[0]
- _spec.Edges = append(_spec.Edges, edge)
- }
- return _node, _spec
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.UserPlatformQuota.Create().
- // SetCreatedAt(v).
- // OnConflict(
- // // Update the row with the new values
- // // the was proposed for insertion.
- // sql.ResolveWithNewValues(),
- // ).
- // // Override some of the fields with custom
- // // update values.
- // Update(func(u *ent.UserPlatformQuotaUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (_c *UserPlatformQuotaCreate) OnConflict(opts ...sql.ConflictOption) *UserPlatformQuotaUpsertOne {
- _c.conflict = opts
- return &UserPlatformQuotaUpsertOne{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.UserPlatformQuota.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *UserPlatformQuotaCreate) OnConflictColumns(columns ...string) *UserPlatformQuotaUpsertOne {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &UserPlatformQuotaUpsertOne{
- create: _c,
- }
- }
- type (
- // UserPlatformQuotaUpsertOne is the builder for "upsert"-ing
- // one UserPlatformQuota node.
- UserPlatformQuotaUpsertOne struct {
- create *UserPlatformQuotaCreate
- }
- // UserPlatformQuotaUpsert is the "OnConflict" setter.
- UserPlatformQuotaUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetUpdatedAt sets the "updated_at" field.
- func (u *UserPlatformQuotaUpsert) SetUpdatedAt(v time.Time) *UserPlatformQuotaUpsert {
- u.Set(userplatformquota.FieldUpdatedAt, v)
- return u
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsert) UpdateUpdatedAt() *UserPlatformQuotaUpsert {
- u.SetExcluded(userplatformquota.FieldUpdatedAt)
- return u
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *UserPlatformQuotaUpsert) SetDeletedAt(v time.Time) *UserPlatformQuotaUpsert {
- u.Set(userplatformquota.FieldDeletedAt, v)
- return u
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsert) UpdateDeletedAt() *UserPlatformQuotaUpsert {
- u.SetExcluded(userplatformquota.FieldDeletedAt)
- return u
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *UserPlatformQuotaUpsert) ClearDeletedAt() *UserPlatformQuotaUpsert {
- u.SetNull(userplatformquota.FieldDeletedAt)
- return u
- }
- // SetUserID sets the "user_id" field.
- func (u *UserPlatformQuotaUpsert) SetUserID(v int64) *UserPlatformQuotaUpsert {
- u.Set(userplatformquota.FieldUserID, v)
- return u
- }
- // UpdateUserID sets the "user_id" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsert) UpdateUserID() *UserPlatformQuotaUpsert {
- u.SetExcluded(userplatformquota.FieldUserID)
- return u
- }
- // SetPlatform sets the "platform" field.
- func (u *UserPlatformQuotaUpsert) SetPlatform(v string) *UserPlatformQuotaUpsert {
- u.Set(userplatformquota.FieldPlatform, v)
- return u
- }
- // UpdatePlatform sets the "platform" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsert) UpdatePlatform() *UserPlatformQuotaUpsert {
- u.SetExcluded(userplatformquota.FieldPlatform)
- return u
- }
- // SetDailyLimitUsd sets the "daily_limit_usd" field.
- func (u *UserPlatformQuotaUpsert) SetDailyLimitUsd(v float64) *UserPlatformQuotaUpsert {
- u.Set(userplatformquota.FieldDailyLimitUsd, v)
- return u
- }
- // UpdateDailyLimitUsd sets the "daily_limit_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsert) UpdateDailyLimitUsd() *UserPlatformQuotaUpsert {
- u.SetExcluded(userplatformquota.FieldDailyLimitUsd)
- return u
- }
- // AddDailyLimitUsd adds v to the "daily_limit_usd" field.
- func (u *UserPlatformQuotaUpsert) AddDailyLimitUsd(v float64) *UserPlatformQuotaUpsert {
- u.Add(userplatformquota.FieldDailyLimitUsd, v)
- return u
- }
- // ClearDailyLimitUsd clears the value of the "daily_limit_usd" field.
- func (u *UserPlatformQuotaUpsert) ClearDailyLimitUsd() *UserPlatformQuotaUpsert {
- u.SetNull(userplatformquota.FieldDailyLimitUsd)
- return u
- }
- // SetWeeklyLimitUsd sets the "weekly_limit_usd" field.
- func (u *UserPlatformQuotaUpsert) SetWeeklyLimitUsd(v float64) *UserPlatformQuotaUpsert {
- u.Set(userplatformquota.FieldWeeklyLimitUsd, v)
- return u
- }
- // UpdateWeeklyLimitUsd sets the "weekly_limit_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsert) UpdateWeeklyLimitUsd() *UserPlatformQuotaUpsert {
- u.SetExcluded(userplatformquota.FieldWeeklyLimitUsd)
- return u
- }
- // AddWeeklyLimitUsd adds v to the "weekly_limit_usd" field.
- func (u *UserPlatformQuotaUpsert) AddWeeklyLimitUsd(v float64) *UserPlatformQuotaUpsert {
- u.Add(userplatformquota.FieldWeeklyLimitUsd, v)
- return u
- }
- // ClearWeeklyLimitUsd clears the value of the "weekly_limit_usd" field.
- func (u *UserPlatformQuotaUpsert) ClearWeeklyLimitUsd() *UserPlatformQuotaUpsert {
- u.SetNull(userplatformquota.FieldWeeklyLimitUsd)
- return u
- }
- // SetMonthlyLimitUsd sets the "monthly_limit_usd" field.
- func (u *UserPlatformQuotaUpsert) SetMonthlyLimitUsd(v float64) *UserPlatformQuotaUpsert {
- u.Set(userplatformquota.FieldMonthlyLimitUsd, v)
- return u
- }
- // UpdateMonthlyLimitUsd sets the "monthly_limit_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsert) UpdateMonthlyLimitUsd() *UserPlatformQuotaUpsert {
- u.SetExcluded(userplatformquota.FieldMonthlyLimitUsd)
- return u
- }
- // AddMonthlyLimitUsd adds v to the "monthly_limit_usd" field.
- func (u *UserPlatformQuotaUpsert) AddMonthlyLimitUsd(v float64) *UserPlatformQuotaUpsert {
- u.Add(userplatformquota.FieldMonthlyLimitUsd, v)
- return u
- }
- // ClearMonthlyLimitUsd clears the value of the "monthly_limit_usd" field.
- func (u *UserPlatformQuotaUpsert) ClearMonthlyLimitUsd() *UserPlatformQuotaUpsert {
- u.SetNull(userplatformquota.FieldMonthlyLimitUsd)
- return u
- }
- // SetDailyUsageUsd sets the "daily_usage_usd" field.
- func (u *UserPlatformQuotaUpsert) SetDailyUsageUsd(v float64) *UserPlatformQuotaUpsert {
- u.Set(userplatformquota.FieldDailyUsageUsd, v)
- return u
- }
- // UpdateDailyUsageUsd sets the "daily_usage_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsert) UpdateDailyUsageUsd() *UserPlatformQuotaUpsert {
- u.SetExcluded(userplatformquota.FieldDailyUsageUsd)
- return u
- }
- // AddDailyUsageUsd adds v to the "daily_usage_usd" field.
- func (u *UserPlatformQuotaUpsert) AddDailyUsageUsd(v float64) *UserPlatformQuotaUpsert {
- u.Add(userplatformquota.FieldDailyUsageUsd, v)
- return u
- }
- // SetWeeklyUsageUsd sets the "weekly_usage_usd" field.
- func (u *UserPlatformQuotaUpsert) SetWeeklyUsageUsd(v float64) *UserPlatformQuotaUpsert {
- u.Set(userplatformquota.FieldWeeklyUsageUsd, v)
- return u
- }
- // UpdateWeeklyUsageUsd sets the "weekly_usage_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsert) UpdateWeeklyUsageUsd() *UserPlatformQuotaUpsert {
- u.SetExcluded(userplatformquota.FieldWeeklyUsageUsd)
- return u
- }
- // AddWeeklyUsageUsd adds v to the "weekly_usage_usd" field.
- func (u *UserPlatformQuotaUpsert) AddWeeklyUsageUsd(v float64) *UserPlatformQuotaUpsert {
- u.Add(userplatformquota.FieldWeeklyUsageUsd, v)
- return u
- }
- // SetMonthlyUsageUsd sets the "monthly_usage_usd" field.
- func (u *UserPlatformQuotaUpsert) SetMonthlyUsageUsd(v float64) *UserPlatformQuotaUpsert {
- u.Set(userplatformquota.FieldMonthlyUsageUsd, v)
- return u
- }
- // UpdateMonthlyUsageUsd sets the "monthly_usage_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsert) UpdateMonthlyUsageUsd() *UserPlatformQuotaUpsert {
- u.SetExcluded(userplatformquota.FieldMonthlyUsageUsd)
- return u
- }
- // AddMonthlyUsageUsd adds v to the "monthly_usage_usd" field.
- func (u *UserPlatformQuotaUpsert) AddMonthlyUsageUsd(v float64) *UserPlatformQuotaUpsert {
- u.Add(userplatformquota.FieldMonthlyUsageUsd, v)
- return u
- }
- // SetDailyWindowStart sets the "daily_window_start" field.
- func (u *UserPlatformQuotaUpsert) SetDailyWindowStart(v time.Time) *UserPlatformQuotaUpsert {
- u.Set(userplatformquota.FieldDailyWindowStart, v)
- return u
- }
- // UpdateDailyWindowStart sets the "daily_window_start" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsert) UpdateDailyWindowStart() *UserPlatformQuotaUpsert {
- u.SetExcluded(userplatformquota.FieldDailyWindowStart)
- return u
- }
- // ClearDailyWindowStart clears the value of the "daily_window_start" field.
- func (u *UserPlatformQuotaUpsert) ClearDailyWindowStart() *UserPlatformQuotaUpsert {
- u.SetNull(userplatformquota.FieldDailyWindowStart)
- return u
- }
- // SetWeeklyWindowStart sets the "weekly_window_start" field.
- func (u *UserPlatformQuotaUpsert) SetWeeklyWindowStart(v time.Time) *UserPlatformQuotaUpsert {
- u.Set(userplatformquota.FieldWeeklyWindowStart, v)
- return u
- }
- // UpdateWeeklyWindowStart sets the "weekly_window_start" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsert) UpdateWeeklyWindowStart() *UserPlatformQuotaUpsert {
- u.SetExcluded(userplatformquota.FieldWeeklyWindowStart)
- return u
- }
- // ClearWeeklyWindowStart clears the value of the "weekly_window_start" field.
- func (u *UserPlatformQuotaUpsert) ClearWeeklyWindowStart() *UserPlatformQuotaUpsert {
- u.SetNull(userplatformquota.FieldWeeklyWindowStart)
- return u
- }
- // SetMonthlyWindowStart sets the "monthly_window_start" field.
- func (u *UserPlatformQuotaUpsert) SetMonthlyWindowStart(v time.Time) *UserPlatformQuotaUpsert {
- u.Set(userplatformquota.FieldMonthlyWindowStart, v)
- return u
- }
- // UpdateMonthlyWindowStart sets the "monthly_window_start" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsert) UpdateMonthlyWindowStart() *UserPlatformQuotaUpsert {
- u.SetExcluded(userplatformquota.FieldMonthlyWindowStart)
- return u
- }
- // ClearMonthlyWindowStart clears the value of the "monthly_window_start" field.
- func (u *UserPlatformQuotaUpsert) ClearMonthlyWindowStart() *UserPlatformQuotaUpsert {
- u.SetNull(userplatformquota.FieldMonthlyWindowStart)
- return u
- }
- // UpdateNewValues updates the mutable fields using the new values that were set on create.
- // Using this option is equivalent to using:
- //
- // client.UserPlatformQuota.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *UserPlatformQuotaUpsertOne) UpdateNewValues() *UserPlatformQuotaUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
- if _, exists := u.create.mutation.CreatedAt(); exists {
- s.SetIgnore(userplatformquota.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.UserPlatformQuota.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *UserPlatformQuotaUpsertOne) Ignore() *UserPlatformQuotaUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
- return u
- }
- // DoNothing configures the conflict_action to `DO NOTHING`.
- // Supported only by SQLite and PostgreSQL.
- func (u *UserPlatformQuotaUpsertOne) DoNothing() *UserPlatformQuotaUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the UserPlatformQuotaCreate.OnConflict
- // documentation for more info.
- func (u *UserPlatformQuotaUpsertOne) Update(set func(*UserPlatformQuotaUpsert)) *UserPlatformQuotaUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&UserPlatformQuotaUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *UserPlatformQuotaUpsertOne) SetUpdatedAt(v time.Time) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertOne) UpdateUpdatedAt() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *UserPlatformQuotaUpsertOne) SetDeletedAt(v time.Time) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertOne) UpdateDeletedAt() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *UserPlatformQuotaUpsertOne) ClearDeletedAt() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetUserID sets the "user_id" field.
- func (u *UserPlatformQuotaUpsertOne) SetUserID(v int64) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetUserID(v)
- })
- }
- // UpdateUserID sets the "user_id" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertOne) UpdateUserID() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateUserID()
- })
- }
- // SetPlatform sets the "platform" field.
- func (u *UserPlatformQuotaUpsertOne) SetPlatform(v string) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetPlatform(v)
- })
- }
- // UpdatePlatform sets the "platform" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertOne) UpdatePlatform() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdatePlatform()
- })
- }
- // SetDailyLimitUsd sets the "daily_limit_usd" field.
- func (u *UserPlatformQuotaUpsertOne) SetDailyLimitUsd(v float64) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetDailyLimitUsd(v)
- })
- }
- // AddDailyLimitUsd adds v to the "daily_limit_usd" field.
- func (u *UserPlatformQuotaUpsertOne) AddDailyLimitUsd(v float64) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.AddDailyLimitUsd(v)
- })
- }
- // UpdateDailyLimitUsd sets the "daily_limit_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertOne) UpdateDailyLimitUsd() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateDailyLimitUsd()
- })
- }
- // ClearDailyLimitUsd clears the value of the "daily_limit_usd" field.
- func (u *UserPlatformQuotaUpsertOne) ClearDailyLimitUsd() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.ClearDailyLimitUsd()
- })
- }
- // SetWeeklyLimitUsd sets the "weekly_limit_usd" field.
- func (u *UserPlatformQuotaUpsertOne) SetWeeklyLimitUsd(v float64) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetWeeklyLimitUsd(v)
- })
- }
- // AddWeeklyLimitUsd adds v to the "weekly_limit_usd" field.
- func (u *UserPlatformQuotaUpsertOne) AddWeeklyLimitUsd(v float64) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.AddWeeklyLimitUsd(v)
- })
- }
- // UpdateWeeklyLimitUsd sets the "weekly_limit_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertOne) UpdateWeeklyLimitUsd() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateWeeklyLimitUsd()
- })
- }
- // ClearWeeklyLimitUsd clears the value of the "weekly_limit_usd" field.
- func (u *UserPlatformQuotaUpsertOne) ClearWeeklyLimitUsd() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.ClearWeeklyLimitUsd()
- })
- }
- // SetMonthlyLimitUsd sets the "monthly_limit_usd" field.
- func (u *UserPlatformQuotaUpsertOne) SetMonthlyLimitUsd(v float64) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetMonthlyLimitUsd(v)
- })
- }
- // AddMonthlyLimitUsd adds v to the "monthly_limit_usd" field.
- func (u *UserPlatformQuotaUpsertOne) AddMonthlyLimitUsd(v float64) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.AddMonthlyLimitUsd(v)
- })
- }
- // UpdateMonthlyLimitUsd sets the "monthly_limit_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertOne) UpdateMonthlyLimitUsd() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateMonthlyLimitUsd()
- })
- }
- // ClearMonthlyLimitUsd clears the value of the "monthly_limit_usd" field.
- func (u *UserPlatformQuotaUpsertOne) ClearMonthlyLimitUsd() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.ClearMonthlyLimitUsd()
- })
- }
- // SetDailyUsageUsd sets the "daily_usage_usd" field.
- func (u *UserPlatformQuotaUpsertOne) SetDailyUsageUsd(v float64) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetDailyUsageUsd(v)
- })
- }
- // AddDailyUsageUsd adds v to the "daily_usage_usd" field.
- func (u *UserPlatformQuotaUpsertOne) AddDailyUsageUsd(v float64) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.AddDailyUsageUsd(v)
- })
- }
- // UpdateDailyUsageUsd sets the "daily_usage_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertOne) UpdateDailyUsageUsd() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateDailyUsageUsd()
- })
- }
- // SetWeeklyUsageUsd sets the "weekly_usage_usd" field.
- func (u *UserPlatformQuotaUpsertOne) SetWeeklyUsageUsd(v float64) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetWeeklyUsageUsd(v)
- })
- }
- // AddWeeklyUsageUsd adds v to the "weekly_usage_usd" field.
- func (u *UserPlatformQuotaUpsertOne) AddWeeklyUsageUsd(v float64) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.AddWeeklyUsageUsd(v)
- })
- }
- // UpdateWeeklyUsageUsd sets the "weekly_usage_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertOne) UpdateWeeklyUsageUsd() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateWeeklyUsageUsd()
- })
- }
- // SetMonthlyUsageUsd sets the "monthly_usage_usd" field.
- func (u *UserPlatformQuotaUpsertOne) SetMonthlyUsageUsd(v float64) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetMonthlyUsageUsd(v)
- })
- }
- // AddMonthlyUsageUsd adds v to the "monthly_usage_usd" field.
- func (u *UserPlatformQuotaUpsertOne) AddMonthlyUsageUsd(v float64) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.AddMonthlyUsageUsd(v)
- })
- }
- // UpdateMonthlyUsageUsd sets the "monthly_usage_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertOne) UpdateMonthlyUsageUsd() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateMonthlyUsageUsd()
- })
- }
- // SetDailyWindowStart sets the "daily_window_start" field.
- func (u *UserPlatformQuotaUpsertOne) SetDailyWindowStart(v time.Time) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetDailyWindowStart(v)
- })
- }
- // UpdateDailyWindowStart sets the "daily_window_start" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertOne) UpdateDailyWindowStart() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateDailyWindowStart()
- })
- }
- // ClearDailyWindowStart clears the value of the "daily_window_start" field.
- func (u *UserPlatformQuotaUpsertOne) ClearDailyWindowStart() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.ClearDailyWindowStart()
- })
- }
- // SetWeeklyWindowStart sets the "weekly_window_start" field.
- func (u *UserPlatformQuotaUpsertOne) SetWeeklyWindowStart(v time.Time) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetWeeklyWindowStart(v)
- })
- }
- // UpdateWeeklyWindowStart sets the "weekly_window_start" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertOne) UpdateWeeklyWindowStart() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateWeeklyWindowStart()
- })
- }
- // ClearWeeklyWindowStart clears the value of the "weekly_window_start" field.
- func (u *UserPlatformQuotaUpsertOne) ClearWeeklyWindowStart() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.ClearWeeklyWindowStart()
- })
- }
- // SetMonthlyWindowStart sets the "monthly_window_start" field.
- func (u *UserPlatformQuotaUpsertOne) SetMonthlyWindowStart(v time.Time) *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetMonthlyWindowStart(v)
- })
- }
- // UpdateMonthlyWindowStart sets the "monthly_window_start" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertOne) UpdateMonthlyWindowStart() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateMonthlyWindowStart()
- })
- }
- // ClearMonthlyWindowStart clears the value of the "monthly_window_start" field.
- func (u *UserPlatformQuotaUpsertOne) ClearMonthlyWindowStart() *UserPlatformQuotaUpsertOne {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.ClearMonthlyWindowStart()
- })
- }
- // Exec executes the query.
- func (u *UserPlatformQuotaUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for UserPlatformQuotaCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *UserPlatformQuotaUpsertOne) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // Exec executes the UPSERT query and returns the inserted/updated ID.
- func (u *UserPlatformQuotaUpsertOne) ID(ctx context.Context) (id int64, err error) {
- node, err := u.create.Save(ctx)
- if err != nil {
- return id, err
- }
- return node.ID, nil
- }
- // IDX is like ID, but panics if an error occurs.
- func (u *UserPlatformQuotaUpsertOne) IDX(ctx context.Context) int64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // UserPlatformQuotaCreateBulk is the builder for creating many UserPlatformQuota entities in bulk.
- type UserPlatformQuotaCreateBulk struct {
- config
- err error
- builders []*UserPlatformQuotaCreate
- conflict []sql.ConflictOption
- }
- // Save creates the UserPlatformQuota entities in the database.
- func (_c *UserPlatformQuotaCreateBulk) Save(ctx context.Context) ([]*UserPlatformQuota, error) {
- if _c.err != nil {
- return nil, _c.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
- nodes := make([]*UserPlatformQuota, len(_c.builders))
- mutators := make([]Mutator, len(_c.builders))
- for i := range _c.builders {
- func(i int, root context.Context) {
- builder := _c.builders[i]
- builder.defaults()
- var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
- mutation, ok := m.(*UserPlatformQuotaMutation)
- if !ok {
- return nil, fmt.Errorf("unexpected mutation type %T", m)
- }
- if err := builder.check(); err != nil {
- return nil, err
- }
- builder.mutation = mutation
- var err error
- nodes[i], specs[i] = builder.createSpec()
- if i < len(mutators)-1 {
- _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
- } else {
- spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
- spec.OnConflict = _c.conflict
- // Invoke the actual operation on the latest mutation in the chain.
- if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
- if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- }
- }
- if err != nil {
- return nil, err
- }
- mutation.id = &nodes[i].ID
- if specs[i].ID.Value != nil {
- id := specs[i].ID.Value.(int64)
- nodes[i].ID = int64(id)
- }
- mutation.done = true
- return nodes[i], nil
- })
- for i := len(builder.hooks) - 1; i >= 0; i-- {
- mut = builder.hooks[i](mut)
- }
- mutators[i] = mut
- }(i, ctx)
- }
- if len(mutators) > 0 {
- if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
- return nil, err
- }
- }
- return nodes, nil
- }
- // SaveX is like Save, but panics if an error occurs.
- func (_c *UserPlatformQuotaCreateBulk) SaveX(ctx context.Context) []*UserPlatformQuota {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *UserPlatformQuotaCreateBulk) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *UserPlatformQuotaCreateBulk) ExecX(ctx context.Context) {
- if err := _c.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.UserPlatformQuota.CreateBulk(builders...).
- // OnConflict(
- // // Update the row with the new values
- // // the was proposed for insertion.
- // sql.ResolveWithNewValues(),
- // ).
- // // Override some of the fields with custom
- // // update values.
- // Update(func(u *ent.UserPlatformQuotaUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (_c *UserPlatformQuotaCreateBulk) OnConflict(opts ...sql.ConflictOption) *UserPlatformQuotaUpsertBulk {
- _c.conflict = opts
- return &UserPlatformQuotaUpsertBulk{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.UserPlatformQuota.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *UserPlatformQuotaCreateBulk) OnConflictColumns(columns ...string) *UserPlatformQuotaUpsertBulk {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &UserPlatformQuotaUpsertBulk{
- create: _c,
- }
- }
- // UserPlatformQuotaUpsertBulk is the builder for "upsert"-ing
- // a bulk of UserPlatformQuota nodes.
- type UserPlatformQuotaUpsertBulk struct {
- create *UserPlatformQuotaCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.UserPlatformQuota.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *UserPlatformQuotaUpsertBulk) UpdateNewValues() *UserPlatformQuotaUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
- for _, b := range u.create.builders {
- if _, exists := b.mutation.CreatedAt(); exists {
- s.SetIgnore(userplatformquota.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.UserPlatformQuota.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *UserPlatformQuotaUpsertBulk) Ignore() *UserPlatformQuotaUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
- return u
- }
- // DoNothing configures the conflict_action to `DO NOTHING`.
- // Supported only by SQLite and PostgreSQL.
- func (u *UserPlatformQuotaUpsertBulk) DoNothing() *UserPlatformQuotaUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the UserPlatformQuotaCreateBulk.OnConflict
- // documentation for more info.
- func (u *UserPlatformQuotaUpsertBulk) Update(set func(*UserPlatformQuotaUpsert)) *UserPlatformQuotaUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&UserPlatformQuotaUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *UserPlatformQuotaUpsertBulk) SetUpdatedAt(v time.Time) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertBulk) UpdateUpdatedAt() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *UserPlatformQuotaUpsertBulk) SetDeletedAt(v time.Time) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertBulk) UpdateDeletedAt() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *UserPlatformQuotaUpsertBulk) ClearDeletedAt() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetUserID sets the "user_id" field.
- func (u *UserPlatformQuotaUpsertBulk) SetUserID(v int64) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetUserID(v)
- })
- }
- // UpdateUserID sets the "user_id" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertBulk) UpdateUserID() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateUserID()
- })
- }
- // SetPlatform sets the "platform" field.
- func (u *UserPlatformQuotaUpsertBulk) SetPlatform(v string) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetPlatform(v)
- })
- }
- // UpdatePlatform sets the "platform" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertBulk) UpdatePlatform() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdatePlatform()
- })
- }
- // SetDailyLimitUsd sets the "daily_limit_usd" field.
- func (u *UserPlatformQuotaUpsertBulk) SetDailyLimitUsd(v float64) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetDailyLimitUsd(v)
- })
- }
- // AddDailyLimitUsd adds v to the "daily_limit_usd" field.
- func (u *UserPlatformQuotaUpsertBulk) AddDailyLimitUsd(v float64) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.AddDailyLimitUsd(v)
- })
- }
- // UpdateDailyLimitUsd sets the "daily_limit_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertBulk) UpdateDailyLimitUsd() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateDailyLimitUsd()
- })
- }
- // ClearDailyLimitUsd clears the value of the "daily_limit_usd" field.
- func (u *UserPlatformQuotaUpsertBulk) ClearDailyLimitUsd() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.ClearDailyLimitUsd()
- })
- }
- // SetWeeklyLimitUsd sets the "weekly_limit_usd" field.
- func (u *UserPlatformQuotaUpsertBulk) SetWeeklyLimitUsd(v float64) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetWeeklyLimitUsd(v)
- })
- }
- // AddWeeklyLimitUsd adds v to the "weekly_limit_usd" field.
- func (u *UserPlatformQuotaUpsertBulk) AddWeeklyLimitUsd(v float64) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.AddWeeklyLimitUsd(v)
- })
- }
- // UpdateWeeklyLimitUsd sets the "weekly_limit_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertBulk) UpdateWeeklyLimitUsd() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateWeeklyLimitUsd()
- })
- }
- // ClearWeeklyLimitUsd clears the value of the "weekly_limit_usd" field.
- func (u *UserPlatformQuotaUpsertBulk) ClearWeeklyLimitUsd() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.ClearWeeklyLimitUsd()
- })
- }
- // SetMonthlyLimitUsd sets the "monthly_limit_usd" field.
- func (u *UserPlatformQuotaUpsertBulk) SetMonthlyLimitUsd(v float64) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetMonthlyLimitUsd(v)
- })
- }
- // AddMonthlyLimitUsd adds v to the "monthly_limit_usd" field.
- func (u *UserPlatformQuotaUpsertBulk) AddMonthlyLimitUsd(v float64) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.AddMonthlyLimitUsd(v)
- })
- }
- // UpdateMonthlyLimitUsd sets the "monthly_limit_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertBulk) UpdateMonthlyLimitUsd() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateMonthlyLimitUsd()
- })
- }
- // ClearMonthlyLimitUsd clears the value of the "monthly_limit_usd" field.
- func (u *UserPlatformQuotaUpsertBulk) ClearMonthlyLimitUsd() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.ClearMonthlyLimitUsd()
- })
- }
- // SetDailyUsageUsd sets the "daily_usage_usd" field.
- func (u *UserPlatformQuotaUpsertBulk) SetDailyUsageUsd(v float64) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetDailyUsageUsd(v)
- })
- }
- // AddDailyUsageUsd adds v to the "daily_usage_usd" field.
- func (u *UserPlatformQuotaUpsertBulk) AddDailyUsageUsd(v float64) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.AddDailyUsageUsd(v)
- })
- }
- // UpdateDailyUsageUsd sets the "daily_usage_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertBulk) UpdateDailyUsageUsd() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateDailyUsageUsd()
- })
- }
- // SetWeeklyUsageUsd sets the "weekly_usage_usd" field.
- func (u *UserPlatformQuotaUpsertBulk) SetWeeklyUsageUsd(v float64) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetWeeklyUsageUsd(v)
- })
- }
- // AddWeeklyUsageUsd adds v to the "weekly_usage_usd" field.
- func (u *UserPlatformQuotaUpsertBulk) AddWeeklyUsageUsd(v float64) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.AddWeeklyUsageUsd(v)
- })
- }
- // UpdateWeeklyUsageUsd sets the "weekly_usage_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertBulk) UpdateWeeklyUsageUsd() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateWeeklyUsageUsd()
- })
- }
- // SetMonthlyUsageUsd sets the "monthly_usage_usd" field.
- func (u *UserPlatformQuotaUpsertBulk) SetMonthlyUsageUsd(v float64) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetMonthlyUsageUsd(v)
- })
- }
- // AddMonthlyUsageUsd adds v to the "monthly_usage_usd" field.
- func (u *UserPlatformQuotaUpsertBulk) AddMonthlyUsageUsd(v float64) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.AddMonthlyUsageUsd(v)
- })
- }
- // UpdateMonthlyUsageUsd sets the "monthly_usage_usd" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertBulk) UpdateMonthlyUsageUsd() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateMonthlyUsageUsd()
- })
- }
- // SetDailyWindowStart sets the "daily_window_start" field.
- func (u *UserPlatformQuotaUpsertBulk) SetDailyWindowStart(v time.Time) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetDailyWindowStart(v)
- })
- }
- // UpdateDailyWindowStart sets the "daily_window_start" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertBulk) UpdateDailyWindowStart() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateDailyWindowStart()
- })
- }
- // ClearDailyWindowStart clears the value of the "daily_window_start" field.
- func (u *UserPlatformQuotaUpsertBulk) ClearDailyWindowStart() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.ClearDailyWindowStart()
- })
- }
- // SetWeeklyWindowStart sets the "weekly_window_start" field.
- func (u *UserPlatformQuotaUpsertBulk) SetWeeklyWindowStart(v time.Time) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetWeeklyWindowStart(v)
- })
- }
- // UpdateWeeklyWindowStart sets the "weekly_window_start" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertBulk) UpdateWeeklyWindowStart() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateWeeklyWindowStart()
- })
- }
- // ClearWeeklyWindowStart clears the value of the "weekly_window_start" field.
- func (u *UserPlatformQuotaUpsertBulk) ClearWeeklyWindowStart() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.ClearWeeklyWindowStart()
- })
- }
- // SetMonthlyWindowStart sets the "monthly_window_start" field.
- func (u *UserPlatformQuotaUpsertBulk) SetMonthlyWindowStart(v time.Time) *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.SetMonthlyWindowStart(v)
- })
- }
- // UpdateMonthlyWindowStart sets the "monthly_window_start" field to the value that was provided on create.
- func (u *UserPlatformQuotaUpsertBulk) UpdateMonthlyWindowStart() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.UpdateMonthlyWindowStart()
- })
- }
- // ClearMonthlyWindowStart clears the value of the "monthly_window_start" field.
- func (u *UserPlatformQuotaUpsertBulk) ClearMonthlyWindowStart() *UserPlatformQuotaUpsertBulk {
- return u.Update(func(s *UserPlatformQuotaUpsert) {
- s.ClearMonthlyWindowStart()
- })
- }
- // Exec executes the query.
- func (u *UserPlatformQuotaUpsertBulk) Exec(ctx context.Context) error {
- if u.create.err != nil {
- return u.create.err
- }
- for i, b := range u.create.builders {
- if len(b.conflict) != 0 {
- return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the UserPlatformQuotaCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for UserPlatformQuotaCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *UserPlatformQuotaUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|