contact_create.go 50 KB

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