contact_create.go 49 KB

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