whatsapp_create.go 55 KB

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