| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387 |
- // 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/subscriptionplan"
- )
- // SubscriptionPlanCreate is the builder for creating a SubscriptionPlan entity.
- type SubscriptionPlanCreate struct {
- config
- mutation *SubscriptionPlanMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetGroupID sets the "group_id" field.
- func (_c *SubscriptionPlanCreate) SetGroupID(v int64) *SubscriptionPlanCreate {
- _c.mutation.SetGroupID(v)
- return _c
- }
- // SetName sets the "name" field.
- func (_c *SubscriptionPlanCreate) SetName(v string) *SubscriptionPlanCreate {
- _c.mutation.SetName(v)
- return _c
- }
- // SetDescription sets the "description" field.
- func (_c *SubscriptionPlanCreate) SetDescription(v string) *SubscriptionPlanCreate {
- _c.mutation.SetDescription(v)
- return _c
- }
- // SetNillableDescription sets the "description" field if the given value is not nil.
- func (_c *SubscriptionPlanCreate) SetNillableDescription(v *string) *SubscriptionPlanCreate {
- if v != nil {
- _c.SetDescription(*v)
- }
- return _c
- }
- // SetPrice sets the "price" field.
- func (_c *SubscriptionPlanCreate) SetPrice(v float64) *SubscriptionPlanCreate {
- _c.mutation.SetPrice(v)
- return _c
- }
- // SetOriginalPrice sets the "original_price" field.
- func (_c *SubscriptionPlanCreate) SetOriginalPrice(v float64) *SubscriptionPlanCreate {
- _c.mutation.SetOriginalPrice(v)
- return _c
- }
- // SetNillableOriginalPrice sets the "original_price" field if the given value is not nil.
- func (_c *SubscriptionPlanCreate) SetNillableOriginalPrice(v *float64) *SubscriptionPlanCreate {
- if v != nil {
- _c.SetOriginalPrice(*v)
- }
- return _c
- }
- // SetCurrency sets the "currency" field.
- func (_c *SubscriptionPlanCreate) SetCurrency(v string) *SubscriptionPlanCreate {
- _c.mutation.SetCurrency(v)
- return _c
- }
- // SetNillableCurrency sets the "currency" field if the given value is not nil.
- func (_c *SubscriptionPlanCreate) SetNillableCurrency(v *string) *SubscriptionPlanCreate {
- if v != nil {
- _c.SetCurrency(*v)
- }
- return _c
- }
- // SetValidityDays sets the "validity_days" field.
- func (_c *SubscriptionPlanCreate) SetValidityDays(v int) *SubscriptionPlanCreate {
- _c.mutation.SetValidityDays(v)
- return _c
- }
- // SetNillableValidityDays sets the "validity_days" field if the given value is not nil.
- func (_c *SubscriptionPlanCreate) SetNillableValidityDays(v *int) *SubscriptionPlanCreate {
- if v != nil {
- _c.SetValidityDays(*v)
- }
- return _c
- }
- // SetValidityUnit sets the "validity_unit" field.
- func (_c *SubscriptionPlanCreate) SetValidityUnit(v string) *SubscriptionPlanCreate {
- _c.mutation.SetValidityUnit(v)
- return _c
- }
- // SetNillableValidityUnit sets the "validity_unit" field if the given value is not nil.
- func (_c *SubscriptionPlanCreate) SetNillableValidityUnit(v *string) *SubscriptionPlanCreate {
- if v != nil {
- _c.SetValidityUnit(*v)
- }
- return _c
- }
- // SetFeatures sets the "features" field.
- func (_c *SubscriptionPlanCreate) SetFeatures(v string) *SubscriptionPlanCreate {
- _c.mutation.SetFeatures(v)
- return _c
- }
- // SetNillableFeatures sets the "features" field if the given value is not nil.
- func (_c *SubscriptionPlanCreate) SetNillableFeatures(v *string) *SubscriptionPlanCreate {
- if v != nil {
- _c.SetFeatures(*v)
- }
- return _c
- }
- // SetProductName sets the "product_name" field.
- func (_c *SubscriptionPlanCreate) SetProductName(v string) *SubscriptionPlanCreate {
- _c.mutation.SetProductName(v)
- return _c
- }
- // SetNillableProductName sets the "product_name" field if the given value is not nil.
- func (_c *SubscriptionPlanCreate) SetNillableProductName(v *string) *SubscriptionPlanCreate {
- if v != nil {
- _c.SetProductName(*v)
- }
- return _c
- }
- // SetForSale sets the "for_sale" field.
- func (_c *SubscriptionPlanCreate) SetForSale(v bool) *SubscriptionPlanCreate {
- _c.mutation.SetForSale(v)
- return _c
- }
- // SetNillableForSale sets the "for_sale" field if the given value is not nil.
- func (_c *SubscriptionPlanCreate) SetNillableForSale(v *bool) *SubscriptionPlanCreate {
- if v != nil {
- _c.SetForSale(*v)
- }
- return _c
- }
- // SetSortOrder sets the "sort_order" field.
- func (_c *SubscriptionPlanCreate) SetSortOrder(v int) *SubscriptionPlanCreate {
- _c.mutation.SetSortOrder(v)
- return _c
- }
- // SetNillableSortOrder sets the "sort_order" field if the given value is not nil.
- func (_c *SubscriptionPlanCreate) SetNillableSortOrder(v *int) *SubscriptionPlanCreate {
- if v != nil {
- _c.SetSortOrder(*v)
- }
- return _c
- }
- // SetCreatedAt sets the "created_at" field.
- func (_c *SubscriptionPlanCreate) SetCreatedAt(v time.Time) *SubscriptionPlanCreate {
- _c.mutation.SetCreatedAt(v)
- return _c
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (_c *SubscriptionPlanCreate) SetNillableCreatedAt(v *time.Time) *SubscriptionPlanCreate {
- if v != nil {
- _c.SetCreatedAt(*v)
- }
- return _c
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (_c *SubscriptionPlanCreate) SetUpdatedAt(v time.Time) *SubscriptionPlanCreate {
- _c.mutation.SetUpdatedAt(v)
- return _c
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (_c *SubscriptionPlanCreate) SetNillableUpdatedAt(v *time.Time) *SubscriptionPlanCreate {
- if v != nil {
- _c.SetUpdatedAt(*v)
- }
- return _c
- }
- // Mutation returns the SubscriptionPlanMutation object of the builder.
- func (_c *SubscriptionPlanCreate) Mutation() *SubscriptionPlanMutation {
- return _c.mutation
- }
- // Save creates the SubscriptionPlan in the database.
- func (_c *SubscriptionPlanCreate) Save(ctx context.Context) (*SubscriptionPlan, error) {
- _c.defaults()
- return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (_c *SubscriptionPlanCreate) SaveX(ctx context.Context) *SubscriptionPlan {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *SubscriptionPlanCreate) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *SubscriptionPlanCreate) 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 *SubscriptionPlanCreate) defaults() {
- if _, ok := _c.mutation.Description(); !ok {
- v := subscriptionplan.DefaultDescription
- _c.mutation.SetDescription(v)
- }
- if _, ok := _c.mutation.Currency(); !ok {
- v := subscriptionplan.DefaultCurrency
- _c.mutation.SetCurrency(v)
- }
- if _, ok := _c.mutation.ValidityDays(); !ok {
- v := subscriptionplan.DefaultValidityDays
- _c.mutation.SetValidityDays(v)
- }
- if _, ok := _c.mutation.ValidityUnit(); !ok {
- v := subscriptionplan.DefaultValidityUnit
- _c.mutation.SetValidityUnit(v)
- }
- if _, ok := _c.mutation.Features(); !ok {
- v := subscriptionplan.DefaultFeatures
- _c.mutation.SetFeatures(v)
- }
- if _, ok := _c.mutation.ProductName(); !ok {
- v := subscriptionplan.DefaultProductName
- _c.mutation.SetProductName(v)
- }
- if _, ok := _c.mutation.ForSale(); !ok {
- v := subscriptionplan.DefaultForSale
- _c.mutation.SetForSale(v)
- }
- if _, ok := _c.mutation.SortOrder(); !ok {
- v := subscriptionplan.DefaultSortOrder
- _c.mutation.SetSortOrder(v)
- }
- if _, ok := _c.mutation.CreatedAt(); !ok {
- v := subscriptionplan.DefaultCreatedAt()
- _c.mutation.SetCreatedAt(v)
- }
- if _, ok := _c.mutation.UpdatedAt(); !ok {
- v := subscriptionplan.DefaultUpdatedAt()
- _c.mutation.SetUpdatedAt(v)
- }
- }
- // check runs all checks and user-defined validators on the builder.
- func (_c *SubscriptionPlanCreate) check() error {
- if _, ok := _c.mutation.GroupID(); !ok {
- return &ValidationError{Name: "group_id", err: errors.New(`ent: missing required field "SubscriptionPlan.group_id"`)}
- }
- if _, ok := _c.mutation.Name(); !ok {
- return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "SubscriptionPlan.name"`)}
- }
- if v, ok := _c.mutation.Name(); ok {
- if err := subscriptionplan.NameValidator(v); err != nil {
- return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "SubscriptionPlan.name": %w`, err)}
- }
- }
- if _, ok := _c.mutation.Description(); !ok {
- return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "SubscriptionPlan.description"`)}
- }
- if _, ok := _c.mutation.Price(); !ok {
- return &ValidationError{Name: "price", err: errors.New(`ent: missing required field "SubscriptionPlan.price"`)}
- }
- if _, ok := _c.mutation.Currency(); !ok {
- return &ValidationError{Name: "currency", err: errors.New(`ent: missing required field "SubscriptionPlan.currency"`)}
- }
- if v, ok := _c.mutation.Currency(); ok {
- if err := subscriptionplan.CurrencyValidator(v); err != nil {
- return &ValidationError{Name: "currency", err: fmt.Errorf(`ent: validator failed for field "SubscriptionPlan.currency": %w`, err)}
- }
- }
- if _, ok := _c.mutation.ValidityDays(); !ok {
- return &ValidationError{Name: "validity_days", err: errors.New(`ent: missing required field "SubscriptionPlan.validity_days"`)}
- }
- if _, ok := _c.mutation.ValidityUnit(); !ok {
- return &ValidationError{Name: "validity_unit", err: errors.New(`ent: missing required field "SubscriptionPlan.validity_unit"`)}
- }
- if v, ok := _c.mutation.ValidityUnit(); ok {
- if err := subscriptionplan.ValidityUnitValidator(v); err != nil {
- return &ValidationError{Name: "validity_unit", err: fmt.Errorf(`ent: validator failed for field "SubscriptionPlan.validity_unit": %w`, err)}
- }
- }
- if _, ok := _c.mutation.Features(); !ok {
- return &ValidationError{Name: "features", err: errors.New(`ent: missing required field "SubscriptionPlan.features"`)}
- }
- if _, ok := _c.mutation.ProductName(); !ok {
- return &ValidationError{Name: "product_name", err: errors.New(`ent: missing required field "SubscriptionPlan.product_name"`)}
- }
- if v, ok := _c.mutation.ProductName(); ok {
- if err := subscriptionplan.ProductNameValidator(v); err != nil {
- return &ValidationError{Name: "product_name", err: fmt.Errorf(`ent: validator failed for field "SubscriptionPlan.product_name": %w`, err)}
- }
- }
- if _, ok := _c.mutation.ForSale(); !ok {
- return &ValidationError{Name: "for_sale", err: errors.New(`ent: missing required field "SubscriptionPlan.for_sale"`)}
- }
- if _, ok := _c.mutation.SortOrder(); !ok {
- return &ValidationError{Name: "sort_order", err: errors.New(`ent: missing required field "SubscriptionPlan.sort_order"`)}
- }
- if _, ok := _c.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "SubscriptionPlan.created_at"`)}
- }
- if _, ok := _c.mutation.UpdatedAt(); !ok {
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "SubscriptionPlan.updated_at"`)}
- }
- return nil
- }
- func (_c *SubscriptionPlanCreate) sqlSave(ctx context.Context) (*SubscriptionPlan, 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 *SubscriptionPlanCreate) createSpec() (*SubscriptionPlan, *sqlgraph.CreateSpec) {
- var (
- _node = &SubscriptionPlan{config: _c.config}
- _spec = sqlgraph.NewCreateSpec(subscriptionplan.Table, sqlgraph.NewFieldSpec(subscriptionplan.FieldID, field.TypeInt64))
- )
- _spec.OnConflict = _c.conflict
- if value, ok := _c.mutation.GroupID(); ok {
- _spec.SetField(subscriptionplan.FieldGroupID, field.TypeInt64, value)
- _node.GroupID = value
- }
- if value, ok := _c.mutation.Name(); ok {
- _spec.SetField(subscriptionplan.FieldName, field.TypeString, value)
- _node.Name = value
- }
- if value, ok := _c.mutation.Description(); ok {
- _spec.SetField(subscriptionplan.FieldDescription, field.TypeString, value)
- _node.Description = value
- }
- if value, ok := _c.mutation.Price(); ok {
- _spec.SetField(subscriptionplan.FieldPrice, field.TypeFloat64, value)
- _node.Price = value
- }
- if value, ok := _c.mutation.OriginalPrice(); ok {
- _spec.SetField(subscriptionplan.FieldOriginalPrice, field.TypeFloat64, value)
- _node.OriginalPrice = &value
- }
- if value, ok := _c.mutation.Currency(); ok {
- _spec.SetField(subscriptionplan.FieldCurrency, field.TypeString, value)
- _node.Currency = value
- }
- if value, ok := _c.mutation.ValidityDays(); ok {
- _spec.SetField(subscriptionplan.FieldValidityDays, field.TypeInt, value)
- _node.ValidityDays = value
- }
- if value, ok := _c.mutation.ValidityUnit(); ok {
- _spec.SetField(subscriptionplan.FieldValidityUnit, field.TypeString, value)
- _node.ValidityUnit = value
- }
- if value, ok := _c.mutation.Features(); ok {
- _spec.SetField(subscriptionplan.FieldFeatures, field.TypeString, value)
- _node.Features = value
- }
- if value, ok := _c.mutation.ProductName(); ok {
- _spec.SetField(subscriptionplan.FieldProductName, field.TypeString, value)
- _node.ProductName = value
- }
- if value, ok := _c.mutation.ForSale(); ok {
- _spec.SetField(subscriptionplan.FieldForSale, field.TypeBool, value)
- _node.ForSale = value
- }
- if value, ok := _c.mutation.SortOrder(); ok {
- _spec.SetField(subscriptionplan.FieldSortOrder, field.TypeInt, value)
- _node.SortOrder = value
- }
- if value, ok := _c.mutation.CreatedAt(); ok {
- _spec.SetField(subscriptionplan.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if value, ok := _c.mutation.UpdatedAt(); ok {
- _spec.SetField(subscriptionplan.FieldUpdatedAt, field.TypeTime, value)
- _node.UpdatedAt = value
- }
- return _node, _spec
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.SubscriptionPlan.Create().
- // SetGroupID(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.SubscriptionPlanUpsert) {
- // SetGroupID(v+v).
- // }).
- // Exec(ctx)
- func (_c *SubscriptionPlanCreate) OnConflict(opts ...sql.ConflictOption) *SubscriptionPlanUpsertOne {
- _c.conflict = opts
- return &SubscriptionPlanUpsertOne{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.SubscriptionPlan.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *SubscriptionPlanCreate) OnConflictColumns(columns ...string) *SubscriptionPlanUpsertOne {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &SubscriptionPlanUpsertOne{
- create: _c,
- }
- }
- type (
- // SubscriptionPlanUpsertOne is the builder for "upsert"-ing
- // one SubscriptionPlan node.
- SubscriptionPlanUpsertOne struct {
- create *SubscriptionPlanCreate
- }
- // SubscriptionPlanUpsert is the "OnConflict" setter.
- SubscriptionPlanUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetGroupID sets the "group_id" field.
- func (u *SubscriptionPlanUpsert) SetGroupID(v int64) *SubscriptionPlanUpsert {
- u.Set(subscriptionplan.FieldGroupID, v)
- return u
- }
- // UpdateGroupID sets the "group_id" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsert) UpdateGroupID() *SubscriptionPlanUpsert {
- u.SetExcluded(subscriptionplan.FieldGroupID)
- return u
- }
- // AddGroupID adds v to the "group_id" field.
- func (u *SubscriptionPlanUpsert) AddGroupID(v int64) *SubscriptionPlanUpsert {
- u.Add(subscriptionplan.FieldGroupID, v)
- return u
- }
- // SetName sets the "name" field.
- func (u *SubscriptionPlanUpsert) SetName(v string) *SubscriptionPlanUpsert {
- u.Set(subscriptionplan.FieldName, v)
- return u
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsert) UpdateName() *SubscriptionPlanUpsert {
- u.SetExcluded(subscriptionplan.FieldName)
- return u
- }
- // SetDescription sets the "description" field.
- func (u *SubscriptionPlanUpsert) SetDescription(v string) *SubscriptionPlanUpsert {
- u.Set(subscriptionplan.FieldDescription, v)
- return u
- }
- // UpdateDescription sets the "description" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsert) UpdateDescription() *SubscriptionPlanUpsert {
- u.SetExcluded(subscriptionplan.FieldDescription)
- return u
- }
- // SetPrice sets the "price" field.
- func (u *SubscriptionPlanUpsert) SetPrice(v float64) *SubscriptionPlanUpsert {
- u.Set(subscriptionplan.FieldPrice, v)
- return u
- }
- // UpdatePrice sets the "price" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsert) UpdatePrice() *SubscriptionPlanUpsert {
- u.SetExcluded(subscriptionplan.FieldPrice)
- return u
- }
- // AddPrice adds v to the "price" field.
- func (u *SubscriptionPlanUpsert) AddPrice(v float64) *SubscriptionPlanUpsert {
- u.Add(subscriptionplan.FieldPrice, v)
- return u
- }
- // SetOriginalPrice sets the "original_price" field.
- func (u *SubscriptionPlanUpsert) SetOriginalPrice(v float64) *SubscriptionPlanUpsert {
- u.Set(subscriptionplan.FieldOriginalPrice, v)
- return u
- }
- // UpdateOriginalPrice sets the "original_price" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsert) UpdateOriginalPrice() *SubscriptionPlanUpsert {
- u.SetExcluded(subscriptionplan.FieldOriginalPrice)
- return u
- }
- // AddOriginalPrice adds v to the "original_price" field.
- func (u *SubscriptionPlanUpsert) AddOriginalPrice(v float64) *SubscriptionPlanUpsert {
- u.Add(subscriptionplan.FieldOriginalPrice, v)
- return u
- }
- // ClearOriginalPrice clears the value of the "original_price" field.
- func (u *SubscriptionPlanUpsert) ClearOriginalPrice() *SubscriptionPlanUpsert {
- u.SetNull(subscriptionplan.FieldOriginalPrice)
- return u
- }
- // SetCurrency sets the "currency" field.
- func (u *SubscriptionPlanUpsert) SetCurrency(v string) *SubscriptionPlanUpsert {
- u.Set(subscriptionplan.FieldCurrency, v)
- return u
- }
- // UpdateCurrency sets the "currency" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsert) UpdateCurrency() *SubscriptionPlanUpsert {
- u.SetExcluded(subscriptionplan.FieldCurrency)
- return u
- }
- // SetValidityDays sets the "validity_days" field.
- func (u *SubscriptionPlanUpsert) SetValidityDays(v int) *SubscriptionPlanUpsert {
- u.Set(subscriptionplan.FieldValidityDays, v)
- return u
- }
- // UpdateValidityDays sets the "validity_days" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsert) UpdateValidityDays() *SubscriptionPlanUpsert {
- u.SetExcluded(subscriptionplan.FieldValidityDays)
- return u
- }
- // AddValidityDays adds v to the "validity_days" field.
- func (u *SubscriptionPlanUpsert) AddValidityDays(v int) *SubscriptionPlanUpsert {
- u.Add(subscriptionplan.FieldValidityDays, v)
- return u
- }
- // SetValidityUnit sets the "validity_unit" field.
- func (u *SubscriptionPlanUpsert) SetValidityUnit(v string) *SubscriptionPlanUpsert {
- u.Set(subscriptionplan.FieldValidityUnit, v)
- return u
- }
- // UpdateValidityUnit sets the "validity_unit" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsert) UpdateValidityUnit() *SubscriptionPlanUpsert {
- u.SetExcluded(subscriptionplan.FieldValidityUnit)
- return u
- }
- // SetFeatures sets the "features" field.
- func (u *SubscriptionPlanUpsert) SetFeatures(v string) *SubscriptionPlanUpsert {
- u.Set(subscriptionplan.FieldFeatures, v)
- return u
- }
- // UpdateFeatures sets the "features" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsert) UpdateFeatures() *SubscriptionPlanUpsert {
- u.SetExcluded(subscriptionplan.FieldFeatures)
- return u
- }
- // SetProductName sets the "product_name" field.
- func (u *SubscriptionPlanUpsert) SetProductName(v string) *SubscriptionPlanUpsert {
- u.Set(subscriptionplan.FieldProductName, v)
- return u
- }
- // UpdateProductName sets the "product_name" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsert) UpdateProductName() *SubscriptionPlanUpsert {
- u.SetExcluded(subscriptionplan.FieldProductName)
- return u
- }
- // SetForSale sets the "for_sale" field.
- func (u *SubscriptionPlanUpsert) SetForSale(v bool) *SubscriptionPlanUpsert {
- u.Set(subscriptionplan.FieldForSale, v)
- return u
- }
- // UpdateForSale sets the "for_sale" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsert) UpdateForSale() *SubscriptionPlanUpsert {
- u.SetExcluded(subscriptionplan.FieldForSale)
- return u
- }
- // SetSortOrder sets the "sort_order" field.
- func (u *SubscriptionPlanUpsert) SetSortOrder(v int) *SubscriptionPlanUpsert {
- u.Set(subscriptionplan.FieldSortOrder, v)
- return u
- }
- // UpdateSortOrder sets the "sort_order" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsert) UpdateSortOrder() *SubscriptionPlanUpsert {
- u.SetExcluded(subscriptionplan.FieldSortOrder)
- return u
- }
- // AddSortOrder adds v to the "sort_order" field.
- func (u *SubscriptionPlanUpsert) AddSortOrder(v int) *SubscriptionPlanUpsert {
- u.Add(subscriptionplan.FieldSortOrder, v)
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *SubscriptionPlanUpsert) SetUpdatedAt(v time.Time) *SubscriptionPlanUpsert {
- u.Set(subscriptionplan.FieldUpdatedAt, v)
- return u
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsert) UpdateUpdatedAt() *SubscriptionPlanUpsert {
- u.SetExcluded(subscriptionplan.FieldUpdatedAt)
- return u
- }
- // UpdateNewValues updates the mutable fields using the new values that were set on create.
- // Using this option is equivalent to using:
- //
- // client.SubscriptionPlan.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *SubscriptionPlanUpsertOne) UpdateNewValues() *SubscriptionPlanUpsertOne {
- 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(subscriptionplan.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.SubscriptionPlan.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *SubscriptionPlanUpsertOne) Ignore() *SubscriptionPlanUpsertOne {
- 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 *SubscriptionPlanUpsertOne) DoNothing() *SubscriptionPlanUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the SubscriptionPlanCreate.OnConflict
- // documentation for more info.
- func (u *SubscriptionPlanUpsertOne) Update(set func(*SubscriptionPlanUpsert)) *SubscriptionPlanUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&SubscriptionPlanUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetGroupID sets the "group_id" field.
- func (u *SubscriptionPlanUpsertOne) SetGroupID(v int64) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetGroupID(v)
- })
- }
- // AddGroupID adds v to the "group_id" field.
- func (u *SubscriptionPlanUpsertOne) AddGroupID(v int64) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.AddGroupID(v)
- })
- }
- // UpdateGroupID sets the "group_id" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertOne) UpdateGroupID() *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateGroupID()
- })
- }
- // SetName sets the "name" field.
- func (u *SubscriptionPlanUpsertOne) SetName(v string) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetName(v)
- })
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertOne) UpdateName() *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateName()
- })
- }
- // SetDescription sets the "description" field.
- func (u *SubscriptionPlanUpsertOne) SetDescription(v string) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetDescription(v)
- })
- }
- // UpdateDescription sets the "description" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertOne) UpdateDescription() *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateDescription()
- })
- }
- // SetPrice sets the "price" field.
- func (u *SubscriptionPlanUpsertOne) SetPrice(v float64) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetPrice(v)
- })
- }
- // AddPrice adds v to the "price" field.
- func (u *SubscriptionPlanUpsertOne) AddPrice(v float64) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.AddPrice(v)
- })
- }
- // UpdatePrice sets the "price" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertOne) UpdatePrice() *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdatePrice()
- })
- }
- // SetOriginalPrice sets the "original_price" field.
- func (u *SubscriptionPlanUpsertOne) SetOriginalPrice(v float64) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetOriginalPrice(v)
- })
- }
- // AddOriginalPrice adds v to the "original_price" field.
- func (u *SubscriptionPlanUpsertOne) AddOriginalPrice(v float64) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.AddOriginalPrice(v)
- })
- }
- // UpdateOriginalPrice sets the "original_price" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertOne) UpdateOriginalPrice() *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateOriginalPrice()
- })
- }
- // ClearOriginalPrice clears the value of the "original_price" field.
- func (u *SubscriptionPlanUpsertOne) ClearOriginalPrice() *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.ClearOriginalPrice()
- })
- }
- // SetCurrency sets the "currency" field.
- func (u *SubscriptionPlanUpsertOne) SetCurrency(v string) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetCurrency(v)
- })
- }
- // UpdateCurrency sets the "currency" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertOne) UpdateCurrency() *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateCurrency()
- })
- }
- // SetValidityDays sets the "validity_days" field.
- func (u *SubscriptionPlanUpsertOne) SetValidityDays(v int) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetValidityDays(v)
- })
- }
- // AddValidityDays adds v to the "validity_days" field.
- func (u *SubscriptionPlanUpsertOne) AddValidityDays(v int) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.AddValidityDays(v)
- })
- }
- // UpdateValidityDays sets the "validity_days" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertOne) UpdateValidityDays() *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateValidityDays()
- })
- }
- // SetValidityUnit sets the "validity_unit" field.
- func (u *SubscriptionPlanUpsertOne) SetValidityUnit(v string) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetValidityUnit(v)
- })
- }
- // UpdateValidityUnit sets the "validity_unit" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertOne) UpdateValidityUnit() *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateValidityUnit()
- })
- }
- // SetFeatures sets the "features" field.
- func (u *SubscriptionPlanUpsertOne) SetFeatures(v string) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetFeatures(v)
- })
- }
- // UpdateFeatures sets the "features" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertOne) UpdateFeatures() *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateFeatures()
- })
- }
- // SetProductName sets the "product_name" field.
- func (u *SubscriptionPlanUpsertOne) SetProductName(v string) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetProductName(v)
- })
- }
- // UpdateProductName sets the "product_name" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertOne) UpdateProductName() *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateProductName()
- })
- }
- // SetForSale sets the "for_sale" field.
- func (u *SubscriptionPlanUpsertOne) SetForSale(v bool) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetForSale(v)
- })
- }
- // UpdateForSale sets the "for_sale" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertOne) UpdateForSale() *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateForSale()
- })
- }
- // SetSortOrder sets the "sort_order" field.
- func (u *SubscriptionPlanUpsertOne) SetSortOrder(v int) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetSortOrder(v)
- })
- }
- // AddSortOrder adds v to the "sort_order" field.
- func (u *SubscriptionPlanUpsertOne) AddSortOrder(v int) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.AddSortOrder(v)
- })
- }
- // UpdateSortOrder sets the "sort_order" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertOne) UpdateSortOrder() *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateSortOrder()
- })
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *SubscriptionPlanUpsertOne) SetUpdatedAt(v time.Time) *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertOne) UpdateUpdatedAt() *SubscriptionPlanUpsertOne {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // Exec executes the query.
- func (u *SubscriptionPlanUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for SubscriptionPlanCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *SubscriptionPlanUpsertOne) 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 *SubscriptionPlanUpsertOne) 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 *SubscriptionPlanUpsertOne) IDX(ctx context.Context) int64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // SubscriptionPlanCreateBulk is the builder for creating many SubscriptionPlan entities in bulk.
- type SubscriptionPlanCreateBulk struct {
- config
- err error
- builders []*SubscriptionPlanCreate
- conflict []sql.ConflictOption
- }
- // Save creates the SubscriptionPlan entities in the database.
- func (_c *SubscriptionPlanCreateBulk) Save(ctx context.Context) ([]*SubscriptionPlan, error) {
- if _c.err != nil {
- return nil, _c.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
- nodes := make([]*SubscriptionPlan, 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.(*SubscriptionPlanMutation)
- 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 *SubscriptionPlanCreateBulk) SaveX(ctx context.Context) []*SubscriptionPlan {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *SubscriptionPlanCreateBulk) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *SubscriptionPlanCreateBulk) 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.SubscriptionPlan.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.SubscriptionPlanUpsert) {
- // SetGroupID(v+v).
- // }).
- // Exec(ctx)
- func (_c *SubscriptionPlanCreateBulk) OnConflict(opts ...sql.ConflictOption) *SubscriptionPlanUpsertBulk {
- _c.conflict = opts
- return &SubscriptionPlanUpsertBulk{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.SubscriptionPlan.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *SubscriptionPlanCreateBulk) OnConflictColumns(columns ...string) *SubscriptionPlanUpsertBulk {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &SubscriptionPlanUpsertBulk{
- create: _c,
- }
- }
- // SubscriptionPlanUpsertBulk is the builder for "upsert"-ing
- // a bulk of SubscriptionPlan nodes.
- type SubscriptionPlanUpsertBulk struct {
- create *SubscriptionPlanCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.SubscriptionPlan.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *SubscriptionPlanUpsertBulk) UpdateNewValues() *SubscriptionPlanUpsertBulk {
- 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(subscriptionplan.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.SubscriptionPlan.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *SubscriptionPlanUpsertBulk) Ignore() *SubscriptionPlanUpsertBulk {
- 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 *SubscriptionPlanUpsertBulk) DoNothing() *SubscriptionPlanUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the SubscriptionPlanCreateBulk.OnConflict
- // documentation for more info.
- func (u *SubscriptionPlanUpsertBulk) Update(set func(*SubscriptionPlanUpsert)) *SubscriptionPlanUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&SubscriptionPlanUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetGroupID sets the "group_id" field.
- func (u *SubscriptionPlanUpsertBulk) SetGroupID(v int64) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetGroupID(v)
- })
- }
- // AddGroupID adds v to the "group_id" field.
- func (u *SubscriptionPlanUpsertBulk) AddGroupID(v int64) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.AddGroupID(v)
- })
- }
- // UpdateGroupID sets the "group_id" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertBulk) UpdateGroupID() *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateGroupID()
- })
- }
- // SetName sets the "name" field.
- func (u *SubscriptionPlanUpsertBulk) SetName(v string) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetName(v)
- })
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertBulk) UpdateName() *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateName()
- })
- }
- // SetDescription sets the "description" field.
- func (u *SubscriptionPlanUpsertBulk) SetDescription(v string) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetDescription(v)
- })
- }
- // UpdateDescription sets the "description" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertBulk) UpdateDescription() *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateDescription()
- })
- }
- // SetPrice sets the "price" field.
- func (u *SubscriptionPlanUpsertBulk) SetPrice(v float64) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetPrice(v)
- })
- }
- // AddPrice adds v to the "price" field.
- func (u *SubscriptionPlanUpsertBulk) AddPrice(v float64) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.AddPrice(v)
- })
- }
- // UpdatePrice sets the "price" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertBulk) UpdatePrice() *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdatePrice()
- })
- }
- // SetOriginalPrice sets the "original_price" field.
- func (u *SubscriptionPlanUpsertBulk) SetOriginalPrice(v float64) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetOriginalPrice(v)
- })
- }
- // AddOriginalPrice adds v to the "original_price" field.
- func (u *SubscriptionPlanUpsertBulk) AddOriginalPrice(v float64) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.AddOriginalPrice(v)
- })
- }
- // UpdateOriginalPrice sets the "original_price" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertBulk) UpdateOriginalPrice() *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateOriginalPrice()
- })
- }
- // ClearOriginalPrice clears the value of the "original_price" field.
- func (u *SubscriptionPlanUpsertBulk) ClearOriginalPrice() *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.ClearOriginalPrice()
- })
- }
- // SetCurrency sets the "currency" field.
- func (u *SubscriptionPlanUpsertBulk) SetCurrency(v string) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetCurrency(v)
- })
- }
- // UpdateCurrency sets the "currency" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertBulk) UpdateCurrency() *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateCurrency()
- })
- }
- // SetValidityDays sets the "validity_days" field.
- func (u *SubscriptionPlanUpsertBulk) SetValidityDays(v int) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetValidityDays(v)
- })
- }
- // AddValidityDays adds v to the "validity_days" field.
- func (u *SubscriptionPlanUpsertBulk) AddValidityDays(v int) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.AddValidityDays(v)
- })
- }
- // UpdateValidityDays sets the "validity_days" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertBulk) UpdateValidityDays() *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateValidityDays()
- })
- }
- // SetValidityUnit sets the "validity_unit" field.
- func (u *SubscriptionPlanUpsertBulk) SetValidityUnit(v string) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetValidityUnit(v)
- })
- }
- // UpdateValidityUnit sets the "validity_unit" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertBulk) UpdateValidityUnit() *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateValidityUnit()
- })
- }
- // SetFeatures sets the "features" field.
- func (u *SubscriptionPlanUpsertBulk) SetFeatures(v string) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetFeatures(v)
- })
- }
- // UpdateFeatures sets the "features" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertBulk) UpdateFeatures() *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateFeatures()
- })
- }
- // SetProductName sets the "product_name" field.
- func (u *SubscriptionPlanUpsertBulk) SetProductName(v string) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetProductName(v)
- })
- }
- // UpdateProductName sets the "product_name" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertBulk) UpdateProductName() *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateProductName()
- })
- }
- // SetForSale sets the "for_sale" field.
- func (u *SubscriptionPlanUpsertBulk) SetForSale(v bool) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetForSale(v)
- })
- }
- // UpdateForSale sets the "for_sale" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertBulk) UpdateForSale() *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateForSale()
- })
- }
- // SetSortOrder sets the "sort_order" field.
- func (u *SubscriptionPlanUpsertBulk) SetSortOrder(v int) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetSortOrder(v)
- })
- }
- // AddSortOrder adds v to the "sort_order" field.
- func (u *SubscriptionPlanUpsertBulk) AddSortOrder(v int) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.AddSortOrder(v)
- })
- }
- // UpdateSortOrder sets the "sort_order" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertBulk) UpdateSortOrder() *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateSortOrder()
- })
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *SubscriptionPlanUpsertBulk) SetUpdatedAt(v time.Time) *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *SubscriptionPlanUpsertBulk) UpdateUpdatedAt() *SubscriptionPlanUpsertBulk {
- return u.Update(func(s *SubscriptionPlanUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // Exec executes the query.
- func (u *SubscriptionPlanUpsertBulk) 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 SubscriptionPlanCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for SubscriptionPlanCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *SubscriptionPlanUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|