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