1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/wxcarduser"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // WxCardUserCreate is the builder for creating a WxCardUser entity.
- type WxCardUserCreate struct {
- config
- mutation *WxCardUserMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetCreatedAt sets the "created_at" field.
- func (wcuc *WxCardUserCreate) SetCreatedAt(t time.Time) *WxCardUserCreate {
- wcuc.mutation.SetCreatedAt(t)
- return wcuc
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (wcuc *WxCardUserCreate) SetNillableCreatedAt(t *time.Time) *WxCardUserCreate {
- if t != nil {
- wcuc.SetCreatedAt(*t)
- }
- return wcuc
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (wcuc *WxCardUserCreate) SetUpdatedAt(t time.Time) *WxCardUserCreate {
- wcuc.mutation.SetUpdatedAt(t)
- return wcuc
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (wcuc *WxCardUserCreate) SetNillableUpdatedAt(t *time.Time) *WxCardUserCreate {
- if t != nil {
- wcuc.SetUpdatedAt(*t)
- }
- return wcuc
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (wcuc *WxCardUserCreate) SetDeletedAt(t time.Time) *WxCardUserCreate {
- wcuc.mutation.SetDeletedAt(t)
- return wcuc
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (wcuc *WxCardUserCreate) SetNillableDeletedAt(t *time.Time) *WxCardUserCreate {
- if t != nil {
- wcuc.SetDeletedAt(*t)
- }
- return wcuc
- }
- // SetWxid sets the "wxid" field.
- func (wcuc *WxCardUserCreate) SetWxid(s string) *WxCardUserCreate {
- wcuc.mutation.SetWxid(s)
- return wcuc
- }
- // SetNillableWxid sets the "wxid" field if the given value is not nil.
- func (wcuc *WxCardUserCreate) SetNillableWxid(s *string) *WxCardUserCreate {
- if s != nil {
- wcuc.SetWxid(*s)
- }
- return wcuc
- }
- // SetAccount sets the "account" field.
- func (wcuc *WxCardUserCreate) SetAccount(s string) *WxCardUserCreate {
- wcuc.mutation.SetAccount(s)
- return wcuc
- }
- // SetNillableAccount sets the "account" field if the given value is not nil.
- func (wcuc *WxCardUserCreate) SetNillableAccount(s *string) *WxCardUserCreate {
- if s != nil {
- wcuc.SetAccount(*s)
- }
- return wcuc
- }
- // SetAvatar sets the "avatar" field.
- func (wcuc *WxCardUserCreate) SetAvatar(s string) *WxCardUserCreate {
- wcuc.mutation.SetAvatar(s)
- return wcuc
- }
- // SetNillableAvatar sets the "avatar" field if the given value is not nil.
- func (wcuc *WxCardUserCreate) SetNillableAvatar(s *string) *WxCardUserCreate {
- if s != nil {
- wcuc.SetAvatar(*s)
- }
- return wcuc
- }
- // SetNickname sets the "nickname" field.
- func (wcuc *WxCardUserCreate) SetNickname(s string) *WxCardUserCreate {
- wcuc.mutation.SetNickname(s)
- return wcuc
- }
- // SetNillableNickname sets the "nickname" field if the given value is not nil.
- func (wcuc *WxCardUserCreate) SetNillableNickname(s *string) *WxCardUserCreate {
- if s != nil {
- wcuc.SetNickname(*s)
- }
- return wcuc
- }
- // SetRemark sets the "remark" field.
- func (wcuc *WxCardUserCreate) SetRemark(s string) *WxCardUserCreate {
- wcuc.mutation.SetRemark(s)
- return wcuc
- }
- // SetNillableRemark sets the "remark" field if the given value is not nil.
- func (wcuc *WxCardUserCreate) SetNillableRemark(s *string) *WxCardUserCreate {
- if s != nil {
- wcuc.SetRemark(*s)
- }
- return wcuc
- }
- // SetPhone sets the "phone" field.
- func (wcuc *WxCardUserCreate) SetPhone(s string) *WxCardUserCreate {
- wcuc.mutation.SetPhone(s)
- return wcuc
- }
- // SetNillablePhone sets the "phone" field if the given value is not nil.
- func (wcuc *WxCardUserCreate) SetNillablePhone(s *string) *WxCardUserCreate {
- if s != nil {
- wcuc.SetPhone(*s)
- }
- return wcuc
- }
- // SetOpenID sets the "open_id" field.
- func (wcuc *WxCardUserCreate) SetOpenID(s string) *WxCardUserCreate {
- wcuc.mutation.SetOpenID(s)
- return wcuc
- }
- // SetNillableOpenID sets the "open_id" field if the given value is not nil.
- func (wcuc *WxCardUserCreate) SetNillableOpenID(s *string) *WxCardUserCreate {
- if s != nil {
- wcuc.SetOpenID(*s)
- }
- return wcuc
- }
- // SetUnionID sets the "union_id" field.
- func (wcuc *WxCardUserCreate) SetUnionID(s string) *WxCardUserCreate {
- wcuc.mutation.SetUnionID(s)
- return wcuc
- }
- // SetNillableUnionID sets the "union_id" field if the given value is not nil.
- func (wcuc *WxCardUserCreate) SetNillableUnionID(s *string) *WxCardUserCreate {
- if s != nil {
- wcuc.SetUnionID(*s)
- }
- return wcuc
- }
- // SetSessionKey sets the "session_key" field.
- func (wcuc *WxCardUserCreate) SetSessionKey(s string) *WxCardUserCreate {
- wcuc.mutation.SetSessionKey(s)
- return wcuc
- }
- // SetNillableSessionKey sets the "session_key" field if the given value is not nil.
- func (wcuc *WxCardUserCreate) SetNillableSessionKey(s *string) *WxCardUserCreate {
- if s != nil {
- wcuc.SetSessionKey(*s)
- }
- return wcuc
- }
- // SetIsVip sets the "is_vip" field.
- func (wcuc *WxCardUserCreate) SetIsVip(i int) *WxCardUserCreate {
- wcuc.mutation.SetIsVip(i)
- return wcuc
- }
- // SetNillableIsVip sets the "is_vip" field if the given value is not nil.
- func (wcuc *WxCardUserCreate) SetNillableIsVip(i *int) *WxCardUserCreate {
- if i != nil {
- wcuc.SetIsVip(*i)
- }
- return wcuc
- }
- // SetID sets the "id" field.
- func (wcuc *WxCardUserCreate) SetID(u uint64) *WxCardUserCreate {
- wcuc.mutation.SetID(u)
- return wcuc
- }
- // Mutation returns the WxCardUserMutation object of the builder.
- func (wcuc *WxCardUserCreate) Mutation() *WxCardUserMutation {
- return wcuc.mutation
- }
- // Save creates the WxCardUser in the database.
- func (wcuc *WxCardUserCreate) Save(ctx context.Context) (*WxCardUser, error) {
- if err := wcuc.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, wcuc.sqlSave, wcuc.mutation, wcuc.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (wcuc *WxCardUserCreate) SaveX(ctx context.Context) *WxCardUser {
- v, err := wcuc.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (wcuc *WxCardUserCreate) Exec(ctx context.Context) error {
- _, err := wcuc.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (wcuc *WxCardUserCreate) ExecX(ctx context.Context) {
- if err := wcuc.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (wcuc *WxCardUserCreate) defaults() error {
- if _, ok := wcuc.mutation.CreatedAt(); !ok {
- if wxcarduser.DefaultCreatedAt == nil {
- return fmt.Errorf("ent: uninitialized wxcarduser.DefaultCreatedAt (forgotten import ent/runtime?)")
- }
- v := wxcarduser.DefaultCreatedAt()
- wcuc.mutation.SetCreatedAt(v)
- }
- if _, ok := wcuc.mutation.UpdatedAt(); !ok {
- if wxcarduser.DefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized wxcarduser.DefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := wxcarduser.DefaultUpdatedAt()
- wcuc.mutation.SetUpdatedAt(v)
- }
- if _, ok := wcuc.mutation.Wxid(); !ok {
- v := wxcarduser.DefaultWxid
- wcuc.mutation.SetWxid(v)
- }
- if _, ok := wcuc.mutation.Account(); !ok {
- v := wxcarduser.DefaultAccount
- wcuc.mutation.SetAccount(v)
- }
- if _, ok := wcuc.mutation.Avatar(); !ok {
- v := wxcarduser.DefaultAvatar
- wcuc.mutation.SetAvatar(v)
- }
- if _, ok := wcuc.mutation.Nickname(); !ok {
- v := wxcarduser.DefaultNickname
- wcuc.mutation.SetNickname(v)
- }
- if _, ok := wcuc.mutation.Remark(); !ok {
- v := wxcarduser.DefaultRemark
- wcuc.mutation.SetRemark(v)
- }
- if _, ok := wcuc.mutation.Phone(); !ok {
- v := wxcarduser.DefaultPhone
- wcuc.mutation.SetPhone(v)
- }
- if _, ok := wcuc.mutation.OpenID(); !ok {
- v := wxcarduser.DefaultOpenID
- wcuc.mutation.SetOpenID(v)
- }
- if _, ok := wcuc.mutation.UnionID(); !ok {
- v := wxcarduser.DefaultUnionID
- wcuc.mutation.SetUnionID(v)
- }
- if _, ok := wcuc.mutation.SessionKey(); !ok {
- v := wxcarduser.DefaultSessionKey
- wcuc.mutation.SetSessionKey(v)
- }
- if _, ok := wcuc.mutation.IsVip(); !ok {
- v := wxcarduser.DefaultIsVip
- wcuc.mutation.SetIsVip(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (wcuc *WxCardUserCreate) check() error {
- if _, ok := wcuc.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "WxCardUser.created_at"`)}
- }
- if _, ok := wcuc.mutation.UpdatedAt(); !ok {
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "WxCardUser.updated_at"`)}
- }
- if _, ok := wcuc.mutation.Wxid(); !ok {
- return &ValidationError{Name: "wxid", err: errors.New(`ent: missing required field "WxCardUser.wxid"`)}
- }
- if _, ok := wcuc.mutation.Account(); !ok {
- return &ValidationError{Name: "account", err: errors.New(`ent: missing required field "WxCardUser.account"`)}
- }
- if _, ok := wcuc.mutation.Avatar(); !ok {
- return &ValidationError{Name: "avatar", err: errors.New(`ent: missing required field "WxCardUser.avatar"`)}
- }
- if _, ok := wcuc.mutation.Nickname(); !ok {
- return &ValidationError{Name: "nickname", err: errors.New(`ent: missing required field "WxCardUser.nickname"`)}
- }
- if _, ok := wcuc.mutation.Remark(); !ok {
- return &ValidationError{Name: "remark", err: errors.New(`ent: missing required field "WxCardUser.remark"`)}
- }
- if _, ok := wcuc.mutation.Phone(); !ok {
- return &ValidationError{Name: "phone", err: errors.New(`ent: missing required field "WxCardUser.phone"`)}
- }
- if _, ok := wcuc.mutation.OpenID(); !ok {
- return &ValidationError{Name: "open_id", err: errors.New(`ent: missing required field "WxCardUser.open_id"`)}
- }
- if _, ok := wcuc.mutation.UnionID(); !ok {
- return &ValidationError{Name: "union_id", err: errors.New(`ent: missing required field "WxCardUser.union_id"`)}
- }
- if _, ok := wcuc.mutation.SessionKey(); !ok {
- return &ValidationError{Name: "session_key", err: errors.New(`ent: missing required field "WxCardUser.session_key"`)}
- }
- if _, ok := wcuc.mutation.IsVip(); !ok {
- return &ValidationError{Name: "is_vip", err: errors.New(`ent: missing required field "WxCardUser.is_vip"`)}
- }
- return nil
- }
- func (wcuc *WxCardUserCreate) sqlSave(ctx context.Context) (*WxCardUser, error) {
- if err := wcuc.check(); err != nil {
- return nil, err
- }
- _node, _spec := wcuc.createSpec()
- if err := sqlgraph.CreateNode(ctx, wcuc.driver, _spec); err != nil {
- if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- if _spec.ID.Value != _node.ID {
- id := _spec.ID.Value.(int64)
- _node.ID = uint64(id)
- }
- wcuc.mutation.id = &_node.ID
- wcuc.mutation.done = true
- return _node, nil
- }
- func (wcuc *WxCardUserCreate) createSpec() (*WxCardUser, *sqlgraph.CreateSpec) {
- var (
- _node = &WxCardUser{config: wcuc.config}
- _spec = sqlgraph.NewCreateSpec(wxcarduser.Table, sqlgraph.NewFieldSpec(wxcarduser.FieldID, field.TypeUint64))
- )
- _spec.OnConflict = wcuc.conflict
- if id, ok := wcuc.mutation.ID(); ok {
- _node.ID = id
- _spec.ID.Value = id
- }
- if value, ok := wcuc.mutation.CreatedAt(); ok {
- _spec.SetField(wxcarduser.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if value, ok := wcuc.mutation.UpdatedAt(); ok {
- _spec.SetField(wxcarduser.FieldUpdatedAt, field.TypeTime, value)
- _node.UpdatedAt = value
- }
- if value, ok := wcuc.mutation.DeletedAt(); ok {
- _spec.SetField(wxcarduser.FieldDeletedAt, field.TypeTime, value)
- _node.DeletedAt = value
- }
- if value, ok := wcuc.mutation.Wxid(); ok {
- _spec.SetField(wxcarduser.FieldWxid, field.TypeString, value)
- _node.Wxid = value
- }
- if value, ok := wcuc.mutation.Account(); ok {
- _spec.SetField(wxcarduser.FieldAccount, field.TypeString, value)
- _node.Account = value
- }
- if value, ok := wcuc.mutation.Avatar(); ok {
- _spec.SetField(wxcarduser.FieldAvatar, field.TypeString, value)
- _node.Avatar = value
- }
- if value, ok := wcuc.mutation.Nickname(); ok {
- _spec.SetField(wxcarduser.FieldNickname, field.TypeString, value)
- _node.Nickname = value
- }
- if value, ok := wcuc.mutation.Remark(); ok {
- _spec.SetField(wxcarduser.FieldRemark, field.TypeString, value)
- _node.Remark = value
- }
- if value, ok := wcuc.mutation.Phone(); ok {
- _spec.SetField(wxcarduser.FieldPhone, field.TypeString, value)
- _node.Phone = value
- }
- if value, ok := wcuc.mutation.OpenID(); ok {
- _spec.SetField(wxcarduser.FieldOpenID, field.TypeString, value)
- _node.OpenID = value
- }
- if value, ok := wcuc.mutation.UnionID(); ok {
- _spec.SetField(wxcarduser.FieldUnionID, field.TypeString, value)
- _node.UnionID = value
- }
- if value, ok := wcuc.mutation.SessionKey(); ok {
- _spec.SetField(wxcarduser.FieldSessionKey, field.TypeString, value)
- _node.SessionKey = value
- }
- if value, ok := wcuc.mutation.IsVip(); ok {
- _spec.SetField(wxcarduser.FieldIsVip, field.TypeInt, value)
- _node.IsVip = value
- }
- return _node, _spec
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.WxCardUser.Create().
- // SetCreatedAt(v).
- // OnConflict(
- // // Update the row with the new values
- // // the was proposed for insertion.
- // sql.ResolveWithNewValues(),
- // ).
- // // Override some of the fields with custom
- // // update values.
- // Update(func(u *ent.WxCardUserUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (wcuc *WxCardUserCreate) OnConflict(opts ...sql.ConflictOption) *WxCardUserUpsertOne {
- wcuc.conflict = opts
- return &WxCardUserUpsertOne{
- create: wcuc,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.WxCardUser.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (wcuc *WxCardUserCreate) OnConflictColumns(columns ...string) *WxCardUserUpsertOne {
- wcuc.conflict = append(wcuc.conflict, sql.ConflictColumns(columns...))
- return &WxCardUserUpsertOne{
- create: wcuc,
- }
- }
- type (
- // WxCardUserUpsertOne is the builder for "upsert"-ing
- // one WxCardUser node.
- WxCardUserUpsertOne struct {
- create *WxCardUserCreate
- }
- // WxCardUserUpsert is the "OnConflict" setter.
- WxCardUserUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetUpdatedAt sets the "updated_at" field.
- func (u *WxCardUserUpsert) SetUpdatedAt(v time.Time) *WxCardUserUpsert {
- u.Set(wxcarduser.FieldUpdatedAt, v)
- return u
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *WxCardUserUpsert) UpdateUpdatedAt() *WxCardUserUpsert {
- u.SetExcluded(wxcarduser.FieldUpdatedAt)
- return u
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *WxCardUserUpsert) SetDeletedAt(v time.Time) *WxCardUserUpsert {
- u.Set(wxcarduser.FieldDeletedAt, v)
- return u
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *WxCardUserUpsert) UpdateDeletedAt() *WxCardUserUpsert {
- u.SetExcluded(wxcarduser.FieldDeletedAt)
- return u
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *WxCardUserUpsert) ClearDeletedAt() *WxCardUserUpsert {
- u.SetNull(wxcarduser.FieldDeletedAt)
- return u
- }
- // SetWxid sets the "wxid" field.
- func (u *WxCardUserUpsert) SetWxid(v string) *WxCardUserUpsert {
- u.Set(wxcarduser.FieldWxid, v)
- return u
- }
- // UpdateWxid sets the "wxid" field to the value that was provided on create.
- func (u *WxCardUserUpsert) UpdateWxid() *WxCardUserUpsert {
- u.SetExcluded(wxcarduser.FieldWxid)
- return u
- }
- // SetAccount sets the "account" field.
- func (u *WxCardUserUpsert) SetAccount(v string) *WxCardUserUpsert {
- u.Set(wxcarduser.FieldAccount, v)
- return u
- }
- // UpdateAccount sets the "account" field to the value that was provided on create.
- func (u *WxCardUserUpsert) UpdateAccount() *WxCardUserUpsert {
- u.SetExcluded(wxcarduser.FieldAccount)
- return u
- }
- // SetAvatar sets the "avatar" field.
- func (u *WxCardUserUpsert) SetAvatar(v string) *WxCardUserUpsert {
- u.Set(wxcarduser.FieldAvatar, v)
- return u
- }
- // UpdateAvatar sets the "avatar" field to the value that was provided on create.
- func (u *WxCardUserUpsert) UpdateAvatar() *WxCardUserUpsert {
- u.SetExcluded(wxcarduser.FieldAvatar)
- return u
- }
- // SetNickname sets the "nickname" field.
- func (u *WxCardUserUpsert) SetNickname(v string) *WxCardUserUpsert {
- u.Set(wxcarduser.FieldNickname, v)
- return u
- }
- // UpdateNickname sets the "nickname" field to the value that was provided on create.
- func (u *WxCardUserUpsert) UpdateNickname() *WxCardUserUpsert {
- u.SetExcluded(wxcarduser.FieldNickname)
- return u
- }
- // SetRemark sets the "remark" field.
- func (u *WxCardUserUpsert) SetRemark(v string) *WxCardUserUpsert {
- u.Set(wxcarduser.FieldRemark, v)
- return u
- }
- // UpdateRemark sets the "remark" field to the value that was provided on create.
- func (u *WxCardUserUpsert) UpdateRemark() *WxCardUserUpsert {
- u.SetExcluded(wxcarduser.FieldRemark)
- return u
- }
- // SetPhone sets the "phone" field.
- func (u *WxCardUserUpsert) SetPhone(v string) *WxCardUserUpsert {
- u.Set(wxcarduser.FieldPhone, v)
- return u
- }
- // UpdatePhone sets the "phone" field to the value that was provided on create.
- func (u *WxCardUserUpsert) UpdatePhone() *WxCardUserUpsert {
- u.SetExcluded(wxcarduser.FieldPhone)
- return u
- }
- // SetOpenID sets the "open_id" field.
- func (u *WxCardUserUpsert) SetOpenID(v string) *WxCardUserUpsert {
- u.Set(wxcarduser.FieldOpenID, v)
- return u
- }
- // UpdateOpenID sets the "open_id" field to the value that was provided on create.
- func (u *WxCardUserUpsert) UpdateOpenID() *WxCardUserUpsert {
- u.SetExcluded(wxcarduser.FieldOpenID)
- return u
- }
- // SetUnionID sets the "union_id" field.
- func (u *WxCardUserUpsert) SetUnionID(v string) *WxCardUserUpsert {
- u.Set(wxcarduser.FieldUnionID, v)
- return u
- }
- // UpdateUnionID sets the "union_id" field to the value that was provided on create.
- func (u *WxCardUserUpsert) UpdateUnionID() *WxCardUserUpsert {
- u.SetExcluded(wxcarduser.FieldUnionID)
- return u
- }
- // SetSessionKey sets the "session_key" field.
- func (u *WxCardUserUpsert) SetSessionKey(v string) *WxCardUserUpsert {
- u.Set(wxcarduser.FieldSessionKey, v)
- return u
- }
- // UpdateSessionKey sets the "session_key" field to the value that was provided on create.
- func (u *WxCardUserUpsert) UpdateSessionKey() *WxCardUserUpsert {
- u.SetExcluded(wxcarduser.FieldSessionKey)
- return u
- }
- // SetIsVip sets the "is_vip" field.
- func (u *WxCardUserUpsert) SetIsVip(v int) *WxCardUserUpsert {
- u.Set(wxcarduser.FieldIsVip, v)
- return u
- }
- // UpdateIsVip sets the "is_vip" field to the value that was provided on create.
- func (u *WxCardUserUpsert) UpdateIsVip() *WxCardUserUpsert {
- u.SetExcluded(wxcarduser.FieldIsVip)
- return u
- }
- // AddIsVip adds v to the "is_vip" field.
- func (u *WxCardUserUpsert) AddIsVip(v int) *WxCardUserUpsert {
- u.Add(wxcarduser.FieldIsVip, v)
- return u
- }
- // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
- // Using this option is equivalent to using:
- //
- // client.WxCardUser.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(wxcarduser.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *WxCardUserUpsertOne) UpdateNewValues() *WxCardUserUpsertOne {
- 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.ID(); exists {
- s.SetIgnore(wxcarduser.FieldID)
- }
- if _, exists := u.create.mutation.CreatedAt(); exists {
- s.SetIgnore(wxcarduser.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.WxCardUser.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *WxCardUserUpsertOne) Ignore() *WxCardUserUpsertOne {
- 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 *WxCardUserUpsertOne) DoNothing() *WxCardUserUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the WxCardUserCreate.OnConflict
- // documentation for more info.
- func (u *WxCardUserUpsertOne) Update(set func(*WxCardUserUpsert)) *WxCardUserUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&WxCardUserUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *WxCardUserUpsertOne) SetUpdatedAt(v time.Time) *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *WxCardUserUpsertOne) UpdateUpdatedAt() *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *WxCardUserUpsertOne) SetDeletedAt(v time.Time) *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *WxCardUserUpsertOne) UpdateDeletedAt() *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *WxCardUserUpsertOne) ClearDeletedAt() *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetWxid sets the "wxid" field.
- func (u *WxCardUserUpsertOne) SetWxid(v string) *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetWxid(v)
- })
- }
- // UpdateWxid sets the "wxid" field to the value that was provided on create.
- func (u *WxCardUserUpsertOne) UpdateWxid() *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateWxid()
- })
- }
- // SetAccount sets the "account" field.
- func (u *WxCardUserUpsertOne) SetAccount(v string) *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetAccount(v)
- })
- }
- // UpdateAccount sets the "account" field to the value that was provided on create.
- func (u *WxCardUserUpsertOne) UpdateAccount() *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateAccount()
- })
- }
- // SetAvatar sets the "avatar" field.
- func (u *WxCardUserUpsertOne) SetAvatar(v string) *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetAvatar(v)
- })
- }
- // UpdateAvatar sets the "avatar" field to the value that was provided on create.
- func (u *WxCardUserUpsertOne) UpdateAvatar() *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateAvatar()
- })
- }
- // SetNickname sets the "nickname" field.
- func (u *WxCardUserUpsertOne) SetNickname(v string) *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetNickname(v)
- })
- }
- // UpdateNickname sets the "nickname" field to the value that was provided on create.
- func (u *WxCardUserUpsertOne) UpdateNickname() *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateNickname()
- })
- }
- // SetRemark sets the "remark" field.
- func (u *WxCardUserUpsertOne) SetRemark(v string) *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetRemark(v)
- })
- }
- // UpdateRemark sets the "remark" field to the value that was provided on create.
- func (u *WxCardUserUpsertOne) UpdateRemark() *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateRemark()
- })
- }
- // SetPhone sets the "phone" field.
- func (u *WxCardUserUpsertOne) SetPhone(v string) *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetPhone(v)
- })
- }
- // UpdatePhone sets the "phone" field to the value that was provided on create.
- func (u *WxCardUserUpsertOne) UpdatePhone() *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdatePhone()
- })
- }
- // SetOpenID sets the "open_id" field.
- func (u *WxCardUserUpsertOne) SetOpenID(v string) *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetOpenID(v)
- })
- }
- // UpdateOpenID sets the "open_id" field to the value that was provided on create.
- func (u *WxCardUserUpsertOne) UpdateOpenID() *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateOpenID()
- })
- }
- // SetUnionID sets the "union_id" field.
- func (u *WxCardUserUpsertOne) SetUnionID(v string) *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetUnionID(v)
- })
- }
- // UpdateUnionID sets the "union_id" field to the value that was provided on create.
- func (u *WxCardUserUpsertOne) UpdateUnionID() *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateUnionID()
- })
- }
- // SetSessionKey sets the "session_key" field.
- func (u *WxCardUserUpsertOne) SetSessionKey(v string) *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetSessionKey(v)
- })
- }
- // UpdateSessionKey sets the "session_key" field to the value that was provided on create.
- func (u *WxCardUserUpsertOne) UpdateSessionKey() *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateSessionKey()
- })
- }
- // SetIsVip sets the "is_vip" field.
- func (u *WxCardUserUpsertOne) SetIsVip(v int) *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetIsVip(v)
- })
- }
- // AddIsVip adds v to the "is_vip" field.
- func (u *WxCardUserUpsertOne) AddIsVip(v int) *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.AddIsVip(v)
- })
- }
- // UpdateIsVip sets the "is_vip" field to the value that was provided on create.
- func (u *WxCardUserUpsertOne) UpdateIsVip() *WxCardUserUpsertOne {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateIsVip()
- })
- }
- // Exec executes the query.
- func (u *WxCardUserUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for WxCardUserCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *WxCardUserUpsertOne) 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 *WxCardUserUpsertOne) ID(ctx context.Context) (id uint64, 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 *WxCardUserUpsertOne) IDX(ctx context.Context) uint64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // WxCardUserCreateBulk is the builder for creating many WxCardUser entities in bulk.
- type WxCardUserCreateBulk struct {
- config
- err error
- builders []*WxCardUserCreate
- conflict []sql.ConflictOption
- }
- // Save creates the WxCardUser entities in the database.
- func (wcucb *WxCardUserCreateBulk) Save(ctx context.Context) ([]*WxCardUser, error) {
- if wcucb.err != nil {
- return nil, wcucb.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(wcucb.builders))
- nodes := make([]*WxCardUser, len(wcucb.builders))
- mutators := make([]Mutator, len(wcucb.builders))
- for i := range wcucb.builders {
- func(i int, root context.Context) {
- builder := wcucb.builders[i]
- builder.defaults()
- var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
- mutation, ok := m.(*WxCardUserMutation)
- 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, wcucb.builders[i+1].mutation)
- } else {
- spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
- spec.OnConflict = wcucb.conflict
- // Invoke the actual operation on the latest mutation in the chain.
- if err = sqlgraph.BatchCreate(ctx, wcucb.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 && nodes[i].ID == 0 {
- id := specs[i].ID.Value.(int64)
- nodes[i].ID = uint64(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, wcucb.builders[0].mutation); err != nil {
- return nil, err
- }
- }
- return nodes, nil
- }
- // SaveX is like Save, but panics if an error occurs.
- func (wcucb *WxCardUserCreateBulk) SaveX(ctx context.Context) []*WxCardUser {
- v, err := wcucb.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (wcucb *WxCardUserCreateBulk) Exec(ctx context.Context) error {
- _, err := wcucb.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (wcucb *WxCardUserCreateBulk) ExecX(ctx context.Context) {
- if err := wcucb.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.WxCardUser.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.WxCardUserUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (wcucb *WxCardUserCreateBulk) OnConflict(opts ...sql.ConflictOption) *WxCardUserUpsertBulk {
- wcucb.conflict = opts
- return &WxCardUserUpsertBulk{
- create: wcucb,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.WxCardUser.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (wcucb *WxCardUserCreateBulk) OnConflictColumns(columns ...string) *WxCardUserUpsertBulk {
- wcucb.conflict = append(wcucb.conflict, sql.ConflictColumns(columns...))
- return &WxCardUserUpsertBulk{
- create: wcucb,
- }
- }
- // WxCardUserUpsertBulk is the builder for "upsert"-ing
- // a bulk of WxCardUser nodes.
- type WxCardUserUpsertBulk struct {
- create *WxCardUserCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.WxCardUser.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(wxcarduser.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *WxCardUserUpsertBulk) UpdateNewValues() *WxCardUserUpsertBulk {
- 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.ID(); exists {
- s.SetIgnore(wxcarduser.FieldID)
- }
- if _, exists := b.mutation.CreatedAt(); exists {
- s.SetIgnore(wxcarduser.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.WxCardUser.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *WxCardUserUpsertBulk) Ignore() *WxCardUserUpsertBulk {
- 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 *WxCardUserUpsertBulk) DoNothing() *WxCardUserUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the WxCardUserCreateBulk.OnConflict
- // documentation for more info.
- func (u *WxCardUserUpsertBulk) Update(set func(*WxCardUserUpsert)) *WxCardUserUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&WxCardUserUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *WxCardUserUpsertBulk) SetUpdatedAt(v time.Time) *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *WxCardUserUpsertBulk) UpdateUpdatedAt() *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *WxCardUserUpsertBulk) SetDeletedAt(v time.Time) *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *WxCardUserUpsertBulk) UpdateDeletedAt() *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *WxCardUserUpsertBulk) ClearDeletedAt() *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetWxid sets the "wxid" field.
- func (u *WxCardUserUpsertBulk) SetWxid(v string) *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetWxid(v)
- })
- }
- // UpdateWxid sets the "wxid" field to the value that was provided on create.
- func (u *WxCardUserUpsertBulk) UpdateWxid() *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateWxid()
- })
- }
- // SetAccount sets the "account" field.
- func (u *WxCardUserUpsertBulk) SetAccount(v string) *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetAccount(v)
- })
- }
- // UpdateAccount sets the "account" field to the value that was provided on create.
- func (u *WxCardUserUpsertBulk) UpdateAccount() *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateAccount()
- })
- }
- // SetAvatar sets the "avatar" field.
- func (u *WxCardUserUpsertBulk) SetAvatar(v string) *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetAvatar(v)
- })
- }
- // UpdateAvatar sets the "avatar" field to the value that was provided on create.
- func (u *WxCardUserUpsertBulk) UpdateAvatar() *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateAvatar()
- })
- }
- // SetNickname sets the "nickname" field.
- func (u *WxCardUserUpsertBulk) SetNickname(v string) *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetNickname(v)
- })
- }
- // UpdateNickname sets the "nickname" field to the value that was provided on create.
- func (u *WxCardUserUpsertBulk) UpdateNickname() *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateNickname()
- })
- }
- // SetRemark sets the "remark" field.
- func (u *WxCardUserUpsertBulk) SetRemark(v string) *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetRemark(v)
- })
- }
- // UpdateRemark sets the "remark" field to the value that was provided on create.
- func (u *WxCardUserUpsertBulk) UpdateRemark() *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateRemark()
- })
- }
- // SetPhone sets the "phone" field.
- func (u *WxCardUserUpsertBulk) SetPhone(v string) *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetPhone(v)
- })
- }
- // UpdatePhone sets the "phone" field to the value that was provided on create.
- func (u *WxCardUserUpsertBulk) UpdatePhone() *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdatePhone()
- })
- }
- // SetOpenID sets the "open_id" field.
- func (u *WxCardUserUpsertBulk) SetOpenID(v string) *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetOpenID(v)
- })
- }
- // UpdateOpenID sets the "open_id" field to the value that was provided on create.
- func (u *WxCardUserUpsertBulk) UpdateOpenID() *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateOpenID()
- })
- }
- // SetUnionID sets the "union_id" field.
- func (u *WxCardUserUpsertBulk) SetUnionID(v string) *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetUnionID(v)
- })
- }
- // UpdateUnionID sets the "union_id" field to the value that was provided on create.
- func (u *WxCardUserUpsertBulk) UpdateUnionID() *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateUnionID()
- })
- }
- // SetSessionKey sets the "session_key" field.
- func (u *WxCardUserUpsertBulk) SetSessionKey(v string) *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetSessionKey(v)
- })
- }
- // UpdateSessionKey sets the "session_key" field to the value that was provided on create.
- func (u *WxCardUserUpsertBulk) UpdateSessionKey() *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateSessionKey()
- })
- }
- // SetIsVip sets the "is_vip" field.
- func (u *WxCardUserUpsertBulk) SetIsVip(v int) *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.SetIsVip(v)
- })
- }
- // AddIsVip adds v to the "is_vip" field.
- func (u *WxCardUserUpsertBulk) AddIsVip(v int) *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.AddIsVip(v)
- })
- }
- // UpdateIsVip sets the "is_vip" field to the value that was provided on create.
- func (u *WxCardUserUpsertBulk) UpdateIsVip() *WxCardUserUpsertBulk {
- return u.Update(func(s *WxCardUserUpsert) {
- s.UpdateIsVip()
- })
- }
- // Exec executes the query.
- func (u *WxCardUserUpsertBulk) 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 WxCardUserCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for WxCardUserCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *WxCardUserUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|