contact_create.go 51 KB

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