12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763 |
- // 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
- }
- // SetAk sets the "ak" field.
- func (wc *WhatsappCreate) SetAk(s string) *WhatsappCreate {
- wc.mutation.SetAk(s)
- return wc
- }
- // SetNillableAk sets the "ak" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillableAk(s *string) *WhatsappCreate {
- if s != nil {
- wc.SetAk(*s)
- }
- return wc
- }
- // SetSk sets the "sk" field.
- func (wc *WhatsappCreate) SetSk(s string) *WhatsappCreate {
- wc.mutation.SetSk(s)
- return wc
- }
- // SetNillableSk sets the "sk" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillableSk(s *string) *WhatsappCreate {
- if s != nil {
- wc.SetSk(*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
- }
- // 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
- }
- // SetNickname sets the "nickname" field.
- func (wc *WhatsappCreate) SetNickname(s string) *WhatsappCreate {
- wc.mutation.SetNickname(s)
- return wc
- }
- // SetNillableNickname sets the "nickname" field if the given value is not nil.
- func (wc *WhatsappCreate) SetNillableNickname(s *string) *WhatsappCreate {
- if s != nil {
- wc.SetNickname(*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
- }
- // 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
- }
- // 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
- }
- // 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.Ak(); !ok {
- v := whatsapp.DefaultAk
- wc.mutation.SetAk(v)
- }
- if _, ok := wc.mutation.Sk(); !ok {
- v := whatsapp.DefaultSk
- wc.mutation.SetSk(v)
- }
- if _, ok := wc.mutation.Callback(); !ok {
- v := whatsapp.DefaultCallback
- wc.mutation.SetCallback(v)
- }
- if _, ok := wc.mutation.Account(); !ok {
- v := whatsapp.DefaultAccount
- wc.mutation.SetAccount(v)
- }
- if _, ok := wc.mutation.Nickname(); !ok {
- v := whatsapp.DefaultNickname
- wc.mutation.SetNickname(v)
- }
- if _, ok := wc.mutation.Phone(); !ok {
- v := whatsapp.DefaultPhone
- wc.mutation.SetPhone(v)
- }
- if _, ok := wc.mutation.OrganizationID(); !ok {
- v := whatsapp.DefaultOrganizationID
- wc.mutation.SetOrganizationID(v)
- }
- if _, ok := wc.mutation.AgentID(); !ok {
- v := whatsapp.DefaultAgentID
- wc.mutation.SetAgentID(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.Sk(); !ok {
- return &ValidationError{Name: "sk", err: errors.New(`ent: missing required field "Whatsapp.sk"`)}
- }
- if _, ok := wc.mutation.Callback(); !ok {
- return &ValidationError{Name: "callback", err: errors.New(`ent: missing required field "Whatsapp.callback"`)}
- }
- if _, ok := wc.mutation.Account(); !ok {
- return &ValidationError{Name: "account", err: errors.New(`ent: missing required field "Whatsapp.account"`)}
- }
- if _, ok := wc.mutation.Nickname(); !ok {
- return &ValidationError{Name: "nickname", err: errors.New(`ent: missing required field "Whatsapp.nickname"`)}
- }
- if _, ok := wc.mutation.Phone(); !ok {
- return &ValidationError{Name: "phone", err: errors.New(`ent: missing required field "Whatsapp.phone"`)}
- }
- 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.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.Ak(); ok {
- _spec.SetField(whatsapp.FieldAk, field.TypeString, value)
- _node.Ak = value
- }
- if value, ok := wc.mutation.Sk(); ok {
- _spec.SetField(whatsapp.FieldSk, field.TypeString, value)
- _node.Sk = 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.Nickname(); ok {
- _spec.SetField(whatsapp.FieldNickname, field.TypeString, value)
- _node.Nickname = value
- }
- if value, ok := wc.mutation.Phone(); ok {
- _spec.SetField(whatsapp.FieldPhone, field.TypeString, value)
- _node.Phone = 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
- }
- // SetAk sets the "ak" field.
- func (u *WhatsappUpsert) SetAk(v string) *WhatsappUpsert {
- u.Set(whatsapp.FieldAk, v)
- return u
- }
- // UpdateAk sets the "ak" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateAk() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldAk)
- return u
- }
- // ClearAk clears the value of the "ak" field.
- func (u *WhatsappUpsert) ClearAk() *WhatsappUpsert {
- u.SetNull(whatsapp.FieldAk)
- return u
- }
- // SetSk sets the "sk" field.
- func (u *WhatsappUpsert) SetSk(v string) *WhatsappUpsert {
- u.Set(whatsapp.FieldSk, v)
- return u
- }
- // UpdateSk sets the "sk" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateSk() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldSk)
- 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
- }
- // 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
- }
- // SetNickname sets the "nickname" field.
- func (u *WhatsappUpsert) SetNickname(v string) *WhatsappUpsert {
- u.Set(whatsapp.FieldNickname, v)
- return u
- }
- // UpdateNickname sets the "nickname" field to the value that was provided on create.
- func (u *WhatsappUpsert) UpdateNickname() *WhatsappUpsert {
- u.SetExcluded(whatsapp.FieldNickname)
- 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
- }
- // 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
- }
- // 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
- }
- // 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()
- })
- }
- // SetAk sets the "ak" field.
- func (u *WhatsappUpsertOne) SetAk(v string) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetAk(v)
- })
- }
- // UpdateAk sets the "ak" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateAk() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateAk()
- })
- }
- // ClearAk clears the value of the "ak" field.
- func (u *WhatsappUpsertOne) ClearAk() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearAk()
- })
- }
- // SetSk sets the "sk" field.
- func (u *WhatsappUpsertOne) SetSk(v string) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetSk(v)
- })
- }
- // UpdateSk sets the "sk" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateSk() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateSk()
- })
- }
- // 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()
- })
- }
- // 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()
- })
- }
- // SetNickname sets the "nickname" field.
- func (u *WhatsappUpsertOne) SetNickname(v string) *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetNickname(v)
- })
- }
- // UpdateNickname sets the "nickname" field to the value that was provided on create.
- func (u *WhatsappUpsertOne) UpdateNickname() *WhatsappUpsertOne {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateNickname()
- })
- }
- // 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()
- })
- }
- // 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()
- })
- }
- // 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()
- })
- }
- // 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()
- })
- }
- // SetAk sets the "ak" field.
- func (u *WhatsappUpsertBulk) SetAk(v string) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetAk(v)
- })
- }
- // UpdateAk sets the "ak" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateAk() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateAk()
- })
- }
- // ClearAk clears the value of the "ak" field.
- func (u *WhatsappUpsertBulk) ClearAk() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.ClearAk()
- })
- }
- // SetSk sets the "sk" field.
- func (u *WhatsappUpsertBulk) SetSk(v string) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetSk(v)
- })
- }
- // UpdateSk sets the "sk" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateSk() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateSk()
- })
- }
- // 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()
- })
- }
- // 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()
- })
- }
- // SetNickname sets the "nickname" field.
- func (u *WhatsappUpsertBulk) SetNickname(v string) *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.SetNickname(v)
- })
- }
- // UpdateNickname sets the "nickname" field to the value that was provided on create.
- func (u *WhatsappUpsertBulk) UpdateNickname() *WhatsappUpsertBulk {
- return u.Update(func(s *WhatsappUpsert) {
- s.UpdateNickname()
- })
- }
- // 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()
- })
- }
- // 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()
- })
- }
- // 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()
- })
- }
- // 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)
- }
- }
|