whatsapp_create.go 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "time"
  8. "wechat-api/ent/agent"
  9. "wechat-api/ent/whatsapp"
  10. "entgo.io/ent/dialect/sql"
  11. "entgo.io/ent/dialect/sql/sqlgraph"
  12. "entgo.io/ent/schema/field"
  13. )
  14. // WhatsappCreate is the builder for creating a Whatsapp entity.
  15. type WhatsappCreate struct {
  16. config
  17. mutation *WhatsappMutation
  18. hooks []Hook
  19. conflict []sql.ConflictOption
  20. }
  21. // SetCreatedAt sets the "created_at" field.
  22. func (wc *WhatsappCreate) SetCreatedAt(t time.Time) *WhatsappCreate {
  23. wc.mutation.SetCreatedAt(t)
  24. return wc
  25. }
  26. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  27. func (wc *WhatsappCreate) SetNillableCreatedAt(t *time.Time) *WhatsappCreate {
  28. if t != nil {
  29. wc.SetCreatedAt(*t)
  30. }
  31. return wc
  32. }
  33. // SetUpdatedAt sets the "updated_at" field.
  34. func (wc *WhatsappCreate) SetUpdatedAt(t time.Time) *WhatsappCreate {
  35. wc.mutation.SetUpdatedAt(t)
  36. return wc
  37. }
  38. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  39. func (wc *WhatsappCreate) SetNillableUpdatedAt(t *time.Time) *WhatsappCreate {
  40. if t != nil {
  41. wc.SetUpdatedAt(*t)
  42. }
  43. return wc
  44. }
  45. // SetStatus sets the "status" field.
  46. func (wc *WhatsappCreate) SetStatus(u uint8) *WhatsappCreate {
  47. wc.mutation.SetStatus(u)
  48. return wc
  49. }
  50. // SetNillableStatus sets the "status" field if the given value is not nil.
  51. func (wc *WhatsappCreate) SetNillableStatus(u *uint8) *WhatsappCreate {
  52. if u != nil {
  53. wc.SetStatus(*u)
  54. }
  55. return wc
  56. }
  57. // SetDeletedAt sets the "deleted_at" field.
  58. func (wc *WhatsappCreate) SetDeletedAt(t time.Time) *WhatsappCreate {
  59. wc.mutation.SetDeletedAt(t)
  60. return wc
  61. }
  62. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  63. func (wc *WhatsappCreate) SetNillableDeletedAt(t *time.Time) *WhatsappCreate {
  64. if t != nil {
  65. wc.SetDeletedAt(*t)
  66. }
  67. return wc
  68. }
  69. // SetWaID sets the "wa_id" field.
  70. func (wc *WhatsappCreate) SetWaID(u uint64) *WhatsappCreate {
  71. wc.mutation.SetWaID(u)
  72. return wc
  73. }
  74. // SetNillableWaID sets the "wa_id" field if the given value is not nil.
  75. func (wc *WhatsappCreate) SetNillableWaID(u *uint64) *WhatsappCreate {
  76. if u != nil {
  77. wc.SetWaID(*u)
  78. }
  79. return wc
  80. }
  81. // SetCallback sets the "callback" field.
  82. func (wc *WhatsappCreate) SetCallback(s string) *WhatsappCreate {
  83. wc.mutation.SetCallback(s)
  84. return wc
  85. }
  86. // SetNillableCallback sets the "callback" field if the given value is not nil.
  87. func (wc *WhatsappCreate) SetNillableCallback(s *string) *WhatsappCreate {
  88. if s != nil {
  89. wc.SetCallback(*s)
  90. }
  91. return wc
  92. }
  93. // SetAgentID sets the "agent_id" field.
  94. func (wc *WhatsappCreate) SetAgentID(u uint64) *WhatsappCreate {
  95. wc.mutation.SetAgentID(u)
  96. return wc
  97. }
  98. // SetNillableAgentID sets the "agent_id" field if the given value is not nil.
  99. func (wc *WhatsappCreate) SetNillableAgentID(u *uint64) *WhatsappCreate {
  100. if u != nil {
  101. wc.SetAgentID(*u)
  102. }
  103. return wc
  104. }
  105. // SetAccount sets the "account" field.
  106. func (wc *WhatsappCreate) SetAccount(s string) *WhatsappCreate {
  107. wc.mutation.SetAccount(s)
  108. return wc
  109. }
  110. // SetNillableAccount sets the "account" field if the given value is not nil.
  111. func (wc *WhatsappCreate) SetNillableAccount(s *string) *WhatsappCreate {
  112. if s != nil {
  113. wc.SetAccount(*s)
  114. }
  115. return wc
  116. }
  117. // SetNickname sets the "nickname" field.
  118. func (wc *WhatsappCreate) SetNickname(s string) *WhatsappCreate {
  119. wc.mutation.SetNickname(s)
  120. return wc
  121. }
  122. // SetNillableNickname sets the "nickname" field if the given value is not nil.
  123. func (wc *WhatsappCreate) SetNillableNickname(s *string) *WhatsappCreate {
  124. if s != nil {
  125. wc.SetNickname(*s)
  126. }
  127. return wc
  128. }
  129. // SetPhone sets the "phone" field.
  130. func (wc *WhatsappCreate) SetPhone(s string) *WhatsappCreate {
  131. wc.mutation.SetPhone(s)
  132. return wc
  133. }
  134. // SetNillablePhone sets the "phone" field if the given value is not nil.
  135. func (wc *WhatsappCreate) SetNillablePhone(s *string) *WhatsappCreate {
  136. if s != nil {
  137. wc.SetPhone(*s)
  138. }
  139. return wc
  140. }
  141. // SetPhoneName sets the "phone_name" field.
  142. func (wc *WhatsappCreate) SetPhoneName(s string) *WhatsappCreate {
  143. wc.mutation.SetPhoneName(s)
  144. return wc
  145. }
  146. // SetNillablePhoneName sets the "phone_name" field if the given value is not nil.
  147. func (wc *WhatsappCreate) SetNillablePhoneName(s *string) *WhatsappCreate {
  148. if s != nil {
  149. wc.SetPhoneName(*s)
  150. }
  151. return wc
  152. }
  153. // SetPhoneStatus sets the "phone_status" field.
  154. func (wc *WhatsappCreate) SetPhoneStatus(i int8) *WhatsappCreate {
  155. wc.mutation.SetPhoneStatus(i)
  156. return wc
  157. }
  158. // SetNillablePhoneStatus sets the "phone_status" field if the given value is not nil.
  159. func (wc *WhatsappCreate) SetNillablePhoneStatus(i *int8) *WhatsappCreate {
  160. if i != nil {
  161. wc.SetPhoneStatus(*i)
  162. }
  163. return wc
  164. }
  165. // SetOrganizationID sets the "organization_id" field.
  166. func (wc *WhatsappCreate) SetOrganizationID(u uint64) *WhatsappCreate {
  167. wc.mutation.SetOrganizationID(u)
  168. return wc
  169. }
  170. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  171. func (wc *WhatsappCreate) SetNillableOrganizationID(u *uint64) *WhatsappCreate {
  172. if u != nil {
  173. wc.SetOrganizationID(*u)
  174. }
  175. return wc
  176. }
  177. // SetAPIBase sets the "api_base" field.
  178. func (wc *WhatsappCreate) SetAPIBase(s string) *WhatsappCreate {
  179. wc.mutation.SetAPIBase(s)
  180. return wc
  181. }
  182. // SetNillableAPIBase sets the "api_base" field if the given value is not nil.
  183. func (wc *WhatsappCreate) SetNillableAPIBase(s *string) *WhatsappCreate {
  184. if s != nil {
  185. wc.SetAPIBase(*s)
  186. }
  187. return wc
  188. }
  189. // SetAPIKey sets the "api_key" field.
  190. func (wc *WhatsappCreate) SetAPIKey(s string) *WhatsappCreate {
  191. wc.mutation.SetAPIKey(s)
  192. return wc
  193. }
  194. // SetNillableAPIKey sets the "api_key" field if the given value is not nil.
  195. func (wc *WhatsappCreate) SetNillableAPIKey(s *string) *WhatsappCreate {
  196. if s != nil {
  197. wc.SetAPIKey(*s)
  198. }
  199. return wc
  200. }
  201. // SetAllowList sets the "allow_list" field.
  202. func (wc *WhatsappCreate) SetAllowList(s []string) *WhatsappCreate {
  203. wc.mutation.SetAllowList(s)
  204. return wc
  205. }
  206. // SetGroupAllowList sets the "group_allow_list" field.
  207. func (wc *WhatsappCreate) SetGroupAllowList(s []string) *WhatsappCreate {
  208. wc.mutation.SetGroupAllowList(s)
  209. return wc
  210. }
  211. // SetBlockList sets the "block_list" field.
  212. func (wc *WhatsappCreate) SetBlockList(s []string) *WhatsappCreate {
  213. wc.mutation.SetBlockList(s)
  214. return wc
  215. }
  216. // SetGroupBlockList sets the "group_block_list" field.
  217. func (wc *WhatsappCreate) SetGroupBlockList(s []string) *WhatsappCreate {
  218. wc.mutation.SetGroupBlockList(s)
  219. return wc
  220. }
  221. // SetID sets the "id" field.
  222. func (wc *WhatsappCreate) SetID(u uint64) *WhatsappCreate {
  223. wc.mutation.SetID(u)
  224. return wc
  225. }
  226. // SetAgent sets the "agent" edge to the Agent entity.
  227. func (wc *WhatsappCreate) SetAgent(a *Agent) *WhatsappCreate {
  228. return wc.SetAgentID(a.ID)
  229. }
  230. // Mutation returns the WhatsappMutation object of the builder.
  231. func (wc *WhatsappCreate) Mutation() *WhatsappMutation {
  232. return wc.mutation
  233. }
  234. // Save creates the Whatsapp in the database.
  235. func (wc *WhatsappCreate) Save(ctx context.Context) (*Whatsapp, error) {
  236. if err := wc.defaults(); err != nil {
  237. return nil, err
  238. }
  239. return withHooks(ctx, wc.sqlSave, wc.mutation, wc.hooks)
  240. }
  241. // SaveX calls Save and panics if Save returns an error.
  242. func (wc *WhatsappCreate) SaveX(ctx context.Context) *Whatsapp {
  243. v, err := wc.Save(ctx)
  244. if err != nil {
  245. panic(err)
  246. }
  247. return v
  248. }
  249. // Exec executes the query.
  250. func (wc *WhatsappCreate) Exec(ctx context.Context) error {
  251. _, err := wc.Save(ctx)
  252. return err
  253. }
  254. // ExecX is like Exec, but panics if an error occurs.
  255. func (wc *WhatsappCreate) ExecX(ctx context.Context) {
  256. if err := wc.Exec(ctx); err != nil {
  257. panic(err)
  258. }
  259. }
  260. // defaults sets the default values of the builder before save.
  261. func (wc *WhatsappCreate) defaults() error {
  262. if _, ok := wc.mutation.CreatedAt(); !ok {
  263. if whatsapp.DefaultCreatedAt == nil {
  264. return fmt.Errorf("ent: uninitialized whatsapp.DefaultCreatedAt (forgotten import ent/runtime?)")
  265. }
  266. v := whatsapp.DefaultCreatedAt()
  267. wc.mutation.SetCreatedAt(v)
  268. }
  269. if _, ok := wc.mutation.UpdatedAt(); !ok {
  270. if whatsapp.DefaultUpdatedAt == nil {
  271. return fmt.Errorf("ent: uninitialized whatsapp.DefaultUpdatedAt (forgotten import ent/runtime?)")
  272. }
  273. v := whatsapp.DefaultUpdatedAt()
  274. wc.mutation.SetUpdatedAt(v)
  275. }
  276. if _, ok := wc.mutation.Status(); !ok {
  277. v := whatsapp.DefaultStatus
  278. wc.mutation.SetStatus(v)
  279. }
  280. if _, ok := wc.mutation.WaID(); !ok {
  281. v := whatsapp.DefaultWaID
  282. wc.mutation.SetWaID(v)
  283. }
  284. if _, ok := wc.mutation.Callback(); !ok {
  285. v := whatsapp.DefaultCallback
  286. wc.mutation.SetCallback(v)
  287. }
  288. if _, ok := wc.mutation.AgentID(); !ok {
  289. v := whatsapp.DefaultAgentID
  290. wc.mutation.SetAgentID(v)
  291. }
  292. if _, ok := wc.mutation.Account(); !ok {
  293. v := whatsapp.DefaultAccount
  294. wc.mutation.SetAccount(v)
  295. }
  296. if _, ok := wc.mutation.Nickname(); !ok {
  297. v := whatsapp.DefaultNickname
  298. wc.mutation.SetNickname(v)
  299. }
  300. if _, ok := wc.mutation.Phone(); !ok {
  301. v := whatsapp.DefaultPhone
  302. wc.mutation.SetPhone(v)
  303. }
  304. if _, ok := wc.mutation.PhoneName(); !ok {
  305. v := whatsapp.DefaultPhoneName
  306. wc.mutation.SetPhoneName(v)
  307. }
  308. if _, ok := wc.mutation.PhoneStatus(); !ok {
  309. v := whatsapp.DefaultPhoneStatus
  310. wc.mutation.SetPhoneStatus(v)
  311. }
  312. if _, ok := wc.mutation.OrganizationID(); !ok {
  313. v := whatsapp.DefaultOrganizationID
  314. wc.mutation.SetOrganizationID(v)
  315. }
  316. if _, ok := wc.mutation.APIBase(); !ok {
  317. v := whatsapp.DefaultAPIBase
  318. wc.mutation.SetAPIBase(v)
  319. }
  320. if _, ok := wc.mutation.APIKey(); !ok {
  321. v := whatsapp.DefaultAPIKey
  322. wc.mutation.SetAPIKey(v)
  323. }
  324. return nil
  325. }
  326. // check runs all checks and user-defined validators on the builder.
  327. func (wc *WhatsappCreate) check() error {
  328. if _, ok := wc.mutation.CreatedAt(); !ok {
  329. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Whatsapp.created_at"`)}
  330. }
  331. if _, ok := wc.mutation.UpdatedAt(); !ok {
  332. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Whatsapp.updated_at"`)}
  333. }
  334. if _, ok := wc.mutation.AgentID(); !ok {
  335. return &ValidationError{Name: "agent_id", err: errors.New(`ent: missing required field "Whatsapp.agent_id"`)}
  336. }
  337. if _, ok := wc.mutation.Nickname(); !ok {
  338. return &ValidationError{Name: "nickname", err: errors.New(`ent: missing required field "Whatsapp.nickname"`)}
  339. }
  340. if _, ok := wc.mutation.Phone(); !ok {
  341. return &ValidationError{Name: "phone", err: errors.New(`ent: missing required field "Whatsapp.phone"`)}
  342. }
  343. if _, ok := wc.mutation.PhoneName(); !ok {
  344. return &ValidationError{Name: "phone_name", err: errors.New(`ent: missing required field "Whatsapp.phone_name"`)}
  345. }
  346. if _, ok := wc.mutation.PhoneStatus(); !ok {
  347. return &ValidationError{Name: "phone_status", err: errors.New(`ent: missing required field "Whatsapp.phone_status"`)}
  348. }
  349. if _, ok := wc.mutation.AgentID(); !ok {
  350. return &ValidationError{Name: "agent", err: errors.New(`ent: missing required edge "Whatsapp.agent"`)}
  351. }
  352. return nil
  353. }
  354. func (wc *WhatsappCreate) sqlSave(ctx context.Context) (*Whatsapp, error) {
  355. if err := wc.check(); err != nil {
  356. return nil, err
  357. }
  358. _node, _spec := wc.createSpec()
  359. if err := sqlgraph.CreateNode(ctx, wc.driver, _spec); err != nil {
  360. if sqlgraph.IsConstraintError(err) {
  361. err = &ConstraintError{msg: err.Error(), wrap: err}
  362. }
  363. return nil, err
  364. }
  365. if _spec.ID.Value != _node.ID {
  366. id := _spec.ID.Value.(int64)
  367. _node.ID = uint64(id)
  368. }
  369. wc.mutation.id = &_node.ID
  370. wc.mutation.done = true
  371. return _node, nil
  372. }
  373. func (wc *WhatsappCreate) createSpec() (*Whatsapp, *sqlgraph.CreateSpec) {
  374. var (
  375. _node = &Whatsapp{config: wc.config}
  376. _spec = sqlgraph.NewCreateSpec(whatsapp.Table, sqlgraph.NewFieldSpec(whatsapp.FieldID, field.TypeUint64))
  377. )
  378. _spec.OnConflict = wc.conflict
  379. if id, ok := wc.mutation.ID(); ok {
  380. _node.ID = id
  381. _spec.ID.Value = id
  382. }
  383. if value, ok := wc.mutation.CreatedAt(); ok {
  384. _spec.SetField(whatsapp.FieldCreatedAt, field.TypeTime, value)
  385. _node.CreatedAt = value
  386. }
  387. if value, ok := wc.mutation.UpdatedAt(); ok {
  388. _spec.SetField(whatsapp.FieldUpdatedAt, field.TypeTime, value)
  389. _node.UpdatedAt = value
  390. }
  391. if value, ok := wc.mutation.Status(); ok {
  392. _spec.SetField(whatsapp.FieldStatus, field.TypeUint8, value)
  393. _node.Status = value
  394. }
  395. if value, ok := wc.mutation.DeletedAt(); ok {
  396. _spec.SetField(whatsapp.FieldDeletedAt, field.TypeTime, value)
  397. _node.DeletedAt = value
  398. }
  399. if value, ok := wc.mutation.WaID(); ok {
  400. _spec.SetField(whatsapp.FieldWaID, field.TypeUint64, value)
  401. _node.WaID = value
  402. }
  403. if value, ok := wc.mutation.Callback(); ok {
  404. _spec.SetField(whatsapp.FieldCallback, field.TypeString, value)
  405. _node.Callback = value
  406. }
  407. if value, ok := wc.mutation.Account(); ok {
  408. _spec.SetField(whatsapp.FieldAccount, field.TypeString, value)
  409. _node.Account = value
  410. }
  411. if value, ok := wc.mutation.Nickname(); ok {
  412. _spec.SetField(whatsapp.FieldNickname, field.TypeString, value)
  413. _node.Nickname = value
  414. }
  415. if value, ok := wc.mutation.Phone(); ok {
  416. _spec.SetField(whatsapp.FieldPhone, field.TypeString, value)
  417. _node.Phone = value
  418. }
  419. if value, ok := wc.mutation.PhoneName(); ok {
  420. _spec.SetField(whatsapp.FieldPhoneName, field.TypeString, value)
  421. _node.PhoneName = value
  422. }
  423. if value, ok := wc.mutation.PhoneStatus(); ok {
  424. _spec.SetField(whatsapp.FieldPhoneStatus, field.TypeInt8, value)
  425. _node.PhoneStatus = value
  426. }
  427. if value, ok := wc.mutation.OrganizationID(); ok {
  428. _spec.SetField(whatsapp.FieldOrganizationID, field.TypeUint64, value)
  429. _node.OrganizationID = value
  430. }
  431. if value, ok := wc.mutation.APIBase(); ok {
  432. _spec.SetField(whatsapp.FieldAPIBase, field.TypeString, value)
  433. _node.APIBase = value
  434. }
  435. if value, ok := wc.mutation.APIKey(); ok {
  436. _spec.SetField(whatsapp.FieldAPIKey, field.TypeString, value)
  437. _node.APIKey = value
  438. }
  439. if value, ok := wc.mutation.AllowList(); ok {
  440. _spec.SetField(whatsapp.FieldAllowList, field.TypeJSON, value)
  441. _node.AllowList = value
  442. }
  443. if value, ok := wc.mutation.GroupAllowList(); ok {
  444. _spec.SetField(whatsapp.FieldGroupAllowList, field.TypeJSON, value)
  445. _node.GroupAllowList = value
  446. }
  447. if value, ok := wc.mutation.BlockList(); ok {
  448. _spec.SetField(whatsapp.FieldBlockList, field.TypeJSON, value)
  449. _node.BlockList = value
  450. }
  451. if value, ok := wc.mutation.GroupBlockList(); ok {
  452. _spec.SetField(whatsapp.FieldGroupBlockList, field.TypeJSON, value)
  453. _node.GroupBlockList = value
  454. }
  455. if nodes := wc.mutation.AgentIDs(); len(nodes) > 0 {
  456. edge := &sqlgraph.EdgeSpec{
  457. Rel: sqlgraph.M2O,
  458. Inverse: true,
  459. Table: whatsapp.AgentTable,
  460. Columns: []string{whatsapp.AgentColumn},
  461. Bidi: false,
  462. Target: &sqlgraph.EdgeTarget{
  463. IDSpec: sqlgraph.NewFieldSpec(agent.FieldID, field.TypeUint64),
  464. },
  465. }
  466. for _, k := range nodes {
  467. edge.Target.Nodes = append(edge.Target.Nodes, k)
  468. }
  469. _node.AgentID = nodes[0]
  470. _spec.Edges = append(_spec.Edges, edge)
  471. }
  472. return _node, _spec
  473. }
  474. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  475. // of the `INSERT` statement. For example:
  476. //
  477. // client.Whatsapp.Create().
  478. // SetCreatedAt(v).
  479. // OnConflict(
  480. // // Update the row with the new values
  481. // // the was proposed for insertion.
  482. // sql.ResolveWithNewValues(),
  483. // ).
  484. // // Override some of the fields with custom
  485. // // update values.
  486. // Update(func(u *ent.WhatsappUpsert) {
  487. // SetCreatedAt(v+v).
  488. // }).
  489. // Exec(ctx)
  490. func (wc *WhatsappCreate) OnConflict(opts ...sql.ConflictOption) *WhatsappUpsertOne {
  491. wc.conflict = opts
  492. return &WhatsappUpsertOne{
  493. create: wc,
  494. }
  495. }
  496. // OnConflictColumns calls `OnConflict` and configures the columns
  497. // as conflict target. Using this option is equivalent to using:
  498. //
  499. // client.Whatsapp.Create().
  500. // OnConflict(sql.ConflictColumns(columns...)).
  501. // Exec(ctx)
  502. func (wc *WhatsappCreate) OnConflictColumns(columns ...string) *WhatsappUpsertOne {
  503. wc.conflict = append(wc.conflict, sql.ConflictColumns(columns...))
  504. return &WhatsappUpsertOne{
  505. create: wc,
  506. }
  507. }
  508. type (
  509. // WhatsappUpsertOne is the builder for "upsert"-ing
  510. // one Whatsapp node.
  511. WhatsappUpsertOne struct {
  512. create *WhatsappCreate
  513. }
  514. // WhatsappUpsert is the "OnConflict" setter.
  515. WhatsappUpsert struct {
  516. *sql.UpdateSet
  517. }
  518. )
  519. // SetUpdatedAt sets the "updated_at" field.
  520. func (u *WhatsappUpsert) SetUpdatedAt(v time.Time) *WhatsappUpsert {
  521. u.Set(whatsapp.FieldUpdatedAt, v)
  522. return u
  523. }
  524. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  525. func (u *WhatsappUpsert) UpdateUpdatedAt() *WhatsappUpsert {
  526. u.SetExcluded(whatsapp.FieldUpdatedAt)
  527. return u
  528. }
  529. // SetStatus sets the "status" field.
  530. func (u *WhatsappUpsert) SetStatus(v uint8) *WhatsappUpsert {
  531. u.Set(whatsapp.FieldStatus, v)
  532. return u
  533. }
  534. // UpdateStatus sets the "status" field to the value that was provided on create.
  535. func (u *WhatsappUpsert) UpdateStatus() *WhatsappUpsert {
  536. u.SetExcluded(whatsapp.FieldStatus)
  537. return u
  538. }
  539. // AddStatus adds v to the "status" field.
  540. func (u *WhatsappUpsert) AddStatus(v uint8) *WhatsappUpsert {
  541. u.Add(whatsapp.FieldStatus, v)
  542. return u
  543. }
  544. // ClearStatus clears the value of the "status" field.
  545. func (u *WhatsappUpsert) ClearStatus() *WhatsappUpsert {
  546. u.SetNull(whatsapp.FieldStatus)
  547. return u
  548. }
  549. // SetDeletedAt sets the "deleted_at" field.
  550. func (u *WhatsappUpsert) SetDeletedAt(v time.Time) *WhatsappUpsert {
  551. u.Set(whatsapp.FieldDeletedAt, v)
  552. return u
  553. }
  554. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  555. func (u *WhatsappUpsert) UpdateDeletedAt() *WhatsappUpsert {
  556. u.SetExcluded(whatsapp.FieldDeletedAt)
  557. return u
  558. }
  559. // ClearDeletedAt clears the value of the "deleted_at" field.
  560. func (u *WhatsappUpsert) ClearDeletedAt() *WhatsappUpsert {
  561. u.SetNull(whatsapp.FieldDeletedAt)
  562. return u
  563. }
  564. // SetWaID sets the "wa_id" field.
  565. func (u *WhatsappUpsert) SetWaID(v uint64) *WhatsappUpsert {
  566. u.Set(whatsapp.FieldWaID, v)
  567. return u
  568. }
  569. // UpdateWaID sets the "wa_id" field to the value that was provided on create.
  570. func (u *WhatsappUpsert) UpdateWaID() *WhatsappUpsert {
  571. u.SetExcluded(whatsapp.FieldWaID)
  572. return u
  573. }
  574. // AddWaID adds v to the "wa_id" field.
  575. func (u *WhatsappUpsert) AddWaID(v uint64) *WhatsappUpsert {
  576. u.Add(whatsapp.FieldWaID, v)
  577. return u
  578. }
  579. // ClearWaID clears the value of the "wa_id" field.
  580. func (u *WhatsappUpsert) ClearWaID() *WhatsappUpsert {
  581. u.SetNull(whatsapp.FieldWaID)
  582. return u
  583. }
  584. // SetCallback sets the "callback" field.
  585. func (u *WhatsappUpsert) SetCallback(v string) *WhatsappUpsert {
  586. u.Set(whatsapp.FieldCallback, v)
  587. return u
  588. }
  589. // UpdateCallback sets the "callback" field to the value that was provided on create.
  590. func (u *WhatsappUpsert) UpdateCallback() *WhatsappUpsert {
  591. u.SetExcluded(whatsapp.FieldCallback)
  592. return u
  593. }
  594. // ClearCallback clears the value of the "callback" field.
  595. func (u *WhatsappUpsert) ClearCallback() *WhatsappUpsert {
  596. u.SetNull(whatsapp.FieldCallback)
  597. return u
  598. }
  599. // SetAgentID sets the "agent_id" field.
  600. func (u *WhatsappUpsert) SetAgentID(v uint64) *WhatsappUpsert {
  601. u.Set(whatsapp.FieldAgentID, v)
  602. return u
  603. }
  604. // UpdateAgentID sets the "agent_id" field to the value that was provided on create.
  605. func (u *WhatsappUpsert) UpdateAgentID() *WhatsappUpsert {
  606. u.SetExcluded(whatsapp.FieldAgentID)
  607. return u
  608. }
  609. // SetAccount sets the "account" field.
  610. func (u *WhatsappUpsert) SetAccount(v string) *WhatsappUpsert {
  611. u.Set(whatsapp.FieldAccount, v)
  612. return u
  613. }
  614. // UpdateAccount sets the "account" field to the value that was provided on create.
  615. func (u *WhatsappUpsert) UpdateAccount() *WhatsappUpsert {
  616. u.SetExcluded(whatsapp.FieldAccount)
  617. return u
  618. }
  619. // ClearAccount clears the value of the "account" field.
  620. func (u *WhatsappUpsert) ClearAccount() *WhatsappUpsert {
  621. u.SetNull(whatsapp.FieldAccount)
  622. return u
  623. }
  624. // SetNickname sets the "nickname" field.
  625. func (u *WhatsappUpsert) SetNickname(v string) *WhatsappUpsert {
  626. u.Set(whatsapp.FieldNickname, v)
  627. return u
  628. }
  629. // UpdateNickname sets the "nickname" field to the value that was provided on create.
  630. func (u *WhatsappUpsert) UpdateNickname() *WhatsappUpsert {
  631. u.SetExcluded(whatsapp.FieldNickname)
  632. return u
  633. }
  634. // SetPhone sets the "phone" field.
  635. func (u *WhatsappUpsert) SetPhone(v string) *WhatsappUpsert {
  636. u.Set(whatsapp.FieldPhone, v)
  637. return u
  638. }
  639. // UpdatePhone sets the "phone" field to the value that was provided on create.
  640. func (u *WhatsappUpsert) UpdatePhone() *WhatsappUpsert {
  641. u.SetExcluded(whatsapp.FieldPhone)
  642. return u
  643. }
  644. // SetPhoneName sets the "phone_name" field.
  645. func (u *WhatsappUpsert) SetPhoneName(v string) *WhatsappUpsert {
  646. u.Set(whatsapp.FieldPhoneName, v)
  647. return u
  648. }
  649. // UpdatePhoneName sets the "phone_name" field to the value that was provided on create.
  650. func (u *WhatsappUpsert) UpdatePhoneName() *WhatsappUpsert {
  651. u.SetExcluded(whatsapp.FieldPhoneName)
  652. return u
  653. }
  654. // SetPhoneStatus sets the "phone_status" field.
  655. func (u *WhatsappUpsert) SetPhoneStatus(v int8) *WhatsappUpsert {
  656. u.Set(whatsapp.FieldPhoneStatus, v)
  657. return u
  658. }
  659. // UpdatePhoneStatus sets the "phone_status" field to the value that was provided on create.
  660. func (u *WhatsappUpsert) UpdatePhoneStatus() *WhatsappUpsert {
  661. u.SetExcluded(whatsapp.FieldPhoneStatus)
  662. return u
  663. }
  664. // AddPhoneStatus adds v to the "phone_status" field.
  665. func (u *WhatsappUpsert) AddPhoneStatus(v int8) *WhatsappUpsert {
  666. u.Add(whatsapp.FieldPhoneStatus, v)
  667. return u
  668. }
  669. // SetOrganizationID sets the "organization_id" field.
  670. func (u *WhatsappUpsert) SetOrganizationID(v uint64) *WhatsappUpsert {
  671. u.Set(whatsapp.FieldOrganizationID, v)
  672. return u
  673. }
  674. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  675. func (u *WhatsappUpsert) UpdateOrganizationID() *WhatsappUpsert {
  676. u.SetExcluded(whatsapp.FieldOrganizationID)
  677. return u
  678. }
  679. // AddOrganizationID adds v to the "organization_id" field.
  680. func (u *WhatsappUpsert) AddOrganizationID(v uint64) *WhatsappUpsert {
  681. u.Add(whatsapp.FieldOrganizationID, v)
  682. return u
  683. }
  684. // ClearOrganizationID clears the value of the "organization_id" field.
  685. func (u *WhatsappUpsert) ClearOrganizationID() *WhatsappUpsert {
  686. u.SetNull(whatsapp.FieldOrganizationID)
  687. return u
  688. }
  689. // SetAPIBase sets the "api_base" field.
  690. func (u *WhatsappUpsert) SetAPIBase(v string) *WhatsappUpsert {
  691. u.Set(whatsapp.FieldAPIBase, v)
  692. return u
  693. }
  694. // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
  695. func (u *WhatsappUpsert) UpdateAPIBase() *WhatsappUpsert {
  696. u.SetExcluded(whatsapp.FieldAPIBase)
  697. return u
  698. }
  699. // ClearAPIBase clears the value of the "api_base" field.
  700. func (u *WhatsappUpsert) ClearAPIBase() *WhatsappUpsert {
  701. u.SetNull(whatsapp.FieldAPIBase)
  702. return u
  703. }
  704. // SetAPIKey sets the "api_key" field.
  705. func (u *WhatsappUpsert) SetAPIKey(v string) *WhatsappUpsert {
  706. u.Set(whatsapp.FieldAPIKey, v)
  707. return u
  708. }
  709. // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
  710. func (u *WhatsappUpsert) UpdateAPIKey() *WhatsappUpsert {
  711. u.SetExcluded(whatsapp.FieldAPIKey)
  712. return u
  713. }
  714. // ClearAPIKey clears the value of the "api_key" field.
  715. func (u *WhatsappUpsert) ClearAPIKey() *WhatsappUpsert {
  716. u.SetNull(whatsapp.FieldAPIKey)
  717. return u
  718. }
  719. // SetAllowList sets the "allow_list" field.
  720. func (u *WhatsappUpsert) SetAllowList(v []string) *WhatsappUpsert {
  721. u.Set(whatsapp.FieldAllowList, v)
  722. return u
  723. }
  724. // UpdateAllowList sets the "allow_list" field to the value that was provided on create.
  725. func (u *WhatsappUpsert) UpdateAllowList() *WhatsappUpsert {
  726. u.SetExcluded(whatsapp.FieldAllowList)
  727. return u
  728. }
  729. // ClearAllowList clears the value of the "allow_list" field.
  730. func (u *WhatsappUpsert) ClearAllowList() *WhatsappUpsert {
  731. u.SetNull(whatsapp.FieldAllowList)
  732. return u
  733. }
  734. // SetGroupAllowList sets the "group_allow_list" field.
  735. func (u *WhatsappUpsert) SetGroupAllowList(v []string) *WhatsappUpsert {
  736. u.Set(whatsapp.FieldGroupAllowList, v)
  737. return u
  738. }
  739. // UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
  740. func (u *WhatsappUpsert) UpdateGroupAllowList() *WhatsappUpsert {
  741. u.SetExcluded(whatsapp.FieldGroupAllowList)
  742. return u
  743. }
  744. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  745. func (u *WhatsappUpsert) ClearGroupAllowList() *WhatsappUpsert {
  746. u.SetNull(whatsapp.FieldGroupAllowList)
  747. return u
  748. }
  749. // SetBlockList sets the "block_list" field.
  750. func (u *WhatsappUpsert) SetBlockList(v []string) *WhatsappUpsert {
  751. u.Set(whatsapp.FieldBlockList, v)
  752. return u
  753. }
  754. // UpdateBlockList sets the "block_list" field to the value that was provided on create.
  755. func (u *WhatsappUpsert) UpdateBlockList() *WhatsappUpsert {
  756. u.SetExcluded(whatsapp.FieldBlockList)
  757. return u
  758. }
  759. // ClearBlockList clears the value of the "block_list" field.
  760. func (u *WhatsappUpsert) ClearBlockList() *WhatsappUpsert {
  761. u.SetNull(whatsapp.FieldBlockList)
  762. return u
  763. }
  764. // SetGroupBlockList sets the "group_block_list" field.
  765. func (u *WhatsappUpsert) SetGroupBlockList(v []string) *WhatsappUpsert {
  766. u.Set(whatsapp.FieldGroupBlockList, v)
  767. return u
  768. }
  769. // UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
  770. func (u *WhatsappUpsert) UpdateGroupBlockList() *WhatsappUpsert {
  771. u.SetExcluded(whatsapp.FieldGroupBlockList)
  772. return u
  773. }
  774. // ClearGroupBlockList clears the value of the "group_block_list" field.
  775. func (u *WhatsappUpsert) ClearGroupBlockList() *WhatsappUpsert {
  776. u.SetNull(whatsapp.FieldGroupBlockList)
  777. return u
  778. }
  779. // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
  780. // Using this option is equivalent to using:
  781. //
  782. // client.Whatsapp.Create().
  783. // OnConflict(
  784. // sql.ResolveWithNewValues(),
  785. // sql.ResolveWith(func(u *sql.UpdateSet) {
  786. // u.SetIgnore(whatsapp.FieldID)
  787. // }),
  788. // ).
  789. // Exec(ctx)
  790. func (u *WhatsappUpsertOne) UpdateNewValues() *WhatsappUpsertOne {
  791. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  792. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  793. if _, exists := u.create.mutation.ID(); exists {
  794. s.SetIgnore(whatsapp.FieldID)
  795. }
  796. if _, exists := u.create.mutation.CreatedAt(); exists {
  797. s.SetIgnore(whatsapp.FieldCreatedAt)
  798. }
  799. }))
  800. return u
  801. }
  802. // Ignore sets each column to itself in case of conflict.
  803. // Using this option is equivalent to using:
  804. //
  805. // client.Whatsapp.Create().
  806. // OnConflict(sql.ResolveWithIgnore()).
  807. // Exec(ctx)
  808. func (u *WhatsappUpsertOne) Ignore() *WhatsappUpsertOne {
  809. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  810. return u
  811. }
  812. // DoNothing configures the conflict_action to `DO NOTHING`.
  813. // Supported only by SQLite and PostgreSQL.
  814. func (u *WhatsappUpsertOne) DoNothing() *WhatsappUpsertOne {
  815. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  816. return u
  817. }
  818. // Update allows overriding fields `UPDATE` values. See the WhatsappCreate.OnConflict
  819. // documentation for more info.
  820. func (u *WhatsappUpsertOne) Update(set func(*WhatsappUpsert)) *WhatsappUpsertOne {
  821. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  822. set(&WhatsappUpsert{UpdateSet: update})
  823. }))
  824. return u
  825. }
  826. // SetUpdatedAt sets the "updated_at" field.
  827. func (u *WhatsappUpsertOne) SetUpdatedAt(v time.Time) *WhatsappUpsertOne {
  828. return u.Update(func(s *WhatsappUpsert) {
  829. s.SetUpdatedAt(v)
  830. })
  831. }
  832. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  833. func (u *WhatsappUpsertOne) UpdateUpdatedAt() *WhatsappUpsertOne {
  834. return u.Update(func(s *WhatsappUpsert) {
  835. s.UpdateUpdatedAt()
  836. })
  837. }
  838. // SetStatus sets the "status" field.
  839. func (u *WhatsappUpsertOne) SetStatus(v uint8) *WhatsappUpsertOne {
  840. return u.Update(func(s *WhatsappUpsert) {
  841. s.SetStatus(v)
  842. })
  843. }
  844. // AddStatus adds v to the "status" field.
  845. func (u *WhatsappUpsertOne) AddStatus(v uint8) *WhatsappUpsertOne {
  846. return u.Update(func(s *WhatsappUpsert) {
  847. s.AddStatus(v)
  848. })
  849. }
  850. // UpdateStatus sets the "status" field to the value that was provided on create.
  851. func (u *WhatsappUpsertOne) UpdateStatus() *WhatsappUpsertOne {
  852. return u.Update(func(s *WhatsappUpsert) {
  853. s.UpdateStatus()
  854. })
  855. }
  856. // ClearStatus clears the value of the "status" field.
  857. func (u *WhatsappUpsertOne) ClearStatus() *WhatsappUpsertOne {
  858. return u.Update(func(s *WhatsappUpsert) {
  859. s.ClearStatus()
  860. })
  861. }
  862. // SetDeletedAt sets the "deleted_at" field.
  863. func (u *WhatsappUpsertOne) SetDeletedAt(v time.Time) *WhatsappUpsertOne {
  864. return u.Update(func(s *WhatsappUpsert) {
  865. s.SetDeletedAt(v)
  866. })
  867. }
  868. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  869. func (u *WhatsappUpsertOne) UpdateDeletedAt() *WhatsappUpsertOne {
  870. return u.Update(func(s *WhatsappUpsert) {
  871. s.UpdateDeletedAt()
  872. })
  873. }
  874. // ClearDeletedAt clears the value of the "deleted_at" field.
  875. func (u *WhatsappUpsertOne) ClearDeletedAt() *WhatsappUpsertOne {
  876. return u.Update(func(s *WhatsappUpsert) {
  877. s.ClearDeletedAt()
  878. })
  879. }
  880. // SetWaID sets the "wa_id" field.
  881. func (u *WhatsappUpsertOne) SetWaID(v uint64) *WhatsappUpsertOne {
  882. return u.Update(func(s *WhatsappUpsert) {
  883. s.SetWaID(v)
  884. })
  885. }
  886. // AddWaID adds v to the "wa_id" field.
  887. func (u *WhatsappUpsertOne) AddWaID(v uint64) *WhatsappUpsertOne {
  888. return u.Update(func(s *WhatsappUpsert) {
  889. s.AddWaID(v)
  890. })
  891. }
  892. // UpdateWaID sets the "wa_id" field to the value that was provided on create.
  893. func (u *WhatsappUpsertOne) UpdateWaID() *WhatsappUpsertOne {
  894. return u.Update(func(s *WhatsappUpsert) {
  895. s.UpdateWaID()
  896. })
  897. }
  898. // ClearWaID clears the value of the "wa_id" field.
  899. func (u *WhatsappUpsertOne) ClearWaID() *WhatsappUpsertOne {
  900. return u.Update(func(s *WhatsappUpsert) {
  901. s.ClearWaID()
  902. })
  903. }
  904. // SetCallback sets the "callback" field.
  905. func (u *WhatsappUpsertOne) SetCallback(v string) *WhatsappUpsertOne {
  906. return u.Update(func(s *WhatsappUpsert) {
  907. s.SetCallback(v)
  908. })
  909. }
  910. // UpdateCallback sets the "callback" field to the value that was provided on create.
  911. func (u *WhatsappUpsertOne) UpdateCallback() *WhatsappUpsertOne {
  912. return u.Update(func(s *WhatsappUpsert) {
  913. s.UpdateCallback()
  914. })
  915. }
  916. // ClearCallback clears the value of the "callback" field.
  917. func (u *WhatsappUpsertOne) ClearCallback() *WhatsappUpsertOne {
  918. return u.Update(func(s *WhatsappUpsert) {
  919. s.ClearCallback()
  920. })
  921. }
  922. // SetAgentID sets the "agent_id" field.
  923. func (u *WhatsappUpsertOne) SetAgentID(v uint64) *WhatsappUpsertOne {
  924. return u.Update(func(s *WhatsappUpsert) {
  925. s.SetAgentID(v)
  926. })
  927. }
  928. // UpdateAgentID sets the "agent_id" field to the value that was provided on create.
  929. func (u *WhatsappUpsertOne) UpdateAgentID() *WhatsappUpsertOne {
  930. return u.Update(func(s *WhatsappUpsert) {
  931. s.UpdateAgentID()
  932. })
  933. }
  934. // SetAccount sets the "account" field.
  935. func (u *WhatsappUpsertOne) SetAccount(v string) *WhatsappUpsertOne {
  936. return u.Update(func(s *WhatsappUpsert) {
  937. s.SetAccount(v)
  938. })
  939. }
  940. // UpdateAccount sets the "account" field to the value that was provided on create.
  941. func (u *WhatsappUpsertOne) UpdateAccount() *WhatsappUpsertOne {
  942. return u.Update(func(s *WhatsappUpsert) {
  943. s.UpdateAccount()
  944. })
  945. }
  946. // ClearAccount clears the value of the "account" field.
  947. func (u *WhatsappUpsertOne) ClearAccount() *WhatsappUpsertOne {
  948. return u.Update(func(s *WhatsappUpsert) {
  949. s.ClearAccount()
  950. })
  951. }
  952. // SetNickname sets the "nickname" field.
  953. func (u *WhatsappUpsertOne) SetNickname(v string) *WhatsappUpsertOne {
  954. return u.Update(func(s *WhatsappUpsert) {
  955. s.SetNickname(v)
  956. })
  957. }
  958. // UpdateNickname sets the "nickname" field to the value that was provided on create.
  959. func (u *WhatsappUpsertOne) UpdateNickname() *WhatsappUpsertOne {
  960. return u.Update(func(s *WhatsappUpsert) {
  961. s.UpdateNickname()
  962. })
  963. }
  964. // SetPhone sets the "phone" field.
  965. func (u *WhatsappUpsertOne) SetPhone(v string) *WhatsappUpsertOne {
  966. return u.Update(func(s *WhatsappUpsert) {
  967. s.SetPhone(v)
  968. })
  969. }
  970. // UpdatePhone sets the "phone" field to the value that was provided on create.
  971. func (u *WhatsappUpsertOne) UpdatePhone() *WhatsappUpsertOne {
  972. return u.Update(func(s *WhatsappUpsert) {
  973. s.UpdatePhone()
  974. })
  975. }
  976. // SetPhoneName sets the "phone_name" field.
  977. func (u *WhatsappUpsertOne) SetPhoneName(v string) *WhatsappUpsertOne {
  978. return u.Update(func(s *WhatsappUpsert) {
  979. s.SetPhoneName(v)
  980. })
  981. }
  982. // UpdatePhoneName sets the "phone_name" field to the value that was provided on create.
  983. func (u *WhatsappUpsertOne) UpdatePhoneName() *WhatsappUpsertOne {
  984. return u.Update(func(s *WhatsappUpsert) {
  985. s.UpdatePhoneName()
  986. })
  987. }
  988. // SetPhoneStatus sets the "phone_status" field.
  989. func (u *WhatsappUpsertOne) SetPhoneStatus(v int8) *WhatsappUpsertOne {
  990. return u.Update(func(s *WhatsappUpsert) {
  991. s.SetPhoneStatus(v)
  992. })
  993. }
  994. // AddPhoneStatus adds v to the "phone_status" field.
  995. func (u *WhatsappUpsertOne) AddPhoneStatus(v int8) *WhatsappUpsertOne {
  996. return u.Update(func(s *WhatsappUpsert) {
  997. s.AddPhoneStatus(v)
  998. })
  999. }
  1000. // UpdatePhoneStatus sets the "phone_status" field to the value that was provided on create.
  1001. func (u *WhatsappUpsertOne) UpdatePhoneStatus() *WhatsappUpsertOne {
  1002. return u.Update(func(s *WhatsappUpsert) {
  1003. s.UpdatePhoneStatus()
  1004. })
  1005. }
  1006. // SetOrganizationID sets the "organization_id" field.
  1007. func (u *WhatsappUpsertOne) SetOrganizationID(v uint64) *WhatsappUpsertOne {
  1008. return u.Update(func(s *WhatsappUpsert) {
  1009. s.SetOrganizationID(v)
  1010. })
  1011. }
  1012. // AddOrganizationID adds v to the "organization_id" field.
  1013. func (u *WhatsappUpsertOne) AddOrganizationID(v uint64) *WhatsappUpsertOne {
  1014. return u.Update(func(s *WhatsappUpsert) {
  1015. s.AddOrganizationID(v)
  1016. })
  1017. }
  1018. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  1019. func (u *WhatsappUpsertOne) UpdateOrganizationID() *WhatsappUpsertOne {
  1020. return u.Update(func(s *WhatsappUpsert) {
  1021. s.UpdateOrganizationID()
  1022. })
  1023. }
  1024. // ClearOrganizationID clears the value of the "organization_id" field.
  1025. func (u *WhatsappUpsertOne) ClearOrganizationID() *WhatsappUpsertOne {
  1026. return u.Update(func(s *WhatsappUpsert) {
  1027. s.ClearOrganizationID()
  1028. })
  1029. }
  1030. // SetAPIBase sets the "api_base" field.
  1031. func (u *WhatsappUpsertOne) SetAPIBase(v string) *WhatsappUpsertOne {
  1032. return u.Update(func(s *WhatsappUpsert) {
  1033. s.SetAPIBase(v)
  1034. })
  1035. }
  1036. // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
  1037. func (u *WhatsappUpsertOne) UpdateAPIBase() *WhatsappUpsertOne {
  1038. return u.Update(func(s *WhatsappUpsert) {
  1039. s.UpdateAPIBase()
  1040. })
  1041. }
  1042. // ClearAPIBase clears the value of the "api_base" field.
  1043. func (u *WhatsappUpsertOne) ClearAPIBase() *WhatsappUpsertOne {
  1044. return u.Update(func(s *WhatsappUpsert) {
  1045. s.ClearAPIBase()
  1046. })
  1047. }
  1048. // SetAPIKey sets the "api_key" field.
  1049. func (u *WhatsappUpsertOne) SetAPIKey(v string) *WhatsappUpsertOne {
  1050. return u.Update(func(s *WhatsappUpsert) {
  1051. s.SetAPIKey(v)
  1052. })
  1053. }
  1054. // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
  1055. func (u *WhatsappUpsertOne) UpdateAPIKey() *WhatsappUpsertOne {
  1056. return u.Update(func(s *WhatsappUpsert) {
  1057. s.UpdateAPIKey()
  1058. })
  1059. }
  1060. // ClearAPIKey clears the value of the "api_key" field.
  1061. func (u *WhatsappUpsertOne) ClearAPIKey() *WhatsappUpsertOne {
  1062. return u.Update(func(s *WhatsappUpsert) {
  1063. s.ClearAPIKey()
  1064. })
  1065. }
  1066. // SetAllowList sets the "allow_list" field.
  1067. func (u *WhatsappUpsertOne) SetAllowList(v []string) *WhatsappUpsertOne {
  1068. return u.Update(func(s *WhatsappUpsert) {
  1069. s.SetAllowList(v)
  1070. })
  1071. }
  1072. // UpdateAllowList sets the "allow_list" field to the value that was provided on create.
  1073. func (u *WhatsappUpsertOne) UpdateAllowList() *WhatsappUpsertOne {
  1074. return u.Update(func(s *WhatsappUpsert) {
  1075. s.UpdateAllowList()
  1076. })
  1077. }
  1078. // ClearAllowList clears the value of the "allow_list" field.
  1079. func (u *WhatsappUpsertOne) ClearAllowList() *WhatsappUpsertOne {
  1080. return u.Update(func(s *WhatsappUpsert) {
  1081. s.ClearAllowList()
  1082. })
  1083. }
  1084. // SetGroupAllowList sets the "group_allow_list" field.
  1085. func (u *WhatsappUpsertOne) SetGroupAllowList(v []string) *WhatsappUpsertOne {
  1086. return u.Update(func(s *WhatsappUpsert) {
  1087. s.SetGroupAllowList(v)
  1088. })
  1089. }
  1090. // UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
  1091. func (u *WhatsappUpsertOne) UpdateGroupAllowList() *WhatsappUpsertOne {
  1092. return u.Update(func(s *WhatsappUpsert) {
  1093. s.UpdateGroupAllowList()
  1094. })
  1095. }
  1096. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  1097. func (u *WhatsappUpsertOne) ClearGroupAllowList() *WhatsappUpsertOne {
  1098. return u.Update(func(s *WhatsappUpsert) {
  1099. s.ClearGroupAllowList()
  1100. })
  1101. }
  1102. // SetBlockList sets the "block_list" field.
  1103. func (u *WhatsappUpsertOne) SetBlockList(v []string) *WhatsappUpsertOne {
  1104. return u.Update(func(s *WhatsappUpsert) {
  1105. s.SetBlockList(v)
  1106. })
  1107. }
  1108. // UpdateBlockList sets the "block_list" field to the value that was provided on create.
  1109. func (u *WhatsappUpsertOne) UpdateBlockList() *WhatsappUpsertOne {
  1110. return u.Update(func(s *WhatsappUpsert) {
  1111. s.UpdateBlockList()
  1112. })
  1113. }
  1114. // ClearBlockList clears the value of the "block_list" field.
  1115. func (u *WhatsappUpsertOne) ClearBlockList() *WhatsappUpsertOne {
  1116. return u.Update(func(s *WhatsappUpsert) {
  1117. s.ClearBlockList()
  1118. })
  1119. }
  1120. // SetGroupBlockList sets the "group_block_list" field.
  1121. func (u *WhatsappUpsertOne) SetGroupBlockList(v []string) *WhatsappUpsertOne {
  1122. return u.Update(func(s *WhatsappUpsert) {
  1123. s.SetGroupBlockList(v)
  1124. })
  1125. }
  1126. // UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
  1127. func (u *WhatsappUpsertOne) UpdateGroupBlockList() *WhatsappUpsertOne {
  1128. return u.Update(func(s *WhatsappUpsert) {
  1129. s.UpdateGroupBlockList()
  1130. })
  1131. }
  1132. // ClearGroupBlockList clears the value of the "group_block_list" field.
  1133. func (u *WhatsappUpsertOne) ClearGroupBlockList() *WhatsappUpsertOne {
  1134. return u.Update(func(s *WhatsappUpsert) {
  1135. s.ClearGroupBlockList()
  1136. })
  1137. }
  1138. // Exec executes the query.
  1139. func (u *WhatsappUpsertOne) Exec(ctx context.Context) error {
  1140. if len(u.create.conflict) == 0 {
  1141. return errors.New("ent: missing options for WhatsappCreate.OnConflict")
  1142. }
  1143. return u.create.Exec(ctx)
  1144. }
  1145. // ExecX is like Exec, but panics if an error occurs.
  1146. func (u *WhatsappUpsertOne) ExecX(ctx context.Context) {
  1147. if err := u.create.Exec(ctx); err != nil {
  1148. panic(err)
  1149. }
  1150. }
  1151. // Exec executes the UPSERT query and returns the inserted/updated ID.
  1152. func (u *WhatsappUpsertOne) ID(ctx context.Context) (id uint64, err error) {
  1153. node, err := u.create.Save(ctx)
  1154. if err != nil {
  1155. return id, err
  1156. }
  1157. return node.ID, nil
  1158. }
  1159. // IDX is like ID, but panics if an error occurs.
  1160. func (u *WhatsappUpsertOne) IDX(ctx context.Context) uint64 {
  1161. id, err := u.ID(ctx)
  1162. if err != nil {
  1163. panic(err)
  1164. }
  1165. return id
  1166. }
  1167. // WhatsappCreateBulk is the builder for creating many Whatsapp entities in bulk.
  1168. type WhatsappCreateBulk struct {
  1169. config
  1170. err error
  1171. builders []*WhatsappCreate
  1172. conflict []sql.ConflictOption
  1173. }
  1174. // Save creates the Whatsapp entities in the database.
  1175. func (wcb *WhatsappCreateBulk) Save(ctx context.Context) ([]*Whatsapp, error) {
  1176. if wcb.err != nil {
  1177. return nil, wcb.err
  1178. }
  1179. specs := make([]*sqlgraph.CreateSpec, len(wcb.builders))
  1180. nodes := make([]*Whatsapp, len(wcb.builders))
  1181. mutators := make([]Mutator, len(wcb.builders))
  1182. for i := range wcb.builders {
  1183. func(i int, root context.Context) {
  1184. builder := wcb.builders[i]
  1185. builder.defaults()
  1186. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  1187. mutation, ok := m.(*WhatsappMutation)
  1188. if !ok {
  1189. return nil, fmt.Errorf("unexpected mutation type %T", m)
  1190. }
  1191. if err := builder.check(); err != nil {
  1192. return nil, err
  1193. }
  1194. builder.mutation = mutation
  1195. var err error
  1196. nodes[i], specs[i] = builder.createSpec()
  1197. if i < len(mutators)-1 {
  1198. _, err = mutators[i+1].Mutate(root, wcb.builders[i+1].mutation)
  1199. } else {
  1200. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  1201. spec.OnConflict = wcb.conflict
  1202. // Invoke the actual operation on the latest mutation in the chain.
  1203. if err = sqlgraph.BatchCreate(ctx, wcb.driver, spec); err != nil {
  1204. if sqlgraph.IsConstraintError(err) {
  1205. err = &ConstraintError{msg: err.Error(), wrap: err}
  1206. }
  1207. }
  1208. }
  1209. if err != nil {
  1210. return nil, err
  1211. }
  1212. mutation.id = &nodes[i].ID
  1213. if specs[i].ID.Value != nil && nodes[i].ID == 0 {
  1214. id := specs[i].ID.Value.(int64)
  1215. nodes[i].ID = uint64(id)
  1216. }
  1217. mutation.done = true
  1218. return nodes[i], nil
  1219. })
  1220. for i := len(builder.hooks) - 1; i >= 0; i-- {
  1221. mut = builder.hooks[i](mut)
  1222. }
  1223. mutators[i] = mut
  1224. }(i, ctx)
  1225. }
  1226. if len(mutators) > 0 {
  1227. if _, err := mutators[0].Mutate(ctx, wcb.builders[0].mutation); err != nil {
  1228. return nil, err
  1229. }
  1230. }
  1231. return nodes, nil
  1232. }
  1233. // SaveX is like Save, but panics if an error occurs.
  1234. func (wcb *WhatsappCreateBulk) SaveX(ctx context.Context) []*Whatsapp {
  1235. v, err := wcb.Save(ctx)
  1236. if err != nil {
  1237. panic(err)
  1238. }
  1239. return v
  1240. }
  1241. // Exec executes the query.
  1242. func (wcb *WhatsappCreateBulk) Exec(ctx context.Context) error {
  1243. _, err := wcb.Save(ctx)
  1244. return err
  1245. }
  1246. // ExecX is like Exec, but panics if an error occurs.
  1247. func (wcb *WhatsappCreateBulk) ExecX(ctx context.Context) {
  1248. if err := wcb.Exec(ctx); err != nil {
  1249. panic(err)
  1250. }
  1251. }
  1252. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  1253. // of the `INSERT` statement. For example:
  1254. //
  1255. // client.Whatsapp.CreateBulk(builders...).
  1256. // OnConflict(
  1257. // // Update the row with the new values
  1258. // // the was proposed for insertion.
  1259. // sql.ResolveWithNewValues(),
  1260. // ).
  1261. // // Override some of the fields with custom
  1262. // // update values.
  1263. // Update(func(u *ent.WhatsappUpsert) {
  1264. // SetCreatedAt(v+v).
  1265. // }).
  1266. // Exec(ctx)
  1267. func (wcb *WhatsappCreateBulk) OnConflict(opts ...sql.ConflictOption) *WhatsappUpsertBulk {
  1268. wcb.conflict = opts
  1269. return &WhatsappUpsertBulk{
  1270. create: wcb,
  1271. }
  1272. }
  1273. // OnConflictColumns calls `OnConflict` and configures the columns
  1274. // as conflict target. Using this option is equivalent to using:
  1275. //
  1276. // client.Whatsapp.Create().
  1277. // OnConflict(sql.ConflictColumns(columns...)).
  1278. // Exec(ctx)
  1279. func (wcb *WhatsappCreateBulk) OnConflictColumns(columns ...string) *WhatsappUpsertBulk {
  1280. wcb.conflict = append(wcb.conflict, sql.ConflictColumns(columns...))
  1281. return &WhatsappUpsertBulk{
  1282. create: wcb,
  1283. }
  1284. }
  1285. // WhatsappUpsertBulk is the builder for "upsert"-ing
  1286. // a bulk of Whatsapp nodes.
  1287. type WhatsappUpsertBulk struct {
  1288. create *WhatsappCreateBulk
  1289. }
  1290. // UpdateNewValues updates the mutable fields using the new values that
  1291. // were set on create. Using this option is equivalent to using:
  1292. //
  1293. // client.Whatsapp.Create().
  1294. // OnConflict(
  1295. // sql.ResolveWithNewValues(),
  1296. // sql.ResolveWith(func(u *sql.UpdateSet) {
  1297. // u.SetIgnore(whatsapp.FieldID)
  1298. // }),
  1299. // ).
  1300. // Exec(ctx)
  1301. func (u *WhatsappUpsertBulk) UpdateNewValues() *WhatsappUpsertBulk {
  1302. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1303. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1304. for _, b := range u.create.builders {
  1305. if _, exists := b.mutation.ID(); exists {
  1306. s.SetIgnore(whatsapp.FieldID)
  1307. }
  1308. if _, exists := b.mutation.CreatedAt(); exists {
  1309. s.SetIgnore(whatsapp.FieldCreatedAt)
  1310. }
  1311. }
  1312. }))
  1313. return u
  1314. }
  1315. // Ignore sets each column to itself in case of conflict.
  1316. // Using this option is equivalent to using:
  1317. //
  1318. // client.Whatsapp.Create().
  1319. // OnConflict(sql.ResolveWithIgnore()).
  1320. // Exec(ctx)
  1321. func (u *WhatsappUpsertBulk) Ignore() *WhatsappUpsertBulk {
  1322. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1323. return u
  1324. }
  1325. // DoNothing configures the conflict_action to `DO NOTHING`.
  1326. // Supported only by SQLite and PostgreSQL.
  1327. func (u *WhatsappUpsertBulk) DoNothing() *WhatsappUpsertBulk {
  1328. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1329. return u
  1330. }
  1331. // Update allows overriding fields `UPDATE` values. See the WhatsappCreateBulk.OnConflict
  1332. // documentation for more info.
  1333. func (u *WhatsappUpsertBulk) Update(set func(*WhatsappUpsert)) *WhatsappUpsertBulk {
  1334. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1335. set(&WhatsappUpsert{UpdateSet: update})
  1336. }))
  1337. return u
  1338. }
  1339. // SetUpdatedAt sets the "updated_at" field.
  1340. func (u *WhatsappUpsertBulk) SetUpdatedAt(v time.Time) *WhatsappUpsertBulk {
  1341. return u.Update(func(s *WhatsappUpsert) {
  1342. s.SetUpdatedAt(v)
  1343. })
  1344. }
  1345. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1346. func (u *WhatsappUpsertBulk) UpdateUpdatedAt() *WhatsappUpsertBulk {
  1347. return u.Update(func(s *WhatsappUpsert) {
  1348. s.UpdateUpdatedAt()
  1349. })
  1350. }
  1351. // SetStatus sets the "status" field.
  1352. func (u *WhatsappUpsertBulk) SetStatus(v uint8) *WhatsappUpsertBulk {
  1353. return u.Update(func(s *WhatsappUpsert) {
  1354. s.SetStatus(v)
  1355. })
  1356. }
  1357. // AddStatus adds v to the "status" field.
  1358. func (u *WhatsappUpsertBulk) AddStatus(v uint8) *WhatsappUpsertBulk {
  1359. return u.Update(func(s *WhatsappUpsert) {
  1360. s.AddStatus(v)
  1361. })
  1362. }
  1363. // UpdateStatus sets the "status" field to the value that was provided on create.
  1364. func (u *WhatsappUpsertBulk) UpdateStatus() *WhatsappUpsertBulk {
  1365. return u.Update(func(s *WhatsappUpsert) {
  1366. s.UpdateStatus()
  1367. })
  1368. }
  1369. // ClearStatus clears the value of the "status" field.
  1370. func (u *WhatsappUpsertBulk) ClearStatus() *WhatsappUpsertBulk {
  1371. return u.Update(func(s *WhatsappUpsert) {
  1372. s.ClearStatus()
  1373. })
  1374. }
  1375. // SetDeletedAt sets the "deleted_at" field.
  1376. func (u *WhatsappUpsertBulk) SetDeletedAt(v time.Time) *WhatsappUpsertBulk {
  1377. return u.Update(func(s *WhatsappUpsert) {
  1378. s.SetDeletedAt(v)
  1379. })
  1380. }
  1381. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  1382. func (u *WhatsappUpsertBulk) UpdateDeletedAt() *WhatsappUpsertBulk {
  1383. return u.Update(func(s *WhatsappUpsert) {
  1384. s.UpdateDeletedAt()
  1385. })
  1386. }
  1387. // ClearDeletedAt clears the value of the "deleted_at" field.
  1388. func (u *WhatsappUpsertBulk) ClearDeletedAt() *WhatsappUpsertBulk {
  1389. return u.Update(func(s *WhatsappUpsert) {
  1390. s.ClearDeletedAt()
  1391. })
  1392. }
  1393. // SetWaID sets the "wa_id" field.
  1394. func (u *WhatsappUpsertBulk) SetWaID(v uint64) *WhatsappUpsertBulk {
  1395. return u.Update(func(s *WhatsappUpsert) {
  1396. s.SetWaID(v)
  1397. })
  1398. }
  1399. // AddWaID adds v to the "wa_id" field.
  1400. func (u *WhatsappUpsertBulk) AddWaID(v uint64) *WhatsappUpsertBulk {
  1401. return u.Update(func(s *WhatsappUpsert) {
  1402. s.AddWaID(v)
  1403. })
  1404. }
  1405. // UpdateWaID sets the "wa_id" field to the value that was provided on create.
  1406. func (u *WhatsappUpsertBulk) UpdateWaID() *WhatsappUpsertBulk {
  1407. return u.Update(func(s *WhatsappUpsert) {
  1408. s.UpdateWaID()
  1409. })
  1410. }
  1411. // ClearWaID clears the value of the "wa_id" field.
  1412. func (u *WhatsappUpsertBulk) ClearWaID() *WhatsappUpsertBulk {
  1413. return u.Update(func(s *WhatsappUpsert) {
  1414. s.ClearWaID()
  1415. })
  1416. }
  1417. // SetCallback sets the "callback" field.
  1418. func (u *WhatsappUpsertBulk) SetCallback(v string) *WhatsappUpsertBulk {
  1419. return u.Update(func(s *WhatsappUpsert) {
  1420. s.SetCallback(v)
  1421. })
  1422. }
  1423. // UpdateCallback sets the "callback" field to the value that was provided on create.
  1424. func (u *WhatsappUpsertBulk) UpdateCallback() *WhatsappUpsertBulk {
  1425. return u.Update(func(s *WhatsappUpsert) {
  1426. s.UpdateCallback()
  1427. })
  1428. }
  1429. // ClearCallback clears the value of the "callback" field.
  1430. func (u *WhatsappUpsertBulk) ClearCallback() *WhatsappUpsertBulk {
  1431. return u.Update(func(s *WhatsappUpsert) {
  1432. s.ClearCallback()
  1433. })
  1434. }
  1435. // SetAgentID sets the "agent_id" field.
  1436. func (u *WhatsappUpsertBulk) SetAgentID(v uint64) *WhatsappUpsertBulk {
  1437. return u.Update(func(s *WhatsappUpsert) {
  1438. s.SetAgentID(v)
  1439. })
  1440. }
  1441. // UpdateAgentID sets the "agent_id" field to the value that was provided on create.
  1442. func (u *WhatsappUpsertBulk) UpdateAgentID() *WhatsappUpsertBulk {
  1443. return u.Update(func(s *WhatsappUpsert) {
  1444. s.UpdateAgentID()
  1445. })
  1446. }
  1447. // SetAccount sets the "account" field.
  1448. func (u *WhatsappUpsertBulk) SetAccount(v string) *WhatsappUpsertBulk {
  1449. return u.Update(func(s *WhatsappUpsert) {
  1450. s.SetAccount(v)
  1451. })
  1452. }
  1453. // UpdateAccount sets the "account" field to the value that was provided on create.
  1454. func (u *WhatsappUpsertBulk) UpdateAccount() *WhatsappUpsertBulk {
  1455. return u.Update(func(s *WhatsappUpsert) {
  1456. s.UpdateAccount()
  1457. })
  1458. }
  1459. // ClearAccount clears the value of the "account" field.
  1460. func (u *WhatsappUpsertBulk) ClearAccount() *WhatsappUpsertBulk {
  1461. return u.Update(func(s *WhatsappUpsert) {
  1462. s.ClearAccount()
  1463. })
  1464. }
  1465. // SetNickname sets the "nickname" field.
  1466. func (u *WhatsappUpsertBulk) SetNickname(v string) *WhatsappUpsertBulk {
  1467. return u.Update(func(s *WhatsappUpsert) {
  1468. s.SetNickname(v)
  1469. })
  1470. }
  1471. // UpdateNickname sets the "nickname" field to the value that was provided on create.
  1472. func (u *WhatsappUpsertBulk) UpdateNickname() *WhatsappUpsertBulk {
  1473. return u.Update(func(s *WhatsappUpsert) {
  1474. s.UpdateNickname()
  1475. })
  1476. }
  1477. // SetPhone sets the "phone" field.
  1478. func (u *WhatsappUpsertBulk) SetPhone(v string) *WhatsappUpsertBulk {
  1479. return u.Update(func(s *WhatsappUpsert) {
  1480. s.SetPhone(v)
  1481. })
  1482. }
  1483. // UpdatePhone sets the "phone" field to the value that was provided on create.
  1484. func (u *WhatsappUpsertBulk) UpdatePhone() *WhatsappUpsertBulk {
  1485. return u.Update(func(s *WhatsappUpsert) {
  1486. s.UpdatePhone()
  1487. })
  1488. }
  1489. // SetPhoneName sets the "phone_name" field.
  1490. func (u *WhatsappUpsertBulk) SetPhoneName(v string) *WhatsappUpsertBulk {
  1491. return u.Update(func(s *WhatsappUpsert) {
  1492. s.SetPhoneName(v)
  1493. })
  1494. }
  1495. // UpdatePhoneName sets the "phone_name" field to the value that was provided on create.
  1496. func (u *WhatsappUpsertBulk) UpdatePhoneName() *WhatsappUpsertBulk {
  1497. return u.Update(func(s *WhatsappUpsert) {
  1498. s.UpdatePhoneName()
  1499. })
  1500. }
  1501. // SetPhoneStatus sets the "phone_status" field.
  1502. func (u *WhatsappUpsertBulk) SetPhoneStatus(v int8) *WhatsappUpsertBulk {
  1503. return u.Update(func(s *WhatsappUpsert) {
  1504. s.SetPhoneStatus(v)
  1505. })
  1506. }
  1507. // AddPhoneStatus adds v to the "phone_status" field.
  1508. func (u *WhatsappUpsertBulk) AddPhoneStatus(v int8) *WhatsappUpsertBulk {
  1509. return u.Update(func(s *WhatsappUpsert) {
  1510. s.AddPhoneStatus(v)
  1511. })
  1512. }
  1513. // UpdatePhoneStatus sets the "phone_status" field to the value that was provided on create.
  1514. func (u *WhatsappUpsertBulk) UpdatePhoneStatus() *WhatsappUpsertBulk {
  1515. return u.Update(func(s *WhatsappUpsert) {
  1516. s.UpdatePhoneStatus()
  1517. })
  1518. }
  1519. // SetOrganizationID sets the "organization_id" field.
  1520. func (u *WhatsappUpsertBulk) SetOrganizationID(v uint64) *WhatsappUpsertBulk {
  1521. return u.Update(func(s *WhatsappUpsert) {
  1522. s.SetOrganizationID(v)
  1523. })
  1524. }
  1525. // AddOrganizationID adds v to the "organization_id" field.
  1526. func (u *WhatsappUpsertBulk) AddOrganizationID(v uint64) *WhatsappUpsertBulk {
  1527. return u.Update(func(s *WhatsappUpsert) {
  1528. s.AddOrganizationID(v)
  1529. })
  1530. }
  1531. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  1532. func (u *WhatsappUpsertBulk) UpdateOrganizationID() *WhatsappUpsertBulk {
  1533. return u.Update(func(s *WhatsappUpsert) {
  1534. s.UpdateOrganizationID()
  1535. })
  1536. }
  1537. // ClearOrganizationID clears the value of the "organization_id" field.
  1538. func (u *WhatsappUpsertBulk) ClearOrganizationID() *WhatsappUpsertBulk {
  1539. return u.Update(func(s *WhatsappUpsert) {
  1540. s.ClearOrganizationID()
  1541. })
  1542. }
  1543. // SetAPIBase sets the "api_base" field.
  1544. func (u *WhatsappUpsertBulk) SetAPIBase(v string) *WhatsappUpsertBulk {
  1545. return u.Update(func(s *WhatsappUpsert) {
  1546. s.SetAPIBase(v)
  1547. })
  1548. }
  1549. // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
  1550. func (u *WhatsappUpsertBulk) UpdateAPIBase() *WhatsappUpsertBulk {
  1551. return u.Update(func(s *WhatsappUpsert) {
  1552. s.UpdateAPIBase()
  1553. })
  1554. }
  1555. // ClearAPIBase clears the value of the "api_base" field.
  1556. func (u *WhatsappUpsertBulk) ClearAPIBase() *WhatsappUpsertBulk {
  1557. return u.Update(func(s *WhatsappUpsert) {
  1558. s.ClearAPIBase()
  1559. })
  1560. }
  1561. // SetAPIKey sets the "api_key" field.
  1562. func (u *WhatsappUpsertBulk) SetAPIKey(v string) *WhatsappUpsertBulk {
  1563. return u.Update(func(s *WhatsappUpsert) {
  1564. s.SetAPIKey(v)
  1565. })
  1566. }
  1567. // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
  1568. func (u *WhatsappUpsertBulk) UpdateAPIKey() *WhatsappUpsertBulk {
  1569. return u.Update(func(s *WhatsappUpsert) {
  1570. s.UpdateAPIKey()
  1571. })
  1572. }
  1573. // ClearAPIKey clears the value of the "api_key" field.
  1574. func (u *WhatsappUpsertBulk) ClearAPIKey() *WhatsappUpsertBulk {
  1575. return u.Update(func(s *WhatsappUpsert) {
  1576. s.ClearAPIKey()
  1577. })
  1578. }
  1579. // SetAllowList sets the "allow_list" field.
  1580. func (u *WhatsappUpsertBulk) SetAllowList(v []string) *WhatsappUpsertBulk {
  1581. return u.Update(func(s *WhatsappUpsert) {
  1582. s.SetAllowList(v)
  1583. })
  1584. }
  1585. // UpdateAllowList sets the "allow_list" field to the value that was provided on create.
  1586. func (u *WhatsappUpsertBulk) UpdateAllowList() *WhatsappUpsertBulk {
  1587. return u.Update(func(s *WhatsappUpsert) {
  1588. s.UpdateAllowList()
  1589. })
  1590. }
  1591. // ClearAllowList clears the value of the "allow_list" field.
  1592. func (u *WhatsappUpsertBulk) ClearAllowList() *WhatsappUpsertBulk {
  1593. return u.Update(func(s *WhatsappUpsert) {
  1594. s.ClearAllowList()
  1595. })
  1596. }
  1597. // SetGroupAllowList sets the "group_allow_list" field.
  1598. func (u *WhatsappUpsertBulk) SetGroupAllowList(v []string) *WhatsappUpsertBulk {
  1599. return u.Update(func(s *WhatsappUpsert) {
  1600. s.SetGroupAllowList(v)
  1601. })
  1602. }
  1603. // UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
  1604. func (u *WhatsappUpsertBulk) UpdateGroupAllowList() *WhatsappUpsertBulk {
  1605. return u.Update(func(s *WhatsappUpsert) {
  1606. s.UpdateGroupAllowList()
  1607. })
  1608. }
  1609. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  1610. func (u *WhatsappUpsertBulk) ClearGroupAllowList() *WhatsappUpsertBulk {
  1611. return u.Update(func(s *WhatsappUpsert) {
  1612. s.ClearGroupAllowList()
  1613. })
  1614. }
  1615. // SetBlockList sets the "block_list" field.
  1616. func (u *WhatsappUpsertBulk) SetBlockList(v []string) *WhatsappUpsertBulk {
  1617. return u.Update(func(s *WhatsappUpsert) {
  1618. s.SetBlockList(v)
  1619. })
  1620. }
  1621. // UpdateBlockList sets the "block_list" field to the value that was provided on create.
  1622. func (u *WhatsappUpsertBulk) UpdateBlockList() *WhatsappUpsertBulk {
  1623. return u.Update(func(s *WhatsappUpsert) {
  1624. s.UpdateBlockList()
  1625. })
  1626. }
  1627. // ClearBlockList clears the value of the "block_list" field.
  1628. func (u *WhatsappUpsertBulk) ClearBlockList() *WhatsappUpsertBulk {
  1629. return u.Update(func(s *WhatsappUpsert) {
  1630. s.ClearBlockList()
  1631. })
  1632. }
  1633. // SetGroupBlockList sets the "group_block_list" field.
  1634. func (u *WhatsappUpsertBulk) SetGroupBlockList(v []string) *WhatsappUpsertBulk {
  1635. return u.Update(func(s *WhatsappUpsert) {
  1636. s.SetGroupBlockList(v)
  1637. })
  1638. }
  1639. // UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
  1640. func (u *WhatsappUpsertBulk) UpdateGroupBlockList() *WhatsappUpsertBulk {
  1641. return u.Update(func(s *WhatsappUpsert) {
  1642. s.UpdateGroupBlockList()
  1643. })
  1644. }
  1645. // ClearGroupBlockList clears the value of the "group_block_list" field.
  1646. func (u *WhatsappUpsertBulk) ClearGroupBlockList() *WhatsappUpsertBulk {
  1647. return u.Update(func(s *WhatsappUpsert) {
  1648. s.ClearGroupBlockList()
  1649. })
  1650. }
  1651. // Exec executes the query.
  1652. func (u *WhatsappUpsertBulk) Exec(ctx context.Context) error {
  1653. if u.create.err != nil {
  1654. return u.create.err
  1655. }
  1656. for i, b := range u.create.builders {
  1657. if len(b.conflict) != 0 {
  1658. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the WhatsappCreateBulk instead", i)
  1659. }
  1660. }
  1661. if len(u.create.conflict) == 0 {
  1662. return errors.New("ent: missing options for WhatsappCreateBulk.OnConflict")
  1663. }
  1664. return u.create.Exec(ctx)
  1665. }
  1666. // ExecX is like Exec, but panics if an error occurs.
  1667. func (u *WhatsappUpsertBulk) ExecX(ctx context.Context) {
  1668. if err := u.create.Exec(ctx); err != nil {
  1669. panic(err)
  1670. }
  1671. }