| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255 |
- // 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/group"
- "github.com/Wei-Shaw/sub2api/ent/redeemcode"
- "github.com/Wei-Shaw/sub2api/ent/user"
- )
- // RedeemCodeCreate is the builder for creating a RedeemCode entity.
- type RedeemCodeCreate struct {
- config
- mutation *RedeemCodeMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetCode sets the "code" field.
- func (_c *RedeemCodeCreate) SetCode(v string) *RedeemCodeCreate {
- _c.mutation.SetCode(v)
- return _c
- }
- // SetType sets the "type" field.
- func (_c *RedeemCodeCreate) SetType(v string) *RedeemCodeCreate {
- _c.mutation.SetType(v)
- return _c
- }
- // SetNillableType sets the "type" field if the given value is not nil.
- func (_c *RedeemCodeCreate) SetNillableType(v *string) *RedeemCodeCreate {
- if v != nil {
- _c.SetType(*v)
- }
- return _c
- }
- // SetValue sets the "value" field.
- func (_c *RedeemCodeCreate) SetValue(v float64) *RedeemCodeCreate {
- _c.mutation.SetValue(v)
- return _c
- }
- // SetNillableValue sets the "value" field if the given value is not nil.
- func (_c *RedeemCodeCreate) SetNillableValue(v *float64) *RedeemCodeCreate {
- if v != nil {
- _c.SetValue(*v)
- }
- return _c
- }
- // SetStatus sets the "status" field.
- func (_c *RedeemCodeCreate) SetStatus(v string) *RedeemCodeCreate {
- _c.mutation.SetStatus(v)
- return _c
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (_c *RedeemCodeCreate) SetNillableStatus(v *string) *RedeemCodeCreate {
- if v != nil {
- _c.SetStatus(*v)
- }
- return _c
- }
- // SetUsedBy sets the "used_by" field.
- func (_c *RedeemCodeCreate) SetUsedBy(v int64) *RedeemCodeCreate {
- _c.mutation.SetUsedBy(v)
- return _c
- }
- // SetNillableUsedBy sets the "used_by" field if the given value is not nil.
- func (_c *RedeemCodeCreate) SetNillableUsedBy(v *int64) *RedeemCodeCreate {
- if v != nil {
- _c.SetUsedBy(*v)
- }
- return _c
- }
- // SetUsedAt sets the "used_at" field.
- func (_c *RedeemCodeCreate) SetUsedAt(v time.Time) *RedeemCodeCreate {
- _c.mutation.SetUsedAt(v)
- return _c
- }
- // SetNillableUsedAt sets the "used_at" field if the given value is not nil.
- func (_c *RedeemCodeCreate) SetNillableUsedAt(v *time.Time) *RedeemCodeCreate {
- if v != nil {
- _c.SetUsedAt(*v)
- }
- return _c
- }
- // SetNotes sets the "notes" field.
- func (_c *RedeemCodeCreate) SetNotes(v string) *RedeemCodeCreate {
- _c.mutation.SetNotes(v)
- return _c
- }
- // SetNillableNotes sets the "notes" field if the given value is not nil.
- func (_c *RedeemCodeCreate) SetNillableNotes(v *string) *RedeemCodeCreate {
- if v != nil {
- _c.SetNotes(*v)
- }
- return _c
- }
- // SetCreatedAt sets the "created_at" field.
- func (_c *RedeemCodeCreate) SetCreatedAt(v time.Time) *RedeemCodeCreate {
- _c.mutation.SetCreatedAt(v)
- return _c
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (_c *RedeemCodeCreate) SetNillableCreatedAt(v *time.Time) *RedeemCodeCreate {
- if v != nil {
- _c.SetCreatedAt(*v)
- }
- return _c
- }
- // SetExpiresAt sets the "expires_at" field.
- func (_c *RedeemCodeCreate) SetExpiresAt(v time.Time) *RedeemCodeCreate {
- _c.mutation.SetExpiresAt(v)
- return _c
- }
- // SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
- func (_c *RedeemCodeCreate) SetNillableExpiresAt(v *time.Time) *RedeemCodeCreate {
- if v != nil {
- _c.SetExpiresAt(*v)
- }
- return _c
- }
- // SetGroupID sets the "group_id" field.
- func (_c *RedeemCodeCreate) SetGroupID(v int64) *RedeemCodeCreate {
- _c.mutation.SetGroupID(v)
- return _c
- }
- // SetNillableGroupID sets the "group_id" field if the given value is not nil.
- func (_c *RedeemCodeCreate) SetNillableGroupID(v *int64) *RedeemCodeCreate {
- if v != nil {
- _c.SetGroupID(*v)
- }
- return _c
- }
- // SetValidityDays sets the "validity_days" field.
- func (_c *RedeemCodeCreate) SetValidityDays(v int) *RedeemCodeCreate {
- _c.mutation.SetValidityDays(v)
- return _c
- }
- // SetNillableValidityDays sets the "validity_days" field if the given value is not nil.
- func (_c *RedeemCodeCreate) SetNillableValidityDays(v *int) *RedeemCodeCreate {
- if v != nil {
- _c.SetValidityDays(*v)
- }
- return _c
- }
- // SetUserID sets the "user" edge to the User entity by ID.
- func (_c *RedeemCodeCreate) SetUserID(id int64) *RedeemCodeCreate {
- _c.mutation.SetUserID(id)
- return _c
- }
- // SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil.
- func (_c *RedeemCodeCreate) SetNillableUserID(id *int64) *RedeemCodeCreate {
- if id != nil {
- _c = _c.SetUserID(*id)
- }
- return _c
- }
- // SetUser sets the "user" edge to the User entity.
- func (_c *RedeemCodeCreate) SetUser(v *User) *RedeemCodeCreate {
- return _c.SetUserID(v.ID)
- }
- // SetGroup sets the "group" edge to the Group entity.
- func (_c *RedeemCodeCreate) SetGroup(v *Group) *RedeemCodeCreate {
- return _c.SetGroupID(v.ID)
- }
- // Mutation returns the RedeemCodeMutation object of the builder.
- func (_c *RedeemCodeCreate) Mutation() *RedeemCodeMutation {
- return _c.mutation
- }
- // Save creates the RedeemCode in the database.
- func (_c *RedeemCodeCreate) Save(ctx context.Context) (*RedeemCode, error) {
- _c.defaults()
- return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (_c *RedeemCodeCreate) SaveX(ctx context.Context) *RedeemCode {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *RedeemCodeCreate) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *RedeemCodeCreate) 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 *RedeemCodeCreate) defaults() {
- if _, ok := _c.mutation.GetType(); !ok {
- v := redeemcode.DefaultType
- _c.mutation.SetType(v)
- }
- if _, ok := _c.mutation.Value(); !ok {
- v := redeemcode.DefaultValue
- _c.mutation.SetValue(v)
- }
- if _, ok := _c.mutation.Status(); !ok {
- v := redeemcode.DefaultStatus
- _c.mutation.SetStatus(v)
- }
- if _, ok := _c.mutation.CreatedAt(); !ok {
- v := redeemcode.DefaultCreatedAt()
- _c.mutation.SetCreatedAt(v)
- }
- if _, ok := _c.mutation.ValidityDays(); !ok {
- v := redeemcode.DefaultValidityDays
- _c.mutation.SetValidityDays(v)
- }
- }
- // check runs all checks and user-defined validators on the builder.
- func (_c *RedeemCodeCreate) check() error {
- if _, ok := _c.mutation.Code(); !ok {
- return &ValidationError{Name: "code", err: errors.New(`ent: missing required field "RedeemCode.code"`)}
- }
- if v, ok := _c.mutation.Code(); ok {
- if err := redeemcode.CodeValidator(v); err != nil {
- return &ValidationError{Name: "code", err: fmt.Errorf(`ent: validator failed for field "RedeemCode.code": %w`, err)}
- }
- }
- if _, ok := _c.mutation.GetType(); !ok {
- return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "RedeemCode.type"`)}
- }
- if v, ok := _c.mutation.GetType(); ok {
- if err := redeemcode.TypeValidator(v); err != nil {
- return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "RedeemCode.type": %w`, err)}
- }
- }
- if _, ok := _c.mutation.Value(); !ok {
- return &ValidationError{Name: "value", err: errors.New(`ent: missing required field "RedeemCode.value"`)}
- }
- if _, ok := _c.mutation.Status(); !ok {
- return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "RedeemCode.status"`)}
- }
- if v, ok := _c.mutation.Status(); ok {
- if err := redeemcode.StatusValidator(v); err != nil {
- return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "RedeemCode.status": %w`, err)}
- }
- }
- if _, ok := _c.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "RedeemCode.created_at"`)}
- }
- if _, ok := _c.mutation.ValidityDays(); !ok {
- return &ValidationError{Name: "validity_days", err: errors.New(`ent: missing required field "RedeemCode.validity_days"`)}
- }
- return nil
- }
- func (_c *RedeemCodeCreate) sqlSave(ctx context.Context) (*RedeemCode, 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 *RedeemCodeCreate) createSpec() (*RedeemCode, *sqlgraph.CreateSpec) {
- var (
- _node = &RedeemCode{config: _c.config}
- _spec = sqlgraph.NewCreateSpec(redeemcode.Table, sqlgraph.NewFieldSpec(redeemcode.FieldID, field.TypeInt64))
- )
- _spec.OnConflict = _c.conflict
- if value, ok := _c.mutation.Code(); ok {
- _spec.SetField(redeemcode.FieldCode, field.TypeString, value)
- _node.Code = value
- }
- if value, ok := _c.mutation.GetType(); ok {
- _spec.SetField(redeemcode.FieldType, field.TypeString, value)
- _node.Type = value
- }
- if value, ok := _c.mutation.Value(); ok {
- _spec.SetField(redeemcode.FieldValue, field.TypeFloat64, value)
- _node.Value = value
- }
- if value, ok := _c.mutation.Status(); ok {
- _spec.SetField(redeemcode.FieldStatus, field.TypeString, value)
- _node.Status = value
- }
- if value, ok := _c.mutation.UsedAt(); ok {
- _spec.SetField(redeemcode.FieldUsedAt, field.TypeTime, value)
- _node.UsedAt = &value
- }
- if value, ok := _c.mutation.Notes(); ok {
- _spec.SetField(redeemcode.FieldNotes, field.TypeString, value)
- _node.Notes = &value
- }
- if value, ok := _c.mutation.CreatedAt(); ok {
- _spec.SetField(redeemcode.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if value, ok := _c.mutation.ExpiresAt(); ok {
- _spec.SetField(redeemcode.FieldExpiresAt, field.TypeTime, value)
- _node.ExpiresAt = &value
- }
- if value, ok := _c.mutation.ValidityDays(); ok {
- _spec.SetField(redeemcode.FieldValidityDays, field.TypeInt, value)
- _node.ValidityDays = value
- }
- if nodes := _c.mutation.UserIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: redeemcode.UserTable,
- Columns: []string{redeemcode.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.UsedBy = &nodes[0]
- _spec.Edges = append(_spec.Edges, edge)
- }
- if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: redeemcode.GroupTable,
- Columns: []string{redeemcode.GroupColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _node.GroupID = &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.RedeemCode.Create().
- // SetCode(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.RedeemCodeUpsert) {
- // SetCode(v+v).
- // }).
- // Exec(ctx)
- func (_c *RedeemCodeCreate) OnConflict(opts ...sql.ConflictOption) *RedeemCodeUpsertOne {
- _c.conflict = opts
- return &RedeemCodeUpsertOne{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.RedeemCode.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *RedeemCodeCreate) OnConflictColumns(columns ...string) *RedeemCodeUpsertOne {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &RedeemCodeUpsertOne{
- create: _c,
- }
- }
- type (
- // RedeemCodeUpsertOne is the builder for "upsert"-ing
- // one RedeemCode node.
- RedeemCodeUpsertOne struct {
- create *RedeemCodeCreate
- }
- // RedeemCodeUpsert is the "OnConflict" setter.
- RedeemCodeUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetCode sets the "code" field.
- func (u *RedeemCodeUpsert) SetCode(v string) *RedeemCodeUpsert {
- u.Set(redeemcode.FieldCode, v)
- return u
- }
- // UpdateCode sets the "code" field to the value that was provided on create.
- func (u *RedeemCodeUpsert) UpdateCode() *RedeemCodeUpsert {
- u.SetExcluded(redeemcode.FieldCode)
- return u
- }
- // SetType sets the "type" field.
- func (u *RedeemCodeUpsert) SetType(v string) *RedeemCodeUpsert {
- u.Set(redeemcode.FieldType, v)
- return u
- }
- // UpdateType sets the "type" field to the value that was provided on create.
- func (u *RedeemCodeUpsert) UpdateType() *RedeemCodeUpsert {
- u.SetExcluded(redeemcode.FieldType)
- return u
- }
- // SetValue sets the "value" field.
- func (u *RedeemCodeUpsert) SetValue(v float64) *RedeemCodeUpsert {
- u.Set(redeemcode.FieldValue, v)
- return u
- }
- // UpdateValue sets the "value" field to the value that was provided on create.
- func (u *RedeemCodeUpsert) UpdateValue() *RedeemCodeUpsert {
- u.SetExcluded(redeemcode.FieldValue)
- return u
- }
- // AddValue adds v to the "value" field.
- func (u *RedeemCodeUpsert) AddValue(v float64) *RedeemCodeUpsert {
- u.Add(redeemcode.FieldValue, v)
- return u
- }
- // SetStatus sets the "status" field.
- func (u *RedeemCodeUpsert) SetStatus(v string) *RedeemCodeUpsert {
- u.Set(redeemcode.FieldStatus, v)
- return u
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *RedeemCodeUpsert) UpdateStatus() *RedeemCodeUpsert {
- u.SetExcluded(redeemcode.FieldStatus)
- return u
- }
- // SetUsedBy sets the "used_by" field.
- func (u *RedeemCodeUpsert) SetUsedBy(v int64) *RedeemCodeUpsert {
- u.Set(redeemcode.FieldUsedBy, v)
- return u
- }
- // UpdateUsedBy sets the "used_by" field to the value that was provided on create.
- func (u *RedeemCodeUpsert) UpdateUsedBy() *RedeemCodeUpsert {
- u.SetExcluded(redeemcode.FieldUsedBy)
- return u
- }
- // ClearUsedBy clears the value of the "used_by" field.
- func (u *RedeemCodeUpsert) ClearUsedBy() *RedeemCodeUpsert {
- u.SetNull(redeemcode.FieldUsedBy)
- return u
- }
- // SetUsedAt sets the "used_at" field.
- func (u *RedeemCodeUpsert) SetUsedAt(v time.Time) *RedeemCodeUpsert {
- u.Set(redeemcode.FieldUsedAt, v)
- return u
- }
- // UpdateUsedAt sets the "used_at" field to the value that was provided on create.
- func (u *RedeemCodeUpsert) UpdateUsedAt() *RedeemCodeUpsert {
- u.SetExcluded(redeemcode.FieldUsedAt)
- return u
- }
- // ClearUsedAt clears the value of the "used_at" field.
- func (u *RedeemCodeUpsert) ClearUsedAt() *RedeemCodeUpsert {
- u.SetNull(redeemcode.FieldUsedAt)
- return u
- }
- // SetNotes sets the "notes" field.
- func (u *RedeemCodeUpsert) SetNotes(v string) *RedeemCodeUpsert {
- u.Set(redeemcode.FieldNotes, v)
- return u
- }
- // UpdateNotes sets the "notes" field to the value that was provided on create.
- func (u *RedeemCodeUpsert) UpdateNotes() *RedeemCodeUpsert {
- u.SetExcluded(redeemcode.FieldNotes)
- return u
- }
- // ClearNotes clears the value of the "notes" field.
- func (u *RedeemCodeUpsert) ClearNotes() *RedeemCodeUpsert {
- u.SetNull(redeemcode.FieldNotes)
- return u
- }
- // SetExpiresAt sets the "expires_at" field.
- func (u *RedeemCodeUpsert) SetExpiresAt(v time.Time) *RedeemCodeUpsert {
- u.Set(redeemcode.FieldExpiresAt, v)
- return u
- }
- // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
- func (u *RedeemCodeUpsert) UpdateExpiresAt() *RedeemCodeUpsert {
- u.SetExcluded(redeemcode.FieldExpiresAt)
- return u
- }
- // ClearExpiresAt clears the value of the "expires_at" field.
- func (u *RedeemCodeUpsert) ClearExpiresAt() *RedeemCodeUpsert {
- u.SetNull(redeemcode.FieldExpiresAt)
- return u
- }
- // SetGroupID sets the "group_id" field.
- func (u *RedeemCodeUpsert) SetGroupID(v int64) *RedeemCodeUpsert {
- u.Set(redeemcode.FieldGroupID, v)
- return u
- }
- // UpdateGroupID sets the "group_id" field to the value that was provided on create.
- func (u *RedeemCodeUpsert) UpdateGroupID() *RedeemCodeUpsert {
- u.SetExcluded(redeemcode.FieldGroupID)
- return u
- }
- // ClearGroupID clears the value of the "group_id" field.
- func (u *RedeemCodeUpsert) ClearGroupID() *RedeemCodeUpsert {
- u.SetNull(redeemcode.FieldGroupID)
- return u
- }
- // SetValidityDays sets the "validity_days" field.
- func (u *RedeemCodeUpsert) SetValidityDays(v int) *RedeemCodeUpsert {
- u.Set(redeemcode.FieldValidityDays, v)
- return u
- }
- // UpdateValidityDays sets the "validity_days" field to the value that was provided on create.
- func (u *RedeemCodeUpsert) UpdateValidityDays() *RedeemCodeUpsert {
- u.SetExcluded(redeemcode.FieldValidityDays)
- return u
- }
- // AddValidityDays adds v to the "validity_days" field.
- func (u *RedeemCodeUpsert) AddValidityDays(v int) *RedeemCodeUpsert {
- u.Add(redeemcode.FieldValidityDays, v)
- return u
- }
- // UpdateNewValues updates the mutable fields using the new values that were set on create.
- // Using this option is equivalent to using:
- //
- // client.RedeemCode.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *RedeemCodeUpsertOne) UpdateNewValues() *RedeemCodeUpsertOne {
- 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(redeemcode.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.RedeemCode.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *RedeemCodeUpsertOne) Ignore() *RedeemCodeUpsertOne {
- 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 *RedeemCodeUpsertOne) DoNothing() *RedeemCodeUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the RedeemCodeCreate.OnConflict
- // documentation for more info.
- func (u *RedeemCodeUpsertOne) Update(set func(*RedeemCodeUpsert)) *RedeemCodeUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&RedeemCodeUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetCode sets the "code" field.
- func (u *RedeemCodeUpsertOne) SetCode(v string) *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetCode(v)
- })
- }
- // UpdateCode sets the "code" field to the value that was provided on create.
- func (u *RedeemCodeUpsertOne) UpdateCode() *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateCode()
- })
- }
- // SetType sets the "type" field.
- func (u *RedeemCodeUpsertOne) SetType(v string) *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetType(v)
- })
- }
- // UpdateType sets the "type" field to the value that was provided on create.
- func (u *RedeemCodeUpsertOne) UpdateType() *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateType()
- })
- }
- // SetValue sets the "value" field.
- func (u *RedeemCodeUpsertOne) SetValue(v float64) *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetValue(v)
- })
- }
- // AddValue adds v to the "value" field.
- func (u *RedeemCodeUpsertOne) AddValue(v float64) *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.AddValue(v)
- })
- }
- // UpdateValue sets the "value" field to the value that was provided on create.
- func (u *RedeemCodeUpsertOne) UpdateValue() *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateValue()
- })
- }
- // SetStatus sets the "status" field.
- func (u *RedeemCodeUpsertOne) SetStatus(v string) *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *RedeemCodeUpsertOne) UpdateStatus() *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateStatus()
- })
- }
- // SetUsedBy sets the "used_by" field.
- func (u *RedeemCodeUpsertOne) SetUsedBy(v int64) *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetUsedBy(v)
- })
- }
- // UpdateUsedBy sets the "used_by" field to the value that was provided on create.
- func (u *RedeemCodeUpsertOne) UpdateUsedBy() *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateUsedBy()
- })
- }
- // ClearUsedBy clears the value of the "used_by" field.
- func (u *RedeemCodeUpsertOne) ClearUsedBy() *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.ClearUsedBy()
- })
- }
- // SetUsedAt sets the "used_at" field.
- func (u *RedeemCodeUpsertOne) SetUsedAt(v time.Time) *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetUsedAt(v)
- })
- }
- // UpdateUsedAt sets the "used_at" field to the value that was provided on create.
- func (u *RedeemCodeUpsertOne) UpdateUsedAt() *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateUsedAt()
- })
- }
- // ClearUsedAt clears the value of the "used_at" field.
- func (u *RedeemCodeUpsertOne) ClearUsedAt() *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.ClearUsedAt()
- })
- }
- // SetNotes sets the "notes" field.
- func (u *RedeemCodeUpsertOne) SetNotes(v string) *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetNotes(v)
- })
- }
- // UpdateNotes sets the "notes" field to the value that was provided on create.
- func (u *RedeemCodeUpsertOne) UpdateNotes() *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateNotes()
- })
- }
- // ClearNotes clears the value of the "notes" field.
- func (u *RedeemCodeUpsertOne) ClearNotes() *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.ClearNotes()
- })
- }
- // SetExpiresAt sets the "expires_at" field.
- func (u *RedeemCodeUpsertOne) SetExpiresAt(v time.Time) *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetExpiresAt(v)
- })
- }
- // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
- func (u *RedeemCodeUpsertOne) UpdateExpiresAt() *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateExpiresAt()
- })
- }
- // ClearExpiresAt clears the value of the "expires_at" field.
- func (u *RedeemCodeUpsertOne) ClearExpiresAt() *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.ClearExpiresAt()
- })
- }
- // SetGroupID sets the "group_id" field.
- func (u *RedeemCodeUpsertOne) SetGroupID(v int64) *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetGroupID(v)
- })
- }
- // UpdateGroupID sets the "group_id" field to the value that was provided on create.
- func (u *RedeemCodeUpsertOne) UpdateGroupID() *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateGroupID()
- })
- }
- // ClearGroupID clears the value of the "group_id" field.
- func (u *RedeemCodeUpsertOne) ClearGroupID() *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.ClearGroupID()
- })
- }
- // SetValidityDays sets the "validity_days" field.
- func (u *RedeemCodeUpsertOne) SetValidityDays(v int) *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetValidityDays(v)
- })
- }
- // AddValidityDays adds v to the "validity_days" field.
- func (u *RedeemCodeUpsertOne) AddValidityDays(v int) *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.AddValidityDays(v)
- })
- }
- // UpdateValidityDays sets the "validity_days" field to the value that was provided on create.
- func (u *RedeemCodeUpsertOne) UpdateValidityDays() *RedeemCodeUpsertOne {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateValidityDays()
- })
- }
- // Exec executes the query.
- func (u *RedeemCodeUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for RedeemCodeCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *RedeemCodeUpsertOne) 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 *RedeemCodeUpsertOne) 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 *RedeemCodeUpsertOne) IDX(ctx context.Context) int64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // RedeemCodeCreateBulk is the builder for creating many RedeemCode entities in bulk.
- type RedeemCodeCreateBulk struct {
- config
- err error
- builders []*RedeemCodeCreate
- conflict []sql.ConflictOption
- }
- // Save creates the RedeemCode entities in the database.
- func (_c *RedeemCodeCreateBulk) Save(ctx context.Context) ([]*RedeemCode, error) {
- if _c.err != nil {
- return nil, _c.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
- nodes := make([]*RedeemCode, 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.(*RedeemCodeMutation)
- 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 *RedeemCodeCreateBulk) SaveX(ctx context.Context) []*RedeemCode {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *RedeemCodeCreateBulk) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *RedeemCodeCreateBulk) 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.RedeemCode.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.RedeemCodeUpsert) {
- // SetCode(v+v).
- // }).
- // Exec(ctx)
- func (_c *RedeemCodeCreateBulk) OnConflict(opts ...sql.ConflictOption) *RedeemCodeUpsertBulk {
- _c.conflict = opts
- return &RedeemCodeUpsertBulk{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.RedeemCode.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *RedeemCodeCreateBulk) OnConflictColumns(columns ...string) *RedeemCodeUpsertBulk {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &RedeemCodeUpsertBulk{
- create: _c,
- }
- }
- // RedeemCodeUpsertBulk is the builder for "upsert"-ing
- // a bulk of RedeemCode nodes.
- type RedeemCodeUpsertBulk struct {
- create *RedeemCodeCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.RedeemCode.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *RedeemCodeUpsertBulk) UpdateNewValues() *RedeemCodeUpsertBulk {
- 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(redeemcode.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.RedeemCode.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *RedeemCodeUpsertBulk) Ignore() *RedeemCodeUpsertBulk {
- 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 *RedeemCodeUpsertBulk) DoNothing() *RedeemCodeUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the RedeemCodeCreateBulk.OnConflict
- // documentation for more info.
- func (u *RedeemCodeUpsertBulk) Update(set func(*RedeemCodeUpsert)) *RedeemCodeUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&RedeemCodeUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetCode sets the "code" field.
- func (u *RedeemCodeUpsertBulk) SetCode(v string) *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetCode(v)
- })
- }
- // UpdateCode sets the "code" field to the value that was provided on create.
- func (u *RedeemCodeUpsertBulk) UpdateCode() *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateCode()
- })
- }
- // SetType sets the "type" field.
- func (u *RedeemCodeUpsertBulk) SetType(v string) *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetType(v)
- })
- }
- // UpdateType sets the "type" field to the value that was provided on create.
- func (u *RedeemCodeUpsertBulk) UpdateType() *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateType()
- })
- }
- // SetValue sets the "value" field.
- func (u *RedeemCodeUpsertBulk) SetValue(v float64) *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetValue(v)
- })
- }
- // AddValue adds v to the "value" field.
- func (u *RedeemCodeUpsertBulk) AddValue(v float64) *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.AddValue(v)
- })
- }
- // UpdateValue sets the "value" field to the value that was provided on create.
- func (u *RedeemCodeUpsertBulk) UpdateValue() *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateValue()
- })
- }
- // SetStatus sets the "status" field.
- func (u *RedeemCodeUpsertBulk) SetStatus(v string) *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *RedeemCodeUpsertBulk) UpdateStatus() *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateStatus()
- })
- }
- // SetUsedBy sets the "used_by" field.
- func (u *RedeemCodeUpsertBulk) SetUsedBy(v int64) *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetUsedBy(v)
- })
- }
- // UpdateUsedBy sets the "used_by" field to the value that was provided on create.
- func (u *RedeemCodeUpsertBulk) UpdateUsedBy() *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateUsedBy()
- })
- }
- // ClearUsedBy clears the value of the "used_by" field.
- func (u *RedeemCodeUpsertBulk) ClearUsedBy() *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.ClearUsedBy()
- })
- }
- // SetUsedAt sets the "used_at" field.
- func (u *RedeemCodeUpsertBulk) SetUsedAt(v time.Time) *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetUsedAt(v)
- })
- }
- // UpdateUsedAt sets the "used_at" field to the value that was provided on create.
- func (u *RedeemCodeUpsertBulk) UpdateUsedAt() *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateUsedAt()
- })
- }
- // ClearUsedAt clears the value of the "used_at" field.
- func (u *RedeemCodeUpsertBulk) ClearUsedAt() *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.ClearUsedAt()
- })
- }
- // SetNotes sets the "notes" field.
- func (u *RedeemCodeUpsertBulk) SetNotes(v string) *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetNotes(v)
- })
- }
- // UpdateNotes sets the "notes" field to the value that was provided on create.
- func (u *RedeemCodeUpsertBulk) UpdateNotes() *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateNotes()
- })
- }
- // ClearNotes clears the value of the "notes" field.
- func (u *RedeemCodeUpsertBulk) ClearNotes() *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.ClearNotes()
- })
- }
- // SetExpiresAt sets the "expires_at" field.
- func (u *RedeemCodeUpsertBulk) SetExpiresAt(v time.Time) *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetExpiresAt(v)
- })
- }
- // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
- func (u *RedeemCodeUpsertBulk) UpdateExpiresAt() *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateExpiresAt()
- })
- }
- // ClearExpiresAt clears the value of the "expires_at" field.
- func (u *RedeemCodeUpsertBulk) ClearExpiresAt() *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.ClearExpiresAt()
- })
- }
- // SetGroupID sets the "group_id" field.
- func (u *RedeemCodeUpsertBulk) SetGroupID(v int64) *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetGroupID(v)
- })
- }
- // UpdateGroupID sets the "group_id" field to the value that was provided on create.
- func (u *RedeemCodeUpsertBulk) UpdateGroupID() *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateGroupID()
- })
- }
- // ClearGroupID clears the value of the "group_id" field.
- func (u *RedeemCodeUpsertBulk) ClearGroupID() *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.ClearGroupID()
- })
- }
- // SetValidityDays sets the "validity_days" field.
- func (u *RedeemCodeUpsertBulk) SetValidityDays(v int) *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.SetValidityDays(v)
- })
- }
- // AddValidityDays adds v to the "validity_days" field.
- func (u *RedeemCodeUpsertBulk) AddValidityDays(v int) *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.AddValidityDays(v)
- })
- }
- // UpdateValidityDays sets the "validity_days" field to the value that was provided on create.
- func (u *RedeemCodeUpsertBulk) UpdateValidityDays() *RedeemCodeUpsertBulk {
- return u.Update(func(s *RedeemCodeUpsert) {
- s.UpdateValidityDays()
- })
- }
- // Exec executes the query.
- func (u *RedeemCodeUpsertBulk) 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 RedeemCodeCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for RedeemCodeCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *RedeemCodeUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|