github.com/ngocphuongnb/tetua@v0.0.7-alpha/packages/entrepository/ent/user_update.go (about) 1 // Code generated by entc, DO NOT EDIT. 2 3 package ent 4 5 import ( 6 "context" 7 "errors" 8 "fmt" 9 "time" 10 11 "entgo.io/ent/dialect/sql" 12 "entgo.io/ent/dialect/sql/sqlgraph" 13 "entgo.io/ent/schema/field" 14 "github.com/ngocphuongnb/tetua/packages/entrepository/ent/comment" 15 "github.com/ngocphuongnb/tetua/packages/entrepository/ent/file" 16 "github.com/ngocphuongnb/tetua/packages/entrepository/ent/post" 17 "github.com/ngocphuongnb/tetua/packages/entrepository/ent/predicate" 18 "github.com/ngocphuongnb/tetua/packages/entrepository/ent/role" 19 "github.com/ngocphuongnb/tetua/packages/entrepository/ent/user" 20 ) 21 22 // UserUpdate is the builder for updating User entities. 23 type UserUpdate struct { 24 config 25 hooks []Hook 26 mutation *UserMutation 27 } 28 29 // Where appends a list predicates to the UserUpdate builder. 30 func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate { 31 uu.mutation.Where(ps...) 32 return uu 33 } 34 35 // SetUpdatedAt sets the "updated_at" field. 36 func (uu *UserUpdate) SetUpdatedAt(t time.Time) *UserUpdate { 37 uu.mutation.SetUpdatedAt(t) 38 return uu 39 } 40 41 // SetDeletedAt sets the "deleted_at" field. 42 func (uu *UserUpdate) SetDeletedAt(t time.Time) *UserUpdate { 43 uu.mutation.SetDeletedAt(t) 44 return uu 45 } 46 47 // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. 48 func (uu *UserUpdate) SetNillableDeletedAt(t *time.Time) *UserUpdate { 49 if t != nil { 50 uu.SetDeletedAt(*t) 51 } 52 return uu 53 } 54 55 // ClearDeletedAt clears the value of the "deleted_at" field. 56 func (uu *UserUpdate) ClearDeletedAt() *UserUpdate { 57 uu.mutation.ClearDeletedAt() 58 return uu 59 } 60 61 // SetUsername sets the "username" field. 62 func (uu *UserUpdate) SetUsername(s string) *UserUpdate { 63 uu.mutation.SetUsername(s) 64 return uu 65 } 66 67 // SetDisplayName sets the "display_name" field. 68 func (uu *UserUpdate) SetDisplayName(s string) *UserUpdate { 69 uu.mutation.SetDisplayName(s) 70 return uu 71 } 72 73 // SetNillableDisplayName sets the "display_name" field if the given value is not nil. 74 func (uu *UserUpdate) SetNillableDisplayName(s *string) *UserUpdate { 75 if s != nil { 76 uu.SetDisplayName(*s) 77 } 78 return uu 79 } 80 81 // ClearDisplayName clears the value of the "display_name" field. 82 func (uu *UserUpdate) ClearDisplayName() *UserUpdate { 83 uu.mutation.ClearDisplayName() 84 return uu 85 } 86 87 // SetURL sets the "url" field. 88 func (uu *UserUpdate) SetURL(s string) *UserUpdate { 89 uu.mutation.SetURL(s) 90 return uu 91 } 92 93 // SetNillableURL sets the "url" field if the given value is not nil. 94 func (uu *UserUpdate) SetNillableURL(s *string) *UserUpdate { 95 if s != nil { 96 uu.SetURL(*s) 97 } 98 return uu 99 } 100 101 // ClearURL clears the value of the "url" field. 102 func (uu *UserUpdate) ClearURL() *UserUpdate { 103 uu.mutation.ClearURL() 104 return uu 105 } 106 107 // SetProvider sets the "provider" field. 108 func (uu *UserUpdate) SetProvider(s string) *UserUpdate { 109 uu.mutation.SetProvider(s) 110 return uu 111 } 112 113 // SetNillableProvider sets the "provider" field if the given value is not nil. 114 func (uu *UserUpdate) SetNillableProvider(s *string) *UserUpdate { 115 if s != nil { 116 uu.SetProvider(*s) 117 } 118 return uu 119 } 120 121 // ClearProvider clears the value of the "provider" field. 122 func (uu *UserUpdate) ClearProvider() *UserUpdate { 123 uu.mutation.ClearProvider() 124 return uu 125 } 126 127 // SetProviderID sets the "provider_id" field. 128 func (uu *UserUpdate) SetProviderID(s string) *UserUpdate { 129 uu.mutation.SetProviderID(s) 130 return uu 131 } 132 133 // SetNillableProviderID sets the "provider_id" field if the given value is not nil. 134 func (uu *UserUpdate) SetNillableProviderID(s *string) *UserUpdate { 135 if s != nil { 136 uu.SetProviderID(*s) 137 } 138 return uu 139 } 140 141 // ClearProviderID clears the value of the "provider_id" field. 142 func (uu *UserUpdate) ClearProviderID() *UserUpdate { 143 uu.mutation.ClearProviderID() 144 return uu 145 } 146 147 // SetProviderUsername sets the "provider_username" field. 148 func (uu *UserUpdate) SetProviderUsername(s string) *UserUpdate { 149 uu.mutation.SetProviderUsername(s) 150 return uu 151 } 152 153 // SetNillableProviderUsername sets the "provider_username" field if the given value is not nil. 154 func (uu *UserUpdate) SetNillableProviderUsername(s *string) *UserUpdate { 155 if s != nil { 156 uu.SetProviderUsername(*s) 157 } 158 return uu 159 } 160 161 // ClearProviderUsername clears the value of the "provider_username" field. 162 func (uu *UserUpdate) ClearProviderUsername() *UserUpdate { 163 uu.mutation.ClearProviderUsername() 164 return uu 165 } 166 167 // SetProviderAvatar sets the "provider_avatar" field. 168 func (uu *UserUpdate) SetProviderAvatar(s string) *UserUpdate { 169 uu.mutation.SetProviderAvatar(s) 170 return uu 171 } 172 173 // SetNillableProviderAvatar sets the "provider_avatar" field if the given value is not nil. 174 func (uu *UserUpdate) SetNillableProviderAvatar(s *string) *UserUpdate { 175 if s != nil { 176 uu.SetProviderAvatar(*s) 177 } 178 return uu 179 } 180 181 // ClearProviderAvatar clears the value of the "provider_avatar" field. 182 func (uu *UserUpdate) ClearProviderAvatar() *UserUpdate { 183 uu.mutation.ClearProviderAvatar() 184 return uu 185 } 186 187 // SetEmail sets the "email" field. 188 func (uu *UserUpdate) SetEmail(s string) *UserUpdate { 189 uu.mutation.SetEmail(s) 190 return uu 191 } 192 193 // SetNillableEmail sets the "email" field if the given value is not nil. 194 func (uu *UserUpdate) SetNillableEmail(s *string) *UserUpdate { 195 if s != nil { 196 uu.SetEmail(*s) 197 } 198 return uu 199 } 200 201 // ClearEmail clears the value of the "email" field. 202 func (uu *UserUpdate) ClearEmail() *UserUpdate { 203 uu.mutation.ClearEmail() 204 return uu 205 } 206 207 // SetPassword sets the "password" field. 208 func (uu *UserUpdate) SetPassword(s string) *UserUpdate { 209 uu.mutation.SetPassword(s) 210 return uu 211 } 212 213 // SetNillablePassword sets the "password" field if the given value is not nil. 214 func (uu *UserUpdate) SetNillablePassword(s *string) *UserUpdate { 215 if s != nil { 216 uu.SetPassword(*s) 217 } 218 return uu 219 } 220 221 // ClearPassword clears the value of the "password" field. 222 func (uu *UserUpdate) ClearPassword() *UserUpdate { 223 uu.mutation.ClearPassword() 224 return uu 225 } 226 227 // SetBio sets the "bio" field. 228 func (uu *UserUpdate) SetBio(s string) *UserUpdate { 229 uu.mutation.SetBio(s) 230 return uu 231 } 232 233 // SetNillableBio sets the "bio" field if the given value is not nil. 234 func (uu *UserUpdate) SetNillableBio(s *string) *UserUpdate { 235 if s != nil { 236 uu.SetBio(*s) 237 } 238 return uu 239 } 240 241 // ClearBio clears the value of the "bio" field. 242 func (uu *UserUpdate) ClearBio() *UserUpdate { 243 uu.mutation.ClearBio() 244 return uu 245 } 246 247 // SetBioHTML sets the "bio_html" field. 248 func (uu *UserUpdate) SetBioHTML(s string) *UserUpdate { 249 uu.mutation.SetBioHTML(s) 250 return uu 251 } 252 253 // SetNillableBioHTML sets the "bio_html" field if the given value is not nil. 254 func (uu *UserUpdate) SetNillableBioHTML(s *string) *UserUpdate { 255 if s != nil { 256 uu.SetBioHTML(*s) 257 } 258 return uu 259 } 260 261 // ClearBioHTML clears the value of the "bio_html" field. 262 func (uu *UserUpdate) ClearBioHTML() *UserUpdate { 263 uu.mutation.ClearBioHTML() 264 return uu 265 } 266 267 // SetActive sets the "active" field. 268 func (uu *UserUpdate) SetActive(b bool) *UserUpdate { 269 uu.mutation.SetActive(b) 270 return uu 271 } 272 273 // SetNillableActive sets the "active" field if the given value is not nil. 274 func (uu *UserUpdate) SetNillableActive(b *bool) *UserUpdate { 275 if b != nil { 276 uu.SetActive(*b) 277 } 278 return uu 279 } 280 281 // SetAvatarImageID sets the "avatar_image_id" field. 282 func (uu *UserUpdate) SetAvatarImageID(i int) *UserUpdate { 283 uu.mutation.SetAvatarImageID(i) 284 return uu 285 } 286 287 // SetNillableAvatarImageID sets the "avatar_image_id" field if the given value is not nil. 288 func (uu *UserUpdate) SetNillableAvatarImageID(i *int) *UserUpdate { 289 if i != nil { 290 uu.SetAvatarImageID(*i) 291 } 292 return uu 293 } 294 295 // ClearAvatarImageID clears the value of the "avatar_image_id" field. 296 func (uu *UserUpdate) ClearAvatarImageID() *UserUpdate { 297 uu.mutation.ClearAvatarImageID() 298 return uu 299 } 300 301 // AddPostIDs adds the "posts" edge to the Post entity by IDs. 302 func (uu *UserUpdate) AddPostIDs(ids ...int) *UserUpdate { 303 uu.mutation.AddPostIDs(ids...) 304 return uu 305 } 306 307 // AddPosts adds the "posts" edges to the Post entity. 308 func (uu *UserUpdate) AddPosts(p ...*Post) *UserUpdate { 309 ids := make([]int, len(p)) 310 for i := range p { 311 ids[i] = p[i].ID 312 } 313 return uu.AddPostIDs(ids...) 314 } 315 316 // AddFileIDs adds the "files" edge to the File entity by IDs. 317 func (uu *UserUpdate) AddFileIDs(ids ...int) *UserUpdate { 318 uu.mutation.AddFileIDs(ids...) 319 return uu 320 } 321 322 // AddFiles adds the "files" edges to the File entity. 323 func (uu *UserUpdate) AddFiles(f ...*File) *UserUpdate { 324 ids := make([]int, len(f)) 325 for i := range f { 326 ids[i] = f[i].ID 327 } 328 return uu.AddFileIDs(ids...) 329 } 330 331 // AddCommentIDs adds the "comments" edge to the Comment entity by IDs. 332 func (uu *UserUpdate) AddCommentIDs(ids ...int) *UserUpdate { 333 uu.mutation.AddCommentIDs(ids...) 334 return uu 335 } 336 337 // AddComments adds the "comments" edges to the Comment entity. 338 func (uu *UserUpdate) AddComments(c ...*Comment) *UserUpdate { 339 ids := make([]int, len(c)) 340 for i := range c { 341 ids[i] = c[i].ID 342 } 343 return uu.AddCommentIDs(ids...) 344 } 345 346 // AddRoleIDs adds the "roles" edge to the Role entity by IDs. 347 func (uu *UserUpdate) AddRoleIDs(ids ...int) *UserUpdate { 348 uu.mutation.AddRoleIDs(ids...) 349 return uu 350 } 351 352 // AddRoles adds the "roles" edges to the Role entity. 353 func (uu *UserUpdate) AddRoles(r ...*Role) *UserUpdate { 354 ids := make([]int, len(r)) 355 for i := range r { 356 ids[i] = r[i].ID 357 } 358 return uu.AddRoleIDs(ids...) 359 } 360 361 // SetAvatarImage sets the "avatar_image" edge to the File entity. 362 func (uu *UserUpdate) SetAvatarImage(f *File) *UserUpdate { 363 return uu.SetAvatarImageID(f.ID) 364 } 365 366 // Mutation returns the UserMutation object of the builder. 367 func (uu *UserUpdate) Mutation() *UserMutation { 368 return uu.mutation 369 } 370 371 // ClearPosts clears all "posts" edges to the Post entity. 372 func (uu *UserUpdate) ClearPosts() *UserUpdate { 373 uu.mutation.ClearPosts() 374 return uu 375 } 376 377 // RemovePostIDs removes the "posts" edge to Post entities by IDs. 378 func (uu *UserUpdate) RemovePostIDs(ids ...int) *UserUpdate { 379 uu.mutation.RemovePostIDs(ids...) 380 return uu 381 } 382 383 // RemovePosts removes "posts" edges to Post entities. 384 func (uu *UserUpdate) RemovePosts(p ...*Post) *UserUpdate { 385 ids := make([]int, len(p)) 386 for i := range p { 387 ids[i] = p[i].ID 388 } 389 return uu.RemovePostIDs(ids...) 390 } 391 392 // ClearFiles clears all "files" edges to the File entity. 393 func (uu *UserUpdate) ClearFiles() *UserUpdate { 394 uu.mutation.ClearFiles() 395 return uu 396 } 397 398 // RemoveFileIDs removes the "files" edge to File entities by IDs. 399 func (uu *UserUpdate) RemoveFileIDs(ids ...int) *UserUpdate { 400 uu.mutation.RemoveFileIDs(ids...) 401 return uu 402 } 403 404 // RemoveFiles removes "files" edges to File entities. 405 func (uu *UserUpdate) RemoveFiles(f ...*File) *UserUpdate { 406 ids := make([]int, len(f)) 407 for i := range f { 408 ids[i] = f[i].ID 409 } 410 return uu.RemoveFileIDs(ids...) 411 } 412 413 // ClearComments clears all "comments" edges to the Comment entity. 414 func (uu *UserUpdate) ClearComments() *UserUpdate { 415 uu.mutation.ClearComments() 416 return uu 417 } 418 419 // RemoveCommentIDs removes the "comments" edge to Comment entities by IDs. 420 func (uu *UserUpdate) RemoveCommentIDs(ids ...int) *UserUpdate { 421 uu.mutation.RemoveCommentIDs(ids...) 422 return uu 423 } 424 425 // RemoveComments removes "comments" edges to Comment entities. 426 func (uu *UserUpdate) RemoveComments(c ...*Comment) *UserUpdate { 427 ids := make([]int, len(c)) 428 for i := range c { 429 ids[i] = c[i].ID 430 } 431 return uu.RemoveCommentIDs(ids...) 432 } 433 434 // ClearRoles clears all "roles" edges to the Role entity. 435 func (uu *UserUpdate) ClearRoles() *UserUpdate { 436 uu.mutation.ClearRoles() 437 return uu 438 } 439 440 // RemoveRoleIDs removes the "roles" edge to Role entities by IDs. 441 func (uu *UserUpdate) RemoveRoleIDs(ids ...int) *UserUpdate { 442 uu.mutation.RemoveRoleIDs(ids...) 443 return uu 444 } 445 446 // RemoveRoles removes "roles" edges to Role entities. 447 func (uu *UserUpdate) RemoveRoles(r ...*Role) *UserUpdate { 448 ids := make([]int, len(r)) 449 for i := range r { 450 ids[i] = r[i].ID 451 } 452 return uu.RemoveRoleIDs(ids...) 453 } 454 455 // ClearAvatarImage clears the "avatar_image" edge to the File entity. 456 func (uu *UserUpdate) ClearAvatarImage() *UserUpdate { 457 uu.mutation.ClearAvatarImage() 458 return uu 459 } 460 461 // Save executes the query and returns the number of nodes affected by the update operation. 462 func (uu *UserUpdate) Save(ctx context.Context) (int, error) { 463 var ( 464 err error 465 affected int 466 ) 467 uu.defaults() 468 if len(uu.hooks) == 0 { 469 affected, err = uu.sqlSave(ctx) 470 } else { 471 var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { 472 mutation, ok := m.(*UserMutation) 473 if !ok { 474 return nil, fmt.Errorf("unexpected mutation type %T", m) 475 } 476 uu.mutation = mutation 477 affected, err = uu.sqlSave(ctx) 478 mutation.done = true 479 return affected, err 480 }) 481 for i := len(uu.hooks) - 1; i >= 0; i-- { 482 if uu.hooks[i] == nil { 483 return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") 484 } 485 mut = uu.hooks[i](mut) 486 } 487 if _, err := mut.Mutate(ctx, uu.mutation); err != nil { 488 return 0, err 489 } 490 } 491 return affected, err 492 } 493 494 // SaveX is like Save, but panics if an error occurs. 495 func (uu *UserUpdate) SaveX(ctx context.Context) int { 496 affected, err := uu.Save(ctx) 497 if err != nil { 498 panic(err) 499 } 500 return affected 501 } 502 503 // Exec executes the query. 504 func (uu *UserUpdate) Exec(ctx context.Context) error { 505 _, err := uu.Save(ctx) 506 return err 507 } 508 509 // ExecX is like Exec, but panics if an error occurs. 510 func (uu *UserUpdate) ExecX(ctx context.Context) { 511 if err := uu.Exec(ctx); err != nil { 512 panic(err) 513 } 514 } 515 516 // defaults sets the default values of the builder before save. 517 func (uu *UserUpdate) defaults() { 518 if _, ok := uu.mutation.UpdatedAt(); !ok { 519 v := user.UpdateDefaultUpdatedAt() 520 uu.mutation.SetUpdatedAt(v) 521 } 522 } 523 524 func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { 525 _spec := &sqlgraph.UpdateSpec{ 526 Node: &sqlgraph.NodeSpec{ 527 Table: user.Table, 528 Columns: user.Columns, 529 ID: &sqlgraph.FieldSpec{ 530 Type: field.TypeInt, 531 Column: user.FieldID, 532 }, 533 }, 534 } 535 if ps := uu.mutation.predicates; len(ps) > 0 { 536 _spec.Predicate = func(selector *sql.Selector) { 537 for i := range ps { 538 ps[i](selector) 539 } 540 } 541 } 542 if value, ok := uu.mutation.UpdatedAt(); ok { 543 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 544 Type: field.TypeTime, 545 Value: value, 546 Column: user.FieldUpdatedAt, 547 }) 548 } 549 if value, ok := uu.mutation.DeletedAt(); ok { 550 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 551 Type: field.TypeTime, 552 Value: value, 553 Column: user.FieldDeletedAt, 554 }) 555 } 556 if uu.mutation.DeletedAtCleared() { 557 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 558 Type: field.TypeTime, 559 Column: user.FieldDeletedAt, 560 }) 561 } 562 if value, ok := uu.mutation.Username(); ok { 563 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 564 Type: field.TypeString, 565 Value: value, 566 Column: user.FieldUsername, 567 }) 568 } 569 if value, ok := uu.mutation.DisplayName(); ok { 570 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 571 Type: field.TypeString, 572 Value: value, 573 Column: user.FieldDisplayName, 574 }) 575 } 576 if uu.mutation.DisplayNameCleared() { 577 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 578 Type: field.TypeString, 579 Column: user.FieldDisplayName, 580 }) 581 } 582 if value, ok := uu.mutation.URL(); ok { 583 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 584 Type: field.TypeString, 585 Value: value, 586 Column: user.FieldURL, 587 }) 588 } 589 if uu.mutation.URLCleared() { 590 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 591 Type: field.TypeString, 592 Column: user.FieldURL, 593 }) 594 } 595 if value, ok := uu.mutation.Provider(); ok { 596 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 597 Type: field.TypeString, 598 Value: value, 599 Column: user.FieldProvider, 600 }) 601 } 602 if uu.mutation.ProviderCleared() { 603 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 604 Type: field.TypeString, 605 Column: user.FieldProvider, 606 }) 607 } 608 if value, ok := uu.mutation.ProviderID(); ok { 609 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 610 Type: field.TypeString, 611 Value: value, 612 Column: user.FieldProviderID, 613 }) 614 } 615 if uu.mutation.ProviderIDCleared() { 616 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 617 Type: field.TypeString, 618 Column: user.FieldProviderID, 619 }) 620 } 621 if value, ok := uu.mutation.ProviderUsername(); ok { 622 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 623 Type: field.TypeString, 624 Value: value, 625 Column: user.FieldProviderUsername, 626 }) 627 } 628 if uu.mutation.ProviderUsernameCleared() { 629 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 630 Type: field.TypeString, 631 Column: user.FieldProviderUsername, 632 }) 633 } 634 if value, ok := uu.mutation.ProviderAvatar(); ok { 635 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 636 Type: field.TypeString, 637 Value: value, 638 Column: user.FieldProviderAvatar, 639 }) 640 } 641 if uu.mutation.ProviderAvatarCleared() { 642 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 643 Type: field.TypeString, 644 Column: user.FieldProviderAvatar, 645 }) 646 } 647 if value, ok := uu.mutation.Email(); ok { 648 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 649 Type: field.TypeString, 650 Value: value, 651 Column: user.FieldEmail, 652 }) 653 } 654 if uu.mutation.EmailCleared() { 655 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 656 Type: field.TypeString, 657 Column: user.FieldEmail, 658 }) 659 } 660 if value, ok := uu.mutation.Password(); ok { 661 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 662 Type: field.TypeString, 663 Value: value, 664 Column: user.FieldPassword, 665 }) 666 } 667 if uu.mutation.PasswordCleared() { 668 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 669 Type: field.TypeString, 670 Column: user.FieldPassword, 671 }) 672 } 673 if value, ok := uu.mutation.Bio(); ok { 674 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 675 Type: field.TypeString, 676 Value: value, 677 Column: user.FieldBio, 678 }) 679 } 680 if uu.mutation.BioCleared() { 681 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 682 Type: field.TypeString, 683 Column: user.FieldBio, 684 }) 685 } 686 if value, ok := uu.mutation.BioHTML(); ok { 687 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 688 Type: field.TypeString, 689 Value: value, 690 Column: user.FieldBioHTML, 691 }) 692 } 693 if uu.mutation.BioHTMLCleared() { 694 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 695 Type: field.TypeString, 696 Column: user.FieldBioHTML, 697 }) 698 } 699 if value, ok := uu.mutation.Active(); ok { 700 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 701 Type: field.TypeBool, 702 Value: value, 703 Column: user.FieldActive, 704 }) 705 } 706 if uu.mutation.PostsCleared() { 707 edge := &sqlgraph.EdgeSpec{ 708 Rel: sqlgraph.O2M, 709 Inverse: false, 710 Table: user.PostsTable, 711 Columns: []string{user.PostsColumn}, 712 Bidi: false, 713 Target: &sqlgraph.EdgeTarget{ 714 IDSpec: &sqlgraph.FieldSpec{ 715 Type: field.TypeInt, 716 Column: post.FieldID, 717 }, 718 }, 719 } 720 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 721 } 722 if nodes := uu.mutation.RemovedPostsIDs(); len(nodes) > 0 && !uu.mutation.PostsCleared() { 723 edge := &sqlgraph.EdgeSpec{ 724 Rel: sqlgraph.O2M, 725 Inverse: false, 726 Table: user.PostsTable, 727 Columns: []string{user.PostsColumn}, 728 Bidi: false, 729 Target: &sqlgraph.EdgeTarget{ 730 IDSpec: &sqlgraph.FieldSpec{ 731 Type: field.TypeInt, 732 Column: post.FieldID, 733 }, 734 }, 735 } 736 for _, k := range nodes { 737 edge.Target.Nodes = append(edge.Target.Nodes, k) 738 } 739 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 740 } 741 if nodes := uu.mutation.PostsIDs(); len(nodes) > 0 { 742 edge := &sqlgraph.EdgeSpec{ 743 Rel: sqlgraph.O2M, 744 Inverse: false, 745 Table: user.PostsTable, 746 Columns: []string{user.PostsColumn}, 747 Bidi: false, 748 Target: &sqlgraph.EdgeTarget{ 749 IDSpec: &sqlgraph.FieldSpec{ 750 Type: field.TypeInt, 751 Column: post.FieldID, 752 }, 753 }, 754 } 755 for _, k := range nodes { 756 edge.Target.Nodes = append(edge.Target.Nodes, k) 757 } 758 _spec.Edges.Add = append(_spec.Edges.Add, edge) 759 } 760 if uu.mutation.FilesCleared() { 761 edge := &sqlgraph.EdgeSpec{ 762 Rel: sqlgraph.O2M, 763 Inverse: false, 764 Table: user.FilesTable, 765 Columns: []string{user.FilesColumn}, 766 Bidi: false, 767 Target: &sqlgraph.EdgeTarget{ 768 IDSpec: &sqlgraph.FieldSpec{ 769 Type: field.TypeInt, 770 Column: file.FieldID, 771 }, 772 }, 773 } 774 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 775 } 776 if nodes := uu.mutation.RemovedFilesIDs(); len(nodes) > 0 && !uu.mutation.FilesCleared() { 777 edge := &sqlgraph.EdgeSpec{ 778 Rel: sqlgraph.O2M, 779 Inverse: false, 780 Table: user.FilesTable, 781 Columns: []string{user.FilesColumn}, 782 Bidi: false, 783 Target: &sqlgraph.EdgeTarget{ 784 IDSpec: &sqlgraph.FieldSpec{ 785 Type: field.TypeInt, 786 Column: file.FieldID, 787 }, 788 }, 789 } 790 for _, k := range nodes { 791 edge.Target.Nodes = append(edge.Target.Nodes, k) 792 } 793 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 794 } 795 if nodes := uu.mutation.FilesIDs(); len(nodes) > 0 { 796 edge := &sqlgraph.EdgeSpec{ 797 Rel: sqlgraph.O2M, 798 Inverse: false, 799 Table: user.FilesTable, 800 Columns: []string{user.FilesColumn}, 801 Bidi: false, 802 Target: &sqlgraph.EdgeTarget{ 803 IDSpec: &sqlgraph.FieldSpec{ 804 Type: field.TypeInt, 805 Column: file.FieldID, 806 }, 807 }, 808 } 809 for _, k := range nodes { 810 edge.Target.Nodes = append(edge.Target.Nodes, k) 811 } 812 _spec.Edges.Add = append(_spec.Edges.Add, edge) 813 } 814 if uu.mutation.CommentsCleared() { 815 edge := &sqlgraph.EdgeSpec{ 816 Rel: sqlgraph.O2M, 817 Inverse: false, 818 Table: user.CommentsTable, 819 Columns: []string{user.CommentsColumn}, 820 Bidi: false, 821 Target: &sqlgraph.EdgeTarget{ 822 IDSpec: &sqlgraph.FieldSpec{ 823 Type: field.TypeInt, 824 Column: comment.FieldID, 825 }, 826 }, 827 } 828 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 829 } 830 if nodes := uu.mutation.RemovedCommentsIDs(); len(nodes) > 0 && !uu.mutation.CommentsCleared() { 831 edge := &sqlgraph.EdgeSpec{ 832 Rel: sqlgraph.O2M, 833 Inverse: false, 834 Table: user.CommentsTable, 835 Columns: []string{user.CommentsColumn}, 836 Bidi: false, 837 Target: &sqlgraph.EdgeTarget{ 838 IDSpec: &sqlgraph.FieldSpec{ 839 Type: field.TypeInt, 840 Column: comment.FieldID, 841 }, 842 }, 843 } 844 for _, k := range nodes { 845 edge.Target.Nodes = append(edge.Target.Nodes, k) 846 } 847 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 848 } 849 if nodes := uu.mutation.CommentsIDs(); len(nodes) > 0 { 850 edge := &sqlgraph.EdgeSpec{ 851 Rel: sqlgraph.O2M, 852 Inverse: false, 853 Table: user.CommentsTable, 854 Columns: []string{user.CommentsColumn}, 855 Bidi: false, 856 Target: &sqlgraph.EdgeTarget{ 857 IDSpec: &sqlgraph.FieldSpec{ 858 Type: field.TypeInt, 859 Column: comment.FieldID, 860 }, 861 }, 862 } 863 for _, k := range nodes { 864 edge.Target.Nodes = append(edge.Target.Nodes, k) 865 } 866 _spec.Edges.Add = append(_spec.Edges.Add, edge) 867 } 868 if uu.mutation.RolesCleared() { 869 edge := &sqlgraph.EdgeSpec{ 870 Rel: sqlgraph.M2M, 871 Inverse: true, 872 Table: user.RolesTable, 873 Columns: user.RolesPrimaryKey, 874 Bidi: false, 875 Target: &sqlgraph.EdgeTarget{ 876 IDSpec: &sqlgraph.FieldSpec{ 877 Type: field.TypeInt, 878 Column: role.FieldID, 879 }, 880 }, 881 } 882 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 883 } 884 if nodes := uu.mutation.RemovedRolesIDs(); len(nodes) > 0 && !uu.mutation.RolesCleared() { 885 edge := &sqlgraph.EdgeSpec{ 886 Rel: sqlgraph.M2M, 887 Inverse: true, 888 Table: user.RolesTable, 889 Columns: user.RolesPrimaryKey, 890 Bidi: false, 891 Target: &sqlgraph.EdgeTarget{ 892 IDSpec: &sqlgraph.FieldSpec{ 893 Type: field.TypeInt, 894 Column: role.FieldID, 895 }, 896 }, 897 } 898 for _, k := range nodes { 899 edge.Target.Nodes = append(edge.Target.Nodes, k) 900 } 901 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 902 } 903 if nodes := uu.mutation.RolesIDs(); len(nodes) > 0 { 904 edge := &sqlgraph.EdgeSpec{ 905 Rel: sqlgraph.M2M, 906 Inverse: true, 907 Table: user.RolesTable, 908 Columns: user.RolesPrimaryKey, 909 Bidi: false, 910 Target: &sqlgraph.EdgeTarget{ 911 IDSpec: &sqlgraph.FieldSpec{ 912 Type: field.TypeInt, 913 Column: role.FieldID, 914 }, 915 }, 916 } 917 for _, k := range nodes { 918 edge.Target.Nodes = append(edge.Target.Nodes, k) 919 } 920 _spec.Edges.Add = append(_spec.Edges.Add, edge) 921 } 922 if uu.mutation.AvatarImageCleared() { 923 edge := &sqlgraph.EdgeSpec{ 924 Rel: sqlgraph.M2O, 925 Inverse: true, 926 Table: user.AvatarImageTable, 927 Columns: []string{user.AvatarImageColumn}, 928 Bidi: false, 929 Target: &sqlgraph.EdgeTarget{ 930 IDSpec: &sqlgraph.FieldSpec{ 931 Type: field.TypeInt, 932 Column: file.FieldID, 933 }, 934 }, 935 } 936 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 937 } 938 if nodes := uu.mutation.AvatarImageIDs(); len(nodes) > 0 { 939 edge := &sqlgraph.EdgeSpec{ 940 Rel: sqlgraph.M2O, 941 Inverse: true, 942 Table: user.AvatarImageTable, 943 Columns: []string{user.AvatarImageColumn}, 944 Bidi: false, 945 Target: &sqlgraph.EdgeTarget{ 946 IDSpec: &sqlgraph.FieldSpec{ 947 Type: field.TypeInt, 948 Column: file.FieldID, 949 }, 950 }, 951 } 952 for _, k := range nodes { 953 edge.Target.Nodes = append(edge.Target.Nodes, k) 954 } 955 _spec.Edges.Add = append(_spec.Edges.Add, edge) 956 } 957 if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { 958 if _, ok := err.(*sqlgraph.NotFoundError); ok { 959 err = &NotFoundError{user.Label} 960 } else if sqlgraph.IsConstraintError(err) { 961 err = &ConstraintError{err.Error(), err} 962 } 963 return 0, err 964 } 965 return n, nil 966 } 967 968 // UserUpdateOne is the builder for updating a single User entity. 969 type UserUpdateOne struct { 970 config 971 fields []string 972 hooks []Hook 973 mutation *UserMutation 974 } 975 976 // SetUpdatedAt sets the "updated_at" field. 977 func (uuo *UserUpdateOne) SetUpdatedAt(t time.Time) *UserUpdateOne { 978 uuo.mutation.SetUpdatedAt(t) 979 return uuo 980 } 981 982 // SetDeletedAt sets the "deleted_at" field. 983 func (uuo *UserUpdateOne) SetDeletedAt(t time.Time) *UserUpdateOne { 984 uuo.mutation.SetDeletedAt(t) 985 return uuo 986 } 987 988 // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. 989 func (uuo *UserUpdateOne) SetNillableDeletedAt(t *time.Time) *UserUpdateOne { 990 if t != nil { 991 uuo.SetDeletedAt(*t) 992 } 993 return uuo 994 } 995 996 // ClearDeletedAt clears the value of the "deleted_at" field. 997 func (uuo *UserUpdateOne) ClearDeletedAt() *UserUpdateOne { 998 uuo.mutation.ClearDeletedAt() 999 return uuo 1000 } 1001 1002 // SetUsername sets the "username" field. 1003 func (uuo *UserUpdateOne) SetUsername(s string) *UserUpdateOne { 1004 uuo.mutation.SetUsername(s) 1005 return uuo 1006 } 1007 1008 // SetDisplayName sets the "display_name" field. 1009 func (uuo *UserUpdateOne) SetDisplayName(s string) *UserUpdateOne { 1010 uuo.mutation.SetDisplayName(s) 1011 return uuo 1012 } 1013 1014 // SetNillableDisplayName sets the "display_name" field if the given value is not nil. 1015 func (uuo *UserUpdateOne) SetNillableDisplayName(s *string) *UserUpdateOne { 1016 if s != nil { 1017 uuo.SetDisplayName(*s) 1018 } 1019 return uuo 1020 } 1021 1022 // ClearDisplayName clears the value of the "display_name" field. 1023 func (uuo *UserUpdateOne) ClearDisplayName() *UserUpdateOne { 1024 uuo.mutation.ClearDisplayName() 1025 return uuo 1026 } 1027 1028 // SetURL sets the "url" field. 1029 func (uuo *UserUpdateOne) SetURL(s string) *UserUpdateOne { 1030 uuo.mutation.SetURL(s) 1031 return uuo 1032 } 1033 1034 // SetNillableURL sets the "url" field if the given value is not nil. 1035 func (uuo *UserUpdateOne) SetNillableURL(s *string) *UserUpdateOne { 1036 if s != nil { 1037 uuo.SetURL(*s) 1038 } 1039 return uuo 1040 } 1041 1042 // ClearURL clears the value of the "url" field. 1043 func (uuo *UserUpdateOne) ClearURL() *UserUpdateOne { 1044 uuo.mutation.ClearURL() 1045 return uuo 1046 } 1047 1048 // SetProvider sets the "provider" field. 1049 func (uuo *UserUpdateOne) SetProvider(s string) *UserUpdateOne { 1050 uuo.mutation.SetProvider(s) 1051 return uuo 1052 } 1053 1054 // SetNillableProvider sets the "provider" field if the given value is not nil. 1055 func (uuo *UserUpdateOne) SetNillableProvider(s *string) *UserUpdateOne { 1056 if s != nil { 1057 uuo.SetProvider(*s) 1058 } 1059 return uuo 1060 } 1061 1062 // ClearProvider clears the value of the "provider" field. 1063 func (uuo *UserUpdateOne) ClearProvider() *UserUpdateOne { 1064 uuo.mutation.ClearProvider() 1065 return uuo 1066 } 1067 1068 // SetProviderID sets the "provider_id" field. 1069 func (uuo *UserUpdateOne) SetProviderID(s string) *UserUpdateOne { 1070 uuo.mutation.SetProviderID(s) 1071 return uuo 1072 } 1073 1074 // SetNillableProviderID sets the "provider_id" field if the given value is not nil. 1075 func (uuo *UserUpdateOne) SetNillableProviderID(s *string) *UserUpdateOne { 1076 if s != nil { 1077 uuo.SetProviderID(*s) 1078 } 1079 return uuo 1080 } 1081 1082 // ClearProviderID clears the value of the "provider_id" field. 1083 func (uuo *UserUpdateOne) ClearProviderID() *UserUpdateOne { 1084 uuo.mutation.ClearProviderID() 1085 return uuo 1086 } 1087 1088 // SetProviderUsername sets the "provider_username" field. 1089 func (uuo *UserUpdateOne) SetProviderUsername(s string) *UserUpdateOne { 1090 uuo.mutation.SetProviderUsername(s) 1091 return uuo 1092 } 1093 1094 // SetNillableProviderUsername sets the "provider_username" field if the given value is not nil. 1095 func (uuo *UserUpdateOne) SetNillableProviderUsername(s *string) *UserUpdateOne { 1096 if s != nil { 1097 uuo.SetProviderUsername(*s) 1098 } 1099 return uuo 1100 } 1101 1102 // ClearProviderUsername clears the value of the "provider_username" field. 1103 func (uuo *UserUpdateOne) ClearProviderUsername() *UserUpdateOne { 1104 uuo.mutation.ClearProviderUsername() 1105 return uuo 1106 } 1107 1108 // SetProviderAvatar sets the "provider_avatar" field. 1109 func (uuo *UserUpdateOne) SetProviderAvatar(s string) *UserUpdateOne { 1110 uuo.mutation.SetProviderAvatar(s) 1111 return uuo 1112 } 1113 1114 // SetNillableProviderAvatar sets the "provider_avatar" field if the given value is not nil. 1115 func (uuo *UserUpdateOne) SetNillableProviderAvatar(s *string) *UserUpdateOne { 1116 if s != nil { 1117 uuo.SetProviderAvatar(*s) 1118 } 1119 return uuo 1120 } 1121 1122 // ClearProviderAvatar clears the value of the "provider_avatar" field. 1123 func (uuo *UserUpdateOne) ClearProviderAvatar() *UserUpdateOne { 1124 uuo.mutation.ClearProviderAvatar() 1125 return uuo 1126 } 1127 1128 // SetEmail sets the "email" field. 1129 func (uuo *UserUpdateOne) SetEmail(s string) *UserUpdateOne { 1130 uuo.mutation.SetEmail(s) 1131 return uuo 1132 } 1133 1134 // SetNillableEmail sets the "email" field if the given value is not nil. 1135 func (uuo *UserUpdateOne) SetNillableEmail(s *string) *UserUpdateOne { 1136 if s != nil { 1137 uuo.SetEmail(*s) 1138 } 1139 return uuo 1140 } 1141 1142 // ClearEmail clears the value of the "email" field. 1143 func (uuo *UserUpdateOne) ClearEmail() *UserUpdateOne { 1144 uuo.mutation.ClearEmail() 1145 return uuo 1146 } 1147 1148 // SetPassword sets the "password" field. 1149 func (uuo *UserUpdateOne) SetPassword(s string) *UserUpdateOne { 1150 uuo.mutation.SetPassword(s) 1151 return uuo 1152 } 1153 1154 // SetNillablePassword sets the "password" field if the given value is not nil. 1155 func (uuo *UserUpdateOne) SetNillablePassword(s *string) *UserUpdateOne { 1156 if s != nil { 1157 uuo.SetPassword(*s) 1158 } 1159 return uuo 1160 } 1161 1162 // ClearPassword clears the value of the "password" field. 1163 func (uuo *UserUpdateOne) ClearPassword() *UserUpdateOne { 1164 uuo.mutation.ClearPassword() 1165 return uuo 1166 } 1167 1168 // SetBio sets the "bio" field. 1169 func (uuo *UserUpdateOne) SetBio(s string) *UserUpdateOne { 1170 uuo.mutation.SetBio(s) 1171 return uuo 1172 } 1173 1174 // SetNillableBio sets the "bio" field if the given value is not nil. 1175 func (uuo *UserUpdateOne) SetNillableBio(s *string) *UserUpdateOne { 1176 if s != nil { 1177 uuo.SetBio(*s) 1178 } 1179 return uuo 1180 } 1181 1182 // ClearBio clears the value of the "bio" field. 1183 func (uuo *UserUpdateOne) ClearBio() *UserUpdateOne { 1184 uuo.mutation.ClearBio() 1185 return uuo 1186 } 1187 1188 // SetBioHTML sets the "bio_html" field. 1189 func (uuo *UserUpdateOne) SetBioHTML(s string) *UserUpdateOne { 1190 uuo.mutation.SetBioHTML(s) 1191 return uuo 1192 } 1193 1194 // SetNillableBioHTML sets the "bio_html" field if the given value is not nil. 1195 func (uuo *UserUpdateOne) SetNillableBioHTML(s *string) *UserUpdateOne { 1196 if s != nil { 1197 uuo.SetBioHTML(*s) 1198 } 1199 return uuo 1200 } 1201 1202 // ClearBioHTML clears the value of the "bio_html" field. 1203 func (uuo *UserUpdateOne) ClearBioHTML() *UserUpdateOne { 1204 uuo.mutation.ClearBioHTML() 1205 return uuo 1206 } 1207 1208 // SetActive sets the "active" field. 1209 func (uuo *UserUpdateOne) SetActive(b bool) *UserUpdateOne { 1210 uuo.mutation.SetActive(b) 1211 return uuo 1212 } 1213 1214 // SetNillableActive sets the "active" field if the given value is not nil. 1215 func (uuo *UserUpdateOne) SetNillableActive(b *bool) *UserUpdateOne { 1216 if b != nil { 1217 uuo.SetActive(*b) 1218 } 1219 return uuo 1220 } 1221 1222 // SetAvatarImageID sets the "avatar_image_id" field. 1223 func (uuo *UserUpdateOne) SetAvatarImageID(i int) *UserUpdateOne { 1224 uuo.mutation.SetAvatarImageID(i) 1225 return uuo 1226 } 1227 1228 // SetNillableAvatarImageID sets the "avatar_image_id" field if the given value is not nil. 1229 func (uuo *UserUpdateOne) SetNillableAvatarImageID(i *int) *UserUpdateOne { 1230 if i != nil { 1231 uuo.SetAvatarImageID(*i) 1232 } 1233 return uuo 1234 } 1235 1236 // ClearAvatarImageID clears the value of the "avatar_image_id" field. 1237 func (uuo *UserUpdateOne) ClearAvatarImageID() *UserUpdateOne { 1238 uuo.mutation.ClearAvatarImageID() 1239 return uuo 1240 } 1241 1242 // AddPostIDs adds the "posts" edge to the Post entity by IDs. 1243 func (uuo *UserUpdateOne) AddPostIDs(ids ...int) *UserUpdateOne { 1244 uuo.mutation.AddPostIDs(ids...) 1245 return uuo 1246 } 1247 1248 // AddPosts adds the "posts" edges to the Post entity. 1249 func (uuo *UserUpdateOne) AddPosts(p ...*Post) *UserUpdateOne { 1250 ids := make([]int, len(p)) 1251 for i := range p { 1252 ids[i] = p[i].ID 1253 } 1254 return uuo.AddPostIDs(ids...) 1255 } 1256 1257 // AddFileIDs adds the "files" edge to the File entity by IDs. 1258 func (uuo *UserUpdateOne) AddFileIDs(ids ...int) *UserUpdateOne { 1259 uuo.mutation.AddFileIDs(ids...) 1260 return uuo 1261 } 1262 1263 // AddFiles adds the "files" edges to the File entity. 1264 func (uuo *UserUpdateOne) AddFiles(f ...*File) *UserUpdateOne { 1265 ids := make([]int, len(f)) 1266 for i := range f { 1267 ids[i] = f[i].ID 1268 } 1269 return uuo.AddFileIDs(ids...) 1270 } 1271 1272 // AddCommentIDs adds the "comments" edge to the Comment entity by IDs. 1273 func (uuo *UserUpdateOne) AddCommentIDs(ids ...int) *UserUpdateOne { 1274 uuo.mutation.AddCommentIDs(ids...) 1275 return uuo 1276 } 1277 1278 // AddComments adds the "comments" edges to the Comment entity. 1279 func (uuo *UserUpdateOne) AddComments(c ...*Comment) *UserUpdateOne { 1280 ids := make([]int, len(c)) 1281 for i := range c { 1282 ids[i] = c[i].ID 1283 } 1284 return uuo.AddCommentIDs(ids...) 1285 } 1286 1287 // AddRoleIDs adds the "roles" edge to the Role entity by IDs. 1288 func (uuo *UserUpdateOne) AddRoleIDs(ids ...int) *UserUpdateOne { 1289 uuo.mutation.AddRoleIDs(ids...) 1290 return uuo 1291 } 1292 1293 // AddRoles adds the "roles" edges to the Role entity. 1294 func (uuo *UserUpdateOne) AddRoles(r ...*Role) *UserUpdateOne { 1295 ids := make([]int, len(r)) 1296 for i := range r { 1297 ids[i] = r[i].ID 1298 } 1299 return uuo.AddRoleIDs(ids...) 1300 } 1301 1302 // SetAvatarImage sets the "avatar_image" edge to the File entity. 1303 func (uuo *UserUpdateOne) SetAvatarImage(f *File) *UserUpdateOne { 1304 return uuo.SetAvatarImageID(f.ID) 1305 } 1306 1307 // Mutation returns the UserMutation object of the builder. 1308 func (uuo *UserUpdateOne) Mutation() *UserMutation { 1309 return uuo.mutation 1310 } 1311 1312 // ClearPosts clears all "posts" edges to the Post entity. 1313 func (uuo *UserUpdateOne) ClearPosts() *UserUpdateOne { 1314 uuo.mutation.ClearPosts() 1315 return uuo 1316 } 1317 1318 // RemovePostIDs removes the "posts" edge to Post entities by IDs. 1319 func (uuo *UserUpdateOne) RemovePostIDs(ids ...int) *UserUpdateOne { 1320 uuo.mutation.RemovePostIDs(ids...) 1321 return uuo 1322 } 1323 1324 // RemovePosts removes "posts" edges to Post entities. 1325 func (uuo *UserUpdateOne) RemovePosts(p ...*Post) *UserUpdateOne { 1326 ids := make([]int, len(p)) 1327 for i := range p { 1328 ids[i] = p[i].ID 1329 } 1330 return uuo.RemovePostIDs(ids...) 1331 } 1332 1333 // ClearFiles clears all "files" edges to the File entity. 1334 func (uuo *UserUpdateOne) ClearFiles() *UserUpdateOne { 1335 uuo.mutation.ClearFiles() 1336 return uuo 1337 } 1338 1339 // RemoveFileIDs removes the "files" edge to File entities by IDs. 1340 func (uuo *UserUpdateOne) RemoveFileIDs(ids ...int) *UserUpdateOne { 1341 uuo.mutation.RemoveFileIDs(ids...) 1342 return uuo 1343 } 1344 1345 // RemoveFiles removes "files" edges to File entities. 1346 func (uuo *UserUpdateOne) RemoveFiles(f ...*File) *UserUpdateOne { 1347 ids := make([]int, len(f)) 1348 for i := range f { 1349 ids[i] = f[i].ID 1350 } 1351 return uuo.RemoveFileIDs(ids...) 1352 } 1353 1354 // ClearComments clears all "comments" edges to the Comment entity. 1355 func (uuo *UserUpdateOne) ClearComments() *UserUpdateOne { 1356 uuo.mutation.ClearComments() 1357 return uuo 1358 } 1359 1360 // RemoveCommentIDs removes the "comments" edge to Comment entities by IDs. 1361 func (uuo *UserUpdateOne) RemoveCommentIDs(ids ...int) *UserUpdateOne { 1362 uuo.mutation.RemoveCommentIDs(ids...) 1363 return uuo 1364 } 1365 1366 // RemoveComments removes "comments" edges to Comment entities. 1367 func (uuo *UserUpdateOne) RemoveComments(c ...*Comment) *UserUpdateOne { 1368 ids := make([]int, len(c)) 1369 for i := range c { 1370 ids[i] = c[i].ID 1371 } 1372 return uuo.RemoveCommentIDs(ids...) 1373 } 1374 1375 // ClearRoles clears all "roles" edges to the Role entity. 1376 func (uuo *UserUpdateOne) ClearRoles() *UserUpdateOne { 1377 uuo.mutation.ClearRoles() 1378 return uuo 1379 } 1380 1381 // RemoveRoleIDs removes the "roles" edge to Role entities by IDs. 1382 func (uuo *UserUpdateOne) RemoveRoleIDs(ids ...int) *UserUpdateOne { 1383 uuo.mutation.RemoveRoleIDs(ids...) 1384 return uuo 1385 } 1386 1387 // RemoveRoles removes "roles" edges to Role entities. 1388 func (uuo *UserUpdateOne) RemoveRoles(r ...*Role) *UserUpdateOne { 1389 ids := make([]int, len(r)) 1390 for i := range r { 1391 ids[i] = r[i].ID 1392 } 1393 return uuo.RemoveRoleIDs(ids...) 1394 } 1395 1396 // ClearAvatarImage clears the "avatar_image" edge to the File entity. 1397 func (uuo *UserUpdateOne) ClearAvatarImage() *UserUpdateOne { 1398 uuo.mutation.ClearAvatarImage() 1399 return uuo 1400 } 1401 1402 // Select allows selecting one or more fields (columns) of the returned entity. 1403 // The default is selecting all fields defined in the entity schema. 1404 func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne { 1405 uuo.fields = append([]string{field}, fields...) 1406 return uuo 1407 } 1408 1409 // Save executes the query and returns the updated User entity. 1410 func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { 1411 var ( 1412 err error 1413 node *User 1414 ) 1415 uuo.defaults() 1416 if len(uuo.hooks) == 0 { 1417 node, err = uuo.sqlSave(ctx) 1418 } else { 1419 var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { 1420 mutation, ok := m.(*UserMutation) 1421 if !ok { 1422 return nil, fmt.Errorf("unexpected mutation type %T", m) 1423 } 1424 uuo.mutation = mutation 1425 node, err = uuo.sqlSave(ctx) 1426 mutation.done = true 1427 return node, err 1428 }) 1429 for i := len(uuo.hooks) - 1; i >= 0; i-- { 1430 if uuo.hooks[i] == nil { 1431 return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") 1432 } 1433 mut = uuo.hooks[i](mut) 1434 } 1435 if _, err := mut.Mutate(ctx, uuo.mutation); err != nil { 1436 return nil, err 1437 } 1438 } 1439 return node, err 1440 } 1441 1442 // SaveX is like Save, but panics if an error occurs. 1443 func (uuo *UserUpdateOne) SaveX(ctx context.Context) *User { 1444 node, err := uuo.Save(ctx) 1445 if err != nil { 1446 panic(err) 1447 } 1448 return node 1449 } 1450 1451 // Exec executes the query on the entity. 1452 func (uuo *UserUpdateOne) Exec(ctx context.Context) error { 1453 _, err := uuo.Save(ctx) 1454 return err 1455 } 1456 1457 // ExecX is like Exec, but panics if an error occurs. 1458 func (uuo *UserUpdateOne) ExecX(ctx context.Context) { 1459 if err := uuo.Exec(ctx); err != nil { 1460 panic(err) 1461 } 1462 } 1463 1464 // defaults sets the default values of the builder before save. 1465 func (uuo *UserUpdateOne) defaults() { 1466 if _, ok := uuo.mutation.UpdatedAt(); !ok { 1467 v := user.UpdateDefaultUpdatedAt() 1468 uuo.mutation.SetUpdatedAt(v) 1469 } 1470 } 1471 1472 func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { 1473 _spec := &sqlgraph.UpdateSpec{ 1474 Node: &sqlgraph.NodeSpec{ 1475 Table: user.Table, 1476 Columns: user.Columns, 1477 ID: &sqlgraph.FieldSpec{ 1478 Type: field.TypeInt, 1479 Column: user.FieldID, 1480 }, 1481 }, 1482 } 1483 id, ok := uuo.mutation.ID() 1484 if !ok { 1485 return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "User.id" for update`)} 1486 } 1487 _spec.Node.ID.Value = id 1488 if fields := uuo.fields; len(fields) > 0 { 1489 _spec.Node.Columns = make([]string, 0, len(fields)) 1490 _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) 1491 for _, f := range fields { 1492 if !user.ValidColumn(f) { 1493 return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} 1494 } 1495 if f != user.FieldID { 1496 _spec.Node.Columns = append(_spec.Node.Columns, f) 1497 } 1498 } 1499 } 1500 if ps := uuo.mutation.predicates; len(ps) > 0 { 1501 _spec.Predicate = func(selector *sql.Selector) { 1502 for i := range ps { 1503 ps[i](selector) 1504 } 1505 } 1506 } 1507 if value, ok := uuo.mutation.UpdatedAt(); ok { 1508 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1509 Type: field.TypeTime, 1510 Value: value, 1511 Column: user.FieldUpdatedAt, 1512 }) 1513 } 1514 if value, ok := uuo.mutation.DeletedAt(); ok { 1515 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1516 Type: field.TypeTime, 1517 Value: value, 1518 Column: user.FieldDeletedAt, 1519 }) 1520 } 1521 if uuo.mutation.DeletedAtCleared() { 1522 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1523 Type: field.TypeTime, 1524 Column: user.FieldDeletedAt, 1525 }) 1526 } 1527 if value, ok := uuo.mutation.Username(); ok { 1528 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1529 Type: field.TypeString, 1530 Value: value, 1531 Column: user.FieldUsername, 1532 }) 1533 } 1534 if value, ok := uuo.mutation.DisplayName(); ok { 1535 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1536 Type: field.TypeString, 1537 Value: value, 1538 Column: user.FieldDisplayName, 1539 }) 1540 } 1541 if uuo.mutation.DisplayNameCleared() { 1542 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1543 Type: field.TypeString, 1544 Column: user.FieldDisplayName, 1545 }) 1546 } 1547 if value, ok := uuo.mutation.URL(); ok { 1548 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1549 Type: field.TypeString, 1550 Value: value, 1551 Column: user.FieldURL, 1552 }) 1553 } 1554 if uuo.mutation.URLCleared() { 1555 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1556 Type: field.TypeString, 1557 Column: user.FieldURL, 1558 }) 1559 } 1560 if value, ok := uuo.mutation.Provider(); ok { 1561 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1562 Type: field.TypeString, 1563 Value: value, 1564 Column: user.FieldProvider, 1565 }) 1566 } 1567 if uuo.mutation.ProviderCleared() { 1568 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1569 Type: field.TypeString, 1570 Column: user.FieldProvider, 1571 }) 1572 } 1573 if value, ok := uuo.mutation.ProviderID(); ok { 1574 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1575 Type: field.TypeString, 1576 Value: value, 1577 Column: user.FieldProviderID, 1578 }) 1579 } 1580 if uuo.mutation.ProviderIDCleared() { 1581 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1582 Type: field.TypeString, 1583 Column: user.FieldProviderID, 1584 }) 1585 } 1586 if value, ok := uuo.mutation.ProviderUsername(); ok { 1587 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1588 Type: field.TypeString, 1589 Value: value, 1590 Column: user.FieldProviderUsername, 1591 }) 1592 } 1593 if uuo.mutation.ProviderUsernameCleared() { 1594 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1595 Type: field.TypeString, 1596 Column: user.FieldProviderUsername, 1597 }) 1598 } 1599 if value, ok := uuo.mutation.ProviderAvatar(); ok { 1600 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1601 Type: field.TypeString, 1602 Value: value, 1603 Column: user.FieldProviderAvatar, 1604 }) 1605 } 1606 if uuo.mutation.ProviderAvatarCleared() { 1607 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1608 Type: field.TypeString, 1609 Column: user.FieldProviderAvatar, 1610 }) 1611 } 1612 if value, ok := uuo.mutation.Email(); ok { 1613 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1614 Type: field.TypeString, 1615 Value: value, 1616 Column: user.FieldEmail, 1617 }) 1618 } 1619 if uuo.mutation.EmailCleared() { 1620 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1621 Type: field.TypeString, 1622 Column: user.FieldEmail, 1623 }) 1624 } 1625 if value, ok := uuo.mutation.Password(); ok { 1626 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1627 Type: field.TypeString, 1628 Value: value, 1629 Column: user.FieldPassword, 1630 }) 1631 } 1632 if uuo.mutation.PasswordCleared() { 1633 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1634 Type: field.TypeString, 1635 Column: user.FieldPassword, 1636 }) 1637 } 1638 if value, ok := uuo.mutation.Bio(); ok { 1639 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1640 Type: field.TypeString, 1641 Value: value, 1642 Column: user.FieldBio, 1643 }) 1644 } 1645 if uuo.mutation.BioCleared() { 1646 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1647 Type: field.TypeString, 1648 Column: user.FieldBio, 1649 }) 1650 } 1651 if value, ok := uuo.mutation.BioHTML(); ok { 1652 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1653 Type: field.TypeString, 1654 Value: value, 1655 Column: user.FieldBioHTML, 1656 }) 1657 } 1658 if uuo.mutation.BioHTMLCleared() { 1659 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1660 Type: field.TypeString, 1661 Column: user.FieldBioHTML, 1662 }) 1663 } 1664 if value, ok := uuo.mutation.Active(); ok { 1665 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1666 Type: field.TypeBool, 1667 Value: value, 1668 Column: user.FieldActive, 1669 }) 1670 } 1671 if uuo.mutation.PostsCleared() { 1672 edge := &sqlgraph.EdgeSpec{ 1673 Rel: sqlgraph.O2M, 1674 Inverse: false, 1675 Table: user.PostsTable, 1676 Columns: []string{user.PostsColumn}, 1677 Bidi: false, 1678 Target: &sqlgraph.EdgeTarget{ 1679 IDSpec: &sqlgraph.FieldSpec{ 1680 Type: field.TypeInt, 1681 Column: post.FieldID, 1682 }, 1683 }, 1684 } 1685 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 1686 } 1687 if nodes := uuo.mutation.RemovedPostsIDs(); len(nodes) > 0 && !uuo.mutation.PostsCleared() { 1688 edge := &sqlgraph.EdgeSpec{ 1689 Rel: sqlgraph.O2M, 1690 Inverse: false, 1691 Table: user.PostsTable, 1692 Columns: []string{user.PostsColumn}, 1693 Bidi: false, 1694 Target: &sqlgraph.EdgeTarget{ 1695 IDSpec: &sqlgraph.FieldSpec{ 1696 Type: field.TypeInt, 1697 Column: post.FieldID, 1698 }, 1699 }, 1700 } 1701 for _, k := range nodes { 1702 edge.Target.Nodes = append(edge.Target.Nodes, k) 1703 } 1704 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 1705 } 1706 if nodes := uuo.mutation.PostsIDs(); len(nodes) > 0 { 1707 edge := &sqlgraph.EdgeSpec{ 1708 Rel: sqlgraph.O2M, 1709 Inverse: false, 1710 Table: user.PostsTable, 1711 Columns: []string{user.PostsColumn}, 1712 Bidi: false, 1713 Target: &sqlgraph.EdgeTarget{ 1714 IDSpec: &sqlgraph.FieldSpec{ 1715 Type: field.TypeInt, 1716 Column: post.FieldID, 1717 }, 1718 }, 1719 } 1720 for _, k := range nodes { 1721 edge.Target.Nodes = append(edge.Target.Nodes, k) 1722 } 1723 _spec.Edges.Add = append(_spec.Edges.Add, edge) 1724 } 1725 if uuo.mutation.FilesCleared() { 1726 edge := &sqlgraph.EdgeSpec{ 1727 Rel: sqlgraph.O2M, 1728 Inverse: false, 1729 Table: user.FilesTable, 1730 Columns: []string{user.FilesColumn}, 1731 Bidi: false, 1732 Target: &sqlgraph.EdgeTarget{ 1733 IDSpec: &sqlgraph.FieldSpec{ 1734 Type: field.TypeInt, 1735 Column: file.FieldID, 1736 }, 1737 }, 1738 } 1739 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 1740 } 1741 if nodes := uuo.mutation.RemovedFilesIDs(); len(nodes) > 0 && !uuo.mutation.FilesCleared() { 1742 edge := &sqlgraph.EdgeSpec{ 1743 Rel: sqlgraph.O2M, 1744 Inverse: false, 1745 Table: user.FilesTable, 1746 Columns: []string{user.FilesColumn}, 1747 Bidi: false, 1748 Target: &sqlgraph.EdgeTarget{ 1749 IDSpec: &sqlgraph.FieldSpec{ 1750 Type: field.TypeInt, 1751 Column: file.FieldID, 1752 }, 1753 }, 1754 } 1755 for _, k := range nodes { 1756 edge.Target.Nodes = append(edge.Target.Nodes, k) 1757 } 1758 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 1759 } 1760 if nodes := uuo.mutation.FilesIDs(); len(nodes) > 0 { 1761 edge := &sqlgraph.EdgeSpec{ 1762 Rel: sqlgraph.O2M, 1763 Inverse: false, 1764 Table: user.FilesTable, 1765 Columns: []string{user.FilesColumn}, 1766 Bidi: false, 1767 Target: &sqlgraph.EdgeTarget{ 1768 IDSpec: &sqlgraph.FieldSpec{ 1769 Type: field.TypeInt, 1770 Column: file.FieldID, 1771 }, 1772 }, 1773 } 1774 for _, k := range nodes { 1775 edge.Target.Nodes = append(edge.Target.Nodes, k) 1776 } 1777 _spec.Edges.Add = append(_spec.Edges.Add, edge) 1778 } 1779 if uuo.mutation.CommentsCleared() { 1780 edge := &sqlgraph.EdgeSpec{ 1781 Rel: sqlgraph.O2M, 1782 Inverse: false, 1783 Table: user.CommentsTable, 1784 Columns: []string{user.CommentsColumn}, 1785 Bidi: false, 1786 Target: &sqlgraph.EdgeTarget{ 1787 IDSpec: &sqlgraph.FieldSpec{ 1788 Type: field.TypeInt, 1789 Column: comment.FieldID, 1790 }, 1791 }, 1792 } 1793 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 1794 } 1795 if nodes := uuo.mutation.RemovedCommentsIDs(); len(nodes) > 0 && !uuo.mutation.CommentsCleared() { 1796 edge := &sqlgraph.EdgeSpec{ 1797 Rel: sqlgraph.O2M, 1798 Inverse: false, 1799 Table: user.CommentsTable, 1800 Columns: []string{user.CommentsColumn}, 1801 Bidi: false, 1802 Target: &sqlgraph.EdgeTarget{ 1803 IDSpec: &sqlgraph.FieldSpec{ 1804 Type: field.TypeInt, 1805 Column: comment.FieldID, 1806 }, 1807 }, 1808 } 1809 for _, k := range nodes { 1810 edge.Target.Nodes = append(edge.Target.Nodes, k) 1811 } 1812 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 1813 } 1814 if nodes := uuo.mutation.CommentsIDs(); len(nodes) > 0 { 1815 edge := &sqlgraph.EdgeSpec{ 1816 Rel: sqlgraph.O2M, 1817 Inverse: false, 1818 Table: user.CommentsTable, 1819 Columns: []string{user.CommentsColumn}, 1820 Bidi: false, 1821 Target: &sqlgraph.EdgeTarget{ 1822 IDSpec: &sqlgraph.FieldSpec{ 1823 Type: field.TypeInt, 1824 Column: comment.FieldID, 1825 }, 1826 }, 1827 } 1828 for _, k := range nodes { 1829 edge.Target.Nodes = append(edge.Target.Nodes, k) 1830 } 1831 _spec.Edges.Add = append(_spec.Edges.Add, edge) 1832 } 1833 if uuo.mutation.RolesCleared() { 1834 edge := &sqlgraph.EdgeSpec{ 1835 Rel: sqlgraph.M2M, 1836 Inverse: true, 1837 Table: user.RolesTable, 1838 Columns: user.RolesPrimaryKey, 1839 Bidi: false, 1840 Target: &sqlgraph.EdgeTarget{ 1841 IDSpec: &sqlgraph.FieldSpec{ 1842 Type: field.TypeInt, 1843 Column: role.FieldID, 1844 }, 1845 }, 1846 } 1847 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 1848 } 1849 if nodes := uuo.mutation.RemovedRolesIDs(); len(nodes) > 0 && !uuo.mutation.RolesCleared() { 1850 edge := &sqlgraph.EdgeSpec{ 1851 Rel: sqlgraph.M2M, 1852 Inverse: true, 1853 Table: user.RolesTable, 1854 Columns: user.RolesPrimaryKey, 1855 Bidi: false, 1856 Target: &sqlgraph.EdgeTarget{ 1857 IDSpec: &sqlgraph.FieldSpec{ 1858 Type: field.TypeInt, 1859 Column: role.FieldID, 1860 }, 1861 }, 1862 } 1863 for _, k := range nodes { 1864 edge.Target.Nodes = append(edge.Target.Nodes, k) 1865 } 1866 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 1867 } 1868 if nodes := uuo.mutation.RolesIDs(); len(nodes) > 0 { 1869 edge := &sqlgraph.EdgeSpec{ 1870 Rel: sqlgraph.M2M, 1871 Inverse: true, 1872 Table: user.RolesTable, 1873 Columns: user.RolesPrimaryKey, 1874 Bidi: false, 1875 Target: &sqlgraph.EdgeTarget{ 1876 IDSpec: &sqlgraph.FieldSpec{ 1877 Type: field.TypeInt, 1878 Column: role.FieldID, 1879 }, 1880 }, 1881 } 1882 for _, k := range nodes { 1883 edge.Target.Nodes = append(edge.Target.Nodes, k) 1884 } 1885 _spec.Edges.Add = append(_spec.Edges.Add, edge) 1886 } 1887 if uuo.mutation.AvatarImageCleared() { 1888 edge := &sqlgraph.EdgeSpec{ 1889 Rel: sqlgraph.M2O, 1890 Inverse: true, 1891 Table: user.AvatarImageTable, 1892 Columns: []string{user.AvatarImageColumn}, 1893 Bidi: false, 1894 Target: &sqlgraph.EdgeTarget{ 1895 IDSpec: &sqlgraph.FieldSpec{ 1896 Type: field.TypeInt, 1897 Column: file.FieldID, 1898 }, 1899 }, 1900 } 1901 _spec.Edges.Clear = append(_spec.Edges.Clear, edge) 1902 } 1903 if nodes := uuo.mutation.AvatarImageIDs(); len(nodes) > 0 { 1904 edge := &sqlgraph.EdgeSpec{ 1905 Rel: sqlgraph.M2O, 1906 Inverse: true, 1907 Table: user.AvatarImageTable, 1908 Columns: []string{user.AvatarImageColumn}, 1909 Bidi: false, 1910 Target: &sqlgraph.EdgeTarget{ 1911 IDSpec: &sqlgraph.FieldSpec{ 1912 Type: field.TypeInt, 1913 Column: file.FieldID, 1914 }, 1915 }, 1916 } 1917 for _, k := range nodes { 1918 edge.Target.Nodes = append(edge.Target.Nodes, k) 1919 } 1920 _spec.Edges.Add = append(_spec.Edges.Add, edge) 1921 } 1922 _node = &User{config: uuo.config} 1923 _spec.Assign = _node.assignValues 1924 _spec.ScanValues = _node.scanValues 1925 if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { 1926 if _, ok := err.(*sqlgraph.NotFoundError); ok { 1927 err = &NotFoundError{user.Label} 1928 } else if sqlgraph.IsConstraintError(err) { 1929 err = &ConstraintError{err.Error(), err} 1930 } 1931 return nil, err 1932 } 1933 return _node, nil 1934 }