1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/agent"
- "wechat-api/ent/whatsapp"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // WhatsappCreate is the builder for creating a Whatsapp entity.
- type WhatsappCreate struct {
- config
- mutation *WhatsappMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetCreatedAt sets the "created_at" field.
- func (wc *WhatsappCreate) SetCreatedAt(t time.Time) *WhatsappCreate {
- wc.mutation.SetCreatedAt(t)
- return wc
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillableCreatedAt(t *time.Time) *WhatsappCreate {
- if t != nil {
- wc.SetCreatedAt(*t)
- }
- return wc
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (wc *WhatsappCreate) SetUpdatedAt(t time.Time) *WhatsappCreate {
- wc.mutation.SetUpdatedAt(t)
- return wc
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillableUpdatedAt(t *time.Time) *WhatsappCreate {
- if t != nil {
- wc.SetUpdatedAt(*t)
- }
- return wc
- }
- // SetStatus sets the "status" field.
- func (wc *WhatsappCreate) SetStatus(u uint8) *WhatsappCreate {
- wc.mutation.SetStatus(u)
- return wc
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillableStatus(u *uint8) *WhatsappCreate {
- if u != nil {
- wc.SetStatus(*u)
- }
- return wc
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (wc *WhatsappCreate) SetDeletedAt(t time.Time) *WhatsappCreate {
- wc.mutation.SetDeletedAt(t)
- return wc
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillableDeletedAt(t *time.Time) *WhatsappCreate {
- if t != nil {
- wc.SetDeletedAt(*t)
- }
- return wc
- }
- // SetWaID sets the "wa_id" field.
- func (wc *WhatsappCreate) SetWaID(s string) *WhatsappCreate {
- wc.mutation.SetWaID(s)
- return wc
- }
- // SetNillableWaID sets the "wa_id" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillableWaID(s *string) *WhatsappCreate {
- if s != nil {
- wc.SetWaID(*s)
- }
- return wc
- }
- // SetWaName sets the "wa_name" field.
- func (wc *WhatsappCreate) SetWaName(s string) *WhatsappCreate {
- wc.mutation.SetWaName(s)
- return wc
- }
- // SetNillableWaName sets the "wa_name" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillableWaName(s *string) *WhatsappCreate {
- if s != nil {
- wc.SetWaName(*s)
- }
- return wc
- }
- // SetCallback sets the "callback" field.
- func (wc *WhatsappCreate) SetCallback(s string) *WhatsappCreate {
- wc.mutation.SetCallback(s)
- return wc
- }
- // SetNillableCallback sets the "callback" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillableCallback(s *string) *WhatsappCreate {
- if s != nil {
- wc.SetCallback(*s)
- }
- return wc
- }
- // SetAgentID sets the "agent_id" field.
- func (wc *WhatsappCreate) SetAgentID(u uint64) *WhatsappCreate {
- wc.mutation.SetAgentID(u)
- return wc
- }
- // SetNillableAgentID sets the "agent_id" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillableAgentID(u *uint64) *WhatsappCreate {
- if u != nil {
- wc.SetAgentID(*u)
- }
- return wc
- }
- // SetAccount sets the "account" field.
- func (wc *WhatsappCreate) SetAccount(s string) *WhatsappCreate {
- wc.mutation.SetAccount(s)
- return wc
- }
- // SetNillableAccount sets the "account" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillableAccount(s *string) *WhatsappCreate {
- if s != nil {
- wc.SetAccount(*s)
- }
- return wc
- }
- // SetCc sets the "cc" field.
- func (wc *WhatsappCreate) SetCc(s string) *WhatsappCreate {
- wc.mutation.SetCc(s)
- return wc
- }
- // SetNillableCc sets the "cc" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillableCc(s *string) *WhatsappCreate {
- if s != nil {
- wc.SetCc(*s)
- }
- return wc
- }
- // SetPhone sets the "phone" field.
- func (wc *WhatsappCreate) SetPhone(s string) *WhatsappCreate {
- wc.mutation.SetPhone(s)
- return wc
- }
- // SetNillablePhone sets the "phone" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillablePhone(s *string) *WhatsappCreate {
- if s != nil {
- wc.SetPhone(*s)
- }
- return wc
- }
- // SetCcPhone sets the "cc_phone" field.
- func (wc *WhatsappCreate) SetCcPhone(s string) *WhatsappCreate {
- wc.mutation.SetCcPhone(s)
- return wc
- }
- // SetNillableCcPhone sets the "cc_phone" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillableCcPhone(s *string) *WhatsappCreate {
- if s != nil {
- wc.SetCcPhone(*s)
- }
- return wc
- }
- // SetPhoneName sets the "phone_name" field.
- func (wc *WhatsappCreate) SetPhoneName(s string) *WhatsappCreate {
- wc.mutation.SetPhoneName(s)
- return wc
- }
- // SetNillablePhoneName sets the "phone_name" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillablePhoneName(s *string) *WhatsappCreate {
- if s != nil {
- wc.SetPhoneName(*s)
- }
- return wc
- }
- // SetPhoneStatus sets the "phone_status" field.
- func (wc *WhatsappCreate) SetPhoneStatus(i int8) *WhatsappCreate {
- wc.mutation.SetPhoneStatus(i)
- return wc
- }
- // SetNillablePhoneStatus sets the "phone_status" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillablePhoneStatus(i *int8) *WhatsappCreate {
- if i != nil {
- wc.SetPhoneStatus(*i)
- }
- return wc
- }
- // SetOrganizationID sets the "organization_id" field.
- func (wc *WhatsappCreate) SetOrganizationID(u uint64) *WhatsappCreate {
- wc.mutation.SetOrganizationID(u)
- return wc
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillableOrganizationID(u *uint64) *WhatsappCreate {
- if u != nil {
- wc.SetOrganizationID(*u)
- }
- return wc
- }
- // SetAPIBase sets the "api_base" field.
- func (wc *WhatsappCreate) SetAPIBase(s string) *WhatsappCreate {
- wc.mutation.SetAPIBase(s)
- return wc
- }
- // SetNillableAPIBase sets the "api_base" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillableAPIBase(s *string) *WhatsappCreate {
- if s != nil {
- wc.SetAPIBase(*s)
- }
- return wc
- }
- // SetAPIKey sets the "api_key" field.
- func (wc *WhatsappCreate) SetAPIKey(s string) *WhatsappCreate {
- wc.mutation.SetAPIKey(s)
- return wc
- }
- // SetNillableAPIKey sets the "api_key" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillableAPIKey(s *string) *WhatsappCreate {
- if s != nil {
- wc.SetAPIKey(*s)
- }
- return wc
- }
- // SetAllowList sets the "allow_list" field.
- func (wc *WhatsappCreate) SetAllowList(s []string) *WhatsappCreate {
- wc.mutation.SetAllowList(s)
- return wc
- }
- // SetGroupAllowList sets the "group_allow_list" field.
- func (wc *WhatsappCreate) SetGroupAllowList(s []string) *WhatsappCreate {
- wc.mutation.SetGroupAllowList(s)
- return wc
- }
- // SetBlockList sets the "block_list" field.
- func (wc *WhatsappCreate) SetBlockList(s []string) *WhatsappCreate {
- wc.mutation.SetBlockList(s)
- return wc
- }
- // SetGroupBlockList sets the "group_block_list" field.
- func (wc *WhatsappCreate) SetGroupBlockList(s []string) *WhatsappCreate {
- wc.mutation.SetGroupBlockList(s)
- return wc
- }
- // SetID sets the "id" field.
- func (wc *WhatsappCreate) SetID(u uint64) *WhatsappCreate {
- wc.mutation.SetID(u)
- return wc
- }
- // SetAgent sets the "agent" edge to the Agent entity.
- func (wc *WhatsappCreate) SetAgent(a *Agent) *WhatsappCreate {
- return wc.SetAgentID(a.ID)
- }
- // Mutation returns the WhatsappMutation object of the builder.
- func (wc *WhatsappCreate) Mutation() *WhatsappMutation {
- return wc.mutation
- }
- // Save creates the Whatsapp in the database.
- func (wc *WhatsappCreate) Save(ctx context.Context) (*Whatsapp, error) {
- if err := wc.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, wc.sqlSave, wc.mutation, wc.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (wc *WhatsappCreate) SaveX(ctx context.Context) *Whatsapp {
- v, err := wc.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (wc *WhatsappCreate) Exec(ctx context.Context) error {
- _, err := wc.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (wc *WhatsappCreate) ExecX(ctx context.Context) {
- if err := wc.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (wc *WhatsappCreate) defaults() error {
- if _, ok := wc.mutation.CreatedAt(); !ok {
- if whatsapp.DefaultCreatedAt == nil {
- return fmt.Errorf("ent: uninitialized whatsapp.DefaultCreatedAt (forgotten import ent/runtime?)")
- }
- v := whatsapp.DefaultCreatedAt()
- wc.mutation.SetCreatedAt(v)
- }
- if _, ok := wc.mutation.UpdatedAt(); !ok {
- if whatsapp.DefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized whatsapp.DefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := whatsapp.DefaultUpdatedAt()
- wc.mutation.SetUpdatedAt(v)
- }
- if _, ok := wc.mutation.Status(); !ok {
- v := whatsapp.DefaultStatus
- wc.mutation.SetStatus(v)
- }
- if _, ok := wc.mutation.WaID(); !ok {
- v := whatsapp.DefaultWaID
- wc.mutation.SetWaID(v)
- }
- if _, ok := wc.mutation.WaName(); !ok {
- v := whatsapp.DefaultWaName
- wc.mutation.SetWaName(v)
- }
- if _, ok := wc.mutation.Callback(); !ok {
- v := whatsapp.DefaultCallback
- wc.mutation.SetCallback(v)
- }
- if _, ok := wc.mutation.AgentID(); !ok {
- v := whatsapp.DefaultAgentID
- wc.mutation.SetAgentID(v)
- }
- if _, ok := wc.mutation.Account(); !ok {
- v := whatsapp.DefaultAccount
- wc.mutation.SetAccount(v)
- }
- if _, ok := wc.mutation.Cc(); !ok {
- v := whatsapp.DefaultCc
- wc.mutation.SetCc(v)
- }
- if _, ok := wc.mutation.Phone(); !ok {
- v := whatsapp.DefaultPhone
- wc.mutation.SetPhone(v)
- }
- if _, ok := wc.mutation.CcPhone(); !ok {
- v := whatsapp.DefaultCcPhone
- wc.mutation.SetCcPhone(v)
- }
- if _, ok := wc.mutation.PhoneName(); !ok {
- v := whatsapp.DefaultPhoneName
- wc.mutation.SetPhoneName(v)
- }
- if _, ok := wc.mutation.PhoneStatus(); !ok {
- v := whatsapp.DefaultPhoneStatus
- wc.mutation.SetPhoneStatus(v)
- }
- if _, ok := wc.mutation.OrganizationID(); !ok {
- v := whatsapp.DefaultOrganizationID
- wc.mutation.SetOrganizationID(v)
- }
- if _, ok := wc.mutation.APIBase(); !ok {
- v := whatsapp.DefaultAPIBase
- wc.mutation.SetAPIBase(v)
- }
- if _, ok := wc.mutation.APIKey(); !ok {
- v := whatsapp.DefaultAPIKey
- wc.mutation.SetAPIKey(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (wc *WhatsappCreate) check() error {
- if _, ok := wc.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Whatsapp.created_at"`)}
- }
- if _, ok := wc.mutation.UpdatedAt(); !ok {
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Whatsapp.updated_at"`)}
- }
- if _, ok := wc.mutation.AgentID(); !ok {
- return &ValidationError{Name: "agent_id", err: errors.New(`ent: missing required field "Whatsapp.agent_id"`)}
- }
- if _, ok := wc.mutation.Cc(); !ok {
- return &ValidationError{Name: "cc", err: errors.New(`ent: missing required field "Whatsapp.cc"`)}
- }
- if _, ok := wc.mutation.Phone(); !ok {
- return &ValidationError{Name: "phone", err: errors.New(`ent: missing required field "Whatsapp.phone"`)}
- }
- if _, ok := wc.mutation.CcPhone(); !ok {
- return &ValidationError{Name: "cc_phone", err: errors.New(`ent: missing required field "Whatsapp.cc_phone"`)}
- }
- if _, ok := wc.mutation.PhoneName(); !ok {
- return &ValidationError{Name: "phone_name", err: errors.New(`ent: missing required field "Whatsapp.phone_name"`)}
- }
- if _, ok := wc.mutation.PhoneStatus(); !ok {
- return &ValidationError{Name: "phone_status", err: errors.New(`ent: missing required field "Whatsapp.phone_status"`)}
- }
- if _, ok := wc.mutation.AgentID(); !ok {
- return &ValidationError{Name: "agent", err: errors.New(`ent: missing required edge "Whatsapp.agent"`)}
- }
- return nil
- }
- func (wc *WhatsappCreate) sqlSave(ctx context.Context) (*Whatsapp, error) {
- if err := wc.check(); err != nil {
- return nil, err
- }
- _node, _spec := wc.createSpec()
- if err := sqlgraph.CreateNode(ctx, wc.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)
- }
- wc.mutation.id = &_node.ID
- wc.mutation.done = true
- return _node, nil
- }
- func (wc *WhatsappCreate) createSpec() (*Whatsapp, *sqlgraph.CreateSpec) {
- var (
- _node = &Whatsapp{config: wc.config}
- _spec = sqlgraph.NewCreateSpec(whatsapp.Table, sqlgraph.NewFieldSpec(whatsapp.FieldID, field.TypeUint64))
- )
- _spec.OnConflict = wc.conflict
- if id, ok := wc.mutation.ID(); ok {
- _node.ID = id
- _spec.ID.Value = id
- }
- if value, ok := wc.mutation.CreatedAt(); ok {
- _spec.SetField(whatsapp.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if value, ok := wc.mutation.UpdatedAt(); ok {
- _spec.SetField(whatsapp.FieldUpdatedAt, field.TypeTime, value)
- _node.UpdatedAt = value
- }
- if value, ok := wc.mutation.Status(); ok {
- _spec.SetField(whatsapp.FieldStatus, field.TypeUint8, value)
- _node.Status = value
- }
- if value, ok := wc.mutation.DeletedAt(); ok {
- _spec.SetField(whatsapp.FieldDeletedAt, field.TypeTime, value)
- _node.DeletedAt = value
- }
- if value, ok := wc.mutation.WaID(); ok {
- _spec.SetField(whatsapp.FieldWaID, field.TypeString, value)
- _node.WaID = value
- }
- if value, ok := wc.mutation.WaName(); ok {
- _spec.SetField(whatsapp.FieldWaName, field.TypeString, value)
- _node.WaName = value
- }
- if value, ok := wc.mutation.Callback(); ok {
- _spec.SetField(whatsapp.FieldCallback, field.TypeString, value)
- _node.Callback = value
- }
- if value, ok := wc.mutation.Account(); ok {
- _spec.SetField(whatsapp.FieldAccount, field.TypeString, value)
- _node.Account = value
- }
- if value, ok := wc.mutation.Cc(); ok {
- _spec.SetField(whatsapp.FieldCc, field.TypeString, value)
- _node.Cc = value
- }
- if value, ok := wc.mutation.Phone(); ok {
- _spec.SetField(whatsapp.FieldPhone, field.TypeString, value)
- _node.Phone = value
- }
- if value, ok := wc.mutation.CcPhone(); ok {
- _spec.SetField(whatsapp.FieldCcPhone, field.TypeString, value)
- _node.CcPhone = value
- }
- if value, ok := wc.mutation.PhoneName(); ok {
- _spec.SetField(whatsapp.FieldPhoneName, field.TypeString, value)
- _node.PhoneName = value
- }
- if value, ok := wc.mutation.PhoneStatus(); ok {
- _spec.SetField(whatsapp.FieldPhoneStatus, field.TypeInt8, value)
- _node.PhoneStatus = value
- }
- if value, ok := wc.mutation.OrganizationID(); ok {
- _spec.SetField(whatsapp.FieldOrganizationID, field.TypeUint64, value)
- _node.OrganizationID = value
- }
- if value, ok := wc.mutation.APIBase(); ok {
- _spec.SetField(whatsapp.FieldAPIBase, field.TypeString, value)
- _node.APIBase = value
- }
- if value, ok := wc.mutation.APIKey(); ok {
- _spec.SetField(whatsapp.FieldAPIKey, field.TypeString, value)
- _node.APIKey = value
- }
- if value, ok := wc.mutation.AllowList(); ok {
- _spec.SetField(whatsapp.FieldAllowList, field.TypeJSON, value)
- _node.AllowList = value
- }
- if value, ok := wc.mutation.GroupAllowList(); ok {
- _spec.SetField(whatsapp.FieldGroupAllowList, field.TypeJSON, value)
- _node.GroupAllowList = value
- }
- if value, ok := wc.mutation.BlockList(); ok {
- _spec.SetField(whatsapp.FieldBlockList, field.TypeJSON, value)
- _node.BlockList = value
- }
- if value, ok := wc.mutation.GroupBlockList(); ok {
- _spec.SetField(whatsapp.FieldGroupBlockList, field.TypeJSON, value)
- _node.GroupBlockList = value
- }
- if nodes := wc.mutation.AgentIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: whatsapp.AgentTable,
- Columns: []string{whatsapp.AgentColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(agent.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _node.AgentID = 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.Whatsapp.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.WhatsappUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (wc *WhatsappCreate) OnConflict(opts ...sql.ConflictOption) *WhatsappUpsertOne {
- wc.conflict = opts
- return &WhatsappUpsertOne{
- create: wc,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.Whatsapp.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (wc *WhatsappCreate) OnConflictColumns(columns ...string) *WhatsappUpsertOne {
- wc.conflict = append(wc.conflict, sql.ConflictColumns(columns...))
- return &WhatsappUpsertOne{
- create: wc,
- }
- }
- type (
- // WhatsappUpsertOne is the builder for "upsert"-ing
- // one Whatsapp node.
- WhatsappUpsertOne struct {
- create *WhatsappCreate
- }
- // WhatsappUpsert is the "OnConflict" setter.
- WhatsappUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetUpdatedAt sets the "updated_at" field.
- func (u *WhatsappUpsert) SetUpdatedAt(v time.Time) *WhatsappUpsert {
- u.Set(whatsapp.FieldUpdatedAt, v)
- return u
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateUpdatedAt() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldUpdatedAt)
- return u
- }
- // SetStatus sets the "status" field.
- func (u *WhatsappUpsert) SetStatus(v uint8) *WhatsappUpsert {
- u.Set(whatsapp.FieldStatus, v)
- return u
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateStatus() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldStatus)
- return u
- }
- // AddStatus adds v to the "status" field.
- func (u *WhatsappUpsert) AddStatus(v uint8) *WhatsappUpsert {
- u.Add(whatsapp.FieldStatus, v)
- return u
- }
- // ClearStatus clears the value of the "status" field.
- func (u *WhatsappUpsert) ClearStatus() *WhatsappUpsert {
- u.SetNull(whatsapp.FieldStatus)
- return u
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *WhatsappUpsert) SetDeletedAt(v time.Time) *WhatsappUpsert {
- u.Set(whatsapp.FieldDeletedAt, v)
- return u
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateDeletedAt() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldDeletedAt)
- return u
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *WhatsappUpsert) ClearDeletedAt() *WhatsappUpsert {
- u.SetNull(whatsapp.FieldDeletedAt)
- return u
- }
- // SetWaID sets the "wa_id" field.
- func (u *WhatsappUpsert) SetWaID(v string) *WhatsappUpsert {
- u.Set(whatsapp.FieldWaID, v)
- return u
- }
- // UpdateWaID sets the "wa_id" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateWaID() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldWaID)
- return u
- }
- // ClearWaID clears the value of the "wa_id" field.
- func (u *WhatsappUpsert) ClearWaID() *WhatsappUpsert {
- u.SetNull(whatsapp.FieldWaID)
- return u
- }
- // SetWaName sets the "wa_name" field.
- func (u *WhatsappUpsert) SetWaName(v string) *WhatsappUpsert {
- u.Set(whatsapp.FieldWaName, v)
- return u
- }
- // UpdateWaName sets the "wa_name" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateWaName() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldWaName)
- return u
- }
- // ClearWaName clears the value of the "wa_name" field.
- func (u *WhatsappUpsert) ClearWaName() *WhatsappUpsert {
- u.SetNull(whatsapp.FieldWaName)
- return u
- }
- // SetCallback sets the "callback" field.
- func (u *WhatsappUpsert) SetCallback(v string) *WhatsappUpsert {
- u.Set(whatsapp.FieldCallback, v)
- return u
- }
- // UpdateCallback sets the "callback" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateCallback() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldCallback)
- return u
- }
- // ClearCallback clears the value of the "callback" field.
- func (u *WhatsappUpsert) ClearCallback() *WhatsappUpsert {
- u.SetNull(whatsapp.FieldCallback)
- return u
- }
- // SetAgentID sets the "agent_id" field.
- func (u *WhatsappUpsert) SetAgentID(v uint64) *WhatsappUpsert {
- u.Set(whatsapp.FieldAgentID, v)
- return u
- }
- // UpdateAgentID sets the "agent_id" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateAgentID() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldAgentID)
- return u
- }
- // SetAccount sets the "account" field.
- func (u *WhatsappUpsert) SetAccount(v string) *WhatsappUpsert {
- u.Set(whatsapp.FieldAccount, v)
- return u
- }
- // UpdateAccount sets the "account" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateAccount() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldAccount)
- return u
- }
- // ClearAccount clears the value of the "account" field.
- func (u *WhatsappUpsert) ClearAccount() *WhatsappUpsert {
- u.SetNull(whatsapp.FieldAccount)
- return u
- }
- // SetCc sets the "cc" field.
- func (u *WhatsappUpsert) SetCc(v string) *WhatsappUpsert {
- u.Set(whatsapp.FieldCc, v)
- return u
- }
- // UpdateCc sets the "cc" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateCc() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldCc)
- return u
- }
- // SetPhone sets the "phone" field.
- func (u *WhatsappUpsert) SetPhone(v string) *WhatsappUpsert {
- u.Set(whatsapp.FieldPhone, v)
- return u
- }
- // UpdatePhone sets the "phone" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdatePhone() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldPhone)
- return u
- }
- // SetCcPhone sets the "cc_phone" field.
- func (u *WhatsappUpsert) SetCcPhone(v string) *WhatsappUpsert {
- u.Set(whatsapp.FieldCcPhone, v)
- return u
- }
- // UpdateCcPhone sets the "cc_phone" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateCcPhone() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldCcPhone)
- return u
- }
- // SetPhoneName sets the "phone_name" field.
- func (u *WhatsappUpsert) SetPhoneName(v string) *WhatsappUpsert {
- u.Set(whatsapp.FieldPhoneName, v)
- return u
- }
- // UpdatePhoneName sets the "phone_name" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdatePhoneName() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldPhoneName)
- return u
- }
- // SetPhoneStatus sets the "phone_status" field.
- func (u *WhatsappUpsert) SetPhoneStatus(v int8) *WhatsappUpsert {
- u.Set(whatsapp.FieldPhoneStatus, v)
- return u
- }
- // UpdatePhoneStatus sets the "phone_status" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdatePhoneStatus() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldPhoneStatus)
- return u
- }
- // AddPhoneStatus adds v to the "phone_status" field.
- func (u *WhatsappUpsert) AddPhoneStatus(v int8) *WhatsappUpsert {
- u.Add(whatsapp.FieldPhoneStatus, v)
- return u
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *WhatsappUpsert) SetOrganizationID(v uint64) *WhatsappUpsert {
- u.Set(whatsapp.FieldOrganizationID, v)
- return u
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateOrganizationID() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldOrganizationID)
- return u
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *WhatsappUpsert) AddOrganizationID(v uint64) *WhatsappUpsert {
- u.Add(whatsapp.FieldOrganizationID, v)
- return u
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (u *WhatsappUpsert) ClearOrganizationID() *WhatsappUpsert {
- u.SetNull(whatsapp.FieldOrganizationID)
- return u
- }
- // SetAPIBase sets the "api_base" field.
- func (u *WhatsappUpsert) SetAPIBase(v string) *WhatsappUpsert {
- u.Set(whatsapp.FieldAPIBase, v)
- return u
- }
- // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateAPIBase() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldAPIBase)
- return u
- }
- // ClearAPIBase clears the value of the "api_base" field.
- func (u *WhatsappUpsert) ClearAPIBase() *WhatsappUpsert {
- u.SetNull(whatsapp.FieldAPIBase)
- return u
- }
- // SetAPIKey sets the "api_key" field.
- func (u *WhatsappUpsert) SetAPIKey(v string) *WhatsappUpsert {
- u.Set(whatsapp.FieldAPIKey, v)
- return u
- }
- // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateAPIKey() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldAPIKey)
- return u
- }
- // ClearAPIKey clears the value of the "api_key" field.
- func (u *WhatsappUpsert) ClearAPIKey() *WhatsappUpsert {
- u.SetNull(whatsapp.FieldAPIKey)
- return u
- }
- // SetAllowList sets the "allow_list" field.
- func (u *WhatsappUpsert) SetAllowList(v []string) *WhatsappUpsert {
- u.Set(whatsapp.FieldAllowList, v)
- return u
- }
- // UpdateAllowList sets the "allow_list" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateAllowList() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldAllowList)
- return u
- }
- // ClearAllowList clears the value of the "allow_list" field.
- func (u *WhatsappUpsert) ClearAllowList() *WhatsappUpsert {
- u.SetNull(whatsapp.FieldAllowList)
- return u
- }
- // SetGroupAllowList sets the "group_allow_list" field.
- func (u *WhatsappUpsert) SetGroupAllowList(v []string) *WhatsappUpsert {
- u.Set(whatsapp.FieldGroupAllowList, v)
- return u
- }
- // UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateGroupAllowList() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldGroupAllowList)
- return u
- }
- // ClearGroupAllowList clears the value of the "group_allow_list" field.
- func (u *WhatsappUpsert) ClearGroupAllowList() *WhatsappUpsert {
- u.SetNull(whatsapp.FieldGroupAllowList)
- return u
- }
- // SetBlockList sets the "block_list" field.
- func (u *WhatsappUpsert) SetBlockList(v []string) *WhatsappUpsert {
- u.Set(whatsapp.FieldBlockList, v)
- return u
- }
- // UpdateBlockList sets the "block_list" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateBlockList() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldBlockList)
- return u
- }
- // ClearBlockList clears the value of the "block_list" field.
- func (u *WhatsappUpsert) ClearBlockList() *WhatsappUpsert {
- u.SetNull(whatsapp.FieldBlockList)
- return u
- }
- // SetGroupBlockList sets the "group_block_list" field.
- func (u *WhatsappUpsert) SetGroupBlockList(v []string) *WhatsappUpsert {
- u.Set(whatsapp.FieldGroupBlockList, v)
- return u
- }
- // UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateGroupBlockList() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldGroupBlockList)
- return u
- }
- // ClearGroupBlockList clears the value of the "group_block_list" field.
- func (u *WhatsappUpsert) ClearGroupBlockList() *WhatsappUpsert {
- u.SetNull(whatsapp.FieldGroupBlockList)
- 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.Whatsapp.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(whatsapp.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *WhatsappUpsertOne) UpdateNewValues() *WhatsappUpsertOne {
- 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(whatsapp.FieldID)
- }
- if _, exists := u.create.mutation.CreatedAt(); exists {
- s.SetIgnore(whatsapp.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.Whatsapp.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *WhatsappUpsertOne) Ignore() *WhatsappUpsertOne {
- 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 *WhatsappUpsertOne) DoNothing() *WhatsappUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the WhatsappCreate.OnConflict
- // documentation for more info.
- func (u *WhatsappUpsertOne) Update(set func(*WhatsappUpsert)) *WhatsappUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&WhatsappUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *WhatsappUpsertOne) SetUpdatedAt(v time.Time) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateUpdatedAt() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetStatus sets the "status" field.
- func (u *WhatsappUpsertOne) SetStatus(v uint8) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetStatus(v)
- })
- }
- // AddStatus adds v to the "status" field.
- func (u *WhatsappUpsertOne) AddStatus(v uint8) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.AddStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateStatus() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateStatus()
- })
- }
- // ClearStatus clears the value of the "status" field.
- func (u *WhatsappUpsertOne) ClearStatus() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearStatus()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *WhatsappUpsertOne) SetDeletedAt(v time.Time) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateDeletedAt() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *WhatsappUpsertOne) ClearDeletedAt() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetWaID sets the "wa_id" field.
- func (u *WhatsappUpsertOne) SetWaID(v string) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetWaID(v)
- })
- }
- // UpdateWaID sets the "wa_id" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateWaID() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateWaID()
- })
- }
- // ClearWaID clears the value of the "wa_id" field.
- func (u *WhatsappUpsertOne) ClearWaID() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearWaID()
- })
- }
- // SetWaName sets the "wa_name" field.
- func (u *WhatsappUpsertOne) SetWaName(v string) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetWaName(v)
- })
- }
- // UpdateWaName sets the "wa_name" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateWaName() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateWaName()
- })
- }
- // ClearWaName clears the value of the "wa_name" field.
- func (u *WhatsappUpsertOne) ClearWaName() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearWaName()
- })
- }
- // SetCallback sets the "callback" field.
- func (u *WhatsappUpsertOne) SetCallback(v string) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetCallback(v)
- })
- }
- // UpdateCallback sets the "callback" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateCallback() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateCallback()
- })
- }
- // ClearCallback clears the value of the "callback" field.
- func (u *WhatsappUpsertOne) ClearCallback() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearCallback()
- })
- }
- // SetAgentID sets the "agent_id" field.
- func (u *WhatsappUpsertOne) SetAgentID(v uint64) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetAgentID(v)
- })
- }
- // UpdateAgentID sets the "agent_id" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateAgentID() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateAgentID()
- })
- }
- // SetAccount sets the "account" field.
- func (u *WhatsappUpsertOne) SetAccount(v string) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetAccount(v)
- })
- }
- // UpdateAccount sets the "account" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateAccount() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateAccount()
- })
- }
- // ClearAccount clears the value of the "account" field.
- func (u *WhatsappUpsertOne) ClearAccount() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearAccount()
- })
- }
- // SetCc sets the "cc" field.
- func (u *WhatsappUpsertOne) SetCc(v string) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetCc(v)
- })
- }
- // UpdateCc sets the "cc" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateCc() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateCc()
- })
- }
- // SetPhone sets the "phone" field.
- func (u *WhatsappUpsertOne) SetPhone(v string) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetPhone(v)
- })
- }
- // UpdatePhone sets the "phone" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdatePhone() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdatePhone()
- })
- }
- // SetCcPhone sets the "cc_phone" field.
- func (u *WhatsappUpsertOne) SetCcPhone(v string) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetCcPhone(v)
- })
- }
- // UpdateCcPhone sets the "cc_phone" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateCcPhone() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateCcPhone()
- })
- }
- // SetPhoneName sets the "phone_name" field.
- func (u *WhatsappUpsertOne) SetPhoneName(v string) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetPhoneName(v)
- })
- }
- // UpdatePhoneName sets the "phone_name" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdatePhoneName() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdatePhoneName()
- })
- }
- // SetPhoneStatus sets the "phone_status" field.
- func (u *WhatsappUpsertOne) SetPhoneStatus(v int8) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetPhoneStatus(v)
- })
- }
- // AddPhoneStatus adds v to the "phone_status" field.
- func (u *WhatsappUpsertOne) AddPhoneStatus(v int8) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.AddPhoneStatus(v)
- })
- }
- // UpdatePhoneStatus sets the "phone_status" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdatePhoneStatus() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdatePhoneStatus()
- })
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *WhatsappUpsertOne) SetOrganizationID(v uint64) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetOrganizationID(v)
- })
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *WhatsappUpsertOne) AddOrganizationID(v uint64) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.AddOrganizationID(v)
- })
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateOrganizationID() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateOrganizationID()
- })
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (u *WhatsappUpsertOne) ClearOrganizationID() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearOrganizationID()
- })
- }
- // SetAPIBase sets the "api_base" field.
- func (u *WhatsappUpsertOne) SetAPIBase(v string) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetAPIBase(v)
- })
- }
- // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateAPIBase() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateAPIBase()
- })
- }
- // ClearAPIBase clears the value of the "api_base" field.
- func (u *WhatsappUpsertOne) ClearAPIBase() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearAPIBase()
- })
- }
- // SetAPIKey sets the "api_key" field.
- func (u *WhatsappUpsertOne) SetAPIKey(v string) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetAPIKey(v)
- })
- }
- // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateAPIKey() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateAPIKey()
- })
- }
- // ClearAPIKey clears the value of the "api_key" field.
- func (u *WhatsappUpsertOne) ClearAPIKey() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearAPIKey()
- })
- }
- // SetAllowList sets the "allow_list" field.
- func (u *WhatsappUpsertOne) SetAllowList(v []string) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetAllowList(v)
- })
- }
- // UpdateAllowList sets the "allow_list" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateAllowList() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateAllowList()
- })
- }
- // ClearAllowList clears the value of the "allow_list" field.
- func (u *WhatsappUpsertOne) ClearAllowList() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearAllowList()
- })
- }
- // SetGroupAllowList sets the "group_allow_list" field.
- func (u *WhatsappUpsertOne) SetGroupAllowList(v []string) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetGroupAllowList(v)
- })
- }
- // UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateGroupAllowList() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateGroupAllowList()
- })
- }
- // ClearGroupAllowList clears the value of the "group_allow_list" field.
- func (u *WhatsappUpsertOne) ClearGroupAllowList() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearGroupAllowList()
- })
- }
- // SetBlockList sets the "block_list" field.
- func (u *WhatsappUpsertOne) SetBlockList(v []string) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetBlockList(v)
- })
- }
- // UpdateBlockList sets the "block_list" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateBlockList() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateBlockList()
- })
- }
- // ClearBlockList clears the value of the "block_list" field.
- func (u *WhatsappUpsertOne) ClearBlockList() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearBlockList()
- })
- }
- // SetGroupBlockList sets the "group_block_list" field.
- func (u *WhatsappUpsertOne) SetGroupBlockList(v []string) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetGroupBlockList(v)
- })
- }
- // UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateGroupBlockList() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateGroupBlockList()
- })
- }
- // ClearGroupBlockList clears the value of the "group_block_list" field.
- func (u *WhatsappUpsertOne) ClearGroupBlockList() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearGroupBlockList()
- })
- }
- // Exec executes the query.
- func (u *WhatsappUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for WhatsappCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *WhatsappUpsertOne) 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 *WhatsappUpsertOne) 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 *WhatsappUpsertOne) IDX(ctx context.Context) uint64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // WhatsappCreateBulk is the builder for creating many Whatsapp entities in bulk.
- type WhatsappCreateBulk struct {
- config
- err error
- builders []*WhatsappCreate
- conflict []sql.ConflictOption
- }
- // Save creates the Whatsapp entities in the database.
- func (wcb *WhatsappCreateBulk) Save(ctx context.Context) ([]*Whatsapp, error) {
- if wcb.err != nil {
- return nil, wcb.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(wcb.builders))
- nodes := make([]*Whatsapp, len(wcb.builders))
- mutators := make([]Mutator, len(wcb.builders))
- for i := range wcb.builders {
- func(i int, root context.Context) {
- builder := wcb.builders[i]
- builder.defaults()
- var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
- mutation, ok := m.(*WhatsappMutation)
- 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, wcb.builders[i+1].mutation)
- } else {
- spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
- spec.OnConflict = wcb.conflict
- // Invoke the actual operation on the latest mutation in the chain.
- if err = sqlgraph.BatchCreate(ctx, wcb.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, wcb.builders[0].mutation); err != nil {
- return nil, err
- }
- }
- return nodes, nil
- }
- // SaveX is like Save, but panics if an error occurs.
- func (wcb *WhatsappCreateBulk) SaveX(ctx context.Context) []*Whatsapp {
- v, err := wcb.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (wcb *WhatsappCreateBulk) Exec(ctx context.Context) error {
- _, err := wcb.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (wcb *WhatsappCreateBulk) ExecX(ctx context.Context) {
- if err := wcb.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.Whatsapp.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.WhatsappUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (wcb *WhatsappCreateBulk) OnConflict(opts ...sql.ConflictOption) *WhatsappUpsertBulk {
- wcb.conflict = opts
- return &WhatsappUpsertBulk{
- create: wcb,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.Whatsapp.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (wcb *WhatsappCreateBulk) OnConflictColumns(columns ...string) *WhatsappUpsertBulk {
- wcb.conflict = append(wcb.conflict, sql.ConflictColumns(columns...))
- return &WhatsappUpsertBulk{
- create: wcb,
- }
- }
- // WhatsappUpsertBulk is the builder for "upsert"-ing
- // a bulk of Whatsapp nodes.
- type WhatsappUpsertBulk struct {
- create *WhatsappCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.Whatsapp.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(whatsapp.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *WhatsappUpsertBulk) UpdateNewValues() *WhatsappUpsertBulk {
- 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(whatsapp.FieldID)
- }
- if _, exists := b.mutation.CreatedAt(); exists {
- s.SetIgnore(whatsapp.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.Whatsapp.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *WhatsappUpsertBulk) Ignore() *WhatsappUpsertBulk {
- 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 *WhatsappUpsertBulk) DoNothing() *WhatsappUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the WhatsappCreateBulk.OnConflict
- // documentation for more info.
- func (u *WhatsappUpsertBulk) Update(set func(*WhatsappUpsert)) *WhatsappUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&WhatsappUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *WhatsappUpsertBulk) SetUpdatedAt(v time.Time) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateUpdatedAt() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetStatus sets the "status" field.
- func (u *WhatsappUpsertBulk) SetStatus(v uint8) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetStatus(v)
- })
- }
- // AddStatus adds v to the "status" field.
- func (u *WhatsappUpsertBulk) AddStatus(v uint8) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.AddStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateStatus() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateStatus()
- })
- }
- // ClearStatus clears the value of the "status" field.
- func (u *WhatsappUpsertBulk) ClearStatus() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearStatus()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *WhatsappUpsertBulk) SetDeletedAt(v time.Time) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateDeletedAt() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *WhatsappUpsertBulk) ClearDeletedAt() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetWaID sets the "wa_id" field.
- func (u *WhatsappUpsertBulk) SetWaID(v string) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetWaID(v)
- })
- }
- // UpdateWaID sets the "wa_id" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateWaID() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateWaID()
- })
- }
- // ClearWaID clears the value of the "wa_id" field.
- func (u *WhatsappUpsertBulk) ClearWaID() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearWaID()
- })
- }
- // SetWaName sets the "wa_name" field.
- func (u *WhatsappUpsertBulk) SetWaName(v string) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetWaName(v)
- })
- }
- // UpdateWaName sets the "wa_name" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateWaName() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateWaName()
- })
- }
- // ClearWaName clears the value of the "wa_name" field.
- func (u *WhatsappUpsertBulk) ClearWaName() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearWaName()
- })
- }
- // SetCallback sets the "callback" field.
- func (u *WhatsappUpsertBulk) SetCallback(v string) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetCallback(v)
- })
- }
- // UpdateCallback sets the "callback" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateCallback() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateCallback()
- })
- }
- // ClearCallback clears the value of the "callback" field.
- func (u *WhatsappUpsertBulk) ClearCallback() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearCallback()
- })
- }
- // SetAgentID sets the "agent_id" field.
- func (u *WhatsappUpsertBulk) SetAgentID(v uint64) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetAgentID(v)
- })
- }
- // UpdateAgentID sets the "agent_id" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateAgentID() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateAgentID()
- })
- }
- // SetAccount sets the "account" field.
- func (u *WhatsappUpsertBulk) SetAccount(v string) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetAccount(v)
- })
- }
- // UpdateAccount sets the "account" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateAccount() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateAccount()
- })
- }
- // ClearAccount clears the value of the "account" field.
- func (u *WhatsappUpsertBulk) ClearAccount() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearAccount()
- })
- }
- // SetCc sets the "cc" field.
- func (u *WhatsappUpsertBulk) SetCc(v string) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetCc(v)
- })
- }
- // UpdateCc sets the "cc" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateCc() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateCc()
- })
- }
- // SetPhone sets the "phone" field.
- func (u *WhatsappUpsertBulk) SetPhone(v string) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetPhone(v)
- })
- }
- // UpdatePhone sets the "phone" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdatePhone() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdatePhone()
- })
- }
- // SetCcPhone sets the "cc_phone" field.
- func (u *WhatsappUpsertBulk) SetCcPhone(v string) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetCcPhone(v)
- })
- }
- // UpdateCcPhone sets the "cc_phone" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateCcPhone() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateCcPhone()
- })
- }
- // SetPhoneName sets the "phone_name" field.
- func (u *WhatsappUpsertBulk) SetPhoneName(v string) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetPhoneName(v)
- })
- }
- // UpdatePhoneName sets the "phone_name" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdatePhoneName() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdatePhoneName()
- })
- }
- // SetPhoneStatus sets the "phone_status" field.
- func (u *WhatsappUpsertBulk) SetPhoneStatus(v int8) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetPhoneStatus(v)
- })
- }
- // AddPhoneStatus adds v to the "phone_status" field.
- func (u *WhatsappUpsertBulk) AddPhoneStatus(v int8) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.AddPhoneStatus(v)
- })
- }
- // UpdatePhoneStatus sets the "phone_status" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdatePhoneStatus() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdatePhoneStatus()
- })
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *WhatsappUpsertBulk) SetOrganizationID(v uint64) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetOrganizationID(v)
- })
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *WhatsappUpsertBulk) AddOrganizationID(v uint64) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.AddOrganizationID(v)
- })
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateOrganizationID() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateOrganizationID()
- })
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (u *WhatsappUpsertBulk) ClearOrganizationID() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearOrganizationID()
- })
- }
- // SetAPIBase sets the "api_base" field.
- func (u *WhatsappUpsertBulk) SetAPIBase(v string) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetAPIBase(v)
- })
- }
- // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateAPIBase() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateAPIBase()
- })
- }
- // ClearAPIBase clears the value of the "api_base" field.
- func (u *WhatsappUpsertBulk) ClearAPIBase() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearAPIBase()
- })
- }
- // SetAPIKey sets the "api_key" field.
- func (u *WhatsappUpsertBulk) SetAPIKey(v string) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetAPIKey(v)
- })
- }
- // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateAPIKey() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateAPIKey()
- })
- }
- // ClearAPIKey clears the value of the "api_key" field.
- func (u *WhatsappUpsertBulk) ClearAPIKey() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearAPIKey()
- })
- }
- // SetAllowList sets the "allow_list" field.
- func (u *WhatsappUpsertBulk) SetAllowList(v []string) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetAllowList(v)
- })
- }
- // UpdateAllowList sets the "allow_list" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateAllowList() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateAllowList()
- })
- }
- // ClearAllowList clears the value of the "allow_list" field.
- func (u *WhatsappUpsertBulk) ClearAllowList() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearAllowList()
- })
- }
- // SetGroupAllowList sets the "group_allow_list" field.
- func (u *WhatsappUpsertBulk) SetGroupAllowList(v []string) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetGroupAllowList(v)
- })
- }
- // UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateGroupAllowList() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateGroupAllowList()
- })
- }
- // ClearGroupAllowList clears the value of the "group_allow_list" field.
- func (u *WhatsappUpsertBulk) ClearGroupAllowList() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearGroupAllowList()
- })
- }
- // SetBlockList sets the "block_list" field.
- func (u *WhatsappUpsertBulk) SetBlockList(v []string) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetBlockList(v)
- })
- }
- // UpdateBlockList sets the "block_list" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateBlockList() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateBlockList()
- })
- }
- // ClearBlockList clears the value of the "block_list" field.
- func (u *WhatsappUpsertBulk) ClearBlockList() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearBlockList()
- })
- }
- // SetGroupBlockList sets the "group_block_list" field.
- func (u *WhatsappUpsertBulk) SetGroupBlockList(v []string) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetGroupBlockList(v)
- })
- }
- // UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateGroupBlockList() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateGroupBlockList()
- })
- }
- // ClearGroupBlockList clears the value of the "group_block_list" field.
- func (u *WhatsappUpsertBulk) ClearGroupBlockList() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearGroupBlockList()
- })
- }
- // Exec executes the query.
- func (u *WhatsappUpsertBulk) 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 WhatsappCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for WhatsappCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *WhatsappUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|