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