whatsapp_create.go 57 KB

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