whatsapp_create.go 51 KB

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