item_create.go
1 // Code generated by ent, DO NOT EDIT. 2 3 package ent 4 5 import ( 6 "context" 7 "errors" 8 "fmt" 9 "time" 10 11 "entgo.io/ent/dialect" 12 "entgo.io/ent/dialect/sql" 13 "entgo.io/ent/dialect/sql/sqlgraph" 14 "entgo.io/ent/schema/field" 15 "github.com/google/uuid" 16 "github.com/mrusme/journalist/ent/feed" 17 "github.com/mrusme/journalist/ent/item" 18 "github.com/mrusme/journalist/ent/read" 19 "github.com/mrusme/journalist/ent/user" 20 ) 21 22 // ItemCreate is the builder for creating a Item entity. 23 type ItemCreate struct { 24 config 25 mutation *ItemMutation 26 hooks []Hook 27 conflict []sql.ConflictOption 28 } 29 30 // SetItemGUID sets the "item_guid" field. 31 func (ic *ItemCreate) SetItemGUID(s string) *ItemCreate { 32 ic.mutation.SetItemGUID(s) 33 return ic 34 } 35 36 // SetItemTitle sets the "item_title" field. 37 func (ic *ItemCreate) SetItemTitle(s string) *ItemCreate { 38 ic.mutation.SetItemTitle(s) 39 return ic 40 } 41 42 // SetItemDescription sets the "item_description" field. 43 func (ic *ItemCreate) SetItemDescription(s string) *ItemCreate { 44 ic.mutation.SetItemDescription(s) 45 return ic 46 } 47 48 // SetItemContent sets the "item_content" field. 49 func (ic *ItemCreate) SetItemContent(s string) *ItemCreate { 50 ic.mutation.SetItemContent(s) 51 return ic 52 } 53 54 // SetItemLink sets the "item_link" field. 55 func (ic *ItemCreate) SetItemLink(s string) *ItemCreate { 56 ic.mutation.SetItemLink(s) 57 return ic 58 } 59 60 // SetItemUpdated sets the "item_updated" field. 61 func (ic *ItemCreate) SetItemUpdated(t time.Time) *ItemCreate { 62 ic.mutation.SetItemUpdated(t) 63 return ic 64 } 65 66 // SetItemPublished sets the "item_published" field. 67 func (ic *ItemCreate) SetItemPublished(t time.Time) *ItemCreate { 68 ic.mutation.SetItemPublished(t) 69 return ic 70 } 71 72 // SetItemAuthorName sets the "item_author_name" field. 73 func (ic *ItemCreate) SetItemAuthorName(s string) *ItemCreate { 74 ic.mutation.SetItemAuthorName(s) 75 return ic 76 } 77 78 // SetNillableItemAuthorName sets the "item_author_name" field if the given value is not nil. 79 func (ic *ItemCreate) SetNillableItemAuthorName(s *string) *ItemCreate { 80 if s != nil { 81 ic.SetItemAuthorName(*s) 82 } 83 return ic 84 } 85 86 // SetItemAuthorEmail sets the "item_author_email" field. 87 func (ic *ItemCreate) SetItemAuthorEmail(s string) *ItemCreate { 88 ic.mutation.SetItemAuthorEmail(s) 89 return ic 90 } 91 92 // SetNillableItemAuthorEmail sets the "item_author_email" field if the given value is not nil. 93 func (ic *ItemCreate) SetNillableItemAuthorEmail(s *string) *ItemCreate { 94 if s != nil { 95 ic.SetItemAuthorEmail(*s) 96 } 97 return ic 98 } 99 100 // SetItemImageTitle sets the "item_image_title" field. 101 func (ic *ItemCreate) SetItemImageTitle(s string) *ItemCreate { 102 ic.mutation.SetItemImageTitle(s) 103 return ic 104 } 105 106 // SetNillableItemImageTitle sets the "item_image_title" field if the given value is not nil. 107 func (ic *ItemCreate) SetNillableItemImageTitle(s *string) *ItemCreate { 108 if s != nil { 109 ic.SetItemImageTitle(*s) 110 } 111 return ic 112 } 113 114 // SetItemImageURL sets the "item_image_url" field. 115 func (ic *ItemCreate) SetItemImageURL(s string) *ItemCreate { 116 ic.mutation.SetItemImageURL(s) 117 return ic 118 } 119 120 // SetNillableItemImageURL sets the "item_image_url" field if the given value is not nil. 121 func (ic *ItemCreate) SetNillableItemImageURL(s *string) *ItemCreate { 122 if s != nil { 123 ic.SetItemImageURL(*s) 124 } 125 return ic 126 } 127 128 // SetItemCategories sets the "item_categories" field. 129 func (ic *ItemCreate) SetItemCategories(s string) *ItemCreate { 130 ic.mutation.SetItemCategories(s) 131 return ic 132 } 133 134 // SetItemEnclosures sets the "item_enclosures" field. 135 func (ic *ItemCreate) SetItemEnclosures(s string) *ItemCreate { 136 ic.mutation.SetItemEnclosures(s) 137 return ic 138 } 139 140 // SetCrawlerTitle sets the "crawler_title" field. 141 func (ic *ItemCreate) SetCrawlerTitle(s string) *ItemCreate { 142 ic.mutation.SetCrawlerTitle(s) 143 return ic 144 } 145 146 // SetNillableCrawlerTitle sets the "crawler_title" field if the given value is not nil. 147 func (ic *ItemCreate) SetNillableCrawlerTitle(s *string) *ItemCreate { 148 if s != nil { 149 ic.SetCrawlerTitle(*s) 150 } 151 return ic 152 } 153 154 // SetCrawlerAuthor sets the "crawler_author" field. 155 func (ic *ItemCreate) SetCrawlerAuthor(s string) *ItemCreate { 156 ic.mutation.SetCrawlerAuthor(s) 157 return ic 158 } 159 160 // SetNillableCrawlerAuthor sets the "crawler_author" field if the given value is not nil. 161 func (ic *ItemCreate) SetNillableCrawlerAuthor(s *string) *ItemCreate { 162 if s != nil { 163 ic.SetCrawlerAuthor(*s) 164 } 165 return ic 166 } 167 168 // SetCrawlerExcerpt sets the "crawler_excerpt" field. 169 func (ic *ItemCreate) SetCrawlerExcerpt(s string) *ItemCreate { 170 ic.mutation.SetCrawlerExcerpt(s) 171 return ic 172 } 173 174 // SetNillableCrawlerExcerpt sets the "crawler_excerpt" field if the given value is not nil. 175 func (ic *ItemCreate) SetNillableCrawlerExcerpt(s *string) *ItemCreate { 176 if s != nil { 177 ic.SetCrawlerExcerpt(*s) 178 } 179 return ic 180 } 181 182 // SetCrawlerSiteName sets the "crawler_site_name" field. 183 func (ic *ItemCreate) SetCrawlerSiteName(s string) *ItemCreate { 184 ic.mutation.SetCrawlerSiteName(s) 185 return ic 186 } 187 188 // SetNillableCrawlerSiteName sets the "crawler_site_name" field if the given value is not nil. 189 func (ic *ItemCreate) SetNillableCrawlerSiteName(s *string) *ItemCreate { 190 if s != nil { 191 ic.SetCrawlerSiteName(*s) 192 } 193 return ic 194 } 195 196 // SetCrawlerImage sets the "crawler_image" field. 197 func (ic *ItemCreate) SetCrawlerImage(s string) *ItemCreate { 198 ic.mutation.SetCrawlerImage(s) 199 return ic 200 } 201 202 // SetNillableCrawlerImage sets the "crawler_image" field if the given value is not nil. 203 func (ic *ItemCreate) SetNillableCrawlerImage(s *string) *ItemCreate { 204 if s != nil { 205 ic.SetCrawlerImage(*s) 206 } 207 return ic 208 } 209 210 // SetCrawlerContentHTML sets the "crawler_content_html" field. 211 func (ic *ItemCreate) SetCrawlerContentHTML(s string) *ItemCreate { 212 ic.mutation.SetCrawlerContentHTML(s) 213 return ic 214 } 215 216 // SetNillableCrawlerContentHTML sets the "crawler_content_html" field if the given value is not nil. 217 func (ic *ItemCreate) SetNillableCrawlerContentHTML(s *string) *ItemCreate { 218 if s != nil { 219 ic.SetCrawlerContentHTML(*s) 220 } 221 return ic 222 } 223 224 // SetCrawlerContentText sets the "crawler_content_text" field. 225 func (ic *ItemCreate) SetCrawlerContentText(s string) *ItemCreate { 226 ic.mutation.SetCrawlerContentText(s) 227 return ic 228 } 229 230 // SetNillableCrawlerContentText sets the "crawler_content_text" field if the given value is not nil. 231 func (ic *ItemCreate) SetNillableCrawlerContentText(s *string) *ItemCreate { 232 if s != nil { 233 ic.SetCrawlerContentText(*s) 234 } 235 return ic 236 } 237 238 // SetCreatedAt sets the "created_at" field. 239 func (ic *ItemCreate) SetCreatedAt(t time.Time) *ItemCreate { 240 ic.mutation.SetCreatedAt(t) 241 return ic 242 } 243 244 // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. 245 func (ic *ItemCreate) SetNillableCreatedAt(t *time.Time) *ItemCreate { 246 if t != nil { 247 ic.SetCreatedAt(*t) 248 } 249 return ic 250 } 251 252 // SetUpdatedAt sets the "updated_at" field. 253 func (ic *ItemCreate) SetUpdatedAt(t time.Time) *ItemCreate { 254 ic.mutation.SetUpdatedAt(t) 255 return ic 256 } 257 258 // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. 259 func (ic *ItemCreate) SetNillableUpdatedAt(t *time.Time) *ItemCreate { 260 if t != nil { 261 ic.SetUpdatedAt(*t) 262 } 263 return ic 264 } 265 266 // SetID sets the "id" field. 267 func (ic *ItemCreate) SetID(u uuid.UUID) *ItemCreate { 268 ic.mutation.SetID(u) 269 return ic 270 } 271 272 // SetNillableID sets the "id" field if the given value is not nil. 273 func (ic *ItemCreate) SetNillableID(u *uuid.UUID) *ItemCreate { 274 if u != nil { 275 ic.SetID(*u) 276 } 277 return ic 278 } 279 280 // SetFeedID sets the "feed" edge to the Feed entity by ID. 281 func (ic *ItemCreate) SetFeedID(id uuid.UUID) *ItemCreate { 282 ic.mutation.SetFeedID(id) 283 return ic 284 } 285 286 // SetNillableFeedID sets the "feed" edge to the Feed entity by ID if the given value is not nil. 287 func (ic *ItemCreate) SetNillableFeedID(id *uuid.UUID) *ItemCreate { 288 if id != nil { 289 ic = ic.SetFeedID(*id) 290 } 291 return ic 292 } 293 294 // SetFeed sets the "feed" edge to the Feed entity. 295 func (ic *ItemCreate) SetFeed(f *Feed) *ItemCreate { 296 return ic.SetFeedID(f.ID) 297 } 298 299 // AddReadByUserIDs adds the "read_by_users" edge to the User entity by IDs. 300 func (ic *ItemCreate) AddReadByUserIDs(ids ...uuid.UUID) *ItemCreate { 301 ic.mutation.AddReadByUserIDs(ids...) 302 return ic 303 } 304 305 // AddReadByUsers adds the "read_by_users" edges to the User entity. 306 func (ic *ItemCreate) AddReadByUsers(u ...*User) *ItemCreate { 307 ids := make([]uuid.UUID, len(u)) 308 for i := range u { 309 ids[i] = u[i].ID 310 } 311 return ic.AddReadByUserIDs(ids...) 312 } 313 314 // AddReadIDs adds the "reads" edge to the Read entity by IDs. 315 func (ic *ItemCreate) AddReadIDs(ids ...uuid.UUID) *ItemCreate { 316 ic.mutation.AddReadIDs(ids...) 317 return ic 318 } 319 320 // AddReads adds the "reads" edges to the Read entity. 321 func (ic *ItemCreate) AddReads(r ...*Read) *ItemCreate { 322 ids := make([]uuid.UUID, len(r)) 323 for i := range r { 324 ids[i] = r[i].ID 325 } 326 return ic.AddReadIDs(ids...) 327 } 328 329 // Mutation returns the ItemMutation object of the builder. 330 func (ic *ItemCreate) Mutation() *ItemMutation { 331 return ic.mutation 332 } 333 334 // Save creates the Item in the database. 335 func (ic *ItemCreate) Save(ctx context.Context) (*Item, error) { 336 ic.defaults() 337 return withHooks(ctx, ic.sqlSave, ic.mutation, ic.hooks) 338 } 339 340 // SaveX calls Save and panics if Save returns an error. 341 func (ic *ItemCreate) SaveX(ctx context.Context) *Item { 342 v, err := ic.Save(ctx) 343 if err != nil { 344 panic(err) 345 } 346 return v 347 } 348 349 // Exec executes the query. 350 func (ic *ItemCreate) Exec(ctx context.Context) error { 351 _, err := ic.Save(ctx) 352 return err 353 } 354 355 // ExecX is like Exec, but panics if an error occurs. 356 func (ic *ItemCreate) ExecX(ctx context.Context) { 357 if err := ic.Exec(ctx); err != nil { 358 panic(err) 359 } 360 } 361 362 // defaults sets the default values of the builder before save. 363 func (ic *ItemCreate) defaults() { 364 if _, ok := ic.mutation.CreatedAt(); !ok { 365 v := item.DefaultCreatedAt() 366 ic.mutation.SetCreatedAt(v) 367 } 368 if _, ok := ic.mutation.UpdatedAt(); !ok { 369 v := item.DefaultUpdatedAt() 370 ic.mutation.SetUpdatedAt(v) 371 } 372 if _, ok := ic.mutation.ID(); !ok { 373 v := item.DefaultID() 374 ic.mutation.SetID(v) 375 } 376 } 377 378 // check runs all checks and user-defined validators on the builder. 379 func (ic *ItemCreate) check() error { 380 if _, ok := ic.mutation.ItemGUID(); !ok { 381 return &ValidationError{Name: "item_guid", err: errors.New(`ent: missing required field "Item.item_guid"`)} 382 } 383 if _, ok := ic.mutation.ItemTitle(); !ok { 384 return &ValidationError{Name: "item_title", err: errors.New(`ent: missing required field "Item.item_title"`)} 385 } 386 if _, ok := ic.mutation.ItemDescription(); !ok { 387 return &ValidationError{Name: "item_description", err: errors.New(`ent: missing required field "Item.item_description"`)} 388 } 389 if _, ok := ic.mutation.ItemContent(); !ok { 390 return &ValidationError{Name: "item_content", err: errors.New(`ent: missing required field "Item.item_content"`)} 391 } 392 if _, ok := ic.mutation.ItemLink(); !ok { 393 return &ValidationError{Name: "item_link", err: errors.New(`ent: missing required field "Item.item_link"`)} 394 } 395 if v, ok := ic.mutation.ItemLink(); ok { 396 if err := item.ItemLinkValidator(v); err != nil { 397 return &ValidationError{Name: "item_link", err: fmt.Errorf(`ent: validator failed for field "Item.item_link": %w`, err)} 398 } 399 } 400 if _, ok := ic.mutation.ItemUpdated(); !ok { 401 return &ValidationError{Name: "item_updated", err: errors.New(`ent: missing required field "Item.item_updated"`)} 402 } 403 if _, ok := ic.mutation.ItemPublished(); !ok { 404 return &ValidationError{Name: "item_published", err: errors.New(`ent: missing required field "Item.item_published"`)} 405 } 406 if _, ok := ic.mutation.ItemCategories(); !ok { 407 return &ValidationError{Name: "item_categories", err: errors.New(`ent: missing required field "Item.item_categories"`)} 408 } 409 if _, ok := ic.mutation.ItemEnclosures(); !ok { 410 return &ValidationError{Name: "item_enclosures", err: errors.New(`ent: missing required field "Item.item_enclosures"`)} 411 } 412 if _, ok := ic.mutation.CreatedAt(); !ok { 413 return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Item.created_at"`)} 414 } 415 if _, ok := ic.mutation.UpdatedAt(); !ok { 416 return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Item.updated_at"`)} 417 } 418 return nil 419 } 420 421 func (ic *ItemCreate) sqlSave(ctx context.Context) (*Item, error) { 422 if err := ic.check(); err != nil { 423 return nil, err 424 } 425 _node, _spec := ic.createSpec() 426 if err := sqlgraph.CreateNode(ctx, ic.driver, _spec); err != nil { 427 if sqlgraph.IsConstraintError(err) { 428 err = &ConstraintError{msg: err.Error(), wrap: err} 429 } 430 return nil, err 431 } 432 if _spec.ID.Value != nil { 433 if id, ok := _spec.ID.Value.(*uuid.UUID); ok { 434 _node.ID = *id 435 } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { 436 return nil, err 437 } 438 } 439 ic.mutation.id = &_node.ID 440 ic.mutation.done = true 441 return _node, nil 442 } 443 444 func (ic *ItemCreate) createSpec() (*Item, *sqlgraph.CreateSpec) { 445 var ( 446 _node = &Item{config: ic.config} 447 _spec = sqlgraph.NewCreateSpec(item.Table, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID)) 448 ) 449 _spec.OnConflict = ic.conflict 450 if id, ok := ic.mutation.ID(); ok { 451 _node.ID = id 452 _spec.ID.Value = &id 453 } 454 if value, ok := ic.mutation.ItemGUID(); ok { 455 _spec.SetField(item.FieldItemGUID, field.TypeString, value) 456 _node.ItemGUID = value 457 } 458 if value, ok := ic.mutation.ItemTitle(); ok { 459 _spec.SetField(item.FieldItemTitle, field.TypeString, value) 460 _node.ItemTitle = value 461 } 462 if value, ok := ic.mutation.ItemDescription(); ok { 463 _spec.SetField(item.FieldItemDescription, field.TypeString, value) 464 _node.ItemDescription = value 465 } 466 if value, ok := ic.mutation.ItemContent(); ok { 467 _spec.SetField(item.FieldItemContent, field.TypeString, value) 468 _node.ItemContent = value 469 } 470 if value, ok := ic.mutation.ItemLink(); ok { 471 _spec.SetField(item.FieldItemLink, field.TypeString, value) 472 _node.ItemLink = value 473 } 474 if value, ok := ic.mutation.ItemUpdated(); ok { 475 _spec.SetField(item.FieldItemUpdated, field.TypeTime, value) 476 _node.ItemUpdated = value 477 } 478 if value, ok := ic.mutation.ItemPublished(); ok { 479 _spec.SetField(item.FieldItemPublished, field.TypeTime, value) 480 _node.ItemPublished = value 481 } 482 if value, ok := ic.mutation.ItemAuthorName(); ok { 483 _spec.SetField(item.FieldItemAuthorName, field.TypeString, value) 484 _node.ItemAuthorName = value 485 } 486 if value, ok := ic.mutation.ItemAuthorEmail(); ok { 487 _spec.SetField(item.FieldItemAuthorEmail, field.TypeString, value) 488 _node.ItemAuthorEmail = value 489 } 490 if value, ok := ic.mutation.ItemImageTitle(); ok { 491 _spec.SetField(item.FieldItemImageTitle, field.TypeString, value) 492 _node.ItemImageTitle = value 493 } 494 if value, ok := ic.mutation.ItemImageURL(); ok { 495 _spec.SetField(item.FieldItemImageURL, field.TypeString, value) 496 _node.ItemImageURL = value 497 } 498 if value, ok := ic.mutation.ItemCategories(); ok { 499 _spec.SetField(item.FieldItemCategories, field.TypeString, value) 500 _node.ItemCategories = value 501 } 502 if value, ok := ic.mutation.ItemEnclosures(); ok { 503 _spec.SetField(item.FieldItemEnclosures, field.TypeString, value) 504 _node.ItemEnclosures = value 505 } 506 if value, ok := ic.mutation.CrawlerTitle(); ok { 507 _spec.SetField(item.FieldCrawlerTitle, field.TypeString, value) 508 _node.CrawlerTitle = value 509 } 510 if value, ok := ic.mutation.CrawlerAuthor(); ok { 511 _spec.SetField(item.FieldCrawlerAuthor, field.TypeString, value) 512 _node.CrawlerAuthor = value 513 } 514 if value, ok := ic.mutation.CrawlerExcerpt(); ok { 515 _spec.SetField(item.FieldCrawlerExcerpt, field.TypeString, value) 516 _node.CrawlerExcerpt = value 517 } 518 if value, ok := ic.mutation.CrawlerSiteName(); ok { 519 _spec.SetField(item.FieldCrawlerSiteName, field.TypeString, value) 520 _node.CrawlerSiteName = value 521 } 522 if value, ok := ic.mutation.CrawlerImage(); ok { 523 _spec.SetField(item.FieldCrawlerImage, field.TypeString, value) 524 _node.CrawlerImage = value 525 } 526 if value, ok := ic.mutation.CrawlerContentHTML(); ok { 527 _spec.SetField(item.FieldCrawlerContentHTML, field.TypeString, value) 528 _node.CrawlerContentHTML = value 529 } 530 if value, ok := ic.mutation.CrawlerContentText(); ok { 531 _spec.SetField(item.FieldCrawlerContentText, field.TypeString, value) 532 _node.CrawlerContentText = value 533 } 534 if value, ok := ic.mutation.CreatedAt(); ok { 535 _spec.SetField(item.FieldCreatedAt, field.TypeTime, value) 536 _node.CreatedAt = value 537 } 538 if value, ok := ic.mutation.UpdatedAt(); ok { 539 _spec.SetField(item.FieldUpdatedAt, field.TypeTime, value) 540 _node.UpdatedAt = value 541 } 542 if nodes := ic.mutation.FeedIDs(); len(nodes) > 0 { 543 edge := &sqlgraph.EdgeSpec{ 544 Rel: sqlgraph.M2O, 545 Inverse: true, 546 Table: item.FeedTable, 547 Columns: []string{item.FeedColumn}, 548 Bidi: false, 549 Target: &sqlgraph.EdgeTarget{ 550 IDSpec: sqlgraph.NewFieldSpec(feed.FieldID, field.TypeUUID), 551 }, 552 } 553 for _, k := range nodes { 554 edge.Target.Nodes = append(edge.Target.Nodes, k) 555 } 556 _node.feed_items = &nodes[0] 557 _spec.Edges = append(_spec.Edges, edge) 558 } 559 if nodes := ic.mutation.ReadByUsersIDs(); len(nodes) > 0 { 560 edge := &sqlgraph.EdgeSpec{ 561 Rel: sqlgraph.M2M, 562 Inverse: true, 563 Table: item.ReadByUsersTable, 564 Columns: item.ReadByUsersPrimaryKey, 565 Bidi: false, 566 Target: &sqlgraph.EdgeTarget{ 567 IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID), 568 }, 569 } 570 for _, k := range nodes { 571 edge.Target.Nodes = append(edge.Target.Nodes, k) 572 } 573 createE := &ReadCreate{config: ic.config, mutation: newReadMutation(ic.config, OpCreate)} 574 createE.defaults() 575 _, specE := createE.createSpec() 576 edge.Target.Fields = specE.Fields 577 if specE.ID.Value != nil { 578 edge.Target.Fields = append(edge.Target.Fields, specE.ID) 579 } 580 _spec.Edges = append(_spec.Edges, edge) 581 } 582 if nodes := ic.mutation.ReadsIDs(); len(nodes) > 0 { 583 edge := &sqlgraph.EdgeSpec{ 584 Rel: sqlgraph.O2M, 585 Inverse: true, 586 Table: item.ReadsTable, 587 Columns: []string{item.ReadsColumn}, 588 Bidi: false, 589 Target: &sqlgraph.EdgeTarget{ 590 IDSpec: sqlgraph.NewFieldSpec(read.FieldID, field.TypeUUID), 591 }, 592 } 593 for _, k := range nodes { 594 edge.Target.Nodes = append(edge.Target.Nodes, k) 595 } 596 _spec.Edges = append(_spec.Edges, edge) 597 } 598 return _node, _spec 599 } 600 601 // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause 602 // of the `INSERT` statement. For example: 603 // 604 // client.Item.Create(). 605 // SetItemGUID(v). 606 // OnConflict( 607 // // Update the row with the new values 608 // // the was proposed for insertion. 609 // sql.ResolveWithNewValues(), 610 // ). 611 // // Override some of the fields with custom 612 // // update values. 613 // Update(func(u *ent.ItemUpsert) { 614 // SetItemGUID(v+v). 615 // }). 616 // Exec(ctx) 617 func (ic *ItemCreate) OnConflict(opts ...sql.ConflictOption) *ItemUpsertOne { 618 ic.conflict = opts 619 return &ItemUpsertOne{ 620 create: ic, 621 } 622 } 623 624 // OnConflictColumns calls `OnConflict` and configures the columns 625 // as conflict target. Using this option is equivalent to using: 626 // 627 // client.Item.Create(). 628 // OnConflict(sql.ConflictColumns(columns...)). 629 // Exec(ctx) 630 func (ic *ItemCreate) OnConflictColumns(columns ...string) *ItemUpsertOne { 631 ic.conflict = append(ic.conflict, sql.ConflictColumns(columns...)) 632 return &ItemUpsertOne{ 633 create: ic, 634 } 635 } 636 637 type ( 638 // ItemUpsertOne is the builder for "upsert"-ing 639 // one Item node. 640 ItemUpsertOne struct { 641 create *ItemCreate 642 } 643 644 // ItemUpsert is the "OnConflict" setter. 645 ItemUpsert struct { 646 *sql.UpdateSet 647 } 648 ) 649 650 // SetItemGUID sets the "item_guid" field. 651 func (u *ItemUpsert) SetItemGUID(v string) *ItemUpsert { 652 u.Set(item.FieldItemGUID, v) 653 return u 654 } 655 656 // UpdateItemGUID sets the "item_guid" field to the value that was provided on create. 657 func (u *ItemUpsert) UpdateItemGUID() *ItemUpsert { 658 u.SetExcluded(item.FieldItemGUID) 659 return u 660 } 661 662 // SetItemTitle sets the "item_title" field. 663 func (u *ItemUpsert) SetItemTitle(v string) *ItemUpsert { 664 u.Set(item.FieldItemTitle, v) 665 return u 666 } 667 668 // UpdateItemTitle sets the "item_title" field to the value that was provided on create. 669 func (u *ItemUpsert) UpdateItemTitle() *ItemUpsert { 670 u.SetExcluded(item.FieldItemTitle) 671 return u 672 } 673 674 // SetItemDescription sets the "item_description" field. 675 func (u *ItemUpsert) SetItemDescription(v string) *ItemUpsert { 676 u.Set(item.FieldItemDescription, v) 677 return u 678 } 679 680 // UpdateItemDescription sets the "item_description" field to the value that was provided on create. 681 func (u *ItemUpsert) UpdateItemDescription() *ItemUpsert { 682 u.SetExcluded(item.FieldItemDescription) 683 return u 684 } 685 686 // SetItemContent sets the "item_content" field. 687 func (u *ItemUpsert) SetItemContent(v string) *ItemUpsert { 688 u.Set(item.FieldItemContent, v) 689 return u 690 } 691 692 // UpdateItemContent sets the "item_content" field to the value that was provided on create. 693 func (u *ItemUpsert) UpdateItemContent() *ItemUpsert { 694 u.SetExcluded(item.FieldItemContent) 695 return u 696 } 697 698 // SetItemLink sets the "item_link" field. 699 func (u *ItemUpsert) SetItemLink(v string) *ItemUpsert { 700 u.Set(item.FieldItemLink, v) 701 return u 702 } 703 704 // UpdateItemLink sets the "item_link" field to the value that was provided on create. 705 func (u *ItemUpsert) UpdateItemLink() *ItemUpsert { 706 u.SetExcluded(item.FieldItemLink) 707 return u 708 } 709 710 // SetItemUpdated sets the "item_updated" field. 711 func (u *ItemUpsert) SetItemUpdated(v time.Time) *ItemUpsert { 712 u.Set(item.FieldItemUpdated, v) 713 return u 714 } 715 716 // UpdateItemUpdated sets the "item_updated" field to the value that was provided on create. 717 func (u *ItemUpsert) UpdateItemUpdated() *ItemUpsert { 718 u.SetExcluded(item.FieldItemUpdated) 719 return u 720 } 721 722 // SetItemPublished sets the "item_published" field. 723 func (u *ItemUpsert) SetItemPublished(v time.Time) *ItemUpsert { 724 u.Set(item.FieldItemPublished, v) 725 return u 726 } 727 728 // UpdateItemPublished sets the "item_published" field to the value that was provided on create. 729 func (u *ItemUpsert) UpdateItemPublished() *ItemUpsert { 730 u.SetExcluded(item.FieldItemPublished) 731 return u 732 } 733 734 // SetItemAuthorName sets the "item_author_name" field. 735 func (u *ItemUpsert) SetItemAuthorName(v string) *ItemUpsert { 736 u.Set(item.FieldItemAuthorName, v) 737 return u 738 } 739 740 // UpdateItemAuthorName sets the "item_author_name" field to the value that was provided on create. 741 func (u *ItemUpsert) UpdateItemAuthorName() *ItemUpsert { 742 u.SetExcluded(item.FieldItemAuthorName) 743 return u 744 } 745 746 // ClearItemAuthorName clears the value of the "item_author_name" field. 747 func (u *ItemUpsert) ClearItemAuthorName() *ItemUpsert { 748 u.SetNull(item.FieldItemAuthorName) 749 return u 750 } 751 752 // SetItemAuthorEmail sets the "item_author_email" field. 753 func (u *ItemUpsert) SetItemAuthorEmail(v string) *ItemUpsert { 754 u.Set(item.FieldItemAuthorEmail, v) 755 return u 756 } 757 758 // UpdateItemAuthorEmail sets the "item_author_email" field to the value that was provided on create. 759 func (u *ItemUpsert) UpdateItemAuthorEmail() *ItemUpsert { 760 u.SetExcluded(item.FieldItemAuthorEmail) 761 return u 762 } 763 764 // ClearItemAuthorEmail clears the value of the "item_author_email" field. 765 func (u *ItemUpsert) ClearItemAuthorEmail() *ItemUpsert { 766 u.SetNull(item.FieldItemAuthorEmail) 767 return u 768 } 769 770 // SetItemImageTitle sets the "item_image_title" field. 771 func (u *ItemUpsert) SetItemImageTitle(v string) *ItemUpsert { 772 u.Set(item.FieldItemImageTitle, v) 773 return u 774 } 775 776 // UpdateItemImageTitle sets the "item_image_title" field to the value that was provided on create. 777 func (u *ItemUpsert) UpdateItemImageTitle() *ItemUpsert { 778 u.SetExcluded(item.FieldItemImageTitle) 779 return u 780 } 781 782 // ClearItemImageTitle clears the value of the "item_image_title" field. 783 func (u *ItemUpsert) ClearItemImageTitle() *ItemUpsert { 784 u.SetNull(item.FieldItemImageTitle) 785 return u 786 } 787 788 // SetItemImageURL sets the "item_image_url" field. 789 func (u *ItemUpsert) SetItemImageURL(v string) *ItemUpsert { 790 u.Set(item.FieldItemImageURL, v) 791 return u 792 } 793 794 // UpdateItemImageURL sets the "item_image_url" field to the value that was provided on create. 795 func (u *ItemUpsert) UpdateItemImageURL() *ItemUpsert { 796 u.SetExcluded(item.FieldItemImageURL) 797 return u 798 } 799 800 // ClearItemImageURL clears the value of the "item_image_url" field. 801 func (u *ItemUpsert) ClearItemImageURL() *ItemUpsert { 802 u.SetNull(item.FieldItemImageURL) 803 return u 804 } 805 806 // SetItemCategories sets the "item_categories" field. 807 func (u *ItemUpsert) SetItemCategories(v string) *ItemUpsert { 808 u.Set(item.FieldItemCategories, v) 809 return u 810 } 811 812 // UpdateItemCategories sets the "item_categories" field to the value that was provided on create. 813 func (u *ItemUpsert) UpdateItemCategories() *ItemUpsert { 814 u.SetExcluded(item.FieldItemCategories) 815 return u 816 } 817 818 // SetItemEnclosures sets the "item_enclosures" field. 819 func (u *ItemUpsert) SetItemEnclosures(v string) *ItemUpsert { 820 u.Set(item.FieldItemEnclosures, v) 821 return u 822 } 823 824 // UpdateItemEnclosures sets the "item_enclosures" field to the value that was provided on create. 825 func (u *ItemUpsert) UpdateItemEnclosures() *ItemUpsert { 826 u.SetExcluded(item.FieldItemEnclosures) 827 return u 828 } 829 830 // SetCrawlerTitle sets the "crawler_title" field. 831 func (u *ItemUpsert) SetCrawlerTitle(v string) *ItemUpsert { 832 u.Set(item.FieldCrawlerTitle, v) 833 return u 834 } 835 836 // UpdateCrawlerTitle sets the "crawler_title" field to the value that was provided on create. 837 func (u *ItemUpsert) UpdateCrawlerTitle() *ItemUpsert { 838 u.SetExcluded(item.FieldCrawlerTitle) 839 return u 840 } 841 842 // ClearCrawlerTitle clears the value of the "crawler_title" field. 843 func (u *ItemUpsert) ClearCrawlerTitle() *ItemUpsert { 844 u.SetNull(item.FieldCrawlerTitle) 845 return u 846 } 847 848 // SetCrawlerAuthor sets the "crawler_author" field. 849 func (u *ItemUpsert) SetCrawlerAuthor(v string) *ItemUpsert { 850 u.Set(item.FieldCrawlerAuthor, v) 851 return u 852 } 853 854 // UpdateCrawlerAuthor sets the "crawler_author" field to the value that was provided on create. 855 func (u *ItemUpsert) UpdateCrawlerAuthor() *ItemUpsert { 856 u.SetExcluded(item.FieldCrawlerAuthor) 857 return u 858 } 859 860 // ClearCrawlerAuthor clears the value of the "crawler_author" field. 861 func (u *ItemUpsert) ClearCrawlerAuthor() *ItemUpsert { 862 u.SetNull(item.FieldCrawlerAuthor) 863 return u 864 } 865 866 // SetCrawlerExcerpt sets the "crawler_excerpt" field. 867 func (u *ItemUpsert) SetCrawlerExcerpt(v string) *ItemUpsert { 868 u.Set(item.FieldCrawlerExcerpt, v) 869 return u 870 } 871 872 // UpdateCrawlerExcerpt sets the "crawler_excerpt" field to the value that was provided on create. 873 func (u *ItemUpsert) UpdateCrawlerExcerpt() *ItemUpsert { 874 u.SetExcluded(item.FieldCrawlerExcerpt) 875 return u 876 } 877 878 // ClearCrawlerExcerpt clears the value of the "crawler_excerpt" field. 879 func (u *ItemUpsert) ClearCrawlerExcerpt() *ItemUpsert { 880 u.SetNull(item.FieldCrawlerExcerpt) 881 return u 882 } 883 884 // SetCrawlerSiteName sets the "crawler_site_name" field. 885 func (u *ItemUpsert) SetCrawlerSiteName(v string) *ItemUpsert { 886 u.Set(item.FieldCrawlerSiteName, v) 887 return u 888 } 889 890 // UpdateCrawlerSiteName sets the "crawler_site_name" field to the value that was provided on create. 891 func (u *ItemUpsert) UpdateCrawlerSiteName() *ItemUpsert { 892 u.SetExcluded(item.FieldCrawlerSiteName) 893 return u 894 } 895 896 // ClearCrawlerSiteName clears the value of the "crawler_site_name" field. 897 func (u *ItemUpsert) ClearCrawlerSiteName() *ItemUpsert { 898 u.SetNull(item.FieldCrawlerSiteName) 899 return u 900 } 901 902 // SetCrawlerImage sets the "crawler_image" field. 903 func (u *ItemUpsert) SetCrawlerImage(v string) *ItemUpsert { 904 u.Set(item.FieldCrawlerImage, v) 905 return u 906 } 907 908 // UpdateCrawlerImage sets the "crawler_image" field to the value that was provided on create. 909 func (u *ItemUpsert) UpdateCrawlerImage() *ItemUpsert { 910 u.SetExcluded(item.FieldCrawlerImage) 911 return u 912 } 913 914 // ClearCrawlerImage clears the value of the "crawler_image" field. 915 func (u *ItemUpsert) ClearCrawlerImage() *ItemUpsert { 916 u.SetNull(item.FieldCrawlerImage) 917 return u 918 } 919 920 // SetCrawlerContentHTML sets the "crawler_content_html" field. 921 func (u *ItemUpsert) SetCrawlerContentHTML(v string) *ItemUpsert { 922 u.Set(item.FieldCrawlerContentHTML, v) 923 return u 924 } 925 926 // UpdateCrawlerContentHTML sets the "crawler_content_html" field to the value that was provided on create. 927 func (u *ItemUpsert) UpdateCrawlerContentHTML() *ItemUpsert { 928 u.SetExcluded(item.FieldCrawlerContentHTML) 929 return u 930 } 931 932 // ClearCrawlerContentHTML clears the value of the "crawler_content_html" field. 933 func (u *ItemUpsert) ClearCrawlerContentHTML() *ItemUpsert { 934 u.SetNull(item.FieldCrawlerContentHTML) 935 return u 936 } 937 938 // SetCrawlerContentText sets the "crawler_content_text" field. 939 func (u *ItemUpsert) SetCrawlerContentText(v string) *ItemUpsert { 940 u.Set(item.FieldCrawlerContentText, v) 941 return u 942 } 943 944 // UpdateCrawlerContentText sets the "crawler_content_text" field to the value that was provided on create. 945 func (u *ItemUpsert) UpdateCrawlerContentText() *ItemUpsert { 946 u.SetExcluded(item.FieldCrawlerContentText) 947 return u 948 } 949 950 // ClearCrawlerContentText clears the value of the "crawler_content_text" field. 951 func (u *ItemUpsert) ClearCrawlerContentText() *ItemUpsert { 952 u.SetNull(item.FieldCrawlerContentText) 953 return u 954 } 955 956 // SetCreatedAt sets the "created_at" field. 957 func (u *ItemUpsert) SetCreatedAt(v time.Time) *ItemUpsert { 958 u.Set(item.FieldCreatedAt, v) 959 return u 960 } 961 962 // UpdateCreatedAt sets the "created_at" field to the value that was provided on create. 963 func (u *ItemUpsert) UpdateCreatedAt() *ItemUpsert { 964 u.SetExcluded(item.FieldCreatedAt) 965 return u 966 } 967 968 // SetUpdatedAt sets the "updated_at" field. 969 func (u *ItemUpsert) SetUpdatedAt(v time.Time) *ItemUpsert { 970 u.Set(item.FieldUpdatedAt, v) 971 return u 972 } 973 974 // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. 975 func (u *ItemUpsert) UpdateUpdatedAt() *ItemUpsert { 976 u.SetExcluded(item.FieldUpdatedAt) 977 return u 978 } 979 980 // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. 981 // Using this option is equivalent to using: 982 // 983 // client.Item.Create(). 984 // OnConflict( 985 // sql.ResolveWithNewValues(), 986 // sql.ResolveWith(func(u *sql.UpdateSet) { 987 // u.SetIgnore(item.FieldID) 988 // }), 989 // ). 990 // Exec(ctx) 991 func (u *ItemUpsertOne) UpdateNewValues() *ItemUpsertOne { 992 u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) 993 u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { 994 if _, exists := u.create.mutation.ID(); exists { 995 s.SetIgnore(item.FieldID) 996 } 997 })) 998 return u 999 } 1000 1001 // Ignore sets each column to itself in case of conflict. 1002 // Using this option is equivalent to using: 1003 // 1004 // client.Item.Create(). 1005 // OnConflict(sql.ResolveWithIgnore()). 1006 // Exec(ctx) 1007 func (u *ItemUpsertOne) Ignore() *ItemUpsertOne { 1008 u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) 1009 return u 1010 } 1011 1012 // DoNothing configures the conflict_action to `DO NOTHING`. 1013 // Supported only by SQLite and PostgreSQL. 1014 func (u *ItemUpsertOne) DoNothing() *ItemUpsertOne { 1015 u.create.conflict = append(u.create.conflict, sql.DoNothing()) 1016 return u 1017 } 1018 1019 // Update allows overriding fields `UPDATE` values. See the ItemCreate.OnConflict 1020 // documentation for more info. 1021 func (u *ItemUpsertOne) Update(set func(*ItemUpsert)) *ItemUpsertOne { 1022 u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { 1023 set(&ItemUpsert{UpdateSet: update}) 1024 })) 1025 return u 1026 } 1027 1028 // SetItemGUID sets the "item_guid" field. 1029 func (u *ItemUpsertOne) SetItemGUID(v string) *ItemUpsertOne { 1030 return u.Update(func(s *ItemUpsert) { 1031 s.SetItemGUID(v) 1032 }) 1033 } 1034 1035 // UpdateItemGUID sets the "item_guid" field to the value that was provided on create. 1036 func (u *ItemUpsertOne) UpdateItemGUID() *ItemUpsertOne { 1037 return u.Update(func(s *ItemUpsert) { 1038 s.UpdateItemGUID() 1039 }) 1040 } 1041 1042 // SetItemTitle sets the "item_title" field. 1043 func (u *ItemUpsertOne) SetItemTitle(v string) *ItemUpsertOne { 1044 return u.Update(func(s *ItemUpsert) { 1045 s.SetItemTitle(v) 1046 }) 1047 } 1048 1049 // UpdateItemTitle sets the "item_title" field to the value that was provided on create. 1050 func (u *ItemUpsertOne) UpdateItemTitle() *ItemUpsertOne { 1051 return u.Update(func(s *ItemUpsert) { 1052 s.UpdateItemTitle() 1053 }) 1054 } 1055 1056 // SetItemDescription sets the "item_description" field. 1057 func (u *ItemUpsertOne) SetItemDescription(v string) *ItemUpsertOne { 1058 return u.Update(func(s *ItemUpsert) { 1059 s.SetItemDescription(v) 1060 }) 1061 } 1062 1063 // UpdateItemDescription sets the "item_description" field to the value that was provided on create. 1064 func (u *ItemUpsertOne) UpdateItemDescription() *ItemUpsertOne { 1065 return u.Update(func(s *ItemUpsert) { 1066 s.UpdateItemDescription() 1067 }) 1068 } 1069 1070 // SetItemContent sets the "item_content" field. 1071 func (u *ItemUpsertOne) SetItemContent(v string) *ItemUpsertOne { 1072 return u.Update(func(s *ItemUpsert) { 1073 s.SetItemContent(v) 1074 }) 1075 } 1076 1077 // UpdateItemContent sets the "item_content" field to the value that was provided on create. 1078 func (u *ItemUpsertOne) UpdateItemContent() *ItemUpsertOne { 1079 return u.Update(func(s *ItemUpsert) { 1080 s.UpdateItemContent() 1081 }) 1082 } 1083 1084 // SetItemLink sets the "item_link" field. 1085 func (u *ItemUpsertOne) SetItemLink(v string) *ItemUpsertOne { 1086 return u.Update(func(s *ItemUpsert) { 1087 s.SetItemLink(v) 1088 }) 1089 } 1090 1091 // UpdateItemLink sets the "item_link" field to the value that was provided on create. 1092 func (u *ItemUpsertOne) UpdateItemLink() *ItemUpsertOne { 1093 return u.Update(func(s *ItemUpsert) { 1094 s.UpdateItemLink() 1095 }) 1096 } 1097 1098 // SetItemUpdated sets the "item_updated" field. 1099 func (u *ItemUpsertOne) SetItemUpdated(v time.Time) *ItemUpsertOne { 1100 return u.Update(func(s *ItemUpsert) { 1101 s.SetItemUpdated(v) 1102 }) 1103 } 1104 1105 // UpdateItemUpdated sets the "item_updated" field to the value that was provided on create. 1106 func (u *ItemUpsertOne) UpdateItemUpdated() *ItemUpsertOne { 1107 return u.Update(func(s *ItemUpsert) { 1108 s.UpdateItemUpdated() 1109 }) 1110 } 1111 1112 // SetItemPublished sets the "item_published" field. 1113 func (u *ItemUpsertOne) SetItemPublished(v time.Time) *ItemUpsertOne { 1114 return u.Update(func(s *ItemUpsert) { 1115 s.SetItemPublished(v) 1116 }) 1117 } 1118 1119 // UpdateItemPublished sets the "item_published" field to the value that was provided on create. 1120 func (u *ItemUpsertOne) UpdateItemPublished() *ItemUpsertOne { 1121 return u.Update(func(s *ItemUpsert) { 1122 s.UpdateItemPublished() 1123 }) 1124 } 1125 1126 // SetItemAuthorName sets the "item_author_name" field. 1127 func (u *ItemUpsertOne) SetItemAuthorName(v string) *ItemUpsertOne { 1128 return u.Update(func(s *ItemUpsert) { 1129 s.SetItemAuthorName(v) 1130 }) 1131 } 1132 1133 // UpdateItemAuthorName sets the "item_author_name" field to the value that was provided on create. 1134 func (u *ItemUpsertOne) UpdateItemAuthorName() *ItemUpsertOne { 1135 return u.Update(func(s *ItemUpsert) { 1136 s.UpdateItemAuthorName() 1137 }) 1138 } 1139 1140 // ClearItemAuthorName clears the value of the "item_author_name" field. 1141 func (u *ItemUpsertOne) ClearItemAuthorName() *ItemUpsertOne { 1142 return u.Update(func(s *ItemUpsert) { 1143 s.ClearItemAuthorName() 1144 }) 1145 } 1146 1147 // SetItemAuthorEmail sets the "item_author_email" field. 1148 func (u *ItemUpsertOne) SetItemAuthorEmail(v string) *ItemUpsertOne { 1149 return u.Update(func(s *ItemUpsert) { 1150 s.SetItemAuthorEmail(v) 1151 }) 1152 } 1153 1154 // UpdateItemAuthorEmail sets the "item_author_email" field to the value that was provided on create. 1155 func (u *ItemUpsertOne) UpdateItemAuthorEmail() *ItemUpsertOne { 1156 return u.Update(func(s *ItemUpsert) { 1157 s.UpdateItemAuthorEmail() 1158 }) 1159 } 1160 1161 // ClearItemAuthorEmail clears the value of the "item_author_email" field. 1162 func (u *ItemUpsertOne) ClearItemAuthorEmail() *ItemUpsertOne { 1163 return u.Update(func(s *ItemUpsert) { 1164 s.ClearItemAuthorEmail() 1165 }) 1166 } 1167 1168 // SetItemImageTitle sets the "item_image_title" field. 1169 func (u *ItemUpsertOne) SetItemImageTitle(v string) *ItemUpsertOne { 1170 return u.Update(func(s *ItemUpsert) { 1171 s.SetItemImageTitle(v) 1172 }) 1173 } 1174 1175 // UpdateItemImageTitle sets the "item_image_title" field to the value that was provided on create. 1176 func (u *ItemUpsertOne) UpdateItemImageTitle() *ItemUpsertOne { 1177 return u.Update(func(s *ItemUpsert) { 1178 s.UpdateItemImageTitle() 1179 }) 1180 } 1181 1182 // ClearItemImageTitle clears the value of the "item_image_title" field. 1183 func (u *ItemUpsertOne) ClearItemImageTitle() *ItemUpsertOne { 1184 return u.Update(func(s *ItemUpsert) { 1185 s.ClearItemImageTitle() 1186 }) 1187 } 1188 1189 // SetItemImageURL sets the "item_image_url" field. 1190 func (u *ItemUpsertOne) SetItemImageURL(v string) *ItemUpsertOne { 1191 return u.Update(func(s *ItemUpsert) { 1192 s.SetItemImageURL(v) 1193 }) 1194 } 1195 1196 // UpdateItemImageURL sets the "item_image_url" field to the value that was provided on create. 1197 func (u *ItemUpsertOne) UpdateItemImageURL() *ItemUpsertOne { 1198 return u.Update(func(s *ItemUpsert) { 1199 s.UpdateItemImageURL() 1200 }) 1201 } 1202 1203 // ClearItemImageURL clears the value of the "item_image_url" field. 1204 func (u *ItemUpsertOne) ClearItemImageURL() *ItemUpsertOne { 1205 return u.Update(func(s *ItemUpsert) { 1206 s.ClearItemImageURL() 1207 }) 1208 } 1209 1210 // SetItemCategories sets the "item_categories" field. 1211 func (u *ItemUpsertOne) SetItemCategories(v string) *ItemUpsertOne { 1212 return u.Update(func(s *ItemUpsert) { 1213 s.SetItemCategories(v) 1214 }) 1215 } 1216 1217 // UpdateItemCategories sets the "item_categories" field to the value that was provided on create. 1218 func (u *ItemUpsertOne) UpdateItemCategories() *ItemUpsertOne { 1219 return u.Update(func(s *ItemUpsert) { 1220 s.UpdateItemCategories() 1221 }) 1222 } 1223 1224 // SetItemEnclosures sets the "item_enclosures" field. 1225 func (u *ItemUpsertOne) SetItemEnclosures(v string) *ItemUpsertOne { 1226 return u.Update(func(s *ItemUpsert) { 1227 s.SetItemEnclosures(v) 1228 }) 1229 } 1230 1231 // UpdateItemEnclosures sets the "item_enclosures" field to the value that was provided on create. 1232 func (u *ItemUpsertOne) UpdateItemEnclosures() *ItemUpsertOne { 1233 return u.Update(func(s *ItemUpsert) { 1234 s.UpdateItemEnclosures() 1235 }) 1236 } 1237 1238 // SetCrawlerTitle sets the "crawler_title" field. 1239 func (u *ItemUpsertOne) SetCrawlerTitle(v string) *ItemUpsertOne { 1240 return u.Update(func(s *ItemUpsert) { 1241 s.SetCrawlerTitle(v) 1242 }) 1243 } 1244 1245 // UpdateCrawlerTitle sets the "crawler_title" field to the value that was provided on create. 1246 func (u *ItemUpsertOne) UpdateCrawlerTitle() *ItemUpsertOne { 1247 return u.Update(func(s *ItemUpsert) { 1248 s.UpdateCrawlerTitle() 1249 }) 1250 } 1251 1252 // ClearCrawlerTitle clears the value of the "crawler_title" field. 1253 func (u *ItemUpsertOne) ClearCrawlerTitle() *ItemUpsertOne { 1254 return u.Update(func(s *ItemUpsert) { 1255 s.ClearCrawlerTitle() 1256 }) 1257 } 1258 1259 // SetCrawlerAuthor sets the "crawler_author" field. 1260 func (u *ItemUpsertOne) SetCrawlerAuthor(v string) *ItemUpsertOne { 1261 return u.Update(func(s *ItemUpsert) { 1262 s.SetCrawlerAuthor(v) 1263 }) 1264 } 1265 1266 // UpdateCrawlerAuthor sets the "crawler_author" field to the value that was provided on create. 1267 func (u *ItemUpsertOne) UpdateCrawlerAuthor() *ItemUpsertOne { 1268 return u.Update(func(s *ItemUpsert) { 1269 s.UpdateCrawlerAuthor() 1270 }) 1271 } 1272 1273 // ClearCrawlerAuthor clears the value of the "crawler_author" field. 1274 func (u *ItemUpsertOne) ClearCrawlerAuthor() *ItemUpsertOne { 1275 return u.Update(func(s *ItemUpsert) { 1276 s.ClearCrawlerAuthor() 1277 }) 1278 } 1279 1280 // SetCrawlerExcerpt sets the "crawler_excerpt" field. 1281 func (u *ItemUpsertOne) SetCrawlerExcerpt(v string) *ItemUpsertOne { 1282 return u.Update(func(s *ItemUpsert) { 1283 s.SetCrawlerExcerpt(v) 1284 }) 1285 } 1286 1287 // UpdateCrawlerExcerpt sets the "crawler_excerpt" field to the value that was provided on create. 1288 func (u *ItemUpsertOne) UpdateCrawlerExcerpt() *ItemUpsertOne { 1289 return u.Update(func(s *ItemUpsert) { 1290 s.UpdateCrawlerExcerpt() 1291 }) 1292 } 1293 1294 // ClearCrawlerExcerpt clears the value of the "crawler_excerpt" field. 1295 func (u *ItemUpsertOne) ClearCrawlerExcerpt() *ItemUpsertOne { 1296 return u.Update(func(s *ItemUpsert) { 1297 s.ClearCrawlerExcerpt() 1298 }) 1299 } 1300 1301 // SetCrawlerSiteName sets the "crawler_site_name" field. 1302 func (u *ItemUpsertOne) SetCrawlerSiteName(v string) *ItemUpsertOne { 1303 return u.Update(func(s *ItemUpsert) { 1304 s.SetCrawlerSiteName(v) 1305 }) 1306 } 1307 1308 // UpdateCrawlerSiteName sets the "crawler_site_name" field to the value that was provided on create. 1309 func (u *ItemUpsertOne) UpdateCrawlerSiteName() *ItemUpsertOne { 1310 return u.Update(func(s *ItemUpsert) { 1311 s.UpdateCrawlerSiteName() 1312 }) 1313 } 1314 1315 // ClearCrawlerSiteName clears the value of the "crawler_site_name" field. 1316 func (u *ItemUpsertOne) ClearCrawlerSiteName() *ItemUpsertOne { 1317 return u.Update(func(s *ItemUpsert) { 1318 s.ClearCrawlerSiteName() 1319 }) 1320 } 1321 1322 // SetCrawlerImage sets the "crawler_image" field. 1323 func (u *ItemUpsertOne) SetCrawlerImage(v string) *ItemUpsertOne { 1324 return u.Update(func(s *ItemUpsert) { 1325 s.SetCrawlerImage(v) 1326 }) 1327 } 1328 1329 // UpdateCrawlerImage sets the "crawler_image" field to the value that was provided on create. 1330 func (u *ItemUpsertOne) UpdateCrawlerImage() *ItemUpsertOne { 1331 return u.Update(func(s *ItemUpsert) { 1332 s.UpdateCrawlerImage() 1333 }) 1334 } 1335 1336 // ClearCrawlerImage clears the value of the "crawler_image" field. 1337 func (u *ItemUpsertOne) ClearCrawlerImage() *ItemUpsertOne { 1338 return u.Update(func(s *ItemUpsert) { 1339 s.ClearCrawlerImage() 1340 }) 1341 } 1342 1343 // SetCrawlerContentHTML sets the "crawler_content_html" field. 1344 func (u *ItemUpsertOne) SetCrawlerContentHTML(v string) *ItemUpsertOne { 1345 return u.Update(func(s *ItemUpsert) { 1346 s.SetCrawlerContentHTML(v) 1347 }) 1348 } 1349 1350 // UpdateCrawlerContentHTML sets the "crawler_content_html" field to the value that was provided on create. 1351 func (u *ItemUpsertOne) UpdateCrawlerContentHTML() *ItemUpsertOne { 1352 return u.Update(func(s *ItemUpsert) { 1353 s.UpdateCrawlerContentHTML() 1354 }) 1355 } 1356 1357 // ClearCrawlerContentHTML clears the value of the "crawler_content_html" field. 1358 func (u *ItemUpsertOne) ClearCrawlerContentHTML() *ItemUpsertOne { 1359 return u.Update(func(s *ItemUpsert) { 1360 s.ClearCrawlerContentHTML() 1361 }) 1362 } 1363 1364 // SetCrawlerContentText sets the "crawler_content_text" field. 1365 func (u *ItemUpsertOne) SetCrawlerContentText(v string) *ItemUpsertOne { 1366 return u.Update(func(s *ItemUpsert) { 1367 s.SetCrawlerContentText(v) 1368 }) 1369 } 1370 1371 // UpdateCrawlerContentText sets the "crawler_content_text" field to the value that was provided on create. 1372 func (u *ItemUpsertOne) UpdateCrawlerContentText() *ItemUpsertOne { 1373 return u.Update(func(s *ItemUpsert) { 1374 s.UpdateCrawlerContentText() 1375 }) 1376 } 1377 1378 // ClearCrawlerContentText clears the value of the "crawler_content_text" field. 1379 func (u *ItemUpsertOne) ClearCrawlerContentText() *ItemUpsertOne { 1380 return u.Update(func(s *ItemUpsert) { 1381 s.ClearCrawlerContentText() 1382 }) 1383 } 1384 1385 // SetCreatedAt sets the "created_at" field. 1386 func (u *ItemUpsertOne) SetCreatedAt(v time.Time) *ItemUpsertOne { 1387 return u.Update(func(s *ItemUpsert) { 1388 s.SetCreatedAt(v) 1389 }) 1390 } 1391 1392 // UpdateCreatedAt sets the "created_at" field to the value that was provided on create. 1393 func (u *ItemUpsertOne) UpdateCreatedAt() *ItemUpsertOne { 1394 return u.Update(func(s *ItemUpsert) { 1395 s.UpdateCreatedAt() 1396 }) 1397 } 1398 1399 // SetUpdatedAt sets the "updated_at" field. 1400 func (u *ItemUpsertOne) SetUpdatedAt(v time.Time) *ItemUpsertOne { 1401 return u.Update(func(s *ItemUpsert) { 1402 s.SetUpdatedAt(v) 1403 }) 1404 } 1405 1406 // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. 1407 func (u *ItemUpsertOne) UpdateUpdatedAt() *ItemUpsertOne { 1408 return u.Update(func(s *ItemUpsert) { 1409 s.UpdateUpdatedAt() 1410 }) 1411 } 1412 1413 // Exec executes the query. 1414 func (u *ItemUpsertOne) Exec(ctx context.Context) error { 1415 if len(u.create.conflict) == 0 { 1416 return errors.New("ent: missing options for ItemCreate.OnConflict") 1417 } 1418 return u.create.Exec(ctx) 1419 } 1420 1421 // ExecX is like Exec, but panics if an error occurs. 1422 func (u *ItemUpsertOne) ExecX(ctx context.Context) { 1423 if err := u.create.Exec(ctx); err != nil { 1424 panic(err) 1425 } 1426 } 1427 1428 // Exec executes the UPSERT query and returns the inserted/updated ID. 1429 func (u *ItemUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) { 1430 if u.create.driver.Dialect() == dialect.MySQL { 1431 // In case of "ON CONFLICT", there is no way to get back non-numeric ID 1432 // fields from the database since MySQL does not support the RETURNING clause. 1433 return id, errors.New("ent: ItemUpsertOne.ID is not supported by MySQL driver. Use ItemUpsertOne.Exec instead") 1434 } 1435 node, err := u.create.Save(ctx) 1436 if err != nil { 1437 return id, err 1438 } 1439 return node.ID, nil 1440 } 1441 1442 // IDX is like ID, but panics if an error occurs. 1443 func (u *ItemUpsertOne) IDX(ctx context.Context) uuid.UUID { 1444 id, err := u.ID(ctx) 1445 if err != nil { 1446 panic(err) 1447 } 1448 return id 1449 } 1450 1451 // ItemCreateBulk is the builder for creating many Item entities in bulk. 1452 type ItemCreateBulk struct { 1453 config 1454 err error 1455 builders []*ItemCreate 1456 conflict []sql.ConflictOption 1457 } 1458 1459 // Save creates the Item entities in the database. 1460 func (icb *ItemCreateBulk) Save(ctx context.Context) ([]*Item, error) { 1461 if icb.err != nil { 1462 return nil, icb.err 1463 } 1464 specs := make([]*sqlgraph.CreateSpec, len(icb.builders)) 1465 nodes := make([]*Item, len(icb.builders)) 1466 mutators := make([]Mutator, len(icb.builders)) 1467 for i := range icb.builders { 1468 func(i int, root context.Context) { 1469 builder := icb.builders[i] 1470 builder.defaults() 1471 var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { 1472 mutation, ok := m.(*ItemMutation) 1473 if !ok { 1474 return nil, fmt.Errorf("unexpected mutation type %T", m) 1475 } 1476 if err := builder.check(); err != nil { 1477 return nil, err 1478 } 1479 builder.mutation = mutation 1480 var err error 1481 nodes[i], specs[i] = builder.createSpec() 1482 if i < len(mutators)-1 { 1483 _, err = mutators[i+1].Mutate(root, icb.builders[i+1].mutation) 1484 } else { 1485 spec := &sqlgraph.BatchCreateSpec{Nodes: specs} 1486 spec.OnConflict = icb.conflict 1487 // Invoke the actual operation on the latest mutation in the chain. 1488 if err = sqlgraph.BatchCreate(ctx, icb.driver, spec); err != nil { 1489 if sqlgraph.IsConstraintError(err) { 1490 err = &ConstraintError{msg: err.Error(), wrap: err} 1491 } 1492 } 1493 } 1494 if err != nil { 1495 return nil, err 1496 } 1497 mutation.id = &nodes[i].ID 1498 mutation.done = true 1499 return nodes[i], nil 1500 }) 1501 for i := len(builder.hooks) - 1; i >= 0; i-- { 1502 mut = builder.hooks[i](mut) 1503 } 1504 mutators[i] = mut 1505 }(i, ctx) 1506 } 1507 if len(mutators) > 0 { 1508 if _, err := mutators[0].Mutate(ctx, icb.builders[0].mutation); err != nil { 1509 return nil, err 1510 } 1511 } 1512 return nodes, nil 1513 } 1514 1515 // SaveX is like Save, but panics if an error occurs. 1516 func (icb *ItemCreateBulk) SaveX(ctx context.Context) []*Item { 1517 v, err := icb.Save(ctx) 1518 if err != nil { 1519 panic(err) 1520 } 1521 return v 1522 } 1523 1524 // Exec executes the query. 1525 func (icb *ItemCreateBulk) Exec(ctx context.Context) error { 1526 _, err := icb.Save(ctx) 1527 return err 1528 } 1529 1530 // ExecX is like Exec, but panics if an error occurs. 1531 func (icb *ItemCreateBulk) ExecX(ctx context.Context) { 1532 if err := icb.Exec(ctx); err != nil { 1533 panic(err) 1534 } 1535 } 1536 1537 // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause 1538 // of the `INSERT` statement. For example: 1539 // 1540 // client.Item.CreateBulk(builders...). 1541 // OnConflict( 1542 // // Update the row with the new values 1543 // // the was proposed for insertion. 1544 // sql.ResolveWithNewValues(), 1545 // ). 1546 // // Override some of the fields with custom 1547 // // update values. 1548 // Update(func(u *ent.ItemUpsert) { 1549 // SetItemGUID(v+v). 1550 // }). 1551 // Exec(ctx) 1552 func (icb *ItemCreateBulk) OnConflict(opts ...sql.ConflictOption) *ItemUpsertBulk { 1553 icb.conflict = opts 1554 return &ItemUpsertBulk{ 1555 create: icb, 1556 } 1557 } 1558 1559 // OnConflictColumns calls `OnConflict` and configures the columns 1560 // as conflict target. Using this option is equivalent to using: 1561 // 1562 // client.Item.Create(). 1563 // OnConflict(sql.ConflictColumns(columns...)). 1564 // Exec(ctx) 1565 func (icb *ItemCreateBulk) OnConflictColumns(columns ...string) *ItemUpsertBulk { 1566 icb.conflict = append(icb.conflict, sql.ConflictColumns(columns...)) 1567 return &ItemUpsertBulk{ 1568 create: icb, 1569 } 1570 } 1571 1572 // ItemUpsertBulk is the builder for "upsert"-ing 1573 // a bulk of Item nodes. 1574 type ItemUpsertBulk struct { 1575 create *ItemCreateBulk 1576 } 1577 1578 // UpdateNewValues updates the mutable fields using the new values that 1579 // were set on create. Using this option is equivalent to using: 1580 // 1581 // client.Item.Create(). 1582 // OnConflict( 1583 // sql.ResolveWithNewValues(), 1584 // sql.ResolveWith(func(u *sql.UpdateSet) { 1585 // u.SetIgnore(item.FieldID) 1586 // }), 1587 // ). 1588 // Exec(ctx) 1589 func (u *ItemUpsertBulk) UpdateNewValues() *ItemUpsertBulk { 1590 u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) 1591 u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { 1592 for _, b := range u.create.builders { 1593 if _, exists := b.mutation.ID(); exists { 1594 s.SetIgnore(item.FieldID) 1595 } 1596 } 1597 })) 1598 return u 1599 } 1600 1601 // Ignore sets each column to itself in case of conflict. 1602 // Using this option is equivalent to using: 1603 // 1604 // client.Item.Create(). 1605 // OnConflict(sql.ResolveWithIgnore()). 1606 // Exec(ctx) 1607 func (u *ItemUpsertBulk) Ignore() *ItemUpsertBulk { 1608 u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) 1609 return u 1610 } 1611 1612 // DoNothing configures the conflict_action to `DO NOTHING`. 1613 // Supported only by SQLite and PostgreSQL. 1614 func (u *ItemUpsertBulk) DoNothing() *ItemUpsertBulk { 1615 u.create.conflict = append(u.create.conflict, sql.DoNothing()) 1616 return u 1617 } 1618 1619 // Update allows overriding fields `UPDATE` values. See the ItemCreateBulk.OnConflict 1620 // documentation for more info. 1621 func (u *ItemUpsertBulk) Update(set func(*ItemUpsert)) *ItemUpsertBulk { 1622 u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { 1623 set(&ItemUpsert{UpdateSet: update}) 1624 })) 1625 return u 1626 } 1627 1628 // SetItemGUID sets the "item_guid" field. 1629 func (u *ItemUpsertBulk) SetItemGUID(v string) *ItemUpsertBulk { 1630 return u.Update(func(s *ItemUpsert) { 1631 s.SetItemGUID(v) 1632 }) 1633 } 1634 1635 // UpdateItemGUID sets the "item_guid" field to the value that was provided on create. 1636 func (u *ItemUpsertBulk) UpdateItemGUID() *ItemUpsertBulk { 1637 return u.Update(func(s *ItemUpsert) { 1638 s.UpdateItemGUID() 1639 }) 1640 } 1641 1642 // SetItemTitle sets the "item_title" field. 1643 func (u *ItemUpsertBulk) SetItemTitle(v string) *ItemUpsertBulk { 1644 return u.Update(func(s *ItemUpsert) { 1645 s.SetItemTitle(v) 1646 }) 1647 } 1648 1649 // UpdateItemTitle sets the "item_title" field to the value that was provided on create. 1650 func (u *ItemUpsertBulk) UpdateItemTitle() *ItemUpsertBulk { 1651 return u.Update(func(s *ItemUpsert) { 1652 s.UpdateItemTitle() 1653 }) 1654 } 1655 1656 // SetItemDescription sets the "item_description" field. 1657 func (u *ItemUpsertBulk) SetItemDescription(v string) *ItemUpsertBulk { 1658 return u.Update(func(s *ItemUpsert) { 1659 s.SetItemDescription(v) 1660 }) 1661 } 1662 1663 // UpdateItemDescription sets the "item_description" field to the value that was provided on create. 1664 func (u *ItemUpsertBulk) UpdateItemDescription() *ItemUpsertBulk { 1665 return u.Update(func(s *ItemUpsert) { 1666 s.UpdateItemDescription() 1667 }) 1668 } 1669 1670 // SetItemContent sets the "item_content" field. 1671 func (u *ItemUpsertBulk) SetItemContent(v string) *ItemUpsertBulk { 1672 return u.Update(func(s *ItemUpsert) { 1673 s.SetItemContent(v) 1674 }) 1675 } 1676 1677 // UpdateItemContent sets the "item_content" field to the value that was provided on create. 1678 func (u *ItemUpsertBulk) UpdateItemContent() *ItemUpsertBulk { 1679 return u.Update(func(s *ItemUpsert) { 1680 s.UpdateItemContent() 1681 }) 1682 } 1683 1684 // SetItemLink sets the "item_link" field. 1685 func (u *ItemUpsertBulk) SetItemLink(v string) *ItemUpsertBulk { 1686 return u.Update(func(s *ItemUpsert) { 1687 s.SetItemLink(v) 1688 }) 1689 } 1690 1691 // UpdateItemLink sets the "item_link" field to the value that was provided on create. 1692 func (u *ItemUpsertBulk) UpdateItemLink() *ItemUpsertBulk { 1693 return u.Update(func(s *ItemUpsert) { 1694 s.UpdateItemLink() 1695 }) 1696 } 1697 1698 // SetItemUpdated sets the "item_updated" field. 1699 func (u *ItemUpsertBulk) SetItemUpdated(v time.Time) *ItemUpsertBulk { 1700 return u.Update(func(s *ItemUpsert) { 1701 s.SetItemUpdated(v) 1702 }) 1703 } 1704 1705 // UpdateItemUpdated sets the "item_updated" field to the value that was provided on create. 1706 func (u *ItemUpsertBulk) UpdateItemUpdated() *ItemUpsertBulk { 1707 return u.Update(func(s *ItemUpsert) { 1708 s.UpdateItemUpdated() 1709 }) 1710 } 1711 1712 // SetItemPublished sets the "item_published" field. 1713 func (u *ItemUpsertBulk) SetItemPublished(v time.Time) *ItemUpsertBulk { 1714 return u.Update(func(s *ItemUpsert) { 1715 s.SetItemPublished(v) 1716 }) 1717 } 1718 1719 // UpdateItemPublished sets the "item_published" field to the value that was provided on create. 1720 func (u *ItemUpsertBulk) UpdateItemPublished() *ItemUpsertBulk { 1721 return u.Update(func(s *ItemUpsert) { 1722 s.UpdateItemPublished() 1723 }) 1724 } 1725 1726 // SetItemAuthorName sets the "item_author_name" field. 1727 func (u *ItemUpsertBulk) SetItemAuthorName(v string) *ItemUpsertBulk { 1728 return u.Update(func(s *ItemUpsert) { 1729 s.SetItemAuthorName(v) 1730 }) 1731 } 1732 1733 // UpdateItemAuthorName sets the "item_author_name" field to the value that was provided on create. 1734 func (u *ItemUpsertBulk) UpdateItemAuthorName() *ItemUpsertBulk { 1735 return u.Update(func(s *ItemUpsert) { 1736 s.UpdateItemAuthorName() 1737 }) 1738 } 1739 1740 // ClearItemAuthorName clears the value of the "item_author_name" field. 1741 func (u *ItemUpsertBulk) ClearItemAuthorName() *ItemUpsertBulk { 1742 return u.Update(func(s *ItemUpsert) { 1743 s.ClearItemAuthorName() 1744 }) 1745 } 1746 1747 // SetItemAuthorEmail sets the "item_author_email" field. 1748 func (u *ItemUpsertBulk) SetItemAuthorEmail(v string) *ItemUpsertBulk { 1749 return u.Update(func(s *ItemUpsert) { 1750 s.SetItemAuthorEmail(v) 1751 }) 1752 } 1753 1754 // UpdateItemAuthorEmail sets the "item_author_email" field to the value that was provided on create. 1755 func (u *ItemUpsertBulk) UpdateItemAuthorEmail() *ItemUpsertBulk { 1756 return u.Update(func(s *ItemUpsert) { 1757 s.UpdateItemAuthorEmail() 1758 }) 1759 } 1760 1761 // ClearItemAuthorEmail clears the value of the "item_author_email" field. 1762 func (u *ItemUpsertBulk) ClearItemAuthorEmail() *ItemUpsertBulk { 1763 return u.Update(func(s *ItemUpsert) { 1764 s.ClearItemAuthorEmail() 1765 }) 1766 } 1767 1768 // SetItemImageTitle sets the "item_image_title" field. 1769 func (u *ItemUpsertBulk) SetItemImageTitle(v string) *ItemUpsertBulk { 1770 return u.Update(func(s *ItemUpsert) { 1771 s.SetItemImageTitle(v) 1772 }) 1773 } 1774 1775 // UpdateItemImageTitle sets the "item_image_title" field to the value that was provided on create. 1776 func (u *ItemUpsertBulk) UpdateItemImageTitle() *ItemUpsertBulk { 1777 return u.Update(func(s *ItemUpsert) { 1778 s.UpdateItemImageTitle() 1779 }) 1780 } 1781 1782 // ClearItemImageTitle clears the value of the "item_image_title" field. 1783 func (u *ItemUpsertBulk) ClearItemImageTitle() *ItemUpsertBulk { 1784 return u.Update(func(s *ItemUpsert) { 1785 s.ClearItemImageTitle() 1786 }) 1787 } 1788 1789 // SetItemImageURL sets the "item_image_url" field. 1790 func (u *ItemUpsertBulk) SetItemImageURL(v string) *ItemUpsertBulk { 1791 return u.Update(func(s *ItemUpsert) { 1792 s.SetItemImageURL(v) 1793 }) 1794 } 1795 1796 // UpdateItemImageURL sets the "item_image_url" field to the value that was provided on create. 1797 func (u *ItemUpsertBulk) UpdateItemImageURL() *ItemUpsertBulk { 1798 return u.Update(func(s *ItemUpsert) { 1799 s.UpdateItemImageURL() 1800 }) 1801 } 1802 1803 // ClearItemImageURL clears the value of the "item_image_url" field. 1804 func (u *ItemUpsertBulk) ClearItemImageURL() *ItemUpsertBulk { 1805 return u.Update(func(s *ItemUpsert) { 1806 s.ClearItemImageURL() 1807 }) 1808 } 1809 1810 // SetItemCategories sets the "item_categories" field. 1811 func (u *ItemUpsertBulk) SetItemCategories(v string) *ItemUpsertBulk { 1812 return u.Update(func(s *ItemUpsert) { 1813 s.SetItemCategories(v) 1814 }) 1815 } 1816 1817 // UpdateItemCategories sets the "item_categories" field to the value that was provided on create. 1818 func (u *ItemUpsertBulk) UpdateItemCategories() *ItemUpsertBulk { 1819 return u.Update(func(s *ItemUpsert) { 1820 s.UpdateItemCategories() 1821 }) 1822 } 1823 1824 // SetItemEnclosures sets the "item_enclosures" field. 1825 func (u *ItemUpsertBulk) SetItemEnclosures(v string) *ItemUpsertBulk { 1826 return u.Update(func(s *ItemUpsert) { 1827 s.SetItemEnclosures(v) 1828 }) 1829 } 1830 1831 // UpdateItemEnclosures sets the "item_enclosures" field to the value that was provided on create. 1832 func (u *ItemUpsertBulk) UpdateItemEnclosures() *ItemUpsertBulk { 1833 return u.Update(func(s *ItemUpsert) { 1834 s.UpdateItemEnclosures() 1835 }) 1836 } 1837 1838 // SetCrawlerTitle sets the "crawler_title" field. 1839 func (u *ItemUpsertBulk) SetCrawlerTitle(v string) *ItemUpsertBulk { 1840 return u.Update(func(s *ItemUpsert) { 1841 s.SetCrawlerTitle(v) 1842 }) 1843 } 1844 1845 // UpdateCrawlerTitle sets the "crawler_title" field to the value that was provided on create. 1846 func (u *ItemUpsertBulk) UpdateCrawlerTitle() *ItemUpsertBulk { 1847 return u.Update(func(s *ItemUpsert) { 1848 s.UpdateCrawlerTitle() 1849 }) 1850 } 1851 1852 // ClearCrawlerTitle clears the value of the "crawler_title" field. 1853 func (u *ItemUpsertBulk) ClearCrawlerTitle() *ItemUpsertBulk { 1854 return u.Update(func(s *ItemUpsert) { 1855 s.ClearCrawlerTitle() 1856 }) 1857 } 1858 1859 // SetCrawlerAuthor sets the "crawler_author" field. 1860 func (u *ItemUpsertBulk) SetCrawlerAuthor(v string) *ItemUpsertBulk { 1861 return u.Update(func(s *ItemUpsert) { 1862 s.SetCrawlerAuthor(v) 1863 }) 1864 } 1865 1866 // UpdateCrawlerAuthor sets the "crawler_author" field to the value that was provided on create. 1867 func (u *ItemUpsertBulk) UpdateCrawlerAuthor() *ItemUpsertBulk { 1868 return u.Update(func(s *ItemUpsert) { 1869 s.UpdateCrawlerAuthor() 1870 }) 1871 } 1872 1873 // ClearCrawlerAuthor clears the value of the "crawler_author" field. 1874 func (u *ItemUpsertBulk) ClearCrawlerAuthor() *ItemUpsertBulk { 1875 return u.Update(func(s *ItemUpsert) { 1876 s.ClearCrawlerAuthor() 1877 }) 1878 } 1879 1880 // SetCrawlerExcerpt sets the "crawler_excerpt" field. 1881 func (u *ItemUpsertBulk) SetCrawlerExcerpt(v string) *ItemUpsertBulk { 1882 return u.Update(func(s *ItemUpsert) { 1883 s.SetCrawlerExcerpt(v) 1884 }) 1885 } 1886 1887 // UpdateCrawlerExcerpt sets the "crawler_excerpt" field to the value that was provided on create. 1888 func (u *ItemUpsertBulk) UpdateCrawlerExcerpt() *ItemUpsertBulk { 1889 return u.Update(func(s *ItemUpsert) { 1890 s.UpdateCrawlerExcerpt() 1891 }) 1892 } 1893 1894 // ClearCrawlerExcerpt clears the value of the "crawler_excerpt" field. 1895 func (u *ItemUpsertBulk) ClearCrawlerExcerpt() *ItemUpsertBulk { 1896 return u.Update(func(s *ItemUpsert) { 1897 s.ClearCrawlerExcerpt() 1898 }) 1899 } 1900 1901 // SetCrawlerSiteName sets the "crawler_site_name" field. 1902 func (u *ItemUpsertBulk) SetCrawlerSiteName(v string) *ItemUpsertBulk { 1903 return u.Update(func(s *ItemUpsert) { 1904 s.SetCrawlerSiteName(v) 1905 }) 1906 } 1907 1908 // UpdateCrawlerSiteName sets the "crawler_site_name" field to the value that was provided on create. 1909 func (u *ItemUpsertBulk) UpdateCrawlerSiteName() *ItemUpsertBulk { 1910 return u.Update(func(s *ItemUpsert) { 1911 s.UpdateCrawlerSiteName() 1912 }) 1913 } 1914 1915 // ClearCrawlerSiteName clears the value of the "crawler_site_name" field. 1916 func (u *ItemUpsertBulk) ClearCrawlerSiteName() *ItemUpsertBulk { 1917 return u.Update(func(s *ItemUpsert) { 1918 s.ClearCrawlerSiteName() 1919 }) 1920 } 1921 1922 // SetCrawlerImage sets the "crawler_image" field. 1923 func (u *ItemUpsertBulk) SetCrawlerImage(v string) *ItemUpsertBulk { 1924 return u.Update(func(s *ItemUpsert) { 1925 s.SetCrawlerImage(v) 1926 }) 1927 } 1928 1929 // UpdateCrawlerImage sets the "crawler_image" field to the value that was provided on create. 1930 func (u *ItemUpsertBulk) UpdateCrawlerImage() *ItemUpsertBulk { 1931 return u.Update(func(s *ItemUpsert) { 1932 s.UpdateCrawlerImage() 1933 }) 1934 } 1935 1936 // ClearCrawlerImage clears the value of the "crawler_image" field. 1937 func (u *ItemUpsertBulk) ClearCrawlerImage() *ItemUpsertBulk { 1938 return u.Update(func(s *ItemUpsert) { 1939 s.ClearCrawlerImage() 1940 }) 1941 } 1942 1943 // SetCrawlerContentHTML sets the "crawler_content_html" field. 1944 func (u *ItemUpsertBulk) SetCrawlerContentHTML(v string) *ItemUpsertBulk { 1945 return u.Update(func(s *ItemUpsert) { 1946 s.SetCrawlerContentHTML(v) 1947 }) 1948 } 1949 1950 // UpdateCrawlerContentHTML sets the "crawler_content_html" field to the value that was provided on create. 1951 func (u *ItemUpsertBulk) UpdateCrawlerContentHTML() *ItemUpsertBulk { 1952 return u.Update(func(s *ItemUpsert) { 1953 s.UpdateCrawlerContentHTML() 1954 }) 1955 } 1956 1957 // ClearCrawlerContentHTML clears the value of the "crawler_content_html" field. 1958 func (u *ItemUpsertBulk) ClearCrawlerContentHTML() *ItemUpsertBulk { 1959 return u.Update(func(s *ItemUpsert) { 1960 s.ClearCrawlerContentHTML() 1961 }) 1962 } 1963 1964 // SetCrawlerContentText sets the "crawler_content_text" field. 1965 func (u *ItemUpsertBulk) SetCrawlerContentText(v string) *ItemUpsertBulk { 1966 return u.Update(func(s *ItemUpsert) { 1967 s.SetCrawlerContentText(v) 1968 }) 1969 } 1970 1971 // UpdateCrawlerContentText sets the "crawler_content_text" field to the value that was provided on create. 1972 func (u *ItemUpsertBulk) UpdateCrawlerContentText() *ItemUpsertBulk { 1973 return u.Update(func(s *ItemUpsert) { 1974 s.UpdateCrawlerContentText() 1975 }) 1976 } 1977 1978 // ClearCrawlerContentText clears the value of the "crawler_content_text" field. 1979 func (u *ItemUpsertBulk) ClearCrawlerContentText() *ItemUpsertBulk { 1980 return u.Update(func(s *ItemUpsert) { 1981 s.ClearCrawlerContentText() 1982 }) 1983 } 1984 1985 // SetCreatedAt sets the "created_at" field. 1986 func (u *ItemUpsertBulk) SetCreatedAt(v time.Time) *ItemUpsertBulk { 1987 return u.Update(func(s *ItemUpsert) { 1988 s.SetCreatedAt(v) 1989 }) 1990 } 1991 1992 // UpdateCreatedAt sets the "created_at" field to the value that was provided on create. 1993 func (u *ItemUpsertBulk) UpdateCreatedAt() *ItemUpsertBulk { 1994 return u.Update(func(s *ItemUpsert) { 1995 s.UpdateCreatedAt() 1996 }) 1997 } 1998 1999 // SetUpdatedAt sets the "updated_at" field. 2000 func (u *ItemUpsertBulk) SetUpdatedAt(v time.Time) *ItemUpsertBulk { 2001 return u.Update(func(s *ItemUpsert) { 2002 s.SetUpdatedAt(v) 2003 }) 2004 } 2005 2006 // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. 2007 func (u *ItemUpsertBulk) UpdateUpdatedAt() *ItemUpsertBulk { 2008 return u.Update(func(s *ItemUpsert) { 2009 s.UpdateUpdatedAt() 2010 }) 2011 } 2012 2013 // Exec executes the query. 2014 func (u *ItemUpsertBulk) Exec(ctx context.Context) error { 2015 if u.create.err != nil { 2016 return u.create.err 2017 } 2018 for i, b := range u.create.builders { 2019 if len(b.conflict) != 0 { 2020 return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ItemCreateBulk instead", i) 2021 } 2022 } 2023 if len(u.create.conflict) == 0 { 2024 return errors.New("ent: missing options for ItemCreateBulk.OnConflict") 2025 } 2026 return u.create.Exec(ctx) 2027 } 2028 2029 // ExecX is like Exec, but panics if an error occurs. 2030 func (u *ItemUpsertBulk) ExecX(ctx context.Context) { 2031 if err := u.create.Exec(ctx); err != nil { 2032 panic(err) 2033 } 2034 }