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