whatsapp_create.go 50 KB

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