whatsapp_create.go 50 KB

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