github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/coindescription_create.go (about) 1 // Code generated by ent, DO NOT EDIT. 2 3 package ent 4 5 import ( 6 "context" 7 "errors" 8 "fmt" 9 10 "entgo.io/ent/dialect/sql" 11 "entgo.io/ent/dialect/sql/sqlgraph" 12 "entgo.io/ent/schema/field" 13 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/coindescription" 14 "github.com/google/uuid" 15 ) 16 17 // CoinDescriptionCreate is the builder for creating a CoinDescription entity. 18 type CoinDescriptionCreate struct { 19 config 20 mutation *CoinDescriptionMutation 21 hooks []Hook 22 conflict []sql.ConflictOption 23 } 24 25 // SetCreatedAt sets the "created_at" field. 26 func (cdc *CoinDescriptionCreate) SetCreatedAt(u uint32) *CoinDescriptionCreate { 27 cdc.mutation.SetCreatedAt(u) 28 return cdc 29 } 30 31 // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. 32 func (cdc *CoinDescriptionCreate) SetNillableCreatedAt(u *uint32) *CoinDescriptionCreate { 33 if u != nil { 34 cdc.SetCreatedAt(*u) 35 } 36 return cdc 37 } 38 39 // SetUpdatedAt sets the "updated_at" field. 40 func (cdc *CoinDescriptionCreate) SetUpdatedAt(u uint32) *CoinDescriptionCreate { 41 cdc.mutation.SetUpdatedAt(u) 42 return cdc 43 } 44 45 // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. 46 func (cdc *CoinDescriptionCreate) SetNillableUpdatedAt(u *uint32) *CoinDescriptionCreate { 47 if u != nil { 48 cdc.SetUpdatedAt(*u) 49 } 50 return cdc 51 } 52 53 // SetDeletedAt sets the "deleted_at" field. 54 func (cdc *CoinDescriptionCreate) SetDeletedAt(u uint32) *CoinDescriptionCreate { 55 cdc.mutation.SetDeletedAt(u) 56 return cdc 57 } 58 59 // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. 60 func (cdc *CoinDescriptionCreate) SetNillableDeletedAt(u *uint32) *CoinDescriptionCreate { 61 if u != nil { 62 cdc.SetDeletedAt(*u) 63 } 64 return cdc 65 } 66 67 // SetEntID sets the "ent_id" field. 68 func (cdc *CoinDescriptionCreate) SetEntID(u uuid.UUID) *CoinDescriptionCreate { 69 cdc.mutation.SetEntID(u) 70 return cdc 71 } 72 73 // SetNillableEntID sets the "ent_id" field if the given value is not nil. 74 func (cdc *CoinDescriptionCreate) SetNillableEntID(u *uuid.UUID) *CoinDescriptionCreate { 75 if u != nil { 76 cdc.SetEntID(*u) 77 } 78 return cdc 79 } 80 81 // SetAppID sets the "app_id" field. 82 func (cdc *CoinDescriptionCreate) SetAppID(u uuid.UUID) *CoinDescriptionCreate { 83 cdc.mutation.SetAppID(u) 84 return cdc 85 } 86 87 // SetNillableAppID sets the "app_id" field if the given value is not nil. 88 func (cdc *CoinDescriptionCreate) SetNillableAppID(u *uuid.UUID) *CoinDescriptionCreate { 89 if u != nil { 90 cdc.SetAppID(*u) 91 } 92 return cdc 93 } 94 95 // SetCoinTypeID sets the "coin_type_id" field. 96 func (cdc *CoinDescriptionCreate) SetCoinTypeID(u uuid.UUID) *CoinDescriptionCreate { 97 cdc.mutation.SetCoinTypeID(u) 98 return cdc 99 } 100 101 // SetNillableCoinTypeID sets the "coin_type_id" field if the given value is not nil. 102 func (cdc *CoinDescriptionCreate) SetNillableCoinTypeID(u *uuid.UUID) *CoinDescriptionCreate { 103 if u != nil { 104 cdc.SetCoinTypeID(*u) 105 } 106 return cdc 107 } 108 109 // SetUsedFor sets the "used_for" field. 110 func (cdc *CoinDescriptionCreate) SetUsedFor(s string) *CoinDescriptionCreate { 111 cdc.mutation.SetUsedFor(s) 112 return cdc 113 } 114 115 // SetNillableUsedFor sets the "used_for" field if the given value is not nil. 116 func (cdc *CoinDescriptionCreate) SetNillableUsedFor(s *string) *CoinDescriptionCreate { 117 if s != nil { 118 cdc.SetUsedFor(*s) 119 } 120 return cdc 121 } 122 123 // SetTitle sets the "title" field. 124 func (cdc *CoinDescriptionCreate) SetTitle(s string) *CoinDescriptionCreate { 125 cdc.mutation.SetTitle(s) 126 return cdc 127 } 128 129 // SetNillableTitle sets the "title" field if the given value is not nil. 130 func (cdc *CoinDescriptionCreate) SetNillableTitle(s *string) *CoinDescriptionCreate { 131 if s != nil { 132 cdc.SetTitle(*s) 133 } 134 return cdc 135 } 136 137 // SetMessage sets the "message" field. 138 func (cdc *CoinDescriptionCreate) SetMessage(s string) *CoinDescriptionCreate { 139 cdc.mutation.SetMessage(s) 140 return cdc 141 } 142 143 // SetNillableMessage sets the "message" field if the given value is not nil. 144 func (cdc *CoinDescriptionCreate) SetNillableMessage(s *string) *CoinDescriptionCreate { 145 if s != nil { 146 cdc.SetMessage(*s) 147 } 148 return cdc 149 } 150 151 // SetID sets the "id" field. 152 func (cdc *CoinDescriptionCreate) SetID(u uint32) *CoinDescriptionCreate { 153 cdc.mutation.SetID(u) 154 return cdc 155 } 156 157 // Mutation returns the CoinDescriptionMutation object of the builder. 158 func (cdc *CoinDescriptionCreate) Mutation() *CoinDescriptionMutation { 159 return cdc.mutation 160 } 161 162 // Save creates the CoinDescription in the database. 163 func (cdc *CoinDescriptionCreate) Save(ctx context.Context) (*CoinDescription, error) { 164 var ( 165 err error 166 node *CoinDescription 167 ) 168 if err := cdc.defaults(); err != nil { 169 return nil, err 170 } 171 if len(cdc.hooks) == 0 { 172 if err = cdc.check(); err != nil { 173 return nil, err 174 } 175 node, err = cdc.sqlSave(ctx) 176 } else { 177 var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { 178 mutation, ok := m.(*CoinDescriptionMutation) 179 if !ok { 180 return nil, fmt.Errorf("unexpected mutation type %T", m) 181 } 182 if err = cdc.check(); err != nil { 183 return nil, err 184 } 185 cdc.mutation = mutation 186 if node, err = cdc.sqlSave(ctx); err != nil { 187 return nil, err 188 } 189 mutation.id = &node.ID 190 mutation.done = true 191 return node, err 192 }) 193 for i := len(cdc.hooks) - 1; i >= 0; i-- { 194 if cdc.hooks[i] == nil { 195 return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") 196 } 197 mut = cdc.hooks[i](mut) 198 } 199 v, err := mut.Mutate(ctx, cdc.mutation) 200 if err != nil { 201 return nil, err 202 } 203 nv, ok := v.(*CoinDescription) 204 if !ok { 205 return nil, fmt.Errorf("unexpected node type %T returned from CoinDescriptionMutation", v) 206 } 207 node = nv 208 } 209 return node, err 210 } 211 212 // SaveX calls Save and panics if Save returns an error. 213 func (cdc *CoinDescriptionCreate) SaveX(ctx context.Context) *CoinDescription { 214 v, err := cdc.Save(ctx) 215 if err != nil { 216 panic(err) 217 } 218 return v 219 } 220 221 // Exec executes the query. 222 func (cdc *CoinDescriptionCreate) Exec(ctx context.Context) error { 223 _, err := cdc.Save(ctx) 224 return err 225 } 226 227 // ExecX is like Exec, but panics if an error occurs. 228 func (cdc *CoinDescriptionCreate) ExecX(ctx context.Context) { 229 if err := cdc.Exec(ctx); err != nil { 230 panic(err) 231 } 232 } 233 234 // defaults sets the default values of the builder before save. 235 func (cdc *CoinDescriptionCreate) defaults() error { 236 if _, ok := cdc.mutation.CreatedAt(); !ok { 237 if coindescription.DefaultCreatedAt == nil { 238 return fmt.Errorf("ent: uninitialized coindescription.DefaultCreatedAt (forgotten import ent/runtime?)") 239 } 240 v := coindescription.DefaultCreatedAt() 241 cdc.mutation.SetCreatedAt(v) 242 } 243 if _, ok := cdc.mutation.UpdatedAt(); !ok { 244 if coindescription.DefaultUpdatedAt == nil { 245 return fmt.Errorf("ent: uninitialized coindescription.DefaultUpdatedAt (forgotten import ent/runtime?)") 246 } 247 v := coindescription.DefaultUpdatedAt() 248 cdc.mutation.SetUpdatedAt(v) 249 } 250 if _, ok := cdc.mutation.DeletedAt(); !ok { 251 if coindescription.DefaultDeletedAt == nil { 252 return fmt.Errorf("ent: uninitialized coindescription.DefaultDeletedAt (forgotten import ent/runtime?)") 253 } 254 v := coindescription.DefaultDeletedAt() 255 cdc.mutation.SetDeletedAt(v) 256 } 257 if _, ok := cdc.mutation.EntID(); !ok { 258 if coindescription.DefaultEntID == nil { 259 return fmt.Errorf("ent: uninitialized coindescription.DefaultEntID (forgotten import ent/runtime?)") 260 } 261 v := coindescription.DefaultEntID() 262 cdc.mutation.SetEntID(v) 263 } 264 if _, ok := cdc.mutation.AppID(); !ok { 265 if coindescription.DefaultAppID == nil { 266 return fmt.Errorf("ent: uninitialized coindescription.DefaultAppID (forgotten import ent/runtime?)") 267 } 268 v := coindescription.DefaultAppID() 269 cdc.mutation.SetAppID(v) 270 } 271 if _, ok := cdc.mutation.CoinTypeID(); !ok { 272 if coindescription.DefaultCoinTypeID == nil { 273 return fmt.Errorf("ent: uninitialized coindescription.DefaultCoinTypeID (forgotten import ent/runtime?)") 274 } 275 v := coindescription.DefaultCoinTypeID() 276 cdc.mutation.SetCoinTypeID(v) 277 } 278 if _, ok := cdc.mutation.UsedFor(); !ok { 279 v := coindescription.DefaultUsedFor 280 cdc.mutation.SetUsedFor(v) 281 } 282 if _, ok := cdc.mutation.Title(); !ok { 283 v := coindescription.DefaultTitle 284 cdc.mutation.SetTitle(v) 285 } 286 if _, ok := cdc.mutation.Message(); !ok { 287 v := coindescription.DefaultMessage 288 cdc.mutation.SetMessage(v) 289 } 290 return nil 291 } 292 293 // check runs all checks and user-defined validators on the builder. 294 func (cdc *CoinDescriptionCreate) check() error { 295 if _, ok := cdc.mutation.CreatedAt(); !ok { 296 return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "CoinDescription.created_at"`)} 297 } 298 if _, ok := cdc.mutation.UpdatedAt(); !ok { 299 return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "CoinDescription.updated_at"`)} 300 } 301 if _, ok := cdc.mutation.DeletedAt(); !ok { 302 return &ValidationError{Name: "deleted_at", err: errors.New(`ent: missing required field "CoinDescription.deleted_at"`)} 303 } 304 if _, ok := cdc.mutation.EntID(); !ok { 305 return &ValidationError{Name: "ent_id", err: errors.New(`ent: missing required field "CoinDescription.ent_id"`)} 306 } 307 return nil 308 } 309 310 func (cdc *CoinDescriptionCreate) sqlSave(ctx context.Context) (*CoinDescription, error) { 311 _node, _spec := cdc.createSpec() 312 if err := sqlgraph.CreateNode(ctx, cdc.driver, _spec); err != nil { 313 if sqlgraph.IsConstraintError(err) { 314 err = &ConstraintError{msg: err.Error(), wrap: err} 315 } 316 return nil, err 317 } 318 if _spec.ID.Value != _node.ID { 319 id := _spec.ID.Value.(int64) 320 _node.ID = uint32(id) 321 } 322 return _node, nil 323 } 324 325 func (cdc *CoinDescriptionCreate) createSpec() (*CoinDescription, *sqlgraph.CreateSpec) { 326 var ( 327 _node = &CoinDescription{config: cdc.config} 328 _spec = &sqlgraph.CreateSpec{ 329 Table: coindescription.Table, 330 ID: &sqlgraph.FieldSpec{ 331 Type: field.TypeUint32, 332 Column: coindescription.FieldID, 333 }, 334 } 335 ) 336 _spec.OnConflict = cdc.conflict 337 if id, ok := cdc.mutation.ID(); ok { 338 _node.ID = id 339 _spec.ID.Value = id 340 } 341 if value, ok := cdc.mutation.CreatedAt(); ok { 342 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 343 Type: field.TypeUint32, 344 Value: value, 345 Column: coindescription.FieldCreatedAt, 346 }) 347 _node.CreatedAt = value 348 } 349 if value, ok := cdc.mutation.UpdatedAt(); ok { 350 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 351 Type: field.TypeUint32, 352 Value: value, 353 Column: coindescription.FieldUpdatedAt, 354 }) 355 _node.UpdatedAt = value 356 } 357 if value, ok := cdc.mutation.DeletedAt(); ok { 358 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 359 Type: field.TypeUint32, 360 Value: value, 361 Column: coindescription.FieldDeletedAt, 362 }) 363 _node.DeletedAt = value 364 } 365 if value, ok := cdc.mutation.EntID(); ok { 366 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 367 Type: field.TypeUUID, 368 Value: value, 369 Column: coindescription.FieldEntID, 370 }) 371 _node.EntID = value 372 } 373 if value, ok := cdc.mutation.AppID(); ok { 374 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 375 Type: field.TypeUUID, 376 Value: value, 377 Column: coindescription.FieldAppID, 378 }) 379 _node.AppID = value 380 } 381 if value, ok := cdc.mutation.CoinTypeID(); ok { 382 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 383 Type: field.TypeUUID, 384 Value: value, 385 Column: coindescription.FieldCoinTypeID, 386 }) 387 _node.CoinTypeID = value 388 } 389 if value, ok := cdc.mutation.UsedFor(); ok { 390 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 391 Type: field.TypeString, 392 Value: value, 393 Column: coindescription.FieldUsedFor, 394 }) 395 _node.UsedFor = value 396 } 397 if value, ok := cdc.mutation.Title(); ok { 398 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 399 Type: field.TypeString, 400 Value: value, 401 Column: coindescription.FieldTitle, 402 }) 403 _node.Title = value 404 } 405 if value, ok := cdc.mutation.Message(); ok { 406 _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ 407 Type: field.TypeString, 408 Value: value, 409 Column: coindescription.FieldMessage, 410 }) 411 _node.Message = value 412 } 413 return _node, _spec 414 } 415 416 // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause 417 // of the `INSERT` statement. For example: 418 // 419 // client.CoinDescription.Create(). 420 // SetCreatedAt(v). 421 // OnConflict( 422 // // Update the row with the new values 423 // // the was proposed for insertion. 424 // sql.ResolveWithNewValues(), 425 // ). 426 // // Override some of the fields with custom 427 // // update values. 428 // Update(func(u *ent.CoinDescriptionUpsert) { 429 // SetCreatedAt(v+v). 430 // }). 431 // Exec(ctx) 432 // 433 func (cdc *CoinDescriptionCreate) OnConflict(opts ...sql.ConflictOption) *CoinDescriptionUpsertOne { 434 cdc.conflict = opts 435 return &CoinDescriptionUpsertOne{ 436 create: cdc, 437 } 438 } 439 440 // OnConflictColumns calls `OnConflict` and configures the columns 441 // as conflict target. Using this option is equivalent to using: 442 // 443 // client.CoinDescription.Create(). 444 // OnConflict(sql.ConflictColumns(columns...)). 445 // Exec(ctx) 446 // 447 func (cdc *CoinDescriptionCreate) OnConflictColumns(columns ...string) *CoinDescriptionUpsertOne { 448 cdc.conflict = append(cdc.conflict, sql.ConflictColumns(columns...)) 449 return &CoinDescriptionUpsertOne{ 450 create: cdc, 451 } 452 } 453 454 type ( 455 // CoinDescriptionUpsertOne is the builder for "upsert"-ing 456 // one CoinDescription node. 457 CoinDescriptionUpsertOne struct { 458 create *CoinDescriptionCreate 459 } 460 461 // CoinDescriptionUpsert is the "OnConflict" setter. 462 CoinDescriptionUpsert struct { 463 *sql.UpdateSet 464 } 465 ) 466 467 // SetCreatedAt sets the "created_at" field. 468 func (u *CoinDescriptionUpsert) SetCreatedAt(v uint32) *CoinDescriptionUpsert { 469 u.Set(coindescription.FieldCreatedAt, v) 470 return u 471 } 472 473 // UpdateCreatedAt sets the "created_at" field to the value that was provided on create. 474 func (u *CoinDescriptionUpsert) UpdateCreatedAt() *CoinDescriptionUpsert { 475 u.SetExcluded(coindescription.FieldCreatedAt) 476 return u 477 } 478 479 // AddCreatedAt adds v to the "created_at" field. 480 func (u *CoinDescriptionUpsert) AddCreatedAt(v uint32) *CoinDescriptionUpsert { 481 u.Add(coindescription.FieldCreatedAt, v) 482 return u 483 } 484 485 // SetUpdatedAt sets the "updated_at" field. 486 func (u *CoinDescriptionUpsert) SetUpdatedAt(v uint32) *CoinDescriptionUpsert { 487 u.Set(coindescription.FieldUpdatedAt, v) 488 return u 489 } 490 491 // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. 492 func (u *CoinDescriptionUpsert) UpdateUpdatedAt() *CoinDescriptionUpsert { 493 u.SetExcluded(coindescription.FieldUpdatedAt) 494 return u 495 } 496 497 // AddUpdatedAt adds v to the "updated_at" field. 498 func (u *CoinDescriptionUpsert) AddUpdatedAt(v uint32) *CoinDescriptionUpsert { 499 u.Add(coindescription.FieldUpdatedAt, v) 500 return u 501 } 502 503 // SetDeletedAt sets the "deleted_at" field. 504 func (u *CoinDescriptionUpsert) SetDeletedAt(v uint32) *CoinDescriptionUpsert { 505 u.Set(coindescription.FieldDeletedAt, v) 506 return u 507 } 508 509 // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. 510 func (u *CoinDescriptionUpsert) UpdateDeletedAt() *CoinDescriptionUpsert { 511 u.SetExcluded(coindescription.FieldDeletedAt) 512 return u 513 } 514 515 // AddDeletedAt adds v to the "deleted_at" field. 516 func (u *CoinDescriptionUpsert) AddDeletedAt(v uint32) *CoinDescriptionUpsert { 517 u.Add(coindescription.FieldDeletedAt, v) 518 return u 519 } 520 521 // SetEntID sets the "ent_id" field. 522 func (u *CoinDescriptionUpsert) SetEntID(v uuid.UUID) *CoinDescriptionUpsert { 523 u.Set(coindescription.FieldEntID, v) 524 return u 525 } 526 527 // UpdateEntID sets the "ent_id" field to the value that was provided on create. 528 func (u *CoinDescriptionUpsert) UpdateEntID() *CoinDescriptionUpsert { 529 u.SetExcluded(coindescription.FieldEntID) 530 return u 531 } 532 533 // SetAppID sets the "app_id" field. 534 func (u *CoinDescriptionUpsert) SetAppID(v uuid.UUID) *CoinDescriptionUpsert { 535 u.Set(coindescription.FieldAppID, v) 536 return u 537 } 538 539 // UpdateAppID sets the "app_id" field to the value that was provided on create. 540 func (u *CoinDescriptionUpsert) UpdateAppID() *CoinDescriptionUpsert { 541 u.SetExcluded(coindescription.FieldAppID) 542 return u 543 } 544 545 // ClearAppID clears the value of the "app_id" field. 546 func (u *CoinDescriptionUpsert) ClearAppID() *CoinDescriptionUpsert { 547 u.SetNull(coindescription.FieldAppID) 548 return u 549 } 550 551 // SetCoinTypeID sets the "coin_type_id" field. 552 func (u *CoinDescriptionUpsert) SetCoinTypeID(v uuid.UUID) *CoinDescriptionUpsert { 553 u.Set(coindescription.FieldCoinTypeID, v) 554 return u 555 } 556 557 // UpdateCoinTypeID sets the "coin_type_id" field to the value that was provided on create. 558 func (u *CoinDescriptionUpsert) UpdateCoinTypeID() *CoinDescriptionUpsert { 559 u.SetExcluded(coindescription.FieldCoinTypeID) 560 return u 561 } 562 563 // ClearCoinTypeID clears the value of the "coin_type_id" field. 564 func (u *CoinDescriptionUpsert) ClearCoinTypeID() *CoinDescriptionUpsert { 565 u.SetNull(coindescription.FieldCoinTypeID) 566 return u 567 } 568 569 // SetUsedFor sets the "used_for" field. 570 func (u *CoinDescriptionUpsert) SetUsedFor(v string) *CoinDescriptionUpsert { 571 u.Set(coindescription.FieldUsedFor, v) 572 return u 573 } 574 575 // UpdateUsedFor sets the "used_for" field to the value that was provided on create. 576 func (u *CoinDescriptionUpsert) UpdateUsedFor() *CoinDescriptionUpsert { 577 u.SetExcluded(coindescription.FieldUsedFor) 578 return u 579 } 580 581 // ClearUsedFor clears the value of the "used_for" field. 582 func (u *CoinDescriptionUpsert) ClearUsedFor() *CoinDescriptionUpsert { 583 u.SetNull(coindescription.FieldUsedFor) 584 return u 585 } 586 587 // SetTitle sets the "title" field. 588 func (u *CoinDescriptionUpsert) SetTitle(v string) *CoinDescriptionUpsert { 589 u.Set(coindescription.FieldTitle, v) 590 return u 591 } 592 593 // UpdateTitle sets the "title" field to the value that was provided on create. 594 func (u *CoinDescriptionUpsert) UpdateTitle() *CoinDescriptionUpsert { 595 u.SetExcluded(coindescription.FieldTitle) 596 return u 597 } 598 599 // ClearTitle clears the value of the "title" field. 600 func (u *CoinDescriptionUpsert) ClearTitle() *CoinDescriptionUpsert { 601 u.SetNull(coindescription.FieldTitle) 602 return u 603 } 604 605 // SetMessage sets the "message" field. 606 func (u *CoinDescriptionUpsert) SetMessage(v string) *CoinDescriptionUpsert { 607 u.Set(coindescription.FieldMessage, v) 608 return u 609 } 610 611 // UpdateMessage sets the "message" field to the value that was provided on create. 612 func (u *CoinDescriptionUpsert) UpdateMessage() *CoinDescriptionUpsert { 613 u.SetExcluded(coindescription.FieldMessage) 614 return u 615 } 616 617 // ClearMessage clears the value of the "message" field. 618 func (u *CoinDescriptionUpsert) ClearMessage() *CoinDescriptionUpsert { 619 u.SetNull(coindescription.FieldMessage) 620 return u 621 } 622 623 // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. 624 // Using this option is equivalent to using: 625 // 626 // client.CoinDescription.Create(). 627 // OnConflict( 628 // sql.ResolveWithNewValues(), 629 // sql.ResolveWith(func(u *sql.UpdateSet) { 630 // u.SetIgnore(coindescription.FieldID) 631 // }), 632 // ). 633 // Exec(ctx) 634 // 635 func (u *CoinDescriptionUpsertOne) UpdateNewValues() *CoinDescriptionUpsertOne { 636 u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) 637 u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { 638 if _, exists := u.create.mutation.ID(); exists { 639 s.SetIgnore(coindescription.FieldID) 640 } 641 })) 642 return u 643 } 644 645 // Ignore sets each column to itself in case of conflict. 646 // Using this option is equivalent to using: 647 // 648 // client.CoinDescription.Create(). 649 // OnConflict(sql.ResolveWithIgnore()). 650 // Exec(ctx) 651 // 652 func (u *CoinDescriptionUpsertOne) Ignore() *CoinDescriptionUpsertOne { 653 u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) 654 return u 655 } 656 657 // DoNothing configures the conflict_action to `DO NOTHING`. 658 // Supported only by SQLite and PostgreSQL. 659 func (u *CoinDescriptionUpsertOne) DoNothing() *CoinDescriptionUpsertOne { 660 u.create.conflict = append(u.create.conflict, sql.DoNothing()) 661 return u 662 } 663 664 // Update allows overriding fields `UPDATE` values. See the CoinDescriptionCreate.OnConflict 665 // documentation for more info. 666 func (u *CoinDescriptionUpsertOne) Update(set func(*CoinDescriptionUpsert)) *CoinDescriptionUpsertOne { 667 u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { 668 set(&CoinDescriptionUpsert{UpdateSet: update}) 669 })) 670 return u 671 } 672 673 // SetCreatedAt sets the "created_at" field. 674 func (u *CoinDescriptionUpsertOne) SetCreatedAt(v uint32) *CoinDescriptionUpsertOne { 675 return u.Update(func(s *CoinDescriptionUpsert) { 676 s.SetCreatedAt(v) 677 }) 678 } 679 680 // AddCreatedAt adds v to the "created_at" field. 681 func (u *CoinDescriptionUpsertOne) AddCreatedAt(v uint32) *CoinDescriptionUpsertOne { 682 return u.Update(func(s *CoinDescriptionUpsert) { 683 s.AddCreatedAt(v) 684 }) 685 } 686 687 // UpdateCreatedAt sets the "created_at" field to the value that was provided on create. 688 func (u *CoinDescriptionUpsertOne) UpdateCreatedAt() *CoinDescriptionUpsertOne { 689 return u.Update(func(s *CoinDescriptionUpsert) { 690 s.UpdateCreatedAt() 691 }) 692 } 693 694 // SetUpdatedAt sets the "updated_at" field. 695 func (u *CoinDescriptionUpsertOne) SetUpdatedAt(v uint32) *CoinDescriptionUpsertOne { 696 return u.Update(func(s *CoinDescriptionUpsert) { 697 s.SetUpdatedAt(v) 698 }) 699 } 700 701 // AddUpdatedAt adds v to the "updated_at" field. 702 func (u *CoinDescriptionUpsertOne) AddUpdatedAt(v uint32) *CoinDescriptionUpsertOne { 703 return u.Update(func(s *CoinDescriptionUpsert) { 704 s.AddUpdatedAt(v) 705 }) 706 } 707 708 // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. 709 func (u *CoinDescriptionUpsertOne) UpdateUpdatedAt() *CoinDescriptionUpsertOne { 710 return u.Update(func(s *CoinDescriptionUpsert) { 711 s.UpdateUpdatedAt() 712 }) 713 } 714 715 // SetDeletedAt sets the "deleted_at" field. 716 func (u *CoinDescriptionUpsertOne) SetDeletedAt(v uint32) *CoinDescriptionUpsertOne { 717 return u.Update(func(s *CoinDescriptionUpsert) { 718 s.SetDeletedAt(v) 719 }) 720 } 721 722 // AddDeletedAt adds v to the "deleted_at" field. 723 func (u *CoinDescriptionUpsertOne) AddDeletedAt(v uint32) *CoinDescriptionUpsertOne { 724 return u.Update(func(s *CoinDescriptionUpsert) { 725 s.AddDeletedAt(v) 726 }) 727 } 728 729 // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. 730 func (u *CoinDescriptionUpsertOne) UpdateDeletedAt() *CoinDescriptionUpsertOne { 731 return u.Update(func(s *CoinDescriptionUpsert) { 732 s.UpdateDeletedAt() 733 }) 734 } 735 736 // SetEntID sets the "ent_id" field. 737 func (u *CoinDescriptionUpsertOne) SetEntID(v uuid.UUID) *CoinDescriptionUpsertOne { 738 return u.Update(func(s *CoinDescriptionUpsert) { 739 s.SetEntID(v) 740 }) 741 } 742 743 // UpdateEntID sets the "ent_id" field to the value that was provided on create. 744 func (u *CoinDescriptionUpsertOne) UpdateEntID() *CoinDescriptionUpsertOne { 745 return u.Update(func(s *CoinDescriptionUpsert) { 746 s.UpdateEntID() 747 }) 748 } 749 750 // SetAppID sets the "app_id" field. 751 func (u *CoinDescriptionUpsertOne) SetAppID(v uuid.UUID) *CoinDescriptionUpsertOne { 752 return u.Update(func(s *CoinDescriptionUpsert) { 753 s.SetAppID(v) 754 }) 755 } 756 757 // UpdateAppID sets the "app_id" field to the value that was provided on create. 758 func (u *CoinDescriptionUpsertOne) UpdateAppID() *CoinDescriptionUpsertOne { 759 return u.Update(func(s *CoinDescriptionUpsert) { 760 s.UpdateAppID() 761 }) 762 } 763 764 // ClearAppID clears the value of the "app_id" field. 765 func (u *CoinDescriptionUpsertOne) ClearAppID() *CoinDescriptionUpsertOne { 766 return u.Update(func(s *CoinDescriptionUpsert) { 767 s.ClearAppID() 768 }) 769 } 770 771 // SetCoinTypeID sets the "coin_type_id" field. 772 func (u *CoinDescriptionUpsertOne) SetCoinTypeID(v uuid.UUID) *CoinDescriptionUpsertOne { 773 return u.Update(func(s *CoinDescriptionUpsert) { 774 s.SetCoinTypeID(v) 775 }) 776 } 777 778 // UpdateCoinTypeID sets the "coin_type_id" field to the value that was provided on create. 779 func (u *CoinDescriptionUpsertOne) UpdateCoinTypeID() *CoinDescriptionUpsertOne { 780 return u.Update(func(s *CoinDescriptionUpsert) { 781 s.UpdateCoinTypeID() 782 }) 783 } 784 785 // ClearCoinTypeID clears the value of the "coin_type_id" field. 786 func (u *CoinDescriptionUpsertOne) ClearCoinTypeID() *CoinDescriptionUpsertOne { 787 return u.Update(func(s *CoinDescriptionUpsert) { 788 s.ClearCoinTypeID() 789 }) 790 } 791 792 // SetUsedFor sets the "used_for" field. 793 func (u *CoinDescriptionUpsertOne) SetUsedFor(v string) *CoinDescriptionUpsertOne { 794 return u.Update(func(s *CoinDescriptionUpsert) { 795 s.SetUsedFor(v) 796 }) 797 } 798 799 // UpdateUsedFor sets the "used_for" field to the value that was provided on create. 800 func (u *CoinDescriptionUpsertOne) UpdateUsedFor() *CoinDescriptionUpsertOne { 801 return u.Update(func(s *CoinDescriptionUpsert) { 802 s.UpdateUsedFor() 803 }) 804 } 805 806 // ClearUsedFor clears the value of the "used_for" field. 807 func (u *CoinDescriptionUpsertOne) ClearUsedFor() *CoinDescriptionUpsertOne { 808 return u.Update(func(s *CoinDescriptionUpsert) { 809 s.ClearUsedFor() 810 }) 811 } 812 813 // SetTitle sets the "title" field. 814 func (u *CoinDescriptionUpsertOne) SetTitle(v string) *CoinDescriptionUpsertOne { 815 return u.Update(func(s *CoinDescriptionUpsert) { 816 s.SetTitle(v) 817 }) 818 } 819 820 // UpdateTitle sets the "title" field to the value that was provided on create. 821 func (u *CoinDescriptionUpsertOne) UpdateTitle() *CoinDescriptionUpsertOne { 822 return u.Update(func(s *CoinDescriptionUpsert) { 823 s.UpdateTitle() 824 }) 825 } 826 827 // ClearTitle clears the value of the "title" field. 828 func (u *CoinDescriptionUpsertOne) ClearTitle() *CoinDescriptionUpsertOne { 829 return u.Update(func(s *CoinDescriptionUpsert) { 830 s.ClearTitle() 831 }) 832 } 833 834 // SetMessage sets the "message" field. 835 func (u *CoinDescriptionUpsertOne) SetMessage(v string) *CoinDescriptionUpsertOne { 836 return u.Update(func(s *CoinDescriptionUpsert) { 837 s.SetMessage(v) 838 }) 839 } 840 841 // UpdateMessage sets the "message" field to the value that was provided on create. 842 func (u *CoinDescriptionUpsertOne) UpdateMessage() *CoinDescriptionUpsertOne { 843 return u.Update(func(s *CoinDescriptionUpsert) { 844 s.UpdateMessage() 845 }) 846 } 847 848 // ClearMessage clears the value of the "message" field. 849 func (u *CoinDescriptionUpsertOne) ClearMessage() *CoinDescriptionUpsertOne { 850 return u.Update(func(s *CoinDescriptionUpsert) { 851 s.ClearMessage() 852 }) 853 } 854 855 // Exec executes the query. 856 func (u *CoinDescriptionUpsertOne) Exec(ctx context.Context) error { 857 if len(u.create.conflict) == 0 { 858 return errors.New("ent: missing options for CoinDescriptionCreate.OnConflict") 859 } 860 return u.create.Exec(ctx) 861 } 862 863 // ExecX is like Exec, but panics if an error occurs. 864 func (u *CoinDescriptionUpsertOne) ExecX(ctx context.Context) { 865 if err := u.create.Exec(ctx); err != nil { 866 panic(err) 867 } 868 } 869 870 // Exec executes the UPSERT query and returns the inserted/updated ID. 871 func (u *CoinDescriptionUpsertOne) ID(ctx context.Context) (id uint32, err error) { 872 node, err := u.create.Save(ctx) 873 if err != nil { 874 return id, err 875 } 876 return node.ID, nil 877 } 878 879 // IDX is like ID, but panics if an error occurs. 880 func (u *CoinDescriptionUpsertOne) IDX(ctx context.Context) uint32 { 881 id, err := u.ID(ctx) 882 if err != nil { 883 panic(err) 884 } 885 return id 886 } 887 888 // CoinDescriptionCreateBulk is the builder for creating many CoinDescription entities in bulk. 889 type CoinDescriptionCreateBulk struct { 890 config 891 builders []*CoinDescriptionCreate 892 conflict []sql.ConflictOption 893 } 894 895 // Save creates the CoinDescription entities in the database. 896 func (cdcb *CoinDescriptionCreateBulk) Save(ctx context.Context) ([]*CoinDescription, error) { 897 specs := make([]*sqlgraph.CreateSpec, len(cdcb.builders)) 898 nodes := make([]*CoinDescription, len(cdcb.builders)) 899 mutators := make([]Mutator, len(cdcb.builders)) 900 for i := range cdcb.builders { 901 func(i int, root context.Context) { 902 builder := cdcb.builders[i] 903 builder.defaults() 904 var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { 905 mutation, ok := m.(*CoinDescriptionMutation) 906 if !ok { 907 return nil, fmt.Errorf("unexpected mutation type %T", m) 908 } 909 if err := builder.check(); err != nil { 910 return nil, err 911 } 912 builder.mutation = mutation 913 nodes[i], specs[i] = builder.createSpec() 914 var err error 915 if i < len(mutators)-1 { 916 _, err = mutators[i+1].Mutate(root, cdcb.builders[i+1].mutation) 917 } else { 918 spec := &sqlgraph.BatchCreateSpec{Nodes: specs} 919 spec.OnConflict = cdcb.conflict 920 // Invoke the actual operation on the latest mutation in the chain. 921 if err = sqlgraph.BatchCreate(ctx, cdcb.driver, spec); err != nil { 922 if sqlgraph.IsConstraintError(err) { 923 err = &ConstraintError{msg: err.Error(), wrap: err} 924 } 925 } 926 } 927 if err != nil { 928 return nil, err 929 } 930 mutation.id = &nodes[i].ID 931 if specs[i].ID.Value != nil && nodes[i].ID == 0 { 932 id := specs[i].ID.Value.(int64) 933 nodes[i].ID = uint32(id) 934 } 935 mutation.done = true 936 return nodes[i], nil 937 }) 938 for i := len(builder.hooks) - 1; i >= 0; i-- { 939 mut = builder.hooks[i](mut) 940 } 941 mutators[i] = mut 942 }(i, ctx) 943 } 944 if len(mutators) > 0 { 945 if _, err := mutators[0].Mutate(ctx, cdcb.builders[0].mutation); err != nil { 946 return nil, err 947 } 948 } 949 return nodes, nil 950 } 951 952 // SaveX is like Save, but panics if an error occurs. 953 func (cdcb *CoinDescriptionCreateBulk) SaveX(ctx context.Context) []*CoinDescription { 954 v, err := cdcb.Save(ctx) 955 if err != nil { 956 panic(err) 957 } 958 return v 959 } 960 961 // Exec executes the query. 962 func (cdcb *CoinDescriptionCreateBulk) Exec(ctx context.Context) error { 963 _, err := cdcb.Save(ctx) 964 return err 965 } 966 967 // ExecX is like Exec, but panics if an error occurs. 968 func (cdcb *CoinDescriptionCreateBulk) ExecX(ctx context.Context) { 969 if err := cdcb.Exec(ctx); err != nil { 970 panic(err) 971 } 972 } 973 974 // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause 975 // of the `INSERT` statement. For example: 976 // 977 // client.CoinDescription.CreateBulk(builders...). 978 // OnConflict( 979 // // Update the row with the new values 980 // // the was proposed for insertion. 981 // sql.ResolveWithNewValues(), 982 // ). 983 // // Override some of the fields with custom 984 // // update values. 985 // Update(func(u *ent.CoinDescriptionUpsert) { 986 // SetCreatedAt(v+v). 987 // }). 988 // Exec(ctx) 989 // 990 func (cdcb *CoinDescriptionCreateBulk) OnConflict(opts ...sql.ConflictOption) *CoinDescriptionUpsertBulk { 991 cdcb.conflict = opts 992 return &CoinDescriptionUpsertBulk{ 993 create: cdcb, 994 } 995 } 996 997 // OnConflictColumns calls `OnConflict` and configures the columns 998 // as conflict target. Using this option is equivalent to using: 999 // 1000 // client.CoinDescription.Create(). 1001 // OnConflict(sql.ConflictColumns(columns...)). 1002 // Exec(ctx) 1003 // 1004 func (cdcb *CoinDescriptionCreateBulk) OnConflictColumns(columns ...string) *CoinDescriptionUpsertBulk { 1005 cdcb.conflict = append(cdcb.conflict, sql.ConflictColumns(columns...)) 1006 return &CoinDescriptionUpsertBulk{ 1007 create: cdcb, 1008 } 1009 } 1010 1011 // CoinDescriptionUpsertBulk is the builder for "upsert"-ing 1012 // a bulk of CoinDescription nodes. 1013 type CoinDescriptionUpsertBulk struct { 1014 create *CoinDescriptionCreateBulk 1015 } 1016 1017 // UpdateNewValues updates the mutable fields using the new values that 1018 // were set on create. Using this option is equivalent to using: 1019 // 1020 // client.CoinDescription.Create(). 1021 // OnConflict( 1022 // sql.ResolveWithNewValues(), 1023 // sql.ResolveWith(func(u *sql.UpdateSet) { 1024 // u.SetIgnore(coindescription.FieldID) 1025 // }), 1026 // ). 1027 // Exec(ctx) 1028 // 1029 func (u *CoinDescriptionUpsertBulk) UpdateNewValues() *CoinDescriptionUpsertBulk { 1030 u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) 1031 u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { 1032 for _, b := range u.create.builders { 1033 if _, exists := b.mutation.ID(); exists { 1034 s.SetIgnore(coindescription.FieldID) 1035 return 1036 } 1037 } 1038 })) 1039 return u 1040 } 1041 1042 // Ignore sets each column to itself in case of conflict. 1043 // Using this option is equivalent to using: 1044 // 1045 // client.CoinDescription.Create(). 1046 // OnConflict(sql.ResolveWithIgnore()). 1047 // Exec(ctx) 1048 // 1049 func (u *CoinDescriptionUpsertBulk) Ignore() *CoinDescriptionUpsertBulk { 1050 u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) 1051 return u 1052 } 1053 1054 // DoNothing configures the conflict_action to `DO NOTHING`. 1055 // Supported only by SQLite and PostgreSQL. 1056 func (u *CoinDescriptionUpsertBulk) DoNothing() *CoinDescriptionUpsertBulk { 1057 u.create.conflict = append(u.create.conflict, sql.DoNothing()) 1058 return u 1059 } 1060 1061 // Update allows overriding fields `UPDATE` values. See the CoinDescriptionCreateBulk.OnConflict 1062 // documentation for more info. 1063 func (u *CoinDescriptionUpsertBulk) Update(set func(*CoinDescriptionUpsert)) *CoinDescriptionUpsertBulk { 1064 u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { 1065 set(&CoinDescriptionUpsert{UpdateSet: update}) 1066 })) 1067 return u 1068 } 1069 1070 // SetCreatedAt sets the "created_at" field. 1071 func (u *CoinDescriptionUpsertBulk) SetCreatedAt(v uint32) *CoinDescriptionUpsertBulk { 1072 return u.Update(func(s *CoinDescriptionUpsert) { 1073 s.SetCreatedAt(v) 1074 }) 1075 } 1076 1077 // AddCreatedAt adds v to the "created_at" field. 1078 func (u *CoinDescriptionUpsertBulk) AddCreatedAt(v uint32) *CoinDescriptionUpsertBulk { 1079 return u.Update(func(s *CoinDescriptionUpsert) { 1080 s.AddCreatedAt(v) 1081 }) 1082 } 1083 1084 // UpdateCreatedAt sets the "created_at" field to the value that was provided on create. 1085 func (u *CoinDescriptionUpsertBulk) UpdateCreatedAt() *CoinDescriptionUpsertBulk { 1086 return u.Update(func(s *CoinDescriptionUpsert) { 1087 s.UpdateCreatedAt() 1088 }) 1089 } 1090 1091 // SetUpdatedAt sets the "updated_at" field. 1092 func (u *CoinDescriptionUpsertBulk) SetUpdatedAt(v uint32) *CoinDescriptionUpsertBulk { 1093 return u.Update(func(s *CoinDescriptionUpsert) { 1094 s.SetUpdatedAt(v) 1095 }) 1096 } 1097 1098 // AddUpdatedAt adds v to the "updated_at" field. 1099 func (u *CoinDescriptionUpsertBulk) AddUpdatedAt(v uint32) *CoinDescriptionUpsertBulk { 1100 return u.Update(func(s *CoinDescriptionUpsert) { 1101 s.AddUpdatedAt(v) 1102 }) 1103 } 1104 1105 // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. 1106 func (u *CoinDescriptionUpsertBulk) UpdateUpdatedAt() *CoinDescriptionUpsertBulk { 1107 return u.Update(func(s *CoinDescriptionUpsert) { 1108 s.UpdateUpdatedAt() 1109 }) 1110 } 1111 1112 // SetDeletedAt sets the "deleted_at" field. 1113 func (u *CoinDescriptionUpsertBulk) SetDeletedAt(v uint32) *CoinDescriptionUpsertBulk { 1114 return u.Update(func(s *CoinDescriptionUpsert) { 1115 s.SetDeletedAt(v) 1116 }) 1117 } 1118 1119 // AddDeletedAt adds v to the "deleted_at" field. 1120 func (u *CoinDescriptionUpsertBulk) AddDeletedAt(v uint32) *CoinDescriptionUpsertBulk { 1121 return u.Update(func(s *CoinDescriptionUpsert) { 1122 s.AddDeletedAt(v) 1123 }) 1124 } 1125 1126 // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. 1127 func (u *CoinDescriptionUpsertBulk) UpdateDeletedAt() *CoinDescriptionUpsertBulk { 1128 return u.Update(func(s *CoinDescriptionUpsert) { 1129 s.UpdateDeletedAt() 1130 }) 1131 } 1132 1133 // SetEntID sets the "ent_id" field. 1134 func (u *CoinDescriptionUpsertBulk) SetEntID(v uuid.UUID) *CoinDescriptionUpsertBulk { 1135 return u.Update(func(s *CoinDescriptionUpsert) { 1136 s.SetEntID(v) 1137 }) 1138 } 1139 1140 // UpdateEntID sets the "ent_id" field to the value that was provided on create. 1141 func (u *CoinDescriptionUpsertBulk) UpdateEntID() *CoinDescriptionUpsertBulk { 1142 return u.Update(func(s *CoinDescriptionUpsert) { 1143 s.UpdateEntID() 1144 }) 1145 } 1146 1147 // SetAppID sets the "app_id" field. 1148 func (u *CoinDescriptionUpsertBulk) SetAppID(v uuid.UUID) *CoinDescriptionUpsertBulk { 1149 return u.Update(func(s *CoinDescriptionUpsert) { 1150 s.SetAppID(v) 1151 }) 1152 } 1153 1154 // UpdateAppID sets the "app_id" field to the value that was provided on create. 1155 func (u *CoinDescriptionUpsertBulk) UpdateAppID() *CoinDescriptionUpsertBulk { 1156 return u.Update(func(s *CoinDescriptionUpsert) { 1157 s.UpdateAppID() 1158 }) 1159 } 1160 1161 // ClearAppID clears the value of the "app_id" field. 1162 func (u *CoinDescriptionUpsertBulk) ClearAppID() *CoinDescriptionUpsertBulk { 1163 return u.Update(func(s *CoinDescriptionUpsert) { 1164 s.ClearAppID() 1165 }) 1166 } 1167 1168 // SetCoinTypeID sets the "coin_type_id" field. 1169 func (u *CoinDescriptionUpsertBulk) SetCoinTypeID(v uuid.UUID) *CoinDescriptionUpsertBulk { 1170 return u.Update(func(s *CoinDescriptionUpsert) { 1171 s.SetCoinTypeID(v) 1172 }) 1173 } 1174 1175 // UpdateCoinTypeID sets the "coin_type_id" field to the value that was provided on create. 1176 func (u *CoinDescriptionUpsertBulk) UpdateCoinTypeID() *CoinDescriptionUpsertBulk { 1177 return u.Update(func(s *CoinDescriptionUpsert) { 1178 s.UpdateCoinTypeID() 1179 }) 1180 } 1181 1182 // ClearCoinTypeID clears the value of the "coin_type_id" field. 1183 func (u *CoinDescriptionUpsertBulk) ClearCoinTypeID() *CoinDescriptionUpsertBulk { 1184 return u.Update(func(s *CoinDescriptionUpsert) { 1185 s.ClearCoinTypeID() 1186 }) 1187 } 1188 1189 // SetUsedFor sets the "used_for" field. 1190 func (u *CoinDescriptionUpsertBulk) SetUsedFor(v string) *CoinDescriptionUpsertBulk { 1191 return u.Update(func(s *CoinDescriptionUpsert) { 1192 s.SetUsedFor(v) 1193 }) 1194 } 1195 1196 // UpdateUsedFor sets the "used_for" field to the value that was provided on create. 1197 func (u *CoinDescriptionUpsertBulk) UpdateUsedFor() *CoinDescriptionUpsertBulk { 1198 return u.Update(func(s *CoinDescriptionUpsert) { 1199 s.UpdateUsedFor() 1200 }) 1201 } 1202 1203 // ClearUsedFor clears the value of the "used_for" field. 1204 func (u *CoinDescriptionUpsertBulk) ClearUsedFor() *CoinDescriptionUpsertBulk { 1205 return u.Update(func(s *CoinDescriptionUpsert) { 1206 s.ClearUsedFor() 1207 }) 1208 } 1209 1210 // SetTitle sets the "title" field. 1211 func (u *CoinDescriptionUpsertBulk) SetTitle(v string) *CoinDescriptionUpsertBulk { 1212 return u.Update(func(s *CoinDescriptionUpsert) { 1213 s.SetTitle(v) 1214 }) 1215 } 1216 1217 // UpdateTitle sets the "title" field to the value that was provided on create. 1218 func (u *CoinDescriptionUpsertBulk) UpdateTitle() *CoinDescriptionUpsertBulk { 1219 return u.Update(func(s *CoinDescriptionUpsert) { 1220 s.UpdateTitle() 1221 }) 1222 } 1223 1224 // ClearTitle clears the value of the "title" field. 1225 func (u *CoinDescriptionUpsertBulk) ClearTitle() *CoinDescriptionUpsertBulk { 1226 return u.Update(func(s *CoinDescriptionUpsert) { 1227 s.ClearTitle() 1228 }) 1229 } 1230 1231 // SetMessage sets the "message" field. 1232 func (u *CoinDescriptionUpsertBulk) SetMessage(v string) *CoinDescriptionUpsertBulk { 1233 return u.Update(func(s *CoinDescriptionUpsert) { 1234 s.SetMessage(v) 1235 }) 1236 } 1237 1238 // UpdateMessage sets the "message" field to the value that was provided on create. 1239 func (u *CoinDescriptionUpsertBulk) UpdateMessage() *CoinDescriptionUpsertBulk { 1240 return u.Update(func(s *CoinDescriptionUpsert) { 1241 s.UpdateMessage() 1242 }) 1243 } 1244 1245 // ClearMessage clears the value of the "message" field. 1246 func (u *CoinDescriptionUpsertBulk) ClearMessage() *CoinDescriptionUpsertBulk { 1247 return u.Update(func(s *CoinDescriptionUpsert) { 1248 s.ClearMessage() 1249 }) 1250 } 1251 1252 // Exec executes the query. 1253 func (u *CoinDescriptionUpsertBulk) Exec(ctx context.Context) error { 1254 for i, b := range u.create.builders { 1255 if len(b.conflict) != 0 { 1256 return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the CoinDescriptionCreateBulk instead", i) 1257 } 1258 } 1259 if len(u.create.conflict) == 0 { 1260 return errors.New("ent: missing options for CoinDescriptionCreateBulk.OnConflict") 1261 } 1262 return u.create.Exec(ctx) 1263 } 1264 1265 // ExecX is like Exec, but panics if an error occurs. 1266 func (u *CoinDescriptionUpsertBulk) ExecX(ctx context.Context) { 1267 if err := u.create.Exec(ctx); err != nil { 1268 panic(err) 1269 } 1270 }