contactfield_update.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  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/contactfield"
  10. "wechat-api/ent/predicate"
  11. "entgo.io/ent/dialect/sql"
  12. "entgo.io/ent/dialect/sql/sqlgraph"
  13. "entgo.io/ent/dialect/sql/sqljson"
  14. "entgo.io/ent/schema/field"
  15. )
  16. // ContactFieldUpdate is the builder for updating ContactField entities.
  17. type ContactFieldUpdate struct {
  18. config
  19. hooks []Hook
  20. mutation *ContactFieldMutation
  21. }
  22. // Where appends a list predicates to the ContactFieldUpdate builder.
  23. func (cfu *ContactFieldUpdate) Where(ps ...predicate.ContactField) *ContactFieldUpdate {
  24. cfu.mutation.Where(ps...)
  25. return cfu
  26. }
  27. // SetUpdatedAt sets the "updated_at" field.
  28. func (cfu *ContactFieldUpdate) SetUpdatedAt(t time.Time) *ContactFieldUpdate {
  29. cfu.mutation.SetUpdatedAt(t)
  30. return cfu
  31. }
  32. // SetStatus sets the "status" field.
  33. func (cfu *ContactFieldUpdate) SetStatus(u uint8) *ContactFieldUpdate {
  34. cfu.mutation.ResetStatus()
  35. cfu.mutation.SetStatus(u)
  36. return cfu
  37. }
  38. // SetNillableStatus sets the "status" field if the given value is not nil.
  39. func (cfu *ContactFieldUpdate) SetNillableStatus(u *uint8) *ContactFieldUpdate {
  40. if u != nil {
  41. cfu.SetStatus(*u)
  42. }
  43. return cfu
  44. }
  45. // AddStatus adds u to the "status" field.
  46. func (cfu *ContactFieldUpdate) AddStatus(u int8) *ContactFieldUpdate {
  47. cfu.mutation.AddStatus(u)
  48. return cfu
  49. }
  50. // ClearStatus clears the value of the "status" field.
  51. func (cfu *ContactFieldUpdate) ClearStatus() *ContactFieldUpdate {
  52. cfu.mutation.ClearStatus()
  53. return cfu
  54. }
  55. // SetDeletedAt sets the "deleted_at" field.
  56. func (cfu *ContactFieldUpdate) SetDeletedAt(t time.Time) *ContactFieldUpdate {
  57. cfu.mutation.SetDeletedAt(t)
  58. return cfu
  59. }
  60. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  61. func (cfu *ContactFieldUpdate) SetNillableDeletedAt(t *time.Time) *ContactFieldUpdate {
  62. if t != nil {
  63. cfu.SetDeletedAt(*t)
  64. }
  65. return cfu
  66. }
  67. // ClearDeletedAt clears the value of the "deleted_at" field.
  68. func (cfu *ContactFieldUpdate) ClearDeletedAt() *ContactFieldUpdate {
  69. cfu.mutation.ClearDeletedAt()
  70. return cfu
  71. }
  72. // SetContactID sets the "contact_id" field.
  73. func (cfu *ContactFieldUpdate) SetContactID(u uint64) *ContactFieldUpdate {
  74. cfu.mutation.SetContactID(u)
  75. return cfu
  76. }
  77. // SetNillableContactID sets the "contact_id" field if the given value is not nil.
  78. func (cfu *ContactFieldUpdate) SetNillableContactID(u *uint64) *ContactFieldUpdate {
  79. if u != nil {
  80. cfu.SetContactID(*u)
  81. }
  82. return cfu
  83. }
  84. // SetFormID sets the "form_id" field.
  85. func (cfu *ContactFieldUpdate) SetFormID(s string) *ContactFieldUpdate {
  86. cfu.mutation.SetFormID(s)
  87. return cfu
  88. }
  89. // SetNillableFormID sets the "form_id" field if the given value is not nil.
  90. func (cfu *ContactFieldUpdate) SetNillableFormID(s *string) *ContactFieldUpdate {
  91. if s != nil {
  92. cfu.SetFormID(*s)
  93. }
  94. return cfu
  95. }
  96. // SetValue sets the "value" field.
  97. func (cfu *ContactFieldUpdate) SetValue(s []string) *ContactFieldUpdate {
  98. cfu.mutation.SetValue(s)
  99. return cfu
  100. }
  101. // AppendValue appends s to the "value" field.
  102. func (cfu *ContactFieldUpdate) AppendValue(s []string) *ContactFieldUpdate {
  103. cfu.mutation.AppendValue(s)
  104. return cfu
  105. }
  106. // SetFieldContactID sets the "field_contact" edge to the Contact entity by ID.
  107. func (cfu *ContactFieldUpdate) SetFieldContactID(id uint64) *ContactFieldUpdate {
  108. cfu.mutation.SetFieldContactID(id)
  109. return cfu
  110. }
  111. // SetFieldContact sets the "field_contact" edge to the Contact entity.
  112. func (cfu *ContactFieldUpdate) SetFieldContact(c *Contact) *ContactFieldUpdate {
  113. return cfu.SetFieldContactID(c.ID)
  114. }
  115. // Mutation returns the ContactFieldMutation object of the builder.
  116. func (cfu *ContactFieldUpdate) Mutation() *ContactFieldMutation {
  117. return cfu.mutation
  118. }
  119. // ClearFieldContact clears the "field_contact" edge to the Contact entity.
  120. func (cfu *ContactFieldUpdate) ClearFieldContact() *ContactFieldUpdate {
  121. cfu.mutation.ClearFieldContact()
  122. return cfu
  123. }
  124. // Save executes the query and returns the number of nodes affected by the update operation.
  125. func (cfu *ContactFieldUpdate) Save(ctx context.Context) (int, error) {
  126. if err := cfu.defaults(); err != nil {
  127. return 0, err
  128. }
  129. return withHooks(ctx, cfu.sqlSave, cfu.mutation, cfu.hooks)
  130. }
  131. // SaveX is like Save, but panics if an error occurs.
  132. func (cfu *ContactFieldUpdate) SaveX(ctx context.Context) int {
  133. affected, err := cfu.Save(ctx)
  134. if err != nil {
  135. panic(err)
  136. }
  137. return affected
  138. }
  139. // Exec executes the query.
  140. func (cfu *ContactFieldUpdate) Exec(ctx context.Context) error {
  141. _, err := cfu.Save(ctx)
  142. return err
  143. }
  144. // ExecX is like Exec, but panics if an error occurs.
  145. func (cfu *ContactFieldUpdate) ExecX(ctx context.Context) {
  146. if err := cfu.Exec(ctx); err != nil {
  147. panic(err)
  148. }
  149. }
  150. // defaults sets the default values of the builder before save.
  151. func (cfu *ContactFieldUpdate) defaults() error {
  152. if _, ok := cfu.mutation.UpdatedAt(); !ok {
  153. if contactfield.UpdateDefaultUpdatedAt == nil {
  154. return fmt.Errorf("ent: uninitialized contactfield.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  155. }
  156. v := contactfield.UpdateDefaultUpdatedAt()
  157. cfu.mutation.SetUpdatedAt(v)
  158. }
  159. return nil
  160. }
  161. // check runs all checks and user-defined validators on the builder.
  162. func (cfu *ContactFieldUpdate) check() error {
  163. if _, ok := cfu.mutation.FieldContactID(); cfu.mutation.FieldContactCleared() && !ok {
  164. return errors.New(`ent: clearing a required unique edge "ContactField.field_contact"`)
  165. }
  166. return nil
  167. }
  168. func (cfu *ContactFieldUpdate) sqlSave(ctx context.Context) (n int, err error) {
  169. if err := cfu.check(); err != nil {
  170. return n, err
  171. }
  172. _spec := sqlgraph.NewUpdateSpec(contactfield.Table, contactfield.Columns, sqlgraph.NewFieldSpec(contactfield.FieldID, field.TypeUint64))
  173. if ps := cfu.mutation.predicates; len(ps) > 0 {
  174. _spec.Predicate = func(selector *sql.Selector) {
  175. for i := range ps {
  176. ps[i](selector)
  177. }
  178. }
  179. }
  180. if value, ok := cfu.mutation.UpdatedAt(); ok {
  181. _spec.SetField(contactfield.FieldUpdatedAt, field.TypeTime, value)
  182. }
  183. if value, ok := cfu.mutation.Status(); ok {
  184. _spec.SetField(contactfield.FieldStatus, field.TypeUint8, value)
  185. }
  186. if value, ok := cfu.mutation.AddedStatus(); ok {
  187. _spec.AddField(contactfield.FieldStatus, field.TypeUint8, value)
  188. }
  189. if cfu.mutation.StatusCleared() {
  190. _spec.ClearField(contactfield.FieldStatus, field.TypeUint8)
  191. }
  192. if value, ok := cfu.mutation.DeletedAt(); ok {
  193. _spec.SetField(contactfield.FieldDeletedAt, field.TypeTime, value)
  194. }
  195. if cfu.mutation.DeletedAtCleared() {
  196. _spec.ClearField(contactfield.FieldDeletedAt, field.TypeTime)
  197. }
  198. if value, ok := cfu.mutation.FormID(); ok {
  199. _spec.SetField(contactfield.FieldFormID, field.TypeString, value)
  200. }
  201. if value, ok := cfu.mutation.Value(); ok {
  202. _spec.SetField(contactfield.FieldValue, field.TypeJSON, value)
  203. }
  204. if value, ok := cfu.mutation.AppendedValue(); ok {
  205. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  206. sqljson.Append(u, contactfield.FieldValue, value)
  207. })
  208. }
  209. if cfu.mutation.FieldContactCleared() {
  210. edge := &sqlgraph.EdgeSpec{
  211. Rel: sqlgraph.M2O,
  212. Inverse: true,
  213. Table: contactfield.FieldContactTable,
  214. Columns: []string{contactfield.FieldContactColumn},
  215. Bidi: false,
  216. Target: &sqlgraph.EdgeTarget{
  217. IDSpec: sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64),
  218. },
  219. }
  220. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  221. }
  222. if nodes := cfu.mutation.FieldContactIDs(); len(nodes) > 0 {
  223. edge := &sqlgraph.EdgeSpec{
  224. Rel: sqlgraph.M2O,
  225. Inverse: true,
  226. Table: contactfield.FieldContactTable,
  227. Columns: []string{contactfield.FieldContactColumn},
  228. Bidi: false,
  229. Target: &sqlgraph.EdgeTarget{
  230. IDSpec: sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64),
  231. },
  232. }
  233. for _, k := range nodes {
  234. edge.Target.Nodes = append(edge.Target.Nodes, k)
  235. }
  236. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  237. }
  238. if n, err = sqlgraph.UpdateNodes(ctx, cfu.driver, _spec); err != nil {
  239. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  240. err = &NotFoundError{contactfield.Label}
  241. } else if sqlgraph.IsConstraintError(err) {
  242. err = &ConstraintError{msg: err.Error(), wrap: err}
  243. }
  244. return 0, err
  245. }
  246. cfu.mutation.done = true
  247. return n, nil
  248. }
  249. // ContactFieldUpdateOne is the builder for updating a single ContactField entity.
  250. type ContactFieldUpdateOne struct {
  251. config
  252. fields []string
  253. hooks []Hook
  254. mutation *ContactFieldMutation
  255. }
  256. // SetUpdatedAt sets the "updated_at" field.
  257. func (cfuo *ContactFieldUpdateOne) SetUpdatedAt(t time.Time) *ContactFieldUpdateOne {
  258. cfuo.mutation.SetUpdatedAt(t)
  259. return cfuo
  260. }
  261. // SetStatus sets the "status" field.
  262. func (cfuo *ContactFieldUpdateOne) SetStatus(u uint8) *ContactFieldUpdateOne {
  263. cfuo.mutation.ResetStatus()
  264. cfuo.mutation.SetStatus(u)
  265. return cfuo
  266. }
  267. // SetNillableStatus sets the "status" field if the given value is not nil.
  268. func (cfuo *ContactFieldUpdateOne) SetNillableStatus(u *uint8) *ContactFieldUpdateOne {
  269. if u != nil {
  270. cfuo.SetStatus(*u)
  271. }
  272. return cfuo
  273. }
  274. // AddStatus adds u to the "status" field.
  275. func (cfuo *ContactFieldUpdateOne) AddStatus(u int8) *ContactFieldUpdateOne {
  276. cfuo.mutation.AddStatus(u)
  277. return cfuo
  278. }
  279. // ClearStatus clears the value of the "status" field.
  280. func (cfuo *ContactFieldUpdateOne) ClearStatus() *ContactFieldUpdateOne {
  281. cfuo.mutation.ClearStatus()
  282. return cfuo
  283. }
  284. // SetDeletedAt sets the "deleted_at" field.
  285. func (cfuo *ContactFieldUpdateOne) SetDeletedAt(t time.Time) *ContactFieldUpdateOne {
  286. cfuo.mutation.SetDeletedAt(t)
  287. return cfuo
  288. }
  289. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  290. func (cfuo *ContactFieldUpdateOne) SetNillableDeletedAt(t *time.Time) *ContactFieldUpdateOne {
  291. if t != nil {
  292. cfuo.SetDeletedAt(*t)
  293. }
  294. return cfuo
  295. }
  296. // ClearDeletedAt clears the value of the "deleted_at" field.
  297. func (cfuo *ContactFieldUpdateOne) ClearDeletedAt() *ContactFieldUpdateOne {
  298. cfuo.mutation.ClearDeletedAt()
  299. return cfuo
  300. }
  301. // SetContactID sets the "contact_id" field.
  302. func (cfuo *ContactFieldUpdateOne) SetContactID(u uint64) *ContactFieldUpdateOne {
  303. cfuo.mutation.SetContactID(u)
  304. return cfuo
  305. }
  306. // SetNillableContactID sets the "contact_id" field if the given value is not nil.
  307. func (cfuo *ContactFieldUpdateOne) SetNillableContactID(u *uint64) *ContactFieldUpdateOne {
  308. if u != nil {
  309. cfuo.SetContactID(*u)
  310. }
  311. return cfuo
  312. }
  313. // SetFormID sets the "form_id" field.
  314. func (cfuo *ContactFieldUpdateOne) SetFormID(s string) *ContactFieldUpdateOne {
  315. cfuo.mutation.SetFormID(s)
  316. return cfuo
  317. }
  318. // SetNillableFormID sets the "form_id" field if the given value is not nil.
  319. func (cfuo *ContactFieldUpdateOne) SetNillableFormID(s *string) *ContactFieldUpdateOne {
  320. if s != nil {
  321. cfuo.SetFormID(*s)
  322. }
  323. return cfuo
  324. }
  325. // SetValue sets the "value" field.
  326. func (cfuo *ContactFieldUpdateOne) SetValue(s []string) *ContactFieldUpdateOne {
  327. cfuo.mutation.SetValue(s)
  328. return cfuo
  329. }
  330. // AppendValue appends s to the "value" field.
  331. func (cfuo *ContactFieldUpdateOne) AppendValue(s []string) *ContactFieldUpdateOne {
  332. cfuo.mutation.AppendValue(s)
  333. return cfuo
  334. }
  335. // SetFieldContactID sets the "field_contact" edge to the Contact entity by ID.
  336. func (cfuo *ContactFieldUpdateOne) SetFieldContactID(id uint64) *ContactFieldUpdateOne {
  337. cfuo.mutation.SetFieldContactID(id)
  338. return cfuo
  339. }
  340. // SetFieldContact sets the "field_contact" edge to the Contact entity.
  341. func (cfuo *ContactFieldUpdateOne) SetFieldContact(c *Contact) *ContactFieldUpdateOne {
  342. return cfuo.SetFieldContactID(c.ID)
  343. }
  344. // Mutation returns the ContactFieldMutation object of the builder.
  345. func (cfuo *ContactFieldUpdateOne) Mutation() *ContactFieldMutation {
  346. return cfuo.mutation
  347. }
  348. // ClearFieldContact clears the "field_contact" edge to the Contact entity.
  349. func (cfuo *ContactFieldUpdateOne) ClearFieldContact() *ContactFieldUpdateOne {
  350. cfuo.mutation.ClearFieldContact()
  351. return cfuo
  352. }
  353. // Where appends a list predicates to the ContactFieldUpdate builder.
  354. func (cfuo *ContactFieldUpdateOne) Where(ps ...predicate.ContactField) *ContactFieldUpdateOne {
  355. cfuo.mutation.Where(ps...)
  356. return cfuo
  357. }
  358. // Select allows selecting one or more fields (columns) of the returned entity.
  359. // The default is selecting all fields defined in the entity schema.
  360. func (cfuo *ContactFieldUpdateOne) Select(field string, fields ...string) *ContactFieldUpdateOne {
  361. cfuo.fields = append([]string{field}, fields...)
  362. return cfuo
  363. }
  364. // Save executes the query and returns the updated ContactField entity.
  365. func (cfuo *ContactFieldUpdateOne) Save(ctx context.Context) (*ContactField, error) {
  366. if err := cfuo.defaults(); err != nil {
  367. return nil, err
  368. }
  369. return withHooks(ctx, cfuo.sqlSave, cfuo.mutation, cfuo.hooks)
  370. }
  371. // SaveX is like Save, but panics if an error occurs.
  372. func (cfuo *ContactFieldUpdateOne) SaveX(ctx context.Context) *ContactField {
  373. node, err := cfuo.Save(ctx)
  374. if err != nil {
  375. panic(err)
  376. }
  377. return node
  378. }
  379. // Exec executes the query on the entity.
  380. func (cfuo *ContactFieldUpdateOne) Exec(ctx context.Context) error {
  381. _, err := cfuo.Save(ctx)
  382. return err
  383. }
  384. // ExecX is like Exec, but panics if an error occurs.
  385. func (cfuo *ContactFieldUpdateOne) ExecX(ctx context.Context) {
  386. if err := cfuo.Exec(ctx); err != nil {
  387. panic(err)
  388. }
  389. }
  390. // defaults sets the default values of the builder before save.
  391. func (cfuo *ContactFieldUpdateOne) defaults() error {
  392. if _, ok := cfuo.mutation.UpdatedAt(); !ok {
  393. if contactfield.UpdateDefaultUpdatedAt == nil {
  394. return fmt.Errorf("ent: uninitialized contactfield.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  395. }
  396. v := contactfield.UpdateDefaultUpdatedAt()
  397. cfuo.mutation.SetUpdatedAt(v)
  398. }
  399. return nil
  400. }
  401. // check runs all checks and user-defined validators on the builder.
  402. func (cfuo *ContactFieldUpdateOne) check() error {
  403. if _, ok := cfuo.mutation.FieldContactID(); cfuo.mutation.FieldContactCleared() && !ok {
  404. return errors.New(`ent: clearing a required unique edge "ContactField.field_contact"`)
  405. }
  406. return nil
  407. }
  408. func (cfuo *ContactFieldUpdateOne) sqlSave(ctx context.Context) (_node *ContactField, err error) {
  409. if err := cfuo.check(); err != nil {
  410. return _node, err
  411. }
  412. _spec := sqlgraph.NewUpdateSpec(contactfield.Table, contactfield.Columns, sqlgraph.NewFieldSpec(contactfield.FieldID, field.TypeUint64))
  413. id, ok := cfuo.mutation.ID()
  414. if !ok {
  415. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ContactField.id" for update`)}
  416. }
  417. _spec.Node.ID.Value = id
  418. if fields := cfuo.fields; len(fields) > 0 {
  419. _spec.Node.Columns = make([]string, 0, len(fields))
  420. _spec.Node.Columns = append(_spec.Node.Columns, contactfield.FieldID)
  421. for _, f := range fields {
  422. if !contactfield.ValidColumn(f) {
  423. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  424. }
  425. if f != contactfield.FieldID {
  426. _spec.Node.Columns = append(_spec.Node.Columns, f)
  427. }
  428. }
  429. }
  430. if ps := cfuo.mutation.predicates; len(ps) > 0 {
  431. _spec.Predicate = func(selector *sql.Selector) {
  432. for i := range ps {
  433. ps[i](selector)
  434. }
  435. }
  436. }
  437. if value, ok := cfuo.mutation.UpdatedAt(); ok {
  438. _spec.SetField(contactfield.FieldUpdatedAt, field.TypeTime, value)
  439. }
  440. if value, ok := cfuo.mutation.Status(); ok {
  441. _spec.SetField(contactfield.FieldStatus, field.TypeUint8, value)
  442. }
  443. if value, ok := cfuo.mutation.AddedStatus(); ok {
  444. _spec.AddField(contactfield.FieldStatus, field.TypeUint8, value)
  445. }
  446. if cfuo.mutation.StatusCleared() {
  447. _spec.ClearField(contactfield.FieldStatus, field.TypeUint8)
  448. }
  449. if value, ok := cfuo.mutation.DeletedAt(); ok {
  450. _spec.SetField(contactfield.FieldDeletedAt, field.TypeTime, value)
  451. }
  452. if cfuo.mutation.DeletedAtCleared() {
  453. _spec.ClearField(contactfield.FieldDeletedAt, field.TypeTime)
  454. }
  455. if value, ok := cfuo.mutation.FormID(); ok {
  456. _spec.SetField(contactfield.FieldFormID, field.TypeString, value)
  457. }
  458. if value, ok := cfuo.mutation.Value(); ok {
  459. _spec.SetField(contactfield.FieldValue, field.TypeJSON, value)
  460. }
  461. if value, ok := cfuo.mutation.AppendedValue(); ok {
  462. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  463. sqljson.Append(u, contactfield.FieldValue, value)
  464. })
  465. }
  466. if cfuo.mutation.FieldContactCleared() {
  467. edge := &sqlgraph.EdgeSpec{
  468. Rel: sqlgraph.M2O,
  469. Inverse: true,
  470. Table: contactfield.FieldContactTable,
  471. Columns: []string{contactfield.FieldContactColumn},
  472. Bidi: false,
  473. Target: &sqlgraph.EdgeTarget{
  474. IDSpec: sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64),
  475. },
  476. }
  477. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  478. }
  479. if nodes := cfuo.mutation.FieldContactIDs(); len(nodes) > 0 {
  480. edge := &sqlgraph.EdgeSpec{
  481. Rel: sqlgraph.M2O,
  482. Inverse: true,
  483. Table: contactfield.FieldContactTable,
  484. Columns: []string{contactfield.FieldContactColumn},
  485. Bidi: false,
  486. Target: &sqlgraph.EdgeTarget{
  487. IDSpec: sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64),
  488. },
  489. }
  490. for _, k := range nodes {
  491. edge.Target.Nodes = append(edge.Target.Nodes, k)
  492. }
  493. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  494. }
  495. _node = &ContactField{config: cfuo.config}
  496. _spec.Assign = _node.assignValues
  497. _spec.ScanValues = _node.scanValues
  498. if err = sqlgraph.UpdateNode(ctx, cfuo.driver, _spec); err != nil {
  499. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  500. err = &NotFoundError{contactfield.Label}
  501. } else if sqlgraph.IsConstraintError(err) {
  502. err = &ConstraintError{msg: err.Error(), wrap: err}
  503. }
  504. return nil, err
  505. }
  506. cfuo.mutation.done = true
  507. return _node, nil
  508. }