whatsapp_create.go 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882
  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. // 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. // SetCc sets the "cc" field.
  118. func (wc *WhatsappCreate) SetCc(s string) *WhatsappCreate {
  119. wc.mutation.SetCc(s)
  120. return wc
  121. }
  122. // SetNillableCc sets the "cc" field if the given value is not nil.
  123. func (wc *WhatsappCreate) SetNillableCc(s *string) *WhatsappCreate {
  124. if s != nil {
  125. wc.SetCc(*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.Cc(); !ok {
  297. v := whatsapp.DefaultCc
  298. wc.mutation.SetCc(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.Cc(); !ok {
  338. return &ValidationError{Name: "cc", err: errors.New(`ent: missing required field "Whatsapp.cc"`)}
  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.TypeString, 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.Cc(); ok {
  412. _spec.SetField(whatsapp.FieldCc, field.TypeString, value)
  413. _node.Cc = 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 string) *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. // ClearWaID clears the value of the "wa_id" field.
  575. func (u *WhatsappUpsert) ClearWaID() *WhatsappUpsert {
  576. u.SetNull(whatsapp.FieldWaID)
  577. return u
  578. }
  579. // SetCallback sets the "callback" field.
  580. func (u *WhatsappUpsert) SetCallback(v string) *WhatsappUpsert {
  581. u.Set(whatsapp.FieldCallback, v)
  582. return u
  583. }
  584. // UpdateCallback sets the "callback" field to the value that was provided on create.
  585. func (u *WhatsappUpsert) UpdateCallback() *WhatsappUpsert {
  586. u.SetExcluded(whatsapp.FieldCallback)
  587. return u
  588. }
  589. // ClearCallback clears the value of the "callback" field.
  590. func (u *WhatsappUpsert) ClearCallback() *WhatsappUpsert {
  591. u.SetNull(whatsapp.FieldCallback)
  592. return u
  593. }
  594. // SetAgentID sets the "agent_id" field.
  595. func (u *WhatsappUpsert) SetAgentID(v uint64) *WhatsappUpsert {
  596. u.Set(whatsapp.FieldAgentID, v)
  597. return u
  598. }
  599. // UpdateAgentID sets the "agent_id" field to the value that was provided on create.
  600. func (u *WhatsappUpsert) UpdateAgentID() *WhatsappUpsert {
  601. u.SetExcluded(whatsapp.FieldAgentID)
  602. return u
  603. }
  604. // SetAccount sets the "account" field.
  605. func (u *WhatsappUpsert) SetAccount(v string) *WhatsappUpsert {
  606. u.Set(whatsapp.FieldAccount, v)
  607. return u
  608. }
  609. // UpdateAccount sets the "account" field to the value that was provided on create.
  610. func (u *WhatsappUpsert) UpdateAccount() *WhatsappUpsert {
  611. u.SetExcluded(whatsapp.FieldAccount)
  612. return u
  613. }
  614. // ClearAccount clears the value of the "account" field.
  615. func (u *WhatsappUpsert) ClearAccount() *WhatsappUpsert {
  616. u.SetNull(whatsapp.FieldAccount)
  617. return u
  618. }
  619. // SetCc sets the "cc" field.
  620. func (u *WhatsappUpsert) SetCc(v string) *WhatsappUpsert {
  621. u.Set(whatsapp.FieldCc, v)
  622. return u
  623. }
  624. // UpdateCc sets the "cc" field to the value that was provided on create.
  625. func (u *WhatsappUpsert) UpdateCc() *WhatsappUpsert {
  626. u.SetExcluded(whatsapp.FieldCc)
  627. return u
  628. }
  629. // SetPhone sets the "phone" field.
  630. func (u *WhatsappUpsert) SetPhone(v string) *WhatsappUpsert {
  631. u.Set(whatsapp.FieldPhone, v)
  632. return u
  633. }
  634. // UpdatePhone sets the "phone" field to the value that was provided on create.
  635. func (u *WhatsappUpsert) UpdatePhone() *WhatsappUpsert {
  636. u.SetExcluded(whatsapp.FieldPhone)
  637. return u
  638. }
  639. // SetPhoneName sets the "phone_name" field.
  640. func (u *WhatsappUpsert) SetPhoneName(v string) *WhatsappUpsert {
  641. u.Set(whatsapp.FieldPhoneName, v)
  642. return u
  643. }
  644. // UpdatePhoneName sets the "phone_name" field to the value that was provided on create.
  645. func (u *WhatsappUpsert) UpdatePhoneName() *WhatsappUpsert {
  646. u.SetExcluded(whatsapp.FieldPhoneName)
  647. return u
  648. }
  649. // SetPhoneStatus sets the "phone_status" field.
  650. func (u *WhatsappUpsert) SetPhoneStatus(v int8) *WhatsappUpsert {
  651. u.Set(whatsapp.FieldPhoneStatus, v)
  652. return u
  653. }
  654. // UpdatePhoneStatus sets the "phone_status" field to the value that was provided on create.
  655. func (u *WhatsappUpsert) UpdatePhoneStatus() *WhatsappUpsert {
  656. u.SetExcluded(whatsapp.FieldPhoneStatus)
  657. return u
  658. }
  659. // AddPhoneStatus adds v to the "phone_status" field.
  660. func (u *WhatsappUpsert) AddPhoneStatus(v int8) *WhatsappUpsert {
  661. u.Add(whatsapp.FieldPhoneStatus, v)
  662. return u
  663. }
  664. // SetOrganizationID sets the "organization_id" field.
  665. func (u *WhatsappUpsert) SetOrganizationID(v uint64) *WhatsappUpsert {
  666. u.Set(whatsapp.FieldOrganizationID, v)
  667. return u
  668. }
  669. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  670. func (u *WhatsappUpsert) UpdateOrganizationID() *WhatsappUpsert {
  671. u.SetExcluded(whatsapp.FieldOrganizationID)
  672. return u
  673. }
  674. // AddOrganizationID adds v to the "organization_id" field.
  675. func (u *WhatsappUpsert) AddOrganizationID(v uint64) *WhatsappUpsert {
  676. u.Add(whatsapp.FieldOrganizationID, v)
  677. return u
  678. }
  679. // ClearOrganizationID clears the value of the "organization_id" field.
  680. func (u *WhatsappUpsert) ClearOrganizationID() *WhatsappUpsert {
  681. u.SetNull(whatsapp.FieldOrganizationID)
  682. return u
  683. }
  684. // SetAPIBase sets the "api_base" field.
  685. func (u *WhatsappUpsert) SetAPIBase(v string) *WhatsappUpsert {
  686. u.Set(whatsapp.FieldAPIBase, v)
  687. return u
  688. }
  689. // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
  690. func (u *WhatsappUpsert) UpdateAPIBase() *WhatsappUpsert {
  691. u.SetExcluded(whatsapp.FieldAPIBase)
  692. return u
  693. }
  694. // ClearAPIBase clears the value of the "api_base" field.
  695. func (u *WhatsappUpsert) ClearAPIBase() *WhatsappUpsert {
  696. u.SetNull(whatsapp.FieldAPIBase)
  697. return u
  698. }
  699. // SetAPIKey sets the "api_key" field.
  700. func (u *WhatsappUpsert) SetAPIKey(v string) *WhatsappUpsert {
  701. u.Set(whatsapp.FieldAPIKey, v)
  702. return u
  703. }
  704. // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
  705. func (u *WhatsappUpsert) UpdateAPIKey() *WhatsappUpsert {
  706. u.SetExcluded(whatsapp.FieldAPIKey)
  707. return u
  708. }
  709. // ClearAPIKey clears the value of the "api_key" field.
  710. func (u *WhatsappUpsert) ClearAPIKey() *WhatsappUpsert {
  711. u.SetNull(whatsapp.FieldAPIKey)
  712. return u
  713. }
  714. // SetAllowList sets the "allow_list" field.
  715. func (u *WhatsappUpsert) SetAllowList(v []string) *WhatsappUpsert {
  716. u.Set(whatsapp.FieldAllowList, v)
  717. return u
  718. }
  719. // UpdateAllowList sets the "allow_list" field to the value that was provided on create.
  720. func (u *WhatsappUpsert) UpdateAllowList() *WhatsappUpsert {
  721. u.SetExcluded(whatsapp.FieldAllowList)
  722. return u
  723. }
  724. // ClearAllowList clears the value of the "allow_list" field.
  725. func (u *WhatsappUpsert) ClearAllowList() *WhatsappUpsert {
  726. u.SetNull(whatsapp.FieldAllowList)
  727. return u
  728. }
  729. // SetGroupAllowList sets the "group_allow_list" field.
  730. func (u *WhatsappUpsert) SetGroupAllowList(v []string) *WhatsappUpsert {
  731. u.Set(whatsapp.FieldGroupAllowList, v)
  732. return u
  733. }
  734. // UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
  735. func (u *WhatsappUpsert) UpdateGroupAllowList() *WhatsappUpsert {
  736. u.SetExcluded(whatsapp.FieldGroupAllowList)
  737. return u
  738. }
  739. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  740. func (u *WhatsappUpsert) ClearGroupAllowList() *WhatsappUpsert {
  741. u.SetNull(whatsapp.FieldGroupAllowList)
  742. return u
  743. }
  744. // SetBlockList sets the "block_list" field.
  745. func (u *WhatsappUpsert) SetBlockList(v []string) *WhatsappUpsert {
  746. u.Set(whatsapp.FieldBlockList, v)
  747. return u
  748. }
  749. // UpdateBlockList sets the "block_list" field to the value that was provided on create.
  750. func (u *WhatsappUpsert) UpdateBlockList() *WhatsappUpsert {
  751. u.SetExcluded(whatsapp.FieldBlockList)
  752. return u
  753. }
  754. // ClearBlockList clears the value of the "block_list" field.
  755. func (u *WhatsappUpsert) ClearBlockList() *WhatsappUpsert {
  756. u.SetNull(whatsapp.FieldBlockList)
  757. return u
  758. }
  759. // SetGroupBlockList sets the "group_block_list" field.
  760. func (u *WhatsappUpsert) SetGroupBlockList(v []string) *WhatsappUpsert {
  761. u.Set(whatsapp.FieldGroupBlockList, v)
  762. return u
  763. }
  764. // UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
  765. func (u *WhatsappUpsert) UpdateGroupBlockList() *WhatsappUpsert {
  766. u.SetExcluded(whatsapp.FieldGroupBlockList)
  767. return u
  768. }
  769. // ClearGroupBlockList clears the value of the "group_block_list" field.
  770. func (u *WhatsappUpsert) ClearGroupBlockList() *WhatsappUpsert {
  771. u.SetNull(whatsapp.FieldGroupBlockList)
  772. return u
  773. }
  774. // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
  775. // Using this option is equivalent to using:
  776. //
  777. // client.Whatsapp.Create().
  778. // OnConflict(
  779. // sql.ResolveWithNewValues(),
  780. // sql.ResolveWith(func(u *sql.UpdateSet) {
  781. // u.SetIgnore(whatsapp.FieldID)
  782. // }),
  783. // ).
  784. // Exec(ctx)
  785. func (u *WhatsappUpsertOne) UpdateNewValues() *WhatsappUpsertOne {
  786. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  787. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  788. if _, exists := u.create.mutation.ID(); exists {
  789. s.SetIgnore(whatsapp.FieldID)
  790. }
  791. if _, exists := u.create.mutation.CreatedAt(); exists {
  792. s.SetIgnore(whatsapp.FieldCreatedAt)
  793. }
  794. }))
  795. return u
  796. }
  797. // Ignore sets each column to itself in case of conflict.
  798. // Using this option is equivalent to using:
  799. //
  800. // client.Whatsapp.Create().
  801. // OnConflict(sql.ResolveWithIgnore()).
  802. // Exec(ctx)
  803. func (u *WhatsappUpsertOne) Ignore() *WhatsappUpsertOne {
  804. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  805. return u
  806. }
  807. // DoNothing configures the conflict_action to `DO NOTHING`.
  808. // Supported only by SQLite and PostgreSQL.
  809. func (u *WhatsappUpsertOne) DoNothing() *WhatsappUpsertOne {
  810. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  811. return u
  812. }
  813. // Update allows overriding fields `UPDATE` values. See the WhatsappCreate.OnConflict
  814. // documentation for more info.
  815. func (u *WhatsappUpsertOne) Update(set func(*WhatsappUpsert)) *WhatsappUpsertOne {
  816. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  817. set(&WhatsappUpsert{UpdateSet: update})
  818. }))
  819. return u
  820. }
  821. // SetUpdatedAt sets the "updated_at" field.
  822. func (u *WhatsappUpsertOne) SetUpdatedAt(v time.Time) *WhatsappUpsertOne {
  823. return u.Update(func(s *WhatsappUpsert) {
  824. s.SetUpdatedAt(v)
  825. })
  826. }
  827. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  828. func (u *WhatsappUpsertOne) UpdateUpdatedAt() *WhatsappUpsertOne {
  829. return u.Update(func(s *WhatsappUpsert) {
  830. s.UpdateUpdatedAt()
  831. })
  832. }
  833. // SetStatus sets the "status" field.
  834. func (u *WhatsappUpsertOne) SetStatus(v uint8) *WhatsappUpsertOne {
  835. return u.Update(func(s *WhatsappUpsert) {
  836. s.SetStatus(v)
  837. })
  838. }
  839. // AddStatus adds v to the "status" field.
  840. func (u *WhatsappUpsertOne) AddStatus(v uint8) *WhatsappUpsertOne {
  841. return u.Update(func(s *WhatsappUpsert) {
  842. s.AddStatus(v)
  843. })
  844. }
  845. // UpdateStatus sets the "status" field to the value that was provided on create.
  846. func (u *WhatsappUpsertOne) UpdateStatus() *WhatsappUpsertOne {
  847. return u.Update(func(s *WhatsappUpsert) {
  848. s.UpdateStatus()
  849. })
  850. }
  851. // ClearStatus clears the value of the "status" field.
  852. func (u *WhatsappUpsertOne) ClearStatus() *WhatsappUpsertOne {
  853. return u.Update(func(s *WhatsappUpsert) {
  854. s.ClearStatus()
  855. })
  856. }
  857. // SetDeletedAt sets the "deleted_at" field.
  858. func (u *WhatsappUpsertOne) SetDeletedAt(v time.Time) *WhatsappUpsertOne {
  859. return u.Update(func(s *WhatsappUpsert) {
  860. s.SetDeletedAt(v)
  861. })
  862. }
  863. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  864. func (u *WhatsappUpsertOne) UpdateDeletedAt() *WhatsappUpsertOne {
  865. return u.Update(func(s *WhatsappUpsert) {
  866. s.UpdateDeletedAt()
  867. })
  868. }
  869. // ClearDeletedAt clears the value of the "deleted_at" field.
  870. func (u *WhatsappUpsertOne) ClearDeletedAt() *WhatsappUpsertOne {
  871. return u.Update(func(s *WhatsappUpsert) {
  872. s.ClearDeletedAt()
  873. })
  874. }
  875. // SetWaID sets the "wa_id" field.
  876. func (u *WhatsappUpsertOne) SetWaID(v string) *WhatsappUpsertOne {
  877. return u.Update(func(s *WhatsappUpsert) {
  878. s.SetWaID(v)
  879. })
  880. }
  881. // UpdateWaID sets the "wa_id" field to the value that was provided on create.
  882. func (u *WhatsappUpsertOne) UpdateWaID() *WhatsappUpsertOne {
  883. return u.Update(func(s *WhatsappUpsert) {
  884. s.UpdateWaID()
  885. })
  886. }
  887. // ClearWaID clears the value of the "wa_id" field.
  888. func (u *WhatsappUpsertOne) ClearWaID() *WhatsappUpsertOne {
  889. return u.Update(func(s *WhatsappUpsert) {
  890. s.ClearWaID()
  891. })
  892. }
  893. // SetCallback sets the "callback" field.
  894. func (u *WhatsappUpsertOne) SetCallback(v string) *WhatsappUpsertOne {
  895. return u.Update(func(s *WhatsappUpsert) {
  896. s.SetCallback(v)
  897. })
  898. }
  899. // UpdateCallback sets the "callback" field to the value that was provided on create.
  900. func (u *WhatsappUpsertOne) UpdateCallback() *WhatsappUpsertOne {
  901. return u.Update(func(s *WhatsappUpsert) {
  902. s.UpdateCallback()
  903. })
  904. }
  905. // ClearCallback clears the value of the "callback" field.
  906. func (u *WhatsappUpsertOne) ClearCallback() *WhatsappUpsertOne {
  907. return u.Update(func(s *WhatsappUpsert) {
  908. s.ClearCallback()
  909. })
  910. }
  911. // SetAgentID sets the "agent_id" field.
  912. func (u *WhatsappUpsertOne) SetAgentID(v uint64) *WhatsappUpsertOne {
  913. return u.Update(func(s *WhatsappUpsert) {
  914. s.SetAgentID(v)
  915. })
  916. }
  917. // UpdateAgentID sets the "agent_id" field to the value that was provided on create.
  918. func (u *WhatsappUpsertOne) UpdateAgentID() *WhatsappUpsertOne {
  919. return u.Update(func(s *WhatsappUpsert) {
  920. s.UpdateAgentID()
  921. })
  922. }
  923. // SetAccount sets the "account" field.
  924. func (u *WhatsappUpsertOne) SetAccount(v string) *WhatsappUpsertOne {
  925. return u.Update(func(s *WhatsappUpsert) {
  926. s.SetAccount(v)
  927. })
  928. }
  929. // UpdateAccount sets the "account" field to the value that was provided on create.
  930. func (u *WhatsappUpsertOne) UpdateAccount() *WhatsappUpsertOne {
  931. return u.Update(func(s *WhatsappUpsert) {
  932. s.UpdateAccount()
  933. })
  934. }
  935. // ClearAccount clears the value of the "account" field.
  936. func (u *WhatsappUpsertOne) ClearAccount() *WhatsappUpsertOne {
  937. return u.Update(func(s *WhatsappUpsert) {
  938. s.ClearAccount()
  939. })
  940. }
  941. // SetCc sets the "cc" field.
  942. func (u *WhatsappUpsertOne) SetCc(v string) *WhatsappUpsertOne {
  943. return u.Update(func(s *WhatsappUpsert) {
  944. s.SetCc(v)
  945. })
  946. }
  947. // UpdateCc sets the "cc" field to the value that was provided on create.
  948. func (u *WhatsappUpsertOne) UpdateCc() *WhatsappUpsertOne {
  949. return u.Update(func(s *WhatsappUpsert) {
  950. s.UpdateCc()
  951. })
  952. }
  953. // SetPhone sets the "phone" field.
  954. func (u *WhatsappUpsertOne) SetPhone(v string) *WhatsappUpsertOne {
  955. return u.Update(func(s *WhatsappUpsert) {
  956. s.SetPhone(v)
  957. })
  958. }
  959. // UpdatePhone sets the "phone" field to the value that was provided on create.
  960. func (u *WhatsappUpsertOne) UpdatePhone() *WhatsappUpsertOne {
  961. return u.Update(func(s *WhatsappUpsert) {
  962. s.UpdatePhone()
  963. })
  964. }
  965. // SetPhoneName sets the "phone_name" field.
  966. func (u *WhatsappUpsertOne) SetPhoneName(v string) *WhatsappUpsertOne {
  967. return u.Update(func(s *WhatsappUpsert) {
  968. s.SetPhoneName(v)
  969. })
  970. }
  971. // UpdatePhoneName sets the "phone_name" field to the value that was provided on create.
  972. func (u *WhatsappUpsertOne) UpdatePhoneName() *WhatsappUpsertOne {
  973. return u.Update(func(s *WhatsappUpsert) {
  974. s.UpdatePhoneName()
  975. })
  976. }
  977. // SetPhoneStatus sets the "phone_status" field.
  978. func (u *WhatsappUpsertOne) SetPhoneStatus(v int8) *WhatsappUpsertOne {
  979. return u.Update(func(s *WhatsappUpsert) {
  980. s.SetPhoneStatus(v)
  981. })
  982. }
  983. // AddPhoneStatus adds v to the "phone_status" field.
  984. func (u *WhatsappUpsertOne) AddPhoneStatus(v int8) *WhatsappUpsertOne {
  985. return u.Update(func(s *WhatsappUpsert) {
  986. s.AddPhoneStatus(v)
  987. })
  988. }
  989. // UpdatePhoneStatus sets the "phone_status" field to the value that was provided on create.
  990. func (u *WhatsappUpsertOne) UpdatePhoneStatus() *WhatsappUpsertOne {
  991. return u.Update(func(s *WhatsappUpsert) {
  992. s.UpdatePhoneStatus()
  993. })
  994. }
  995. // SetOrganizationID sets the "organization_id" field.
  996. func (u *WhatsappUpsertOne) SetOrganizationID(v uint64) *WhatsappUpsertOne {
  997. return u.Update(func(s *WhatsappUpsert) {
  998. s.SetOrganizationID(v)
  999. })
  1000. }
  1001. // AddOrganizationID adds v to the "organization_id" field.
  1002. func (u *WhatsappUpsertOne) AddOrganizationID(v uint64) *WhatsappUpsertOne {
  1003. return u.Update(func(s *WhatsappUpsert) {
  1004. s.AddOrganizationID(v)
  1005. })
  1006. }
  1007. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  1008. func (u *WhatsappUpsertOne) UpdateOrganizationID() *WhatsappUpsertOne {
  1009. return u.Update(func(s *WhatsappUpsert) {
  1010. s.UpdateOrganizationID()
  1011. })
  1012. }
  1013. // ClearOrganizationID clears the value of the "organization_id" field.
  1014. func (u *WhatsappUpsertOne) ClearOrganizationID() *WhatsappUpsertOne {
  1015. return u.Update(func(s *WhatsappUpsert) {
  1016. s.ClearOrganizationID()
  1017. })
  1018. }
  1019. // SetAPIBase sets the "api_base" field.
  1020. func (u *WhatsappUpsertOne) SetAPIBase(v string) *WhatsappUpsertOne {
  1021. return u.Update(func(s *WhatsappUpsert) {
  1022. s.SetAPIBase(v)
  1023. })
  1024. }
  1025. // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
  1026. func (u *WhatsappUpsertOne) UpdateAPIBase() *WhatsappUpsertOne {
  1027. return u.Update(func(s *WhatsappUpsert) {
  1028. s.UpdateAPIBase()
  1029. })
  1030. }
  1031. // ClearAPIBase clears the value of the "api_base" field.
  1032. func (u *WhatsappUpsertOne) ClearAPIBase() *WhatsappUpsertOne {
  1033. return u.Update(func(s *WhatsappUpsert) {
  1034. s.ClearAPIBase()
  1035. })
  1036. }
  1037. // SetAPIKey sets the "api_key" field.
  1038. func (u *WhatsappUpsertOne) SetAPIKey(v string) *WhatsappUpsertOne {
  1039. return u.Update(func(s *WhatsappUpsert) {
  1040. s.SetAPIKey(v)
  1041. })
  1042. }
  1043. // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
  1044. func (u *WhatsappUpsertOne) UpdateAPIKey() *WhatsappUpsertOne {
  1045. return u.Update(func(s *WhatsappUpsert) {
  1046. s.UpdateAPIKey()
  1047. })
  1048. }
  1049. // ClearAPIKey clears the value of the "api_key" field.
  1050. func (u *WhatsappUpsertOne) ClearAPIKey() *WhatsappUpsertOne {
  1051. return u.Update(func(s *WhatsappUpsert) {
  1052. s.ClearAPIKey()
  1053. })
  1054. }
  1055. // SetAllowList sets the "allow_list" field.
  1056. func (u *WhatsappUpsertOne) SetAllowList(v []string) *WhatsappUpsertOne {
  1057. return u.Update(func(s *WhatsappUpsert) {
  1058. s.SetAllowList(v)
  1059. })
  1060. }
  1061. // UpdateAllowList sets the "allow_list" field to the value that was provided on create.
  1062. func (u *WhatsappUpsertOne) UpdateAllowList() *WhatsappUpsertOne {
  1063. return u.Update(func(s *WhatsappUpsert) {
  1064. s.UpdateAllowList()
  1065. })
  1066. }
  1067. // ClearAllowList clears the value of the "allow_list" field.
  1068. func (u *WhatsappUpsertOne) ClearAllowList() *WhatsappUpsertOne {
  1069. return u.Update(func(s *WhatsappUpsert) {
  1070. s.ClearAllowList()
  1071. })
  1072. }
  1073. // SetGroupAllowList sets the "group_allow_list" field.
  1074. func (u *WhatsappUpsertOne) SetGroupAllowList(v []string) *WhatsappUpsertOne {
  1075. return u.Update(func(s *WhatsappUpsert) {
  1076. s.SetGroupAllowList(v)
  1077. })
  1078. }
  1079. // UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
  1080. func (u *WhatsappUpsertOne) UpdateGroupAllowList() *WhatsappUpsertOne {
  1081. return u.Update(func(s *WhatsappUpsert) {
  1082. s.UpdateGroupAllowList()
  1083. })
  1084. }
  1085. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  1086. func (u *WhatsappUpsertOne) ClearGroupAllowList() *WhatsappUpsertOne {
  1087. return u.Update(func(s *WhatsappUpsert) {
  1088. s.ClearGroupAllowList()
  1089. })
  1090. }
  1091. // SetBlockList sets the "block_list" field.
  1092. func (u *WhatsappUpsertOne) SetBlockList(v []string) *WhatsappUpsertOne {
  1093. return u.Update(func(s *WhatsappUpsert) {
  1094. s.SetBlockList(v)
  1095. })
  1096. }
  1097. // UpdateBlockList sets the "block_list" field to the value that was provided on create.
  1098. func (u *WhatsappUpsertOne) UpdateBlockList() *WhatsappUpsertOne {
  1099. return u.Update(func(s *WhatsappUpsert) {
  1100. s.UpdateBlockList()
  1101. })
  1102. }
  1103. // ClearBlockList clears the value of the "block_list" field.
  1104. func (u *WhatsappUpsertOne) ClearBlockList() *WhatsappUpsertOne {
  1105. return u.Update(func(s *WhatsappUpsert) {
  1106. s.ClearBlockList()
  1107. })
  1108. }
  1109. // SetGroupBlockList sets the "group_block_list" field.
  1110. func (u *WhatsappUpsertOne) SetGroupBlockList(v []string) *WhatsappUpsertOne {
  1111. return u.Update(func(s *WhatsappUpsert) {
  1112. s.SetGroupBlockList(v)
  1113. })
  1114. }
  1115. // UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
  1116. func (u *WhatsappUpsertOne) UpdateGroupBlockList() *WhatsappUpsertOne {
  1117. return u.Update(func(s *WhatsappUpsert) {
  1118. s.UpdateGroupBlockList()
  1119. })
  1120. }
  1121. // ClearGroupBlockList clears the value of the "group_block_list" field.
  1122. func (u *WhatsappUpsertOne) ClearGroupBlockList() *WhatsappUpsertOne {
  1123. return u.Update(func(s *WhatsappUpsert) {
  1124. s.ClearGroupBlockList()
  1125. })
  1126. }
  1127. // Exec executes the query.
  1128. func (u *WhatsappUpsertOne) Exec(ctx context.Context) error {
  1129. if len(u.create.conflict) == 0 {
  1130. return errors.New("ent: missing options for WhatsappCreate.OnConflict")
  1131. }
  1132. return u.create.Exec(ctx)
  1133. }
  1134. // ExecX is like Exec, but panics if an error occurs.
  1135. func (u *WhatsappUpsertOne) ExecX(ctx context.Context) {
  1136. if err := u.create.Exec(ctx); err != nil {
  1137. panic(err)
  1138. }
  1139. }
  1140. // Exec executes the UPSERT query and returns the inserted/updated ID.
  1141. func (u *WhatsappUpsertOne) ID(ctx context.Context) (id uint64, err error) {
  1142. node, err := u.create.Save(ctx)
  1143. if err != nil {
  1144. return id, err
  1145. }
  1146. return node.ID, nil
  1147. }
  1148. // IDX is like ID, but panics if an error occurs.
  1149. func (u *WhatsappUpsertOne) IDX(ctx context.Context) uint64 {
  1150. id, err := u.ID(ctx)
  1151. if err != nil {
  1152. panic(err)
  1153. }
  1154. return id
  1155. }
  1156. // WhatsappCreateBulk is the builder for creating many Whatsapp entities in bulk.
  1157. type WhatsappCreateBulk struct {
  1158. config
  1159. err error
  1160. builders []*WhatsappCreate
  1161. conflict []sql.ConflictOption
  1162. }
  1163. // Save creates the Whatsapp entities in the database.
  1164. func (wcb *WhatsappCreateBulk) Save(ctx context.Context) ([]*Whatsapp, error) {
  1165. if wcb.err != nil {
  1166. return nil, wcb.err
  1167. }
  1168. specs := make([]*sqlgraph.CreateSpec, len(wcb.builders))
  1169. nodes := make([]*Whatsapp, len(wcb.builders))
  1170. mutators := make([]Mutator, len(wcb.builders))
  1171. for i := range wcb.builders {
  1172. func(i int, root context.Context) {
  1173. builder := wcb.builders[i]
  1174. builder.defaults()
  1175. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  1176. mutation, ok := m.(*WhatsappMutation)
  1177. if !ok {
  1178. return nil, fmt.Errorf("unexpected mutation type %T", m)
  1179. }
  1180. if err := builder.check(); err != nil {
  1181. return nil, err
  1182. }
  1183. builder.mutation = mutation
  1184. var err error
  1185. nodes[i], specs[i] = builder.createSpec()
  1186. if i < len(mutators)-1 {
  1187. _, err = mutators[i+1].Mutate(root, wcb.builders[i+1].mutation)
  1188. } else {
  1189. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  1190. spec.OnConflict = wcb.conflict
  1191. // Invoke the actual operation on the latest mutation in the chain.
  1192. if err = sqlgraph.BatchCreate(ctx, wcb.driver, spec); err != nil {
  1193. if sqlgraph.IsConstraintError(err) {
  1194. err = &ConstraintError{msg: err.Error(), wrap: err}
  1195. }
  1196. }
  1197. }
  1198. if err != nil {
  1199. return nil, err
  1200. }
  1201. mutation.id = &nodes[i].ID
  1202. if specs[i].ID.Value != nil && nodes[i].ID == 0 {
  1203. id := specs[i].ID.Value.(int64)
  1204. nodes[i].ID = uint64(id)
  1205. }
  1206. mutation.done = true
  1207. return nodes[i], nil
  1208. })
  1209. for i := len(builder.hooks) - 1; i >= 0; i-- {
  1210. mut = builder.hooks[i](mut)
  1211. }
  1212. mutators[i] = mut
  1213. }(i, ctx)
  1214. }
  1215. if len(mutators) > 0 {
  1216. if _, err := mutators[0].Mutate(ctx, wcb.builders[0].mutation); err != nil {
  1217. return nil, err
  1218. }
  1219. }
  1220. return nodes, nil
  1221. }
  1222. // SaveX is like Save, but panics if an error occurs.
  1223. func (wcb *WhatsappCreateBulk) SaveX(ctx context.Context) []*Whatsapp {
  1224. v, err := wcb.Save(ctx)
  1225. if err != nil {
  1226. panic(err)
  1227. }
  1228. return v
  1229. }
  1230. // Exec executes the query.
  1231. func (wcb *WhatsappCreateBulk) Exec(ctx context.Context) error {
  1232. _, err := wcb.Save(ctx)
  1233. return err
  1234. }
  1235. // ExecX is like Exec, but panics if an error occurs.
  1236. func (wcb *WhatsappCreateBulk) ExecX(ctx context.Context) {
  1237. if err := wcb.Exec(ctx); err != nil {
  1238. panic(err)
  1239. }
  1240. }
  1241. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  1242. // of the `INSERT` statement. For example:
  1243. //
  1244. // client.Whatsapp.CreateBulk(builders...).
  1245. // OnConflict(
  1246. // // Update the row with the new values
  1247. // // the was proposed for insertion.
  1248. // sql.ResolveWithNewValues(),
  1249. // ).
  1250. // // Override some of the fields with custom
  1251. // // update values.
  1252. // Update(func(u *ent.WhatsappUpsert) {
  1253. // SetCreatedAt(v+v).
  1254. // }).
  1255. // Exec(ctx)
  1256. func (wcb *WhatsappCreateBulk) OnConflict(opts ...sql.ConflictOption) *WhatsappUpsertBulk {
  1257. wcb.conflict = opts
  1258. return &WhatsappUpsertBulk{
  1259. create: wcb,
  1260. }
  1261. }
  1262. // OnConflictColumns calls `OnConflict` and configures the columns
  1263. // as conflict target. Using this option is equivalent to using:
  1264. //
  1265. // client.Whatsapp.Create().
  1266. // OnConflict(sql.ConflictColumns(columns...)).
  1267. // Exec(ctx)
  1268. func (wcb *WhatsappCreateBulk) OnConflictColumns(columns ...string) *WhatsappUpsertBulk {
  1269. wcb.conflict = append(wcb.conflict, sql.ConflictColumns(columns...))
  1270. return &WhatsappUpsertBulk{
  1271. create: wcb,
  1272. }
  1273. }
  1274. // WhatsappUpsertBulk is the builder for "upsert"-ing
  1275. // a bulk of Whatsapp nodes.
  1276. type WhatsappUpsertBulk struct {
  1277. create *WhatsappCreateBulk
  1278. }
  1279. // UpdateNewValues updates the mutable fields using the new values that
  1280. // were set on create. Using this option is equivalent to using:
  1281. //
  1282. // client.Whatsapp.Create().
  1283. // OnConflict(
  1284. // sql.ResolveWithNewValues(),
  1285. // sql.ResolveWith(func(u *sql.UpdateSet) {
  1286. // u.SetIgnore(whatsapp.FieldID)
  1287. // }),
  1288. // ).
  1289. // Exec(ctx)
  1290. func (u *WhatsappUpsertBulk) UpdateNewValues() *WhatsappUpsertBulk {
  1291. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1292. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1293. for _, b := range u.create.builders {
  1294. if _, exists := b.mutation.ID(); exists {
  1295. s.SetIgnore(whatsapp.FieldID)
  1296. }
  1297. if _, exists := b.mutation.CreatedAt(); exists {
  1298. s.SetIgnore(whatsapp.FieldCreatedAt)
  1299. }
  1300. }
  1301. }))
  1302. return u
  1303. }
  1304. // Ignore sets each column to itself in case of conflict.
  1305. // Using this option is equivalent to using:
  1306. //
  1307. // client.Whatsapp.Create().
  1308. // OnConflict(sql.ResolveWithIgnore()).
  1309. // Exec(ctx)
  1310. func (u *WhatsappUpsertBulk) Ignore() *WhatsappUpsertBulk {
  1311. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1312. return u
  1313. }
  1314. // DoNothing configures the conflict_action to `DO NOTHING`.
  1315. // Supported only by SQLite and PostgreSQL.
  1316. func (u *WhatsappUpsertBulk) DoNothing() *WhatsappUpsertBulk {
  1317. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1318. return u
  1319. }
  1320. // Update allows overriding fields `UPDATE` values. See the WhatsappCreateBulk.OnConflict
  1321. // documentation for more info.
  1322. func (u *WhatsappUpsertBulk) Update(set func(*WhatsappUpsert)) *WhatsappUpsertBulk {
  1323. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1324. set(&WhatsappUpsert{UpdateSet: update})
  1325. }))
  1326. return u
  1327. }
  1328. // SetUpdatedAt sets the "updated_at" field.
  1329. func (u *WhatsappUpsertBulk) SetUpdatedAt(v time.Time) *WhatsappUpsertBulk {
  1330. return u.Update(func(s *WhatsappUpsert) {
  1331. s.SetUpdatedAt(v)
  1332. })
  1333. }
  1334. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1335. func (u *WhatsappUpsertBulk) UpdateUpdatedAt() *WhatsappUpsertBulk {
  1336. return u.Update(func(s *WhatsappUpsert) {
  1337. s.UpdateUpdatedAt()
  1338. })
  1339. }
  1340. // SetStatus sets the "status" field.
  1341. func (u *WhatsappUpsertBulk) SetStatus(v uint8) *WhatsappUpsertBulk {
  1342. return u.Update(func(s *WhatsappUpsert) {
  1343. s.SetStatus(v)
  1344. })
  1345. }
  1346. // AddStatus adds v to the "status" field.
  1347. func (u *WhatsappUpsertBulk) AddStatus(v uint8) *WhatsappUpsertBulk {
  1348. return u.Update(func(s *WhatsappUpsert) {
  1349. s.AddStatus(v)
  1350. })
  1351. }
  1352. // UpdateStatus sets the "status" field to the value that was provided on create.
  1353. func (u *WhatsappUpsertBulk) UpdateStatus() *WhatsappUpsertBulk {
  1354. return u.Update(func(s *WhatsappUpsert) {
  1355. s.UpdateStatus()
  1356. })
  1357. }
  1358. // ClearStatus clears the value of the "status" field.
  1359. func (u *WhatsappUpsertBulk) ClearStatus() *WhatsappUpsertBulk {
  1360. return u.Update(func(s *WhatsappUpsert) {
  1361. s.ClearStatus()
  1362. })
  1363. }
  1364. // SetDeletedAt sets the "deleted_at" field.
  1365. func (u *WhatsappUpsertBulk) SetDeletedAt(v time.Time) *WhatsappUpsertBulk {
  1366. return u.Update(func(s *WhatsappUpsert) {
  1367. s.SetDeletedAt(v)
  1368. })
  1369. }
  1370. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  1371. func (u *WhatsappUpsertBulk) UpdateDeletedAt() *WhatsappUpsertBulk {
  1372. return u.Update(func(s *WhatsappUpsert) {
  1373. s.UpdateDeletedAt()
  1374. })
  1375. }
  1376. // ClearDeletedAt clears the value of the "deleted_at" field.
  1377. func (u *WhatsappUpsertBulk) ClearDeletedAt() *WhatsappUpsertBulk {
  1378. return u.Update(func(s *WhatsappUpsert) {
  1379. s.ClearDeletedAt()
  1380. })
  1381. }
  1382. // SetWaID sets the "wa_id" field.
  1383. func (u *WhatsappUpsertBulk) SetWaID(v string) *WhatsappUpsertBulk {
  1384. return u.Update(func(s *WhatsappUpsert) {
  1385. s.SetWaID(v)
  1386. })
  1387. }
  1388. // UpdateWaID sets the "wa_id" field to the value that was provided on create.
  1389. func (u *WhatsappUpsertBulk) UpdateWaID() *WhatsappUpsertBulk {
  1390. return u.Update(func(s *WhatsappUpsert) {
  1391. s.UpdateWaID()
  1392. })
  1393. }
  1394. // ClearWaID clears the value of the "wa_id" field.
  1395. func (u *WhatsappUpsertBulk) ClearWaID() *WhatsappUpsertBulk {
  1396. return u.Update(func(s *WhatsappUpsert) {
  1397. s.ClearWaID()
  1398. })
  1399. }
  1400. // SetCallback sets the "callback" field.
  1401. func (u *WhatsappUpsertBulk) SetCallback(v string) *WhatsappUpsertBulk {
  1402. return u.Update(func(s *WhatsappUpsert) {
  1403. s.SetCallback(v)
  1404. })
  1405. }
  1406. // UpdateCallback sets the "callback" field to the value that was provided on create.
  1407. func (u *WhatsappUpsertBulk) UpdateCallback() *WhatsappUpsertBulk {
  1408. return u.Update(func(s *WhatsappUpsert) {
  1409. s.UpdateCallback()
  1410. })
  1411. }
  1412. // ClearCallback clears the value of the "callback" field.
  1413. func (u *WhatsappUpsertBulk) ClearCallback() *WhatsappUpsertBulk {
  1414. return u.Update(func(s *WhatsappUpsert) {
  1415. s.ClearCallback()
  1416. })
  1417. }
  1418. // SetAgentID sets the "agent_id" field.
  1419. func (u *WhatsappUpsertBulk) SetAgentID(v uint64) *WhatsappUpsertBulk {
  1420. return u.Update(func(s *WhatsappUpsert) {
  1421. s.SetAgentID(v)
  1422. })
  1423. }
  1424. // UpdateAgentID sets the "agent_id" field to the value that was provided on create.
  1425. func (u *WhatsappUpsertBulk) UpdateAgentID() *WhatsappUpsertBulk {
  1426. return u.Update(func(s *WhatsappUpsert) {
  1427. s.UpdateAgentID()
  1428. })
  1429. }
  1430. // SetAccount sets the "account" field.
  1431. func (u *WhatsappUpsertBulk) SetAccount(v string) *WhatsappUpsertBulk {
  1432. return u.Update(func(s *WhatsappUpsert) {
  1433. s.SetAccount(v)
  1434. })
  1435. }
  1436. // UpdateAccount sets the "account" field to the value that was provided on create.
  1437. func (u *WhatsappUpsertBulk) UpdateAccount() *WhatsappUpsertBulk {
  1438. return u.Update(func(s *WhatsappUpsert) {
  1439. s.UpdateAccount()
  1440. })
  1441. }
  1442. // ClearAccount clears the value of the "account" field.
  1443. func (u *WhatsappUpsertBulk) ClearAccount() *WhatsappUpsertBulk {
  1444. return u.Update(func(s *WhatsappUpsert) {
  1445. s.ClearAccount()
  1446. })
  1447. }
  1448. // SetCc sets the "cc" field.
  1449. func (u *WhatsappUpsertBulk) SetCc(v string) *WhatsappUpsertBulk {
  1450. return u.Update(func(s *WhatsappUpsert) {
  1451. s.SetCc(v)
  1452. })
  1453. }
  1454. // UpdateCc sets the "cc" field to the value that was provided on create.
  1455. func (u *WhatsappUpsertBulk) UpdateCc() *WhatsappUpsertBulk {
  1456. return u.Update(func(s *WhatsappUpsert) {
  1457. s.UpdateCc()
  1458. })
  1459. }
  1460. // SetPhone sets the "phone" field.
  1461. func (u *WhatsappUpsertBulk) SetPhone(v string) *WhatsappUpsertBulk {
  1462. return u.Update(func(s *WhatsappUpsert) {
  1463. s.SetPhone(v)
  1464. })
  1465. }
  1466. // UpdatePhone sets the "phone" field to the value that was provided on create.
  1467. func (u *WhatsappUpsertBulk) UpdatePhone() *WhatsappUpsertBulk {
  1468. return u.Update(func(s *WhatsappUpsert) {
  1469. s.UpdatePhone()
  1470. })
  1471. }
  1472. // SetPhoneName sets the "phone_name" field.
  1473. func (u *WhatsappUpsertBulk) SetPhoneName(v string) *WhatsappUpsertBulk {
  1474. return u.Update(func(s *WhatsappUpsert) {
  1475. s.SetPhoneName(v)
  1476. })
  1477. }
  1478. // UpdatePhoneName sets the "phone_name" field to the value that was provided on create.
  1479. func (u *WhatsappUpsertBulk) UpdatePhoneName() *WhatsappUpsertBulk {
  1480. return u.Update(func(s *WhatsappUpsert) {
  1481. s.UpdatePhoneName()
  1482. })
  1483. }
  1484. // SetPhoneStatus sets the "phone_status" field.
  1485. func (u *WhatsappUpsertBulk) SetPhoneStatus(v int8) *WhatsappUpsertBulk {
  1486. return u.Update(func(s *WhatsappUpsert) {
  1487. s.SetPhoneStatus(v)
  1488. })
  1489. }
  1490. // AddPhoneStatus adds v to the "phone_status" field.
  1491. func (u *WhatsappUpsertBulk) AddPhoneStatus(v int8) *WhatsappUpsertBulk {
  1492. return u.Update(func(s *WhatsappUpsert) {
  1493. s.AddPhoneStatus(v)
  1494. })
  1495. }
  1496. // UpdatePhoneStatus sets the "phone_status" field to the value that was provided on create.
  1497. func (u *WhatsappUpsertBulk) UpdatePhoneStatus() *WhatsappUpsertBulk {
  1498. return u.Update(func(s *WhatsappUpsert) {
  1499. s.UpdatePhoneStatus()
  1500. })
  1501. }
  1502. // SetOrganizationID sets the "organization_id" field.
  1503. func (u *WhatsappUpsertBulk) SetOrganizationID(v uint64) *WhatsappUpsertBulk {
  1504. return u.Update(func(s *WhatsappUpsert) {
  1505. s.SetOrganizationID(v)
  1506. })
  1507. }
  1508. // AddOrganizationID adds v to the "organization_id" field.
  1509. func (u *WhatsappUpsertBulk) AddOrganizationID(v uint64) *WhatsappUpsertBulk {
  1510. return u.Update(func(s *WhatsappUpsert) {
  1511. s.AddOrganizationID(v)
  1512. })
  1513. }
  1514. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  1515. func (u *WhatsappUpsertBulk) UpdateOrganizationID() *WhatsappUpsertBulk {
  1516. return u.Update(func(s *WhatsappUpsert) {
  1517. s.UpdateOrganizationID()
  1518. })
  1519. }
  1520. // ClearOrganizationID clears the value of the "organization_id" field.
  1521. func (u *WhatsappUpsertBulk) ClearOrganizationID() *WhatsappUpsertBulk {
  1522. return u.Update(func(s *WhatsappUpsert) {
  1523. s.ClearOrganizationID()
  1524. })
  1525. }
  1526. // SetAPIBase sets the "api_base" field.
  1527. func (u *WhatsappUpsertBulk) SetAPIBase(v string) *WhatsappUpsertBulk {
  1528. return u.Update(func(s *WhatsappUpsert) {
  1529. s.SetAPIBase(v)
  1530. })
  1531. }
  1532. // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
  1533. func (u *WhatsappUpsertBulk) UpdateAPIBase() *WhatsappUpsertBulk {
  1534. return u.Update(func(s *WhatsappUpsert) {
  1535. s.UpdateAPIBase()
  1536. })
  1537. }
  1538. // ClearAPIBase clears the value of the "api_base" field.
  1539. func (u *WhatsappUpsertBulk) ClearAPIBase() *WhatsappUpsertBulk {
  1540. return u.Update(func(s *WhatsappUpsert) {
  1541. s.ClearAPIBase()
  1542. })
  1543. }
  1544. // SetAPIKey sets the "api_key" field.
  1545. func (u *WhatsappUpsertBulk) SetAPIKey(v string) *WhatsappUpsertBulk {
  1546. return u.Update(func(s *WhatsappUpsert) {
  1547. s.SetAPIKey(v)
  1548. })
  1549. }
  1550. // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
  1551. func (u *WhatsappUpsertBulk) UpdateAPIKey() *WhatsappUpsertBulk {
  1552. return u.Update(func(s *WhatsappUpsert) {
  1553. s.UpdateAPIKey()
  1554. })
  1555. }
  1556. // ClearAPIKey clears the value of the "api_key" field.
  1557. func (u *WhatsappUpsertBulk) ClearAPIKey() *WhatsappUpsertBulk {
  1558. return u.Update(func(s *WhatsappUpsert) {
  1559. s.ClearAPIKey()
  1560. })
  1561. }
  1562. // SetAllowList sets the "allow_list" field.
  1563. func (u *WhatsappUpsertBulk) SetAllowList(v []string) *WhatsappUpsertBulk {
  1564. return u.Update(func(s *WhatsappUpsert) {
  1565. s.SetAllowList(v)
  1566. })
  1567. }
  1568. // UpdateAllowList sets the "allow_list" field to the value that was provided on create.
  1569. func (u *WhatsappUpsertBulk) UpdateAllowList() *WhatsappUpsertBulk {
  1570. return u.Update(func(s *WhatsappUpsert) {
  1571. s.UpdateAllowList()
  1572. })
  1573. }
  1574. // ClearAllowList clears the value of the "allow_list" field.
  1575. func (u *WhatsappUpsertBulk) ClearAllowList() *WhatsappUpsertBulk {
  1576. return u.Update(func(s *WhatsappUpsert) {
  1577. s.ClearAllowList()
  1578. })
  1579. }
  1580. // SetGroupAllowList sets the "group_allow_list" field.
  1581. func (u *WhatsappUpsertBulk) SetGroupAllowList(v []string) *WhatsappUpsertBulk {
  1582. return u.Update(func(s *WhatsappUpsert) {
  1583. s.SetGroupAllowList(v)
  1584. })
  1585. }
  1586. // UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
  1587. func (u *WhatsappUpsertBulk) UpdateGroupAllowList() *WhatsappUpsertBulk {
  1588. return u.Update(func(s *WhatsappUpsert) {
  1589. s.UpdateGroupAllowList()
  1590. })
  1591. }
  1592. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  1593. func (u *WhatsappUpsertBulk) ClearGroupAllowList() *WhatsappUpsertBulk {
  1594. return u.Update(func(s *WhatsappUpsert) {
  1595. s.ClearGroupAllowList()
  1596. })
  1597. }
  1598. // SetBlockList sets the "block_list" field.
  1599. func (u *WhatsappUpsertBulk) SetBlockList(v []string) *WhatsappUpsertBulk {
  1600. return u.Update(func(s *WhatsappUpsert) {
  1601. s.SetBlockList(v)
  1602. })
  1603. }
  1604. // UpdateBlockList sets the "block_list" field to the value that was provided on create.
  1605. func (u *WhatsappUpsertBulk) UpdateBlockList() *WhatsappUpsertBulk {
  1606. return u.Update(func(s *WhatsappUpsert) {
  1607. s.UpdateBlockList()
  1608. })
  1609. }
  1610. // ClearBlockList clears the value of the "block_list" field.
  1611. func (u *WhatsappUpsertBulk) ClearBlockList() *WhatsappUpsertBulk {
  1612. return u.Update(func(s *WhatsappUpsert) {
  1613. s.ClearBlockList()
  1614. })
  1615. }
  1616. // SetGroupBlockList sets the "group_block_list" field.
  1617. func (u *WhatsappUpsertBulk) SetGroupBlockList(v []string) *WhatsappUpsertBulk {
  1618. return u.Update(func(s *WhatsappUpsert) {
  1619. s.SetGroupBlockList(v)
  1620. })
  1621. }
  1622. // UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
  1623. func (u *WhatsappUpsertBulk) UpdateGroupBlockList() *WhatsappUpsertBulk {
  1624. return u.Update(func(s *WhatsappUpsert) {
  1625. s.UpdateGroupBlockList()
  1626. })
  1627. }
  1628. // ClearGroupBlockList clears the value of the "group_block_list" field.
  1629. func (u *WhatsappUpsertBulk) ClearGroupBlockList() *WhatsappUpsertBulk {
  1630. return u.Update(func(s *WhatsappUpsert) {
  1631. s.ClearGroupBlockList()
  1632. })
  1633. }
  1634. // Exec executes the query.
  1635. func (u *WhatsappUpsertBulk) Exec(ctx context.Context) error {
  1636. if u.create.err != nil {
  1637. return u.create.err
  1638. }
  1639. for i, b := range u.create.builders {
  1640. if len(b.conflict) != 0 {
  1641. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the WhatsappCreateBulk instead", i)
  1642. }
  1643. }
  1644. if len(u.create.conflict) == 0 {
  1645. return errors.New("ent: missing options for WhatsappCreateBulk.OnConflict")
  1646. }
  1647. return u.create.Exec(ctx)
  1648. }
  1649. // ExecX is like Exec, but panics if an error occurs.
  1650. func (u *WhatsappUpsertBulk) ExecX(ctx context.Context) {
  1651. if err := u.create.Exec(ctx); err != nil {
  1652. panic(err)
  1653. }
  1654. }