github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/mutation.go (about) 1 // Code generated by ent, DO NOT EDIT. 2 3 package ent 4 5 import ( 6 "context" 7 "errors" 8 "fmt" 9 "sync" 10 11 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/appcoin" 12 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/chainbase" 13 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/coinbase" 14 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/coindescription" 15 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/coinextra" 16 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/coinfiat" 17 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/coinfiatcurrency" 18 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/coinfiatcurrencyhistory" 19 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/coinusedfor" 20 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/currency" 21 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/currencyfeed" 22 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/currencyhistory" 23 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/exchangerate" 24 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/fiat" 25 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/fiatcurrency" 26 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/fiatcurrencyfeed" 27 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/fiatcurrencyhistory" 28 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/predicate" 29 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/setting" 30 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/tran" 31 "github.com/google/uuid" 32 "github.com/shopspring/decimal" 33 34 "entgo.io/ent" 35 ) 36 37 const ( 38 // Operation types. 39 OpCreate = ent.OpCreate 40 OpDelete = ent.OpDelete 41 OpDeleteOne = ent.OpDeleteOne 42 OpUpdate = ent.OpUpdate 43 OpUpdateOne = ent.OpUpdateOne 44 45 // Node types. 46 TypeAppCoin = "AppCoin" 47 TypeChainBase = "ChainBase" 48 TypeCoinBase = "CoinBase" 49 TypeCoinDescription = "CoinDescription" 50 TypeCoinExtra = "CoinExtra" 51 TypeCoinFiat = "CoinFiat" 52 TypeCoinFiatCurrency = "CoinFiatCurrency" 53 TypeCoinFiatCurrencyHistory = "CoinFiatCurrencyHistory" 54 TypeCoinUsedFor = "CoinUsedFor" 55 TypeCurrency = "Currency" 56 TypeCurrencyFeed = "CurrencyFeed" 57 TypeCurrencyHistory = "CurrencyHistory" 58 TypeExchangeRate = "ExchangeRate" 59 TypeFiat = "Fiat" 60 TypeFiatCurrency = "FiatCurrency" 61 TypeFiatCurrencyFeed = "FiatCurrencyFeed" 62 TypeFiatCurrencyHistory = "FiatCurrencyHistory" 63 TypeSetting = "Setting" 64 TypeTran = "Tran" 65 ) 66 67 // AppCoinMutation represents an operation that mutates the AppCoin nodes in the graph. 68 type AppCoinMutation struct { 69 config 70 op Op 71 typ string 72 id *uint32 73 created_at *uint32 74 addcreated_at *int32 75 updated_at *uint32 76 addupdated_at *int32 77 deleted_at *uint32 78 adddeleted_at *int32 79 ent_id *uuid.UUID 80 app_id *uuid.UUID 81 coin_type_id *uuid.UUID 82 name *string 83 display_names *[]string 84 logo *string 85 for_pay *bool 86 withdraw_auto_review_amount *decimal.Decimal 87 product_page *string 88 disabled *bool 89 daily_reward_amount *decimal.Decimal 90 display *bool 91 display_index *uint32 92 adddisplay_index *int32 93 max_amount_per_withdraw *decimal.Decimal 94 clearedFields map[string]struct{} 95 done bool 96 oldValue func(context.Context) (*AppCoin, error) 97 predicates []predicate.AppCoin 98 } 99 100 var _ ent.Mutation = (*AppCoinMutation)(nil) 101 102 // appcoinOption allows management of the mutation configuration using functional options. 103 type appcoinOption func(*AppCoinMutation) 104 105 // newAppCoinMutation creates new mutation for the AppCoin entity. 106 func newAppCoinMutation(c config, op Op, opts ...appcoinOption) *AppCoinMutation { 107 m := &AppCoinMutation{ 108 config: c, 109 op: op, 110 typ: TypeAppCoin, 111 clearedFields: make(map[string]struct{}), 112 } 113 for _, opt := range opts { 114 opt(m) 115 } 116 return m 117 } 118 119 // withAppCoinID sets the ID field of the mutation. 120 func withAppCoinID(id uint32) appcoinOption { 121 return func(m *AppCoinMutation) { 122 var ( 123 err error 124 once sync.Once 125 value *AppCoin 126 ) 127 m.oldValue = func(ctx context.Context) (*AppCoin, error) { 128 once.Do(func() { 129 if m.done { 130 err = errors.New("querying old values post mutation is not allowed") 131 } else { 132 value, err = m.Client().AppCoin.Get(ctx, id) 133 } 134 }) 135 return value, err 136 } 137 m.id = &id 138 } 139 } 140 141 // withAppCoin sets the old AppCoin of the mutation. 142 func withAppCoin(node *AppCoin) appcoinOption { 143 return func(m *AppCoinMutation) { 144 m.oldValue = func(context.Context) (*AppCoin, error) { 145 return node, nil 146 } 147 m.id = &node.ID 148 } 149 } 150 151 // Client returns a new `ent.Client` from the mutation. If the mutation was 152 // executed in a transaction (ent.Tx), a transactional client is returned. 153 func (m AppCoinMutation) Client() *Client { 154 client := &Client{config: m.config} 155 client.init() 156 return client 157 } 158 159 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 160 // it returns an error otherwise. 161 func (m AppCoinMutation) Tx() (*Tx, error) { 162 if _, ok := m.driver.(*txDriver); !ok { 163 return nil, errors.New("ent: mutation is not running in a transaction") 164 } 165 tx := &Tx{config: m.config} 166 tx.init() 167 return tx, nil 168 } 169 170 // SetID sets the value of the id field. Note that this 171 // operation is only accepted on creation of AppCoin entities. 172 func (m *AppCoinMutation) SetID(id uint32) { 173 m.id = &id 174 } 175 176 // ID returns the ID value in the mutation. Note that the ID is only available 177 // if it was provided to the builder or after it was returned from the database. 178 func (m *AppCoinMutation) ID() (id uint32, exists bool) { 179 if m.id == nil { 180 return 181 } 182 return *m.id, true 183 } 184 185 // IDs queries the database and returns the entity ids that match the mutation's predicate. 186 // That means, if the mutation is applied within a transaction with an isolation level such 187 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 188 // or updated by the mutation. 189 func (m *AppCoinMutation) IDs(ctx context.Context) ([]uint32, error) { 190 switch { 191 case m.op.Is(OpUpdateOne | OpDeleteOne): 192 id, exists := m.ID() 193 if exists { 194 return []uint32{id}, nil 195 } 196 fallthrough 197 case m.op.Is(OpUpdate | OpDelete): 198 return m.Client().AppCoin.Query().Where(m.predicates...).IDs(ctx) 199 default: 200 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 201 } 202 } 203 204 // SetCreatedAt sets the "created_at" field. 205 func (m *AppCoinMutation) SetCreatedAt(u uint32) { 206 m.created_at = &u 207 m.addcreated_at = nil 208 } 209 210 // CreatedAt returns the value of the "created_at" field in the mutation. 211 func (m *AppCoinMutation) CreatedAt() (r uint32, exists bool) { 212 v := m.created_at 213 if v == nil { 214 return 215 } 216 return *v, true 217 } 218 219 // OldCreatedAt returns the old "created_at" field's value of the AppCoin entity. 220 // If the AppCoin object wasn't provided to the builder, the object is fetched from the database. 221 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 222 func (m *AppCoinMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 223 if !m.op.Is(OpUpdateOne) { 224 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 225 } 226 if m.id == nil || m.oldValue == nil { 227 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 228 } 229 oldValue, err := m.oldValue(ctx) 230 if err != nil { 231 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 232 } 233 return oldValue.CreatedAt, nil 234 } 235 236 // AddCreatedAt adds u to the "created_at" field. 237 func (m *AppCoinMutation) AddCreatedAt(u int32) { 238 if m.addcreated_at != nil { 239 *m.addcreated_at += u 240 } else { 241 m.addcreated_at = &u 242 } 243 } 244 245 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 246 func (m *AppCoinMutation) AddedCreatedAt() (r int32, exists bool) { 247 v := m.addcreated_at 248 if v == nil { 249 return 250 } 251 return *v, true 252 } 253 254 // ResetCreatedAt resets all changes to the "created_at" field. 255 func (m *AppCoinMutation) ResetCreatedAt() { 256 m.created_at = nil 257 m.addcreated_at = nil 258 } 259 260 // SetUpdatedAt sets the "updated_at" field. 261 func (m *AppCoinMutation) SetUpdatedAt(u uint32) { 262 m.updated_at = &u 263 m.addupdated_at = nil 264 } 265 266 // UpdatedAt returns the value of the "updated_at" field in the mutation. 267 func (m *AppCoinMutation) UpdatedAt() (r uint32, exists bool) { 268 v := m.updated_at 269 if v == nil { 270 return 271 } 272 return *v, true 273 } 274 275 // OldUpdatedAt returns the old "updated_at" field's value of the AppCoin entity. 276 // If the AppCoin object wasn't provided to the builder, the object is fetched from the database. 277 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 278 func (m *AppCoinMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 279 if !m.op.Is(OpUpdateOne) { 280 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 281 } 282 if m.id == nil || m.oldValue == nil { 283 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 284 } 285 oldValue, err := m.oldValue(ctx) 286 if err != nil { 287 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 288 } 289 return oldValue.UpdatedAt, nil 290 } 291 292 // AddUpdatedAt adds u to the "updated_at" field. 293 func (m *AppCoinMutation) AddUpdatedAt(u int32) { 294 if m.addupdated_at != nil { 295 *m.addupdated_at += u 296 } else { 297 m.addupdated_at = &u 298 } 299 } 300 301 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 302 func (m *AppCoinMutation) AddedUpdatedAt() (r int32, exists bool) { 303 v := m.addupdated_at 304 if v == nil { 305 return 306 } 307 return *v, true 308 } 309 310 // ResetUpdatedAt resets all changes to the "updated_at" field. 311 func (m *AppCoinMutation) ResetUpdatedAt() { 312 m.updated_at = nil 313 m.addupdated_at = nil 314 } 315 316 // SetDeletedAt sets the "deleted_at" field. 317 func (m *AppCoinMutation) SetDeletedAt(u uint32) { 318 m.deleted_at = &u 319 m.adddeleted_at = nil 320 } 321 322 // DeletedAt returns the value of the "deleted_at" field in the mutation. 323 func (m *AppCoinMutation) DeletedAt() (r uint32, exists bool) { 324 v := m.deleted_at 325 if v == nil { 326 return 327 } 328 return *v, true 329 } 330 331 // OldDeletedAt returns the old "deleted_at" field's value of the AppCoin entity. 332 // If the AppCoin object wasn't provided to the builder, the object is fetched from the database. 333 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 334 func (m *AppCoinMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 335 if !m.op.Is(OpUpdateOne) { 336 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 337 } 338 if m.id == nil || m.oldValue == nil { 339 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 340 } 341 oldValue, err := m.oldValue(ctx) 342 if err != nil { 343 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 344 } 345 return oldValue.DeletedAt, nil 346 } 347 348 // AddDeletedAt adds u to the "deleted_at" field. 349 func (m *AppCoinMutation) AddDeletedAt(u int32) { 350 if m.adddeleted_at != nil { 351 *m.adddeleted_at += u 352 } else { 353 m.adddeleted_at = &u 354 } 355 } 356 357 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 358 func (m *AppCoinMutation) AddedDeletedAt() (r int32, exists bool) { 359 v := m.adddeleted_at 360 if v == nil { 361 return 362 } 363 return *v, true 364 } 365 366 // ResetDeletedAt resets all changes to the "deleted_at" field. 367 func (m *AppCoinMutation) ResetDeletedAt() { 368 m.deleted_at = nil 369 m.adddeleted_at = nil 370 } 371 372 // SetEntID sets the "ent_id" field. 373 func (m *AppCoinMutation) SetEntID(u uuid.UUID) { 374 m.ent_id = &u 375 } 376 377 // EntID returns the value of the "ent_id" field in the mutation. 378 func (m *AppCoinMutation) EntID() (r uuid.UUID, exists bool) { 379 v := m.ent_id 380 if v == nil { 381 return 382 } 383 return *v, true 384 } 385 386 // OldEntID returns the old "ent_id" field's value of the AppCoin entity. 387 // If the AppCoin object wasn't provided to the builder, the object is fetched from the database. 388 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 389 func (m *AppCoinMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 390 if !m.op.Is(OpUpdateOne) { 391 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 392 } 393 if m.id == nil || m.oldValue == nil { 394 return v, errors.New("OldEntID requires an ID field in the mutation") 395 } 396 oldValue, err := m.oldValue(ctx) 397 if err != nil { 398 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 399 } 400 return oldValue.EntID, nil 401 } 402 403 // ResetEntID resets all changes to the "ent_id" field. 404 func (m *AppCoinMutation) ResetEntID() { 405 m.ent_id = nil 406 } 407 408 // SetAppID sets the "app_id" field. 409 func (m *AppCoinMutation) SetAppID(u uuid.UUID) { 410 m.app_id = &u 411 } 412 413 // AppID returns the value of the "app_id" field in the mutation. 414 func (m *AppCoinMutation) AppID() (r uuid.UUID, exists bool) { 415 v := m.app_id 416 if v == nil { 417 return 418 } 419 return *v, true 420 } 421 422 // OldAppID returns the old "app_id" field's value of the AppCoin entity. 423 // If the AppCoin object wasn't provided to the builder, the object is fetched from the database. 424 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 425 func (m *AppCoinMutation) OldAppID(ctx context.Context) (v uuid.UUID, err error) { 426 if !m.op.Is(OpUpdateOne) { 427 return v, errors.New("OldAppID is only allowed on UpdateOne operations") 428 } 429 if m.id == nil || m.oldValue == nil { 430 return v, errors.New("OldAppID requires an ID field in the mutation") 431 } 432 oldValue, err := m.oldValue(ctx) 433 if err != nil { 434 return v, fmt.Errorf("querying old value for OldAppID: %w", err) 435 } 436 return oldValue.AppID, nil 437 } 438 439 // ClearAppID clears the value of the "app_id" field. 440 func (m *AppCoinMutation) ClearAppID() { 441 m.app_id = nil 442 m.clearedFields[appcoin.FieldAppID] = struct{}{} 443 } 444 445 // AppIDCleared returns if the "app_id" field was cleared in this mutation. 446 func (m *AppCoinMutation) AppIDCleared() bool { 447 _, ok := m.clearedFields[appcoin.FieldAppID] 448 return ok 449 } 450 451 // ResetAppID resets all changes to the "app_id" field. 452 func (m *AppCoinMutation) ResetAppID() { 453 m.app_id = nil 454 delete(m.clearedFields, appcoin.FieldAppID) 455 } 456 457 // SetCoinTypeID sets the "coin_type_id" field. 458 func (m *AppCoinMutation) SetCoinTypeID(u uuid.UUID) { 459 m.coin_type_id = &u 460 } 461 462 // CoinTypeID returns the value of the "coin_type_id" field in the mutation. 463 func (m *AppCoinMutation) CoinTypeID() (r uuid.UUID, exists bool) { 464 v := m.coin_type_id 465 if v == nil { 466 return 467 } 468 return *v, true 469 } 470 471 // OldCoinTypeID returns the old "coin_type_id" field's value of the AppCoin entity. 472 // If the AppCoin object wasn't provided to the builder, the object is fetched from the database. 473 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 474 func (m *AppCoinMutation) OldCoinTypeID(ctx context.Context) (v uuid.UUID, err error) { 475 if !m.op.Is(OpUpdateOne) { 476 return v, errors.New("OldCoinTypeID is only allowed on UpdateOne operations") 477 } 478 if m.id == nil || m.oldValue == nil { 479 return v, errors.New("OldCoinTypeID requires an ID field in the mutation") 480 } 481 oldValue, err := m.oldValue(ctx) 482 if err != nil { 483 return v, fmt.Errorf("querying old value for OldCoinTypeID: %w", err) 484 } 485 return oldValue.CoinTypeID, nil 486 } 487 488 // ClearCoinTypeID clears the value of the "coin_type_id" field. 489 func (m *AppCoinMutation) ClearCoinTypeID() { 490 m.coin_type_id = nil 491 m.clearedFields[appcoin.FieldCoinTypeID] = struct{}{} 492 } 493 494 // CoinTypeIDCleared returns if the "coin_type_id" field was cleared in this mutation. 495 func (m *AppCoinMutation) CoinTypeIDCleared() bool { 496 _, ok := m.clearedFields[appcoin.FieldCoinTypeID] 497 return ok 498 } 499 500 // ResetCoinTypeID resets all changes to the "coin_type_id" field. 501 func (m *AppCoinMutation) ResetCoinTypeID() { 502 m.coin_type_id = nil 503 delete(m.clearedFields, appcoin.FieldCoinTypeID) 504 } 505 506 // SetName sets the "name" field. 507 func (m *AppCoinMutation) SetName(s string) { 508 m.name = &s 509 } 510 511 // Name returns the value of the "name" field in the mutation. 512 func (m *AppCoinMutation) Name() (r string, exists bool) { 513 v := m.name 514 if v == nil { 515 return 516 } 517 return *v, true 518 } 519 520 // OldName returns the old "name" field's value of the AppCoin entity. 521 // If the AppCoin object wasn't provided to the builder, the object is fetched from the database. 522 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 523 func (m *AppCoinMutation) OldName(ctx context.Context) (v string, err error) { 524 if !m.op.Is(OpUpdateOne) { 525 return v, errors.New("OldName is only allowed on UpdateOne operations") 526 } 527 if m.id == nil || m.oldValue == nil { 528 return v, errors.New("OldName requires an ID field in the mutation") 529 } 530 oldValue, err := m.oldValue(ctx) 531 if err != nil { 532 return v, fmt.Errorf("querying old value for OldName: %w", err) 533 } 534 return oldValue.Name, nil 535 } 536 537 // ClearName clears the value of the "name" field. 538 func (m *AppCoinMutation) ClearName() { 539 m.name = nil 540 m.clearedFields[appcoin.FieldName] = struct{}{} 541 } 542 543 // NameCleared returns if the "name" field was cleared in this mutation. 544 func (m *AppCoinMutation) NameCleared() bool { 545 _, ok := m.clearedFields[appcoin.FieldName] 546 return ok 547 } 548 549 // ResetName resets all changes to the "name" field. 550 func (m *AppCoinMutation) ResetName() { 551 m.name = nil 552 delete(m.clearedFields, appcoin.FieldName) 553 } 554 555 // SetDisplayNames sets the "display_names" field. 556 func (m *AppCoinMutation) SetDisplayNames(s []string) { 557 m.display_names = &s 558 } 559 560 // DisplayNames returns the value of the "display_names" field in the mutation. 561 func (m *AppCoinMutation) DisplayNames() (r []string, exists bool) { 562 v := m.display_names 563 if v == nil { 564 return 565 } 566 return *v, true 567 } 568 569 // OldDisplayNames returns the old "display_names" field's value of the AppCoin entity. 570 // If the AppCoin object wasn't provided to the builder, the object is fetched from the database. 571 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 572 func (m *AppCoinMutation) OldDisplayNames(ctx context.Context) (v []string, err error) { 573 if !m.op.Is(OpUpdateOne) { 574 return v, errors.New("OldDisplayNames is only allowed on UpdateOne operations") 575 } 576 if m.id == nil || m.oldValue == nil { 577 return v, errors.New("OldDisplayNames requires an ID field in the mutation") 578 } 579 oldValue, err := m.oldValue(ctx) 580 if err != nil { 581 return v, fmt.Errorf("querying old value for OldDisplayNames: %w", err) 582 } 583 return oldValue.DisplayNames, nil 584 } 585 586 // ClearDisplayNames clears the value of the "display_names" field. 587 func (m *AppCoinMutation) ClearDisplayNames() { 588 m.display_names = nil 589 m.clearedFields[appcoin.FieldDisplayNames] = struct{}{} 590 } 591 592 // DisplayNamesCleared returns if the "display_names" field was cleared in this mutation. 593 func (m *AppCoinMutation) DisplayNamesCleared() bool { 594 _, ok := m.clearedFields[appcoin.FieldDisplayNames] 595 return ok 596 } 597 598 // ResetDisplayNames resets all changes to the "display_names" field. 599 func (m *AppCoinMutation) ResetDisplayNames() { 600 m.display_names = nil 601 delete(m.clearedFields, appcoin.FieldDisplayNames) 602 } 603 604 // SetLogo sets the "logo" field. 605 func (m *AppCoinMutation) SetLogo(s string) { 606 m.logo = &s 607 } 608 609 // Logo returns the value of the "logo" field in the mutation. 610 func (m *AppCoinMutation) Logo() (r string, exists bool) { 611 v := m.logo 612 if v == nil { 613 return 614 } 615 return *v, true 616 } 617 618 // OldLogo returns the old "logo" field's value of the AppCoin entity. 619 // If the AppCoin object wasn't provided to the builder, the object is fetched from the database. 620 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 621 func (m *AppCoinMutation) OldLogo(ctx context.Context) (v string, err error) { 622 if !m.op.Is(OpUpdateOne) { 623 return v, errors.New("OldLogo is only allowed on UpdateOne operations") 624 } 625 if m.id == nil || m.oldValue == nil { 626 return v, errors.New("OldLogo requires an ID field in the mutation") 627 } 628 oldValue, err := m.oldValue(ctx) 629 if err != nil { 630 return v, fmt.Errorf("querying old value for OldLogo: %w", err) 631 } 632 return oldValue.Logo, nil 633 } 634 635 // ClearLogo clears the value of the "logo" field. 636 func (m *AppCoinMutation) ClearLogo() { 637 m.logo = nil 638 m.clearedFields[appcoin.FieldLogo] = struct{}{} 639 } 640 641 // LogoCleared returns if the "logo" field was cleared in this mutation. 642 func (m *AppCoinMutation) LogoCleared() bool { 643 _, ok := m.clearedFields[appcoin.FieldLogo] 644 return ok 645 } 646 647 // ResetLogo resets all changes to the "logo" field. 648 func (m *AppCoinMutation) ResetLogo() { 649 m.logo = nil 650 delete(m.clearedFields, appcoin.FieldLogo) 651 } 652 653 // SetForPay sets the "for_pay" field. 654 func (m *AppCoinMutation) SetForPay(b bool) { 655 m.for_pay = &b 656 } 657 658 // ForPay returns the value of the "for_pay" field in the mutation. 659 func (m *AppCoinMutation) ForPay() (r bool, exists bool) { 660 v := m.for_pay 661 if v == nil { 662 return 663 } 664 return *v, true 665 } 666 667 // OldForPay returns the old "for_pay" field's value of the AppCoin entity. 668 // If the AppCoin object wasn't provided to the builder, the object is fetched from the database. 669 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 670 func (m *AppCoinMutation) OldForPay(ctx context.Context) (v bool, err error) { 671 if !m.op.Is(OpUpdateOne) { 672 return v, errors.New("OldForPay is only allowed on UpdateOne operations") 673 } 674 if m.id == nil || m.oldValue == nil { 675 return v, errors.New("OldForPay requires an ID field in the mutation") 676 } 677 oldValue, err := m.oldValue(ctx) 678 if err != nil { 679 return v, fmt.Errorf("querying old value for OldForPay: %w", err) 680 } 681 return oldValue.ForPay, nil 682 } 683 684 // ClearForPay clears the value of the "for_pay" field. 685 func (m *AppCoinMutation) ClearForPay() { 686 m.for_pay = nil 687 m.clearedFields[appcoin.FieldForPay] = struct{}{} 688 } 689 690 // ForPayCleared returns if the "for_pay" field was cleared in this mutation. 691 func (m *AppCoinMutation) ForPayCleared() bool { 692 _, ok := m.clearedFields[appcoin.FieldForPay] 693 return ok 694 } 695 696 // ResetForPay resets all changes to the "for_pay" field. 697 func (m *AppCoinMutation) ResetForPay() { 698 m.for_pay = nil 699 delete(m.clearedFields, appcoin.FieldForPay) 700 } 701 702 // SetWithdrawAutoReviewAmount sets the "withdraw_auto_review_amount" field. 703 func (m *AppCoinMutation) SetWithdrawAutoReviewAmount(d decimal.Decimal) { 704 m.withdraw_auto_review_amount = &d 705 } 706 707 // WithdrawAutoReviewAmount returns the value of the "withdraw_auto_review_amount" field in the mutation. 708 func (m *AppCoinMutation) WithdrawAutoReviewAmount() (r decimal.Decimal, exists bool) { 709 v := m.withdraw_auto_review_amount 710 if v == nil { 711 return 712 } 713 return *v, true 714 } 715 716 // OldWithdrawAutoReviewAmount returns the old "withdraw_auto_review_amount" field's value of the AppCoin entity. 717 // If the AppCoin object wasn't provided to the builder, the object is fetched from the database. 718 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 719 func (m *AppCoinMutation) OldWithdrawAutoReviewAmount(ctx context.Context) (v decimal.Decimal, err error) { 720 if !m.op.Is(OpUpdateOne) { 721 return v, errors.New("OldWithdrawAutoReviewAmount is only allowed on UpdateOne operations") 722 } 723 if m.id == nil || m.oldValue == nil { 724 return v, errors.New("OldWithdrawAutoReviewAmount requires an ID field in the mutation") 725 } 726 oldValue, err := m.oldValue(ctx) 727 if err != nil { 728 return v, fmt.Errorf("querying old value for OldWithdrawAutoReviewAmount: %w", err) 729 } 730 return oldValue.WithdrawAutoReviewAmount, nil 731 } 732 733 // ClearWithdrawAutoReviewAmount clears the value of the "withdraw_auto_review_amount" field. 734 func (m *AppCoinMutation) ClearWithdrawAutoReviewAmount() { 735 m.withdraw_auto_review_amount = nil 736 m.clearedFields[appcoin.FieldWithdrawAutoReviewAmount] = struct{}{} 737 } 738 739 // WithdrawAutoReviewAmountCleared returns if the "withdraw_auto_review_amount" field was cleared in this mutation. 740 func (m *AppCoinMutation) WithdrawAutoReviewAmountCleared() bool { 741 _, ok := m.clearedFields[appcoin.FieldWithdrawAutoReviewAmount] 742 return ok 743 } 744 745 // ResetWithdrawAutoReviewAmount resets all changes to the "withdraw_auto_review_amount" field. 746 func (m *AppCoinMutation) ResetWithdrawAutoReviewAmount() { 747 m.withdraw_auto_review_amount = nil 748 delete(m.clearedFields, appcoin.FieldWithdrawAutoReviewAmount) 749 } 750 751 // SetProductPage sets the "product_page" field. 752 func (m *AppCoinMutation) SetProductPage(s string) { 753 m.product_page = &s 754 } 755 756 // ProductPage returns the value of the "product_page" field in the mutation. 757 func (m *AppCoinMutation) ProductPage() (r string, exists bool) { 758 v := m.product_page 759 if v == nil { 760 return 761 } 762 return *v, true 763 } 764 765 // OldProductPage returns the old "product_page" field's value of the AppCoin entity. 766 // If the AppCoin object wasn't provided to the builder, the object is fetched from the database. 767 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 768 func (m *AppCoinMutation) OldProductPage(ctx context.Context) (v string, err error) { 769 if !m.op.Is(OpUpdateOne) { 770 return v, errors.New("OldProductPage is only allowed on UpdateOne operations") 771 } 772 if m.id == nil || m.oldValue == nil { 773 return v, errors.New("OldProductPage requires an ID field in the mutation") 774 } 775 oldValue, err := m.oldValue(ctx) 776 if err != nil { 777 return v, fmt.Errorf("querying old value for OldProductPage: %w", err) 778 } 779 return oldValue.ProductPage, nil 780 } 781 782 // ClearProductPage clears the value of the "product_page" field. 783 func (m *AppCoinMutation) ClearProductPage() { 784 m.product_page = nil 785 m.clearedFields[appcoin.FieldProductPage] = struct{}{} 786 } 787 788 // ProductPageCleared returns if the "product_page" field was cleared in this mutation. 789 func (m *AppCoinMutation) ProductPageCleared() bool { 790 _, ok := m.clearedFields[appcoin.FieldProductPage] 791 return ok 792 } 793 794 // ResetProductPage resets all changes to the "product_page" field. 795 func (m *AppCoinMutation) ResetProductPage() { 796 m.product_page = nil 797 delete(m.clearedFields, appcoin.FieldProductPage) 798 } 799 800 // SetDisabled sets the "disabled" field. 801 func (m *AppCoinMutation) SetDisabled(b bool) { 802 m.disabled = &b 803 } 804 805 // Disabled returns the value of the "disabled" field in the mutation. 806 func (m *AppCoinMutation) Disabled() (r bool, exists bool) { 807 v := m.disabled 808 if v == nil { 809 return 810 } 811 return *v, true 812 } 813 814 // OldDisabled returns the old "disabled" field's value of the AppCoin entity. 815 // If the AppCoin object wasn't provided to the builder, the object is fetched from the database. 816 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 817 func (m *AppCoinMutation) OldDisabled(ctx context.Context) (v bool, err error) { 818 if !m.op.Is(OpUpdateOne) { 819 return v, errors.New("OldDisabled is only allowed on UpdateOne operations") 820 } 821 if m.id == nil || m.oldValue == nil { 822 return v, errors.New("OldDisabled requires an ID field in the mutation") 823 } 824 oldValue, err := m.oldValue(ctx) 825 if err != nil { 826 return v, fmt.Errorf("querying old value for OldDisabled: %w", err) 827 } 828 return oldValue.Disabled, nil 829 } 830 831 // ClearDisabled clears the value of the "disabled" field. 832 func (m *AppCoinMutation) ClearDisabled() { 833 m.disabled = nil 834 m.clearedFields[appcoin.FieldDisabled] = struct{}{} 835 } 836 837 // DisabledCleared returns if the "disabled" field was cleared in this mutation. 838 func (m *AppCoinMutation) DisabledCleared() bool { 839 _, ok := m.clearedFields[appcoin.FieldDisabled] 840 return ok 841 } 842 843 // ResetDisabled resets all changes to the "disabled" field. 844 func (m *AppCoinMutation) ResetDisabled() { 845 m.disabled = nil 846 delete(m.clearedFields, appcoin.FieldDisabled) 847 } 848 849 // SetDailyRewardAmount sets the "daily_reward_amount" field. 850 func (m *AppCoinMutation) SetDailyRewardAmount(d decimal.Decimal) { 851 m.daily_reward_amount = &d 852 } 853 854 // DailyRewardAmount returns the value of the "daily_reward_amount" field in the mutation. 855 func (m *AppCoinMutation) DailyRewardAmount() (r decimal.Decimal, exists bool) { 856 v := m.daily_reward_amount 857 if v == nil { 858 return 859 } 860 return *v, true 861 } 862 863 // OldDailyRewardAmount returns the old "daily_reward_amount" field's value of the AppCoin entity. 864 // If the AppCoin object wasn't provided to the builder, the object is fetched from the database. 865 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 866 func (m *AppCoinMutation) OldDailyRewardAmount(ctx context.Context) (v decimal.Decimal, err error) { 867 if !m.op.Is(OpUpdateOne) { 868 return v, errors.New("OldDailyRewardAmount is only allowed on UpdateOne operations") 869 } 870 if m.id == nil || m.oldValue == nil { 871 return v, errors.New("OldDailyRewardAmount requires an ID field in the mutation") 872 } 873 oldValue, err := m.oldValue(ctx) 874 if err != nil { 875 return v, fmt.Errorf("querying old value for OldDailyRewardAmount: %w", err) 876 } 877 return oldValue.DailyRewardAmount, nil 878 } 879 880 // ClearDailyRewardAmount clears the value of the "daily_reward_amount" field. 881 func (m *AppCoinMutation) ClearDailyRewardAmount() { 882 m.daily_reward_amount = nil 883 m.clearedFields[appcoin.FieldDailyRewardAmount] = struct{}{} 884 } 885 886 // DailyRewardAmountCleared returns if the "daily_reward_amount" field was cleared in this mutation. 887 func (m *AppCoinMutation) DailyRewardAmountCleared() bool { 888 _, ok := m.clearedFields[appcoin.FieldDailyRewardAmount] 889 return ok 890 } 891 892 // ResetDailyRewardAmount resets all changes to the "daily_reward_amount" field. 893 func (m *AppCoinMutation) ResetDailyRewardAmount() { 894 m.daily_reward_amount = nil 895 delete(m.clearedFields, appcoin.FieldDailyRewardAmount) 896 } 897 898 // SetDisplay sets the "display" field. 899 func (m *AppCoinMutation) SetDisplay(b bool) { 900 m.display = &b 901 } 902 903 // Display returns the value of the "display" field in the mutation. 904 func (m *AppCoinMutation) Display() (r bool, exists bool) { 905 v := m.display 906 if v == nil { 907 return 908 } 909 return *v, true 910 } 911 912 // OldDisplay returns the old "display" field's value of the AppCoin entity. 913 // If the AppCoin object wasn't provided to the builder, the object is fetched from the database. 914 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 915 func (m *AppCoinMutation) OldDisplay(ctx context.Context) (v bool, err error) { 916 if !m.op.Is(OpUpdateOne) { 917 return v, errors.New("OldDisplay is only allowed on UpdateOne operations") 918 } 919 if m.id == nil || m.oldValue == nil { 920 return v, errors.New("OldDisplay requires an ID field in the mutation") 921 } 922 oldValue, err := m.oldValue(ctx) 923 if err != nil { 924 return v, fmt.Errorf("querying old value for OldDisplay: %w", err) 925 } 926 return oldValue.Display, nil 927 } 928 929 // ClearDisplay clears the value of the "display" field. 930 func (m *AppCoinMutation) ClearDisplay() { 931 m.display = nil 932 m.clearedFields[appcoin.FieldDisplay] = struct{}{} 933 } 934 935 // DisplayCleared returns if the "display" field was cleared in this mutation. 936 func (m *AppCoinMutation) DisplayCleared() bool { 937 _, ok := m.clearedFields[appcoin.FieldDisplay] 938 return ok 939 } 940 941 // ResetDisplay resets all changes to the "display" field. 942 func (m *AppCoinMutation) ResetDisplay() { 943 m.display = nil 944 delete(m.clearedFields, appcoin.FieldDisplay) 945 } 946 947 // SetDisplayIndex sets the "display_index" field. 948 func (m *AppCoinMutation) SetDisplayIndex(u uint32) { 949 m.display_index = &u 950 m.adddisplay_index = nil 951 } 952 953 // DisplayIndex returns the value of the "display_index" field in the mutation. 954 func (m *AppCoinMutation) DisplayIndex() (r uint32, exists bool) { 955 v := m.display_index 956 if v == nil { 957 return 958 } 959 return *v, true 960 } 961 962 // OldDisplayIndex returns the old "display_index" field's value of the AppCoin entity. 963 // If the AppCoin object wasn't provided to the builder, the object is fetched from the database. 964 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 965 func (m *AppCoinMutation) OldDisplayIndex(ctx context.Context) (v uint32, err error) { 966 if !m.op.Is(OpUpdateOne) { 967 return v, errors.New("OldDisplayIndex is only allowed on UpdateOne operations") 968 } 969 if m.id == nil || m.oldValue == nil { 970 return v, errors.New("OldDisplayIndex requires an ID field in the mutation") 971 } 972 oldValue, err := m.oldValue(ctx) 973 if err != nil { 974 return v, fmt.Errorf("querying old value for OldDisplayIndex: %w", err) 975 } 976 return oldValue.DisplayIndex, nil 977 } 978 979 // AddDisplayIndex adds u to the "display_index" field. 980 func (m *AppCoinMutation) AddDisplayIndex(u int32) { 981 if m.adddisplay_index != nil { 982 *m.adddisplay_index += u 983 } else { 984 m.adddisplay_index = &u 985 } 986 } 987 988 // AddedDisplayIndex returns the value that was added to the "display_index" field in this mutation. 989 func (m *AppCoinMutation) AddedDisplayIndex() (r int32, exists bool) { 990 v := m.adddisplay_index 991 if v == nil { 992 return 993 } 994 return *v, true 995 } 996 997 // ClearDisplayIndex clears the value of the "display_index" field. 998 func (m *AppCoinMutation) ClearDisplayIndex() { 999 m.display_index = nil 1000 m.adddisplay_index = nil 1001 m.clearedFields[appcoin.FieldDisplayIndex] = struct{}{} 1002 } 1003 1004 // DisplayIndexCleared returns if the "display_index" field was cleared in this mutation. 1005 func (m *AppCoinMutation) DisplayIndexCleared() bool { 1006 _, ok := m.clearedFields[appcoin.FieldDisplayIndex] 1007 return ok 1008 } 1009 1010 // ResetDisplayIndex resets all changes to the "display_index" field. 1011 func (m *AppCoinMutation) ResetDisplayIndex() { 1012 m.display_index = nil 1013 m.adddisplay_index = nil 1014 delete(m.clearedFields, appcoin.FieldDisplayIndex) 1015 } 1016 1017 // SetMaxAmountPerWithdraw sets the "max_amount_per_withdraw" field. 1018 func (m *AppCoinMutation) SetMaxAmountPerWithdraw(d decimal.Decimal) { 1019 m.max_amount_per_withdraw = &d 1020 } 1021 1022 // MaxAmountPerWithdraw returns the value of the "max_amount_per_withdraw" field in the mutation. 1023 func (m *AppCoinMutation) MaxAmountPerWithdraw() (r decimal.Decimal, exists bool) { 1024 v := m.max_amount_per_withdraw 1025 if v == nil { 1026 return 1027 } 1028 return *v, true 1029 } 1030 1031 // OldMaxAmountPerWithdraw returns the old "max_amount_per_withdraw" field's value of the AppCoin entity. 1032 // If the AppCoin object wasn't provided to the builder, the object is fetched from the database. 1033 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 1034 func (m *AppCoinMutation) OldMaxAmountPerWithdraw(ctx context.Context) (v decimal.Decimal, err error) { 1035 if !m.op.Is(OpUpdateOne) { 1036 return v, errors.New("OldMaxAmountPerWithdraw is only allowed on UpdateOne operations") 1037 } 1038 if m.id == nil || m.oldValue == nil { 1039 return v, errors.New("OldMaxAmountPerWithdraw requires an ID field in the mutation") 1040 } 1041 oldValue, err := m.oldValue(ctx) 1042 if err != nil { 1043 return v, fmt.Errorf("querying old value for OldMaxAmountPerWithdraw: %w", err) 1044 } 1045 return oldValue.MaxAmountPerWithdraw, nil 1046 } 1047 1048 // ClearMaxAmountPerWithdraw clears the value of the "max_amount_per_withdraw" field. 1049 func (m *AppCoinMutation) ClearMaxAmountPerWithdraw() { 1050 m.max_amount_per_withdraw = nil 1051 m.clearedFields[appcoin.FieldMaxAmountPerWithdraw] = struct{}{} 1052 } 1053 1054 // MaxAmountPerWithdrawCleared returns if the "max_amount_per_withdraw" field was cleared in this mutation. 1055 func (m *AppCoinMutation) MaxAmountPerWithdrawCleared() bool { 1056 _, ok := m.clearedFields[appcoin.FieldMaxAmountPerWithdraw] 1057 return ok 1058 } 1059 1060 // ResetMaxAmountPerWithdraw resets all changes to the "max_amount_per_withdraw" field. 1061 func (m *AppCoinMutation) ResetMaxAmountPerWithdraw() { 1062 m.max_amount_per_withdraw = nil 1063 delete(m.clearedFields, appcoin.FieldMaxAmountPerWithdraw) 1064 } 1065 1066 // Where appends a list predicates to the AppCoinMutation builder. 1067 func (m *AppCoinMutation) Where(ps ...predicate.AppCoin) { 1068 m.predicates = append(m.predicates, ps...) 1069 } 1070 1071 // Op returns the operation name. 1072 func (m *AppCoinMutation) Op() Op { 1073 return m.op 1074 } 1075 1076 // Type returns the node type of this mutation (AppCoin). 1077 func (m *AppCoinMutation) Type() string { 1078 return m.typ 1079 } 1080 1081 // Fields returns all fields that were changed during this mutation. Note that in 1082 // order to get all numeric fields that were incremented/decremented, call 1083 // AddedFields(). 1084 func (m *AppCoinMutation) Fields() []string { 1085 fields := make([]string, 0, 17) 1086 if m.created_at != nil { 1087 fields = append(fields, appcoin.FieldCreatedAt) 1088 } 1089 if m.updated_at != nil { 1090 fields = append(fields, appcoin.FieldUpdatedAt) 1091 } 1092 if m.deleted_at != nil { 1093 fields = append(fields, appcoin.FieldDeletedAt) 1094 } 1095 if m.ent_id != nil { 1096 fields = append(fields, appcoin.FieldEntID) 1097 } 1098 if m.app_id != nil { 1099 fields = append(fields, appcoin.FieldAppID) 1100 } 1101 if m.coin_type_id != nil { 1102 fields = append(fields, appcoin.FieldCoinTypeID) 1103 } 1104 if m.name != nil { 1105 fields = append(fields, appcoin.FieldName) 1106 } 1107 if m.display_names != nil { 1108 fields = append(fields, appcoin.FieldDisplayNames) 1109 } 1110 if m.logo != nil { 1111 fields = append(fields, appcoin.FieldLogo) 1112 } 1113 if m.for_pay != nil { 1114 fields = append(fields, appcoin.FieldForPay) 1115 } 1116 if m.withdraw_auto_review_amount != nil { 1117 fields = append(fields, appcoin.FieldWithdrawAutoReviewAmount) 1118 } 1119 if m.product_page != nil { 1120 fields = append(fields, appcoin.FieldProductPage) 1121 } 1122 if m.disabled != nil { 1123 fields = append(fields, appcoin.FieldDisabled) 1124 } 1125 if m.daily_reward_amount != nil { 1126 fields = append(fields, appcoin.FieldDailyRewardAmount) 1127 } 1128 if m.display != nil { 1129 fields = append(fields, appcoin.FieldDisplay) 1130 } 1131 if m.display_index != nil { 1132 fields = append(fields, appcoin.FieldDisplayIndex) 1133 } 1134 if m.max_amount_per_withdraw != nil { 1135 fields = append(fields, appcoin.FieldMaxAmountPerWithdraw) 1136 } 1137 return fields 1138 } 1139 1140 // Field returns the value of a field with the given name. The second boolean 1141 // return value indicates that this field was not set, or was not defined in the 1142 // schema. 1143 func (m *AppCoinMutation) Field(name string) (ent.Value, bool) { 1144 switch name { 1145 case appcoin.FieldCreatedAt: 1146 return m.CreatedAt() 1147 case appcoin.FieldUpdatedAt: 1148 return m.UpdatedAt() 1149 case appcoin.FieldDeletedAt: 1150 return m.DeletedAt() 1151 case appcoin.FieldEntID: 1152 return m.EntID() 1153 case appcoin.FieldAppID: 1154 return m.AppID() 1155 case appcoin.FieldCoinTypeID: 1156 return m.CoinTypeID() 1157 case appcoin.FieldName: 1158 return m.Name() 1159 case appcoin.FieldDisplayNames: 1160 return m.DisplayNames() 1161 case appcoin.FieldLogo: 1162 return m.Logo() 1163 case appcoin.FieldForPay: 1164 return m.ForPay() 1165 case appcoin.FieldWithdrawAutoReviewAmount: 1166 return m.WithdrawAutoReviewAmount() 1167 case appcoin.FieldProductPage: 1168 return m.ProductPage() 1169 case appcoin.FieldDisabled: 1170 return m.Disabled() 1171 case appcoin.FieldDailyRewardAmount: 1172 return m.DailyRewardAmount() 1173 case appcoin.FieldDisplay: 1174 return m.Display() 1175 case appcoin.FieldDisplayIndex: 1176 return m.DisplayIndex() 1177 case appcoin.FieldMaxAmountPerWithdraw: 1178 return m.MaxAmountPerWithdraw() 1179 } 1180 return nil, false 1181 } 1182 1183 // OldField returns the old value of the field from the database. An error is 1184 // returned if the mutation operation is not UpdateOne, or the query to the 1185 // database failed. 1186 func (m *AppCoinMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 1187 switch name { 1188 case appcoin.FieldCreatedAt: 1189 return m.OldCreatedAt(ctx) 1190 case appcoin.FieldUpdatedAt: 1191 return m.OldUpdatedAt(ctx) 1192 case appcoin.FieldDeletedAt: 1193 return m.OldDeletedAt(ctx) 1194 case appcoin.FieldEntID: 1195 return m.OldEntID(ctx) 1196 case appcoin.FieldAppID: 1197 return m.OldAppID(ctx) 1198 case appcoin.FieldCoinTypeID: 1199 return m.OldCoinTypeID(ctx) 1200 case appcoin.FieldName: 1201 return m.OldName(ctx) 1202 case appcoin.FieldDisplayNames: 1203 return m.OldDisplayNames(ctx) 1204 case appcoin.FieldLogo: 1205 return m.OldLogo(ctx) 1206 case appcoin.FieldForPay: 1207 return m.OldForPay(ctx) 1208 case appcoin.FieldWithdrawAutoReviewAmount: 1209 return m.OldWithdrawAutoReviewAmount(ctx) 1210 case appcoin.FieldProductPage: 1211 return m.OldProductPage(ctx) 1212 case appcoin.FieldDisabled: 1213 return m.OldDisabled(ctx) 1214 case appcoin.FieldDailyRewardAmount: 1215 return m.OldDailyRewardAmount(ctx) 1216 case appcoin.FieldDisplay: 1217 return m.OldDisplay(ctx) 1218 case appcoin.FieldDisplayIndex: 1219 return m.OldDisplayIndex(ctx) 1220 case appcoin.FieldMaxAmountPerWithdraw: 1221 return m.OldMaxAmountPerWithdraw(ctx) 1222 } 1223 return nil, fmt.Errorf("unknown AppCoin field %s", name) 1224 } 1225 1226 // SetField sets the value of a field with the given name. It returns an error if 1227 // the field is not defined in the schema, or if the type mismatched the field 1228 // type. 1229 func (m *AppCoinMutation) SetField(name string, value ent.Value) error { 1230 switch name { 1231 case appcoin.FieldCreatedAt: 1232 v, ok := value.(uint32) 1233 if !ok { 1234 return fmt.Errorf("unexpected type %T for field %s", value, name) 1235 } 1236 m.SetCreatedAt(v) 1237 return nil 1238 case appcoin.FieldUpdatedAt: 1239 v, ok := value.(uint32) 1240 if !ok { 1241 return fmt.Errorf("unexpected type %T for field %s", value, name) 1242 } 1243 m.SetUpdatedAt(v) 1244 return nil 1245 case appcoin.FieldDeletedAt: 1246 v, ok := value.(uint32) 1247 if !ok { 1248 return fmt.Errorf("unexpected type %T for field %s", value, name) 1249 } 1250 m.SetDeletedAt(v) 1251 return nil 1252 case appcoin.FieldEntID: 1253 v, ok := value.(uuid.UUID) 1254 if !ok { 1255 return fmt.Errorf("unexpected type %T for field %s", value, name) 1256 } 1257 m.SetEntID(v) 1258 return nil 1259 case appcoin.FieldAppID: 1260 v, ok := value.(uuid.UUID) 1261 if !ok { 1262 return fmt.Errorf("unexpected type %T for field %s", value, name) 1263 } 1264 m.SetAppID(v) 1265 return nil 1266 case appcoin.FieldCoinTypeID: 1267 v, ok := value.(uuid.UUID) 1268 if !ok { 1269 return fmt.Errorf("unexpected type %T for field %s", value, name) 1270 } 1271 m.SetCoinTypeID(v) 1272 return nil 1273 case appcoin.FieldName: 1274 v, ok := value.(string) 1275 if !ok { 1276 return fmt.Errorf("unexpected type %T for field %s", value, name) 1277 } 1278 m.SetName(v) 1279 return nil 1280 case appcoin.FieldDisplayNames: 1281 v, ok := value.([]string) 1282 if !ok { 1283 return fmt.Errorf("unexpected type %T for field %s", value, name) 1284 } 1285 m.SetDisplayNames(v) 1286 return nil 1287 case appcoin.FieldLogo: 1288 v, ok := value.(string) 1289 if !ok { 1290 return fmt.Errorf("unexpected type %T for field %s", value, name) 1291 } 1292 m.SetLogo(v) 1293 return nil 1294 case appcoin.FieldForPay: 1295 v, ok := value.(bool) 1296 if !ok { 1297 return fmt.Errorf("unexpected type %T for field %s", value, name) 1298 } 1299 m.SetForPay(v) 1300 return nil 1301 case appcoin.FieldWithdrawAutoReviewAmount: 1302 v, ok := value.(decimal.Decimal) 1303 if !ok { 1304 return fmt.Errorf("unexpected type %T for field %s", value, name) 1305 } 1306 m.SetWithdrawAutoReviewAmount(v) 1307 return nil 1308 case appcoin.FieldProductPage: 1309 v, ok := value.(string) 1310 if !ok { 1311 return fmt.Errorf("unexpected type %T for field %s", value, name) 1312 } 1313 m.SetProductPage(v) 1314 return nil 1315 case appcoin.FieldDisabled: 1316 v, ok := value.(bool) 1317 if !ok { 1318 return fmt.Errorf("unexpected type %T for field %s", value, name) 1319 } 1320 m.SetDisabled(v) 1321 return nil 1322 case appcoin.FieldDailyRewardAmount: 1323 v, ok := value.(decimal.Decimal) 1324 if !ok { 1325 return fmt.Errorf("unexpected type %T for field %s", value, name) 1326 } 1327 m.SetDailyRewardAmount(v) 1328 return nil 1329 case appcoin.FieldDisplay: 1330 v, ok := value.(bool) 1331 if !ok { 1332 return fmt.Errorf("unexpected type %T for field %s", value, name) 1333 } 1334 m.SetDisplay(v) 1335 return nil 1336 case appcoin.FieldDisplayIndex: 1337 v, ok := value.(uint32) 1338 if !ok { 1339 return fmt.Errorf("unexpected type %T for field %s", value, name) 1340 } 1341 m.SetDisplayIndex(v) 1342 return nil 1343 case appcoin.FieldMaxAmountPerWithdraw: 1344 v, ok := value.(decimal.Decimal) 1345 if !ok { 1346 return fmt.Errorf("unexpected type %T for field %s", value, name) 1347 } 1348 m.SetMaxAmountPerWithdraw(v) 1349 return nil 1350 } 1351 return fmt.Errorf("unknown AppCoin field %s", name) 1352 } 1353 1354 // AddedFields returns all numeric fields that were incremented/decremented during 1355 // this mutation. 1356 func (m *AppCoinMutation) AddedFields() []string { 1357 var fields []string 1358 if m.addcreated_at != nil { 1359 fields = append(fields, appcoin.FieldCreatedAt) 1360 } 1361 if m.addupdated_at != nil { 1362 fields = append(fields, appcoin.FieldUpdatedAt) 1363 } 1364 if m.adddeleted_at != nil { 1365 fields = append(fields, appcoin.FieldDeletedAt) 1366 } 1367 if m.adddisplay_index != nil { 1368 fields = append(fields, appcoin.FieldDisplayIndex) 1369 } 1370 return fields 1371 } 1372 1373 // AddedField returns the numeric value that was incremented/decremented on a field 1374 // with the given name. The second boolean return value indicates that this field 1375 // was not set, or was not defined in the schema. 1376 func (m *AppCoinMutation) AddedField(name string) (ent.Value, bool) { 1377 switch name { 1378 case appcoin.FieldCreatedAt: 1379 return m.AddedCreatedAt() 1380 case appcoin.FieldUpdatedAt: 1381 return m.AddedUpdatedAt() 1382 case appcoin.FieldDeletedAt: 1383 return m.AddedDeletedAt() 1384 case appcoin.FieldDisplayIndex: 1385 return m.AddedDisplayIndex() 1386 } 1387 return nil, false 1388 } 1389 1390 // AddField adds the value to the field with the given name. It returns an error if 1391 // the field is not defined in the schema, or if the type mismatched the field 1392 // type. 1393 func (m *AppCoinMutation) AddField(name string, value ent.Value) error { 1394 switch name { 1395 case appcoin.FieldCreatedAt: 1396 v, ok := value.(int32) 1397 if !ok { 1398 return fmt.Errorf("unexpected type %T for field %s", value, name) 1399 } 1400 m.AddCreatedAt(v) 1401 return nil 1402 case appcoin.FieldUpdatedAt: 1403 v, ok := value.(int32) 1404 if !ok { 1405 return fmt.Errorf("unexpected type %T for field %s", value, name) 1406 } 1407 m.AddUpdatedAt(v) 1408 return nil 1409 case appcoin.FieldDeletedAt: 1410 v, ok := value.(int32) 1411 if !ok { 1412 return fmt.Errorf("unexpected type %T for field %s", value, name) 1413 } 1414 m.AddDeletedAt(v) 1415 return nil 1416 case appcoin.FieldDisplayIndex: 1417 v, ok := value.(int32) 1418 if !ok { 1419 return fmt.Errorf("unexpected type %T for field %s", value, name) 1420 } 1421 m.AddDisplayIndex(v) 1422 return nil 1423 } 1424 return fmt.Errorf("unknown AppCoin numeric field %s", name) 1425 } 1426 1427 // ClearedFields returns all nullable fields that were cleared during this 1428 // mutation. 1429 func (m *AppCoinMutation) ClearedFields() []string { 1430 var fields []string 1431 if m.FieldCleared(appcoin.FieldAppID) { 1432 fields = append(fields, appcoin.FieldAppID) 1433 } 1434 if m.FieldCleared(appcoin.FieldCoinTypeID) { 1435 fields = append(fields, appcoin.FieldCoinTypeID) 1436 } 1437 if m.FieldCleared(appcoin.FieldName) { 1438 fields = append(fields, appcoin.FieldName) 1439 } 1440 if m.FieldCleared(appcoin.FieldDisplayNames) { 1441 fields = append(fields, appcoin.FieldDisplayNames) 1442 } 1443 if m.FieldCleared(appcoin.FieldLogo) { 1444 fields = append(fields, appcoin.FieldLogo) 1445 } 1446 if m.FieldCleared(appcoin.FieldForPay) { 1447 fields = append(fields, appcoin.FieldForPay) 1448 } 1449 if m.FieldCleared(appcoin.FieldWithdrawAutoReviewAmount) { 1450 fields = append(fields, appcoin.FieldWithdrawAutoReviewAmount) 1451 } 1452 if m.FieldCleared(appcoin.FieldProductPage) { 1453 fields = append(fields, appcoin.FieldProductPage) 1454 } 1455 if m.FieldCleared(appcoin.FieldDisabled) { 1456 fields = append(fields, appcoin.FieldDisabled) 1457 } 1458 if m.FieldCleared(appcoin.FieldDailyRewardAmount) { 1459 fields = append(fields, appcoin.FieldDailyRewardAmount) 1460 } 1461 if m.FieldCleared(appcoin.FieldDisplay) { 1462 fields = append(fields, appcoin.FieldDisplay) 1463 } 1464 if m.FieldCleared(appcoin.FieldDisplayIndex) { 1465 fields = append(fields, appcoin.FieldDisplayIndex) 1466 } 1467 if m.FieldCleared(appcoin.FieldMaxAmountPerWithdraw) { 1468 fields = append(fields, appcoin.FieldMaxAmountPerWithdraw) 1469 } 1470 return fields 1471 } 1472 1473 // FieldCleared returns a boolean indicating if a field with the given name was 1474 // cleared in this mutation. 1475 func (m *AppCoinMutation) FieldCleared(name string) bool { 1476 _, ok := m.clearedFields[name] 1477 return ok 1478 } 1479 1480 // ClearField clears the value of the field with the given name. It returns an 1481 // error if the field is not defined in the schema. 1482 func (m *AppCoinMutation) ClearField(name string) error { 1483 switch name { 1484 case appcoin.FieldAppID: 1485 m.ClearAppID() 1486 return nil 1487 case appcoin.FieldCoinTypeID: 1488 m.ClearCoinTypeID() 1489 return nil 1490 case appcoin.FieldName: 1491 m.ClearName() 1492 return nil 1493 case appcoin.FieldDisplayNames: 1494 m.ClearDisplayNames() 1495 return nil 1496 case appcoin.FieldLogo: 1497 m.ClearLogo() 1498 return nil 1499 case appcoin.FieldForPay: 1500 m.ClearForPay() 1501 return nil 1502 case appcoin.FieldWithdrawAutoReviewAmount: 1503 m.ClearWithdrawAutoReviewAmount() 1504 return nil 1505 case appcoin.FieldProductPage: 1506 m.ClearProductPage() 1507 return nil 1508 case appcoin.FieldDisabled: 1509 m.ClearDisabled() 1510 return nil 1511 case appcoin.FieldDailyRewardAmount: 1512 m.ClearDailyRewardAmount() 1513 return nil 1514 case appcoin.FieldDisplay: 1515 m.ClearDisplay() 1516 return nil 1517 case appcoin.FieldDisplayIndex: 1518 m.ClearDisplayIndex() 1519 return nil 1520 case appcoin.FieldMaxAmountPerWithdraw: 1521 m.ClearMaxAmountPerWithdraw() 1522 return nil 1523 } 1524 return fmt.Errorf("unknown AppCoin nullable field %s", name) 1525 } 1526 1527 // ResetField resets all changes in the mutation for the field with the given name. 1528 // It returns an error if the field is not defined in the schema. 1529 func (m *AppCoinMutation) ResetField(name string) error { 1530 switch name { 1531 case appcoin.FieldCreatedAt: 1532 m.ResetCreatedAt() 1533 return nil 1534 case appcoin.FieldUpdatedAt: 1535 m.ResetUpdatedAt() 1536 return nil 1537 case appcoin.FieldDeletedAt: 1538 m.ResetDeletedAt() 1539 return nil 1540 case appcoin.FieldEntID: 1541 m.ResetEntID() 1542 return nil 1543 case appcoin.FieldAppID: 1544 m.ResetAppID() 1545 return nil 1546 case appcoin.FieldCoinTypeID: 1547 m.ResetCoinTypeID() 1548 return nil 1549 case appcoin.FieldName: 1550 m.ResetName() 1551 return nil 1552 case appcoin.FieldDisplayNames: 1553 m.ResetDisplayNames() 1554 return nil 1555 case appcoin.FieldLogo: 1556 m.ResetLogo() 1557 return nil 1558 case appcoin.FieldForPay: 1559 m.ResetForPay() 1560 return nil 1561 case appcoin.FieldWithdrawAutoReviewAmount: 1562 m.ResetWithdrawAutoReviewAmount() 1563 return nil 1564 case appcoin.FieldProductPage: 1565 m.ResetProductPage() 1566 return nil 1567 case appcoin.FieldDisabled: 1568 m.ResetDisabled() 1569 return nil 1570 case appcoin.FieldDailyRewardAmount: 1571 m.ResetDailyRewardAmount() 1572 return nil 1573 case appcoin.FieldDisplay: 1574 m.ResetDisplay() 1575 return nil 1576 case appcoin.FieldDisplayIndex: 1577 m.ResetDisplayIndex() 1578 return nil 1579 case appcoin.FieldMaxAmountPerWithdraw: 1580 m.ResetMaxAmountPerWithdraw() 1581 return nil 1582 } 1583 return fmt.Errorf("unknown AppCoin field %s", name) 1584 } 1585 1586 // AddedEdges returns all edge names that were set/added in this mutation. 1587 func (m *AppCoinMutation) AddedEdges() []string { 1588 edges := make([]string, 0, 0) 1589 return edges 1590 } 1591 1592 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 1593 // name in this mutation. 1594 func (m *AppCoinMutation) AddedIDs(name string) []ent.Value { 1595 return nil 1596 } 1597 1598 // RemovedEdges returns all edge names that were removed in this mutation. 1599 func (m *AppCoinMutation) RemovedEdges() []string { 1600 edges := make([]string, 0, 0) 1601 return edges 1602 } 1603 1604 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 1605 // the given name in this mutation. 1606 func (m *AppCoinMutation) RemovedIDs(name string) []ent.Value { 1607 return nil 1608 } 1609 1610 // ClearedEdges returns all edge names that were cleared in this mutation. 1611 func (m *AppCoinMutation) ClearedEdges() []string { 1612 edges := make([]string, 0, 0) 1613 return edges 1614 } 1615 1616 // EdgeCleared returns a boolean which indicates if the edge with the given name 1617 // was cleared in this mutation. 1618 func (m *AppCoinMutation) EdgeCleared(name string) bool { 1619 return false 1620 } 1621 1622 // ClearEdge clears the value of the edge with the given name. It returns an error 1623 // if that edge is not defined in the schema. 1624 func (m *AppCoinMutation) ClearEdge(name string) error { 1625 return fmt.Errorf("unknown AppCoin unique edge %s", name) 1626 } 1627 1628 // ResetEdge resets all changes to the edge with the given name in this mutation. 1629 // It returns an error if the edge is not defined in the schema. 1630 func (m *AppCoinMutation) ResetEdge(name string) error { 1631 return fmt.Errorf("unknown AppCoin edge %s", name) 1632 } 1633 1634 // ChainBaseMutation represents an operation that mutates the ChainBase nodes in the graph. 1635 type ChainBaseMutation struct { 1636 config 1637 op Op 1638 typ string 1639 id *uint32 1640 created_at *uint32 1641 addcreated_at *int32 1642 updated_at *uint32 1643 addupdated_at *int32 1644 deleted_at *uint32 1645 adddeleted_at *int32 1646 ent_id *uuid.UUID 1647 name *string 1648 logo *string 1649 native_unit *string 1650 atomic_unit *string 1651 unit_exp *uint32 1652 addunit_exp *int32 1653 env *string 1654 chain_id *string 1655 nickname *string 1656 gas_type *string 1657 clearedFields map[string]struct{} 1658 done bool 1659 oldValue func(context.Context) (*ChainBase, error) 1660 predicates []predicate.ChainBase 1661 } 1662 1663 var _ ent.Mutation = (*ChainBaseMutation)(nil) 1664 1665 // chainbaseOption allows management of the mutation configuration using functional options. 1666 type chainbaseOption func(*ChainBaseMutation) 1667 1668 // newChainBaseMutation creates new mutation for the ChainBase entity. 1669 func newChainBaseMutation(c config, op Op, opts ...chainbaseOption) *ChainBaseMutation { 1670 m := &ChainBaseMutation{ 1671 config: c, 1672 op: op, 1673 typ: TypeChainBase, 1674 clearedFields: make(map[string]struct{}), 1675 } 1676 for _, opt := range opts { 1677 opt(m) 1678 } 1679 return m 1680 } 1681 1682 // withChainBaseID sets the ID field of the mutation. 1683 func withChainBaseID(id uint32) chainbaseOption { 1684 return func(m *ChainBaseMutation) { 1685 var ( 1686 err error 1687 once sync.Once 1688 value *ChainBase 1689 ) 1690 m.oldValue = func(ctx context.Context) (*ChainBase, error) { 1691 once.Do(func() { 1692 if m.done { 1693 err = errors.New("querying old values post mutation is not allowed") 1694 } else { 1695 value, err = m.Client().ChainBase.Get(ctx, id) 1696 } 1697 }) 1698 return value, err 1699 } 1700 m.id = &id 1701 } 1702 } 1703 1704 // withChainBase sets the old ChainBase of the mutation. 1705 func withChainBase(node *ChainBase) chainbaseOption { 1706 return func(m *ChainBaseMutation) { 1707 m.oldValue = func(context.Context) (*ChainBase, error) { 1708 return node, nil 1709 } 1710 m.id = &node.ID 1711 } 1712 } 1713 1714 // Client returns a new `ent.Client` from the mutation. If the mutation was 1715 // executed in a transaction (ent.Tx), a transactional client is returned. 1716 func (m ChainBaseMutation) Client() *Client { 1717 client := &Client{config: m.config} 1718 client.init() 1719 return client 1720 } 1721 1722 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 1723 // it returns an error otherwise. 1724 func (m ChainBaseMutation) Tx() (*Tx, error) { 1725 if _, ok := m.driver.(*txDriver); !ok { 1726 return nil, errors.New("ent: mutation is not running in a transaction") 1727 } 1728 tx := &Tx{config: m.config} 1729 tx.init() 1730 return tx, nil 1731 } 1732 1733 // SetID sets the value of the id field. Note that this 1734 // operation is only accepted on creation of ChainBase entities. 1735 func (m *ChainBaseMutation) SetID(id uint32) { 1736 m.id = &id 1737 } 1738 1739 // ID returns the ID value in the mutation. Note that the ID is only available 1740 // if it was provided to the builder or after it was returned from the database. 1741 func (m *ChainBaseMutation) ID() (id uint32, exists bool) { 1742 if m.id == nil { 1743 return 1744 } 1745 return *m.id, true 1746 } 1747 1748 // IDs queries the database and returns the entity ids that match the mutation's predicate. 1749 // That means, if the mutation is applied within a transaction with an isolation level such 1750 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 1751 // or updated by the mutation. 1752 func (m *ChainBaseMutation) IDs(ctx context.Context) ([]uint32, error) { 1753 switch { 1754 case m.op.Is(OpUpdateOne | OpDeleteOne): 1755 id, exists := m.ID() 1756 if exists { 1757 return []uint32{id}, nil 1758 } 1759 fallthrough 1760 case m.op.Is(OpUpdate | OpDelete): 1761 return m.Client().ChainBase.Query().Where(m.predicates...).IDs(ctx) 1762 default: 1763 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 1764 } 1765 } 1766 1767 // SetCreatedAt sets the "created_at" field. 1768 func (m *ChainBaseMutation) SetCreatedAt(u uint32) { 1769 m.created_at = &u 1770 m.addcreated_at = nil 1771 } 1772 1773 // CreatedAt returns the value of the "created_at" field in the mutation. 1774 func (m *ChainBaseMutation) CreatedAt() (r uint32, exists bool) { 1775 v := m.created_at 1776 if v == nil { 1777 return 1778 } 1779 return *v, true 1780 } 1781 1782 // OldCreatedAt returns the old "created_at" field's value of the ChainBase entity. 1783 // If the ChainBase object wasn't provided to the builder, the object is fetched from the database. 1784 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 1785 func (m *ChainBaseMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 1786 if !m.op.Is(OpUpdateOne) { 1787 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 1788 } 1789 if m.id == nil || m.oldValue == nil { 1790 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 1791 } 1792 oldValue, err := m.oldValue(ctx) 1793 if err != nil { 1794 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 1795 } 1796 return oldValue.CreatedAt, nil 1797 } 1798 1799 // AddCreatedAt adds u to the "created_at" field. 1800 func (m *ChainBaseMutation) AddCreatedAt(u int32) { 1801 if m.addcreated_at != nil { 1802 *m.addcreated_at += u 1803 } else { 1804 m.addcreated_at = &u 1805 } 1806 } 1807 1808 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 1809 func (m *ChainBaseMutation) AddedCreatedAt() (r int32, exists bool) { 1810 v := m.addcreated_at 1811 if v == nil { 1812 return 1813 } 1814 return *v, true 1815 } 1816 1817 // ResetCreatedAt resets all changes to the "created_at" field. 1818 func (m *ChainBaseMutation) ResetCreatedAt() { 1819 m.created_at = nil 1820 m.addcreated_at = nil 1821 } 1822 1823 // SetUpdatedAt sets the "updated_at" field. 1824 func (m *ChainBaseMutation) SetUpdatedAt(u uint32) { 1825 m.updated_at = &u 1826 m.addupdated_at = nil 1827 } 1828 1829 // UpdatedAt returns the value of the "updated_at" field in the mutation. 1830 func (m *ChainBaseMutation) UpdatedAt() (r uint32, exists bool) { 1831 v := m.updated_at 1832 if v == nil { 1833 return 1834 } 1835 return *v, true 1836 } 1837 1838 // OldUpdatedAt returns the old "updated_at" field's value of the ChainBase entity. 1839 // If the ChainBase object wasn't provided to the builder, the object is fetched from the database. 1840 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 1841 func (m *ChainBaseMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 1842 if !m.op.Is(OpUpdateOne) { 1843 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 1844 } 1845 if m.id == nil || m.oldValue == nil { 1846 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 1847 } 1848 oldValue, err := m.oldValue(ctx) 1849 if err != nil { 1850 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 1851 } 1852 return oldValue.UpdatedAt, nil 1853 } 1854 1855 // AddUpdatedAt adds u to the "updated_at" field. 1856 func (m *ChainBaseMutation) AddUpdatedAt(u int32) { 1857 if m.addupdated_at != nil { 1858 *m.addupdated_at += u 1859 } else { 1860 m.addupdated_at = &u 1861 } 1862 } 1863 1864 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 1865 func (m *ChainBaseMutation) AddedUpdatedAt() (r int32, exists bool) { 1866 v := m.addupdated_at 1867 if v == nil { 1868 return 1869 } 1870 return *v, true 1871 } 1872 1873 // ResetUpdatedAt resets all changes to the "updated_at" field. 1874 func (m *ChainBaseMutation) ResetUpdatedAt() { 1875 m.updated_at = nil 1876 m.addupdated_at = nil 1877 } 1878 1879 // SetDeletedAt sets the "deleted_at" field. 1880 func (m *ChainBaseMutation) SetDeletedAt(u uint32) { 1881 m.deleted_at = &u 1882 m.adddeleted_at = nil 1883 } 1884 1885 // DeletedAt returns the value of the "deleted_at" field in the mutation. 1886 func (m *ChainBaseMutation) DeletedAt() (r uint32, exists bool) { 1887 v := m.deleted_at 1888 if v == nil { 1889 return 1890 } 1891 return *v, true 1892 } 1893 1894 // OldDeletedAt returns the old "deleted_at" field's value of the ChainBase entity. 1895 // If the ChainBase object wasn't provided to the builder, the object is fetched from the database. 1896 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 1897 func (m *ChainBaseMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 1898 if !m.op.Is(OpUpdateOne) { 1899 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 1900 } 1901 if m.id == nil || m.oldValue == nil { 1902 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 1903 } 1904 oldValue, err := m.oldValue(ctx) 1905 if err != nil { 1906 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 1907 } 1908 return oldValue.DeletedAt, nil 1909 } 1910 1911 // AddDeletedAt adds u to the "deleted_at" field. 1912 func (m *ChainBaseMutation) AddDeletedAt(u int32) { 1913 if m.adddeleted_at != nil { 1914 *m.adddeleted_at += u 1915 } else { 1916 m.adddeleted_at = &u 1917 } 1918 } 1919 1920 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 1921 func (m *ChainBaseMutation) AddedDeletedAt() (r int32, exists bool) { 1922 v := m.adddeleted_at 1923 if v == nil { 1924 return 1925 } 1926 return *v, true 1927 } 1928 1929 // ResetDeletedAt resets all changes to the "deleted_at" field. 1930 func (m *ChainBaseMutation) ResetDeletedAt() { 1931 m.deleted_at = nil 1932 m.adddeleted_at = nil 1933 } 1934 1935 // SetEntID sets the "ent_id" field. 1936 func (m *ChainBaseMutation) SetEntID(u uuid.UUID) { 1937 m.ent_id = &u 1938 } 1939 1940 // EntID returns the value of the "ent_id" field in the mutation. 1941 func (m *ChainBaseMutation) EntID() (r uuid.UUID, exists bool) { 1942 v := m.ent_id 1943 if v == nil { 1944 return 1945 } 1946 return *v, true 1947 } 1948 1949 // OldEntID returns the old "ent_id" field's value of the ChainBase entity. 1950 // If the ChainBase object wasn't provided to the builder, the object is fetched from the database. 1951 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 1952 func (m *ChainBaseMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 1953 if !m.op.Is(OpUpdateOne) { 1954 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 1955 } 1956 if m.id == nil || m.oldValue == nil { 1957 return v, errors.New("OldEntID requires an ID field in the mutation") 1958 } 1959 oldValue, err := m.oldValue(ctx) 1960 if err != nil { 1961 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 1962 } 1963 return oldValue.EntID, nil 1964 } 1965 1966 // ResetEntID resets all changes to the "ent_id" field. 1967 func (m *ChainBaseMutation) ResetEntID() { 1968 m.ent_id = nil 1969 } 1970 1971 // SetName sets the "name" field. 1972 func (m *ChainBaseMutation) SetName(s string) { 1973 m.name = &s 1974 } 1975 1976 // Name returns the value of the "name" field in the mutation. 1977 func (m *ChainBaseMutation) Name() (r string, exists bool) { 1978 v := m.name 1979 if v == nil { 1980 return 1981 } 1982 return *v, true 1983 } 1984 1985 // OldName returns the old "name" field's value of the ChainBase entity. 1986 // If the ChainBase object wasn't provided to the builder, the object is fetched from the database. 1987 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 1988 func (m *ChainBaseMutation) OldName(ctx context.Context) (v string, err error) { 1989 if !m.op.Is(OpUpdateOne) { 1990 return v, errors.New("OldName is only allowed on UpdateOne operations") 1991 } 1992 if m.id == nil || m.oldValue == nil { 1993 return v, errors.New("OldName requires an ID field in the mutation") 1994 } 1995 oldValue, err := m.oldValue(ctx) 1996 if err != nil { 1997 return v, fmt.Errorf("querying old value for OldName: %w", err) 1998 } 1999 return oldValue.Name, nil 2000 } 2001 2002 // ClearName clears the value of the "name" field. 2003 func (m *ChainBaseMutation) ClearName() { 2004 m.name = nil 2005 m.clearedFields[chainbase.FieldName] = struct{}{} 2006 } 2007 2008 // NameCleared returns if the "name" field was cleared in this mutation. 2009 func (m *ChainBaseMutation) NameCleared() bool { 2010 _, ok := m.clearedFields[chainbase.FieldName] 2011 return ok 2012 } 2013 2014 // ResetName resets all changes to the "name" field. 2015 func (m *ChainBaseMutation) ResetName() { 2016 m.name = nil 2017 delete(m.clearedFields, chainbase.FieldName) 2018 } 2019 2020 // SetLogo sets the "logo" field. 2021 func (m *ChainBaseMutation) SetLogo(s string) { 2022 m.logo = &s 2023 } 2024 2025 // Logo returns the value of the "logo" field in the mutation. 2026 func (m *ChainBaseMutation) Logo() (r string, exists bool) { 2027 v := m.logo 2028 if v == nil { 2029 return 2030 } 2031 return *v, true 2032 } 2033 2034 // OldLogo returns the old "logo" field's value of the ChainBase entity. 2035 // If the ChainBase object wasn't provided to the builder, the object is fetched from the database. 2036 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2037 func (m *ChainBaseMutation) OldLogo(ctx context.Context) (v string, err error) { 2038 if !m.op.Is(OpUpdateOne) { 2039 return v, errors.New("OldLogo is only allowed on UpdateOne operations") 2040 } 2041 if m.id == nil || m.oldValue == nil { 2042 return v, errors.New("OldLogo requires an ID field in the mutation") 2043 } 2044 oldValue, err := m.oldValue(ctx) 2045 if err != nil { 2046 return v, fmt.Errorf("querying old value for OldLogo: %w", err) 2047 } 2048 return oldValue.Logo, nil 2049 } 2050 2051 // ClearLogo clears the value of the "logo" field. 2052 func (m *ChainBaseMutation) ClearLogo() { 2053 m.logo = nil 2054 m.clearedFields[chainbase.FieldLogo] = struct{}{} 2055 } 2056 2057 // LogoCleared returns if the "logo" field was cleared in this mutation. 2058 func (m *ChainBaseMutation) LogoCleared() bool { 2059 _, ok := m.clearedFields[chainbase.FieldLogo] 2060 return ok 2061 } 2062 2063 // ResetLogo resets all changes to the "logo" field. 2064 func (m *ChainBaseMutation) ResetLogo() { 2065 m.logo = nil 2066 delete(m.clearedFields, chainbase.FieldLogo) 2067 } 2068 2069 // SetNativeUnit sets the "native_unit" field. 2070 func (m *ChainBaseMutation) SetNativeUnit(s string) { 2071 m.native_unit = &s 2072 } 2073 2074 // NativeUnit returns the value of the "native_unit" field in the mutation. 2075 func (m *ChainBaseMutation) NativeUnit() (r string, exists bool) { 2076 v := m.native_unit 2077 if v == nil { 2078 return 2079 } 2080 return *v, true 2081 } 2082 2083 // OldNativeUnit returns the old "native_unit" field's value of the ChainBase entity. 2084 // If the ChainBase object wasn't provided to the builder, the object is fetched from the database. 2085 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2086 func (m *ChainBaseMutation) OldNativeUnit(ctx context.Context) (v string, err error) { 2087 if !m.op.Is(OpUpdateOne) { 2088 return v, errors.New("OldNativeUnit is only allowed on UpdateOne operations") 2089 } 2090 if m.id == nil || m.oldValue == nil { 2091 return v, errors.New("OldNativeUnit requires an ID field in the mutation") 2092 } 2093 oldValue, err := m.oldValue(ctx) 2094 if err != nil { 2095 return v, fmt.Errorf("querying old value for OldNativeUnit: %w", err) 2096 } 2097 return oldValue.NativeUnit, nil 2098 } 2099 2100 // ClearNativeUnit clears the value of the "native_unit" field. 2101 func (m *ChainBaseMutation) ClearNativeUnit() { 2102 m.native_unit = nil 2103 m.clearedFields[chainbase.FieldNativeUnit] = struct{}{} 2104 } 2105 2106 // NativeUnitCleared returns if the "native_unit" field was cleared in this mutation. 2107 func (m *ChainBaseMutation) NativeUnitCleared() bool { 2108 _, ok := m.clearedFields[chainbase.FieldNativeUnit] 2109 return ok 2110 } 2111 2112 // ResetNativeUnit resets all changes to the "native_unit" field. 2113 func (m *ChainBaseMutation) ResetNativeUnit() { 2114 m.native_unit = nil 2115 delete(m.clearedFields, chainbase.FieldNativeUnit) 2116 } 2117 2118 // SetAtomicUnit sets the "atomic_unit" field. 2119 func (m *ChainBaseMutation) SetAtomicUnit(s string) { 2120 m.atomic_unit = &s 2121 } 2122 2123 // AtomicUnit returns the value of the "atomic_unit" field in the mutation. 2124 func (m *ChainBaseMutation) AtomicUnit() (r string, exists bool) { 2125 v := m.atomic_unit 2126 if v == nil { 2127 return 2128 } 2129 return *v, true 2130 } 2131 2132 // OldAtomicUnit returns the old "atomic_unit" field's value of the ChainBase entity. 2133 // If the ChainBase object wasn't provided to the builder, the object is fetched from the database. 2134 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2135 func (m *ChainBaseMutation) OldAtomicUnit(ctx context.Context) (v string, err error) { 2136 if !m.op.Is(OpUpdateOne) { 2137 return v, errors.New("OldAtomicUnit is only allowed on UpdateOne operations") 2138 } 2139 if m.id == nil || m.oldValue == nil { 2140 return v, errors.New("OldAtomicUnit requires an ID field in the mutation") 2141 } 2142 oldValue, err := m.oldValue(ctx) 2143 if err != nil { 2144 return v, fmt.Errorf("querying old value for OldAtomicUnit: %w", err) 2145 } 2146 return oldValue.AtomicUnit, nil 2147 } 2148 2149 // ClearAtomicUnit clears the value of the "atomic_unit" field. 2150 func (m *ChainBaseMutation) ClearAtomicUnit() { 2151 m.atomic_unit = nil 2152 m.clearedFields[chainbase.FieldAtomicUnit] = struct{}{} 2153 } 2154 2155 // AtomicUnitCleared returns if the "atomic_unit" field was cleared in this mutation. 2156 func (m *ChainBaseMutation) AtomicUnitCleared() bool { 2157 _, ok := m.clearedFields[chainbase.FieldAtomicUnit] 2158 return ok 2159 } 2160 2161 // ResetAtomicUnit resets all changes to the "atomic_unit" field. 2162 func (m *ChainBaseMutation) ResetAtomicUnit() { 2163 m.atomic_unit = nil 2164 delete(m.clearedFields, chainbase.FieldAtomicUnit) 2165 } 2166 2167 // SetUnitExp sets the "unit_exp" field. 2168 func (m *ChainBaseMutation) SetUnitExp(u uint32) { 2169 m.unit_exp = &u 2170 m.addunit_exp = nil 2171 } 2172 2173 // UnitExp returns the value of the "unit_exp" field in the mutation. 2174 func (m *ChainBaseMutation) UnitExp() (r uint32, exists bool) { 2175 v := m.unit_exp 2176 if v == nil { 2177 return 2178 } 2179 return *v, true 2180 } 2181 2182 // OldUnitExp returns the old "unit_exp" field's value of the ChainBase entity. 2183 // If the ChainBase object wasn't provided to the builder, the object is fetched from the database. 2184 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2185 func (m *ChainBaseMutation) OldUnitExp(ctx context.Context) (v uint32, err error) { 2186 if !m.op.Is(OpUpdateOne) { 2187 return v, errors.New("OldUnitExp is only allowed on UpdateOne operations") 2188 } 2189 if m.id == nil || m.oldValue == nil { 2190 return v, errors.New("OldUnitExp requires an ID field in the mutation") 2191 } 2192 oldValue, err := m.oldValue(ctx) 2193 if err != nil { 2194 return v, fmt.Errorf("querying old value for OldUnitExp: %w", err) 2195 } 2196 return oldValue.UnitExp, nil 2197 } 2198 2199 // AddUnitExp adds u to the "unit_exp" field. 2200 func (m *ChainBaseMutation) AddUnitExp(u int32) { 2201 if m.addunit_exp != nil { 2202 *m.addunit_exp += u 2203 } else { 2204 m.addunit_exp = &u 2205 } 2206 } 2207 2208 // AddedUnitExp returns the value that was added to the "unit_exp" field in this mutation. 2209 func (m *ChainBaseMutation) AddedUnitExp() (r int32, exists bool) { 2210 v := m.addunit_exp 2211 if v == nil { 2212 return 2213 } 2214 return *v, true 2215 } 2216 2217 // ClearUnitExp clears the value of the "unit_exp" field. 2218 func (m *ChainBaseMutation) ClearUnitExp() { 2219 m.unit_exp = nil 2220 m.addunit_exp = nil 2221 m.clearedFields[chainbase.FieldUnitExp] = struct{}{} 2222 } 2223 2224 // UnitExpCleared returns if the "unit_exp" field was cleared in this mutation. 2225 func (m *ChainBaseMutation) UnitExpCleared() bool { 2226 _, ok := m.clearedFields[chainbase.FieldUnitExp] 2227 return ok 2228 } 2229 2230 // ResetUnitExp resets all changes to the "unit_exp" field. 2231 func (m *ChainBaseMutation) ResetUnitExp() { 2232 m.unit_exp = nil 2233 m.addunit_exp = nil 2234 delete(m.clearedFields, chainbase.FieldUnitExp) 2235 } 2236 2237 // SetEnv sets the "env" field. 2238 func (m *ChainBaseMutation) SetEnv(s string) { 2239 m.env = &s 2240 } 2241 2242 // Env returns the value of the "env" field in the mutation. 2243 func (m *ChainBaseMutation) Env() (r string, exists bool) { 2244 v := m.env 2245 if v == nil { 2246 return 2247 } 2248 return *v, true 2249 } 2250 2251 // OldEnv returns the old "env" field's value of the ChainBase entity. 2252 // If the ChainBase object wasn't provided to the builder, the object is fetched from the database. 2253 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2254 func (m *ChainBaseMutation) OldEnv(ctx context.Context) (v string, err error) { 2255 if !m.op.Is(OpUpdateOne) { 2256 return v, errors.New("OldEnv is only allowed on UpdateOne operations") 2257 } 2258 if m.id == nil || m.oldValue == nil { 2259 return v, errors.New("OldEnv requires an ID field in the mutation") 2260 } 2261 oldValue, err := m.oldValue(ctx) 2262 if err != nil { 2263 return v, fmt.Errorf("querying old value for OldEnv: %w", err) 2264 } 2265 return oldValue.Env, nil 2266 } 2267 2268 // ClearEnv clears the value of the "env" field. 2269 func (m *ChainBaseMutation) ClearEnv() { 2270 m.env = nil 2271 m.clearedFields[chainbase.FieldEnv] = struct{}{} 2272 } 2273 2274 // EnvCleared returns if the "env" field was cleared in this mutation. 2275 func (m *ChainBaseMutation) EnvCleared() bool { 2276 _, ok := m.clearedFields[chainbase.FieldEnv] 2277 return ok 2278 } 2279 2280 // ResetEnv resets all changes to the "env" field. 2281 func (m *ChainBaseMutation) ResetEnv() { 2282 m.env = nil 2283 delete(m.clearedFields, chainbase.FieldEnv) 2284 } 2285 2286 // SetChainID sets the "chain_id" field. 2287 func (m *ChainBaseMutation) SetChainID(s string) { 2288 m.chain_id = &s 2289 } 2290 2291 // ChainID returns the value of the "chain_id" field in the mutation. 2292 func (m *ChainBaseMutation) ChainID() (r string, exists bool) { 2293 v := m.chain_id 2294 if v == nil { 2295 return 2296 } 2297 return *v, true 2298 } 2299 2300 // OldChainID returns the old "chain_id" field's value of the ChainBase entity. 2301 // If the ChainBase object wasn't provided to the builder, the object is fetched from the database. 2302 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2303 func (m *ChainBaseMutation) OldChainID(ctx context.Context) (v string, err error) { 2304 if !m.op.Is(OpUpdateOne) { 2305 return v, errors.New("OldChainID is only allowed on UpdateOne operations") 2306 } 2307 if m.id == nil || m.oldValue == nil { 2308 return v, errors.New("OldChainID requires an ID field in the mutation") 2309 } 2310 oldValue, err := m.oldValue(ctx) 2311 if err != nil { 2312 return v, fmt.Errorf("querying old value for OldChainID: %w", err) 2313 } 2314 return oldValue.ChainID, nil 2315 } 2316 2317 // ClearChainID clears the value of the "chain_id" field. 2318 func (m *ChainBaseMutation) ClearChainID() { 2319 m.chain_id = nil 2320 m.clearedFields[chainbase.FieldChainID] = struct{}{} 2321 } 2322 2323 // ChainIDCleared returns if the "chain_id" field was cleared in this mutation. 2324 func (m *ChainBaseMutation) ChainIDCleared() bool { 2325 _, ok := m.clearedFields[chainbase.FieldChainID] 2326 return ok 2327 } 2328 2329 // ResetChainID resets all changes to the "chain_id" field. 2330 func (m *ChainBaseMutation) ResetChainID() { 2331 m.chain_id = nil 2332 delete(m.clearedFields, chainbase.FieldChainID) 2333 } 2334 2335 // SetNickname sets the "nickname" field. 2336 func (m *ChainBaseMutation) SetNickname(s string) { 2337 m.nickname = &s 2338 } 2339 2340 // Nickname returns the value of the "nickname" field in the mutation. 2341 func (m *ChainBaseMutation) Nickname() (r string, exists bool) { 2342 v := m.nickname 2343 if v == nil { 2344 return 2345 } 2346 return *v, true 2347 } 2348 2349 // OldNickname returns the old "nickname" field's value of the ChainBase entity. 2350 // If the ChainBase object wasn't provided to the builder, the object is fetched from the database. 2351 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2352 func (m *ChainBaseMutation) OldNickname(ctx context.Context) (v string, err error) { 2353 if !m.op.Is(OpUpdateOne) { 2354 return v, errors.New("OldNickname is only allowed on UpdateOne operations") 2355 } 2356 if m.id == nil || m.oldValue == nil { 2357 return v, errors.New("OldNickname requires an ID field in the mutation") 2358 } 2359 oldValue, err := m.oldValue(ctx) 2360 if err != nil { 2361 return v, fmt.Errorf("querying old value for OldNickname: %w", err) 2362 } 2363 return oldValue.Nickname, nil 2364 } 2365 2366 // ClearNickname clears the value of the "nickname" field. 2367 func (m *ChainBaseMutation) ClearNickname() { 2368 m.nickname = nil 2369 m.clearedFields[chainbase.FieldNickname] = struct{}{} 2370 } 2371 2372 // NicknameCleared returns if the "nickname" field was cleared in this mutation. 2373 func (m *ChainBaseMutation) NicknameCleared() bool { 2374 _, ok := m.clearedFields[chainbase.FieldNickname] 2375 return ok 2376 } 2377 2378 // ResetNickname resets all changes to the "nickname" field. 2379 func (m *ChainBaseMutation) ResetNickname() { 2380 m.nickname = nil 2381 delete(m.clearedFields, chainbase.FieldNickname) 2382 } 2383 2384 // SetGasType sets the "gas_type" field. 2385 func (m *ChainBaseMutation) SetGasType(s string) { 2386 m.gas_type = &s 2387 } 2388 2389 // GasType returns the value of the "gas_type" field in the mutation. 2390 func (m *ChainBaseMutation) GasType() (r string, exists bool) { 2391 v := m.gas_type 2392 if v == nil { 2393 return 2394 } 2395 return *v, true 2396 } 2397 2398 // OldGasType returns the old "gas_type" field's value of the ChainBase entity. 2399 // If the ChainBase object wasn't provided to the builder, the object is fetched from the database. 2400 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 2401 func (m *ChainBaseMutation) OldGasType(ctx context.Context) (v string, err error) { 2402 if !m.op.Is(OpUpdateOne) { 2403 return v, errors.New("OldGasType is only allowed on UpdateOne operations") 2404 } 2405 if m.id == nil || m.oldValue == nil { 2406 return v, errors.New("OldGasType requires an ID field in the mutation") 2407 } 2408 oldValue, err := m.oldValue(ctx) 2409 if err != nil { 2410 return v, fmt.Errorf("querying old value for OldGasType: %w", err) 2411 } 2412 return oldValue.GasType, nil 2413 } 2414 2415 // ClearGasType clears the value of the "gas_type" field. 2416 func (m *ChainBaseMutation) ClearGasType() { 2417 m.gas_type = nil 2418 m.clearedFields[chainbase.FieldGasType] = struct{}{} 2419 } 2420 2421 // GasTypeCleared returns if the "gas_type" field was cleared in this mutation. 2422 func (m *ChainBaseMutation) GasTypeCleared() bool { 2423 _, ok := m.clearedFields[chainbase.FieldGasType] 2424 return ok 2425 } 2426 2427 // ResetGasType resets all changes to the "gas_type" field. 2428 func (m *ChainBaseMutation) ResetGasType() { 2429 m.gas_type = nil 2430 delete(m.clearedFields, chainbase.FieldGasType) 2431 } 2432 2433 // Where appends a list predicates to the ChainBaseMutation builder. 2434 func (m *ChainBaseMutation) Where(ps ...predicate.ChainBase) { 2435 m.predicates = append(m.predicates, ps...) 2436 } 2437 2438 // Op returns the operation name. 2439 func (m *ChainBaseMutation) Op() Op { 2440 return m.op 2441 } 2442 2443 // Type returns the node type of this mutation (ChainBase). 2444 func (m *ChainBaseMutation) Type() string { 2445 return m.typ 2446 } 2447 2448 // Fields returns all fields that were changed during this mutation. Note that in 2449 // order to get all numeric fields that were incremented/decremented, call 2450 // AddedFields(). 2451 func (m *ChainBaseMutation) Fields() []string { 2452 fields := make([]string, 0, 13) 2453 if m.created_at != nil { 2454 fields = append(fields, chainbase.FieldCreatedAt) 2455 } 2456 if m.updated_at != nil { 2457 fields = append(fields, chainbase.FieldUpdatedAt) 2458 } 2459 if m.deleted_at != nil { 2460 fields = append(fields, chainbase.FieldDeletedAt) 2461 } 2462 if m.ent_id != nil { 2463 fields = append(fields, chainbase.FieldEntID) 2464 } 2465 if m.name != nil { 2466 fields = append(fields, chainbase.FieldName) 2467 } 2468 if m.logo != nil { 2469 fields = append(fields, chainbase.FieldLogo) 2470 } 2471 if m.native_unit != nil { 2472 fields = append(fields, chainbase.FieldNativeUnit) 2473 } 2474 if m.atomic_unit != nil { 2475 fields = append(fields, chainbase.FieldAtomicUnit) 2476 } 2477 if m.unit_exp != nil { 2478 fields = append(fields, chainbase.FieldUnitExp) 2479 } 2480 if m.env != nil { 2481 fields = append(fields, chainbase.FieldEnv) 2482 } 2483 if m.chain_id != nil { 2484 fields = append(fields, chainbase.FieldChainID) 2485 } 2486 if m.nickname != nil { 2487 fields = append(fields, chainbase.FieldNickname) 2488 } 2489 if m.gas_type != nil { 2490 fields = append(fields, chainbase.FieldGasType) 2491 } 2492 return fields 2493 } 2494 2495 // Field returns the value of a field with the given name. The second boolean 2496 // return value indicates that this field was not set, or was not defined in the 2497 // schema. 2498 func (m *ChainBaseMutation) Field(name string) (ent.Value, bool) { 2499 switch name { 2500 case chainbase.FieldCreatedAt: 2501 return m.CreatedAt() 2502 case chainbase.FieldUpdatedAt: 2503 return m.UpdatedAt() 2504 case chainbase.FieldDeletedAt: 2505 return m.DeletedAt() 2506 case chainbase.FieldEntID: 2507 return m.EntID() 2508 case chainbase.FieldName: 2509 return m.Name() 2510 case chainbase.FieldLogo: 2511 return m.Logo() 2512 case chainbase.FieldNativeUnit: 2513 return m.NativeUnit() 2514 case chainbase.FieldAtomicUnit: 2515 return m.AtomicUnit() 2516 case chainbase.FieldUnitExp: 2517 return m.UnitExp() 2518 case chainbase.FieldEnv: 2519 return m.Env() 2520 case chainbase.FieldChainID: 2521 return m.ChainID() 2522 case chainbase.FieldNickname: 2523 return m.Nickname() 2524 case chainbase.FieldGasType: 2525 return m.GasType() 2526 } 2527 return nil, false 2528 } 2529 2530 // OldField returns the old value of the field from the database. An error is 2531 // returned if the mutation operation is not UpdateOne, or the query to the 2532 // database failed. 2533 func (m *ChainBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 2534 switch name { 2535 case chainbase.FieldCreatedAt: 2536 return m.OldCreatedAt(ctx) 2537 case chainbase.FieldUpdatedAt: 2538 return m.OldUpdatedAt(ctx) 2539 case chainbase.FieldDeletedAt: 2540 return m.OldDeletedAt(ctx) 2541 case chainbase.FieldEntID: 2542 return m.OldEntID(ctx) 2543 case chainbase.FieldName: 2544 return m.OldName(ctx) 2545 case chainbase.FieldLogo: 2546 return m.OldLogo(ctx) 2547 case chainbase.FieldNativeUnit: 2548 return m.OldNativeUnit(ctx) 2549 case chainbase.FieldAtomicUnit: 2550 return m.OldAtomicUnit(ctx) 2551 case chainbase.FieldUnitExp: 2552 return m.OldUnitExp(ctx) 2553 case chainbase.FieldEnv: 2554 return m.OldEnv(ctx) 2555 case chainbase.FieldChainID: 2556 return m.OldChainID(ctx) 2557 case chainbase.FieldNickname: 2558 return m.OldNickname(ctx) 2559 case chainbase.FieldGasType: 2560 return m.OldGasType(ctx) 2561 } 2562 return nil, fmt.Errorf("unknown ChainBase field %s", name) 2563 } 2564 2565 // SetField sets the value of a field with the given name. It returns an error if 2566 // the field is not defined in the schema, or if the type mismatched the field 2567 // type. 2568 func (m *ChainBaseMutation) SetField(name string, value ent.Value) error { 2569 switch name { 2570 case chainbase.FieldCreatedAt: 2571 v, ok := value.(uint32) 2572 if !ok { 2573 return fmt.Errorf("unexpected type %T for field %s", value, name) 2574 } 2575 m.SetCreatedAt(v) 2576 return nil 2577 case chainbase.FieldUpdatedAt: 2578 v, ok := value.(uint32) 2579 if !ok { 2580 return fmt.Errorf("unexpected type %T for field %s", value, name) 2581 } 2582 m.SetUpdatedAt(v) 2583 return nil 2584 case chainbase.FieldDeletedAt: 2585 v, ok := value.(uint32) 2586 if !ok { 2587 return fmt.Errorf("unexpected type %T for field %s", value, name) 2588 } 2589 m.SetDeletedAt(v) 2590 return nil 2591 case chainbase.FieldEntID: 2592 v, ok := value.(uuid.UUID) 2593 if !ok { 2594 return fmt.Errorf("unexpected type %T for field %s", value, name) 2595 } 2596 m.SetEntID(v) 2597 return nil 2598 case chainbase.FieldName: 2599 v, ok := value.(string) 2600 if !ok { 2601 return fmt.Errorf("unexpected type %T for field %s", value, name) 2602 } 2603 m.SetName(v) 2604 return nil 2605 case chainbase.FieldLogo: 2606 v, ok := value.(string) 2607 if !ok { 2608 return fmt.Errorf("unexpected type %T for field %s", value, name) 2609 } 2610 m.SetLogo(v) 2611 return nil 2612 case chainbase.FieldNativeUnit: 2613 v, ok := value.(string) 2614 if !ok { 2615 return fmt.Errorf("unexpected type %T for field %s", value, name) 2616 } 2617 m.SetNativeUnit(v) 2618 return nil 2619 case chainbase.FieldAtomicUnit: 2620 v, ok := value.(string) 2621 if !ok { 2622 return fmt.Errorf("unexpected type %T for field %s", value, name) 2623 } 2624 m.SetAtomicUnit(v) 2625 return nil 2626 case chainbase.FieldUnitExp: 2627 v, ok := value.(uint32) 2628 if !ok { 2629 return fmt.Errorf("unexpected type %T for field %s", value, name) 2630 } 2631 m.SetUnitExp(v) 2632 return nil 2633 case chainbase.FieldEnv: 2634 v, ok := value.(string) 2635 if !ok { 2636 return fmt.Errorf("unexpected type %T for field %s", value, name) 2637 } 2638 m.SetEnv(v) 2639 return nil 2640 case chainbase.FieldChainID: 2641 v, ok := value.(string) 2642 if !ok { 2643 return fmt.Errorf("unexpected type %T for field %s", value, name) 2644 } 2645 m.SetChainID(v) 2646 return nil 2647 case chainbase.FieldNickname: 2648 v, ok := value.(string) 2649 if !ok { 2650 return fmt.Errorf("unexpected type %T for field %s", value, name) 2651 } 2652 m.SetNickname(v) 2653 return nil 2654 case chainbase.FieldGasType: 2655 v, ok := value.(string) 2656 if !ok { 2657 return fmt.Errorf("unexpected type %T for field %s", value, name) 2658 } 2659 m.SetGasType(v) 2660 return nil 2661 } 2662 return fmt.Errorf("unknown ChainBase field %s", name) 2663 } 2664 2665 // AddedFields returns all numeric fields that were incremented/decremented during 2666 // this mutation. 2667 func (m *ChainBaseMutation) AddedFields() []string { 2668 var fields []string 2669 if m.addcreated_at != nil { 2670 fields = append(fields, chainbase.FieldCreatedAt) 2671 } 2672 if m.addupdated_at != nil { 2673 fields = append(fields, chainbase.FieldUpdatedAt) 2674 } 2675 if m.adddeleted_at != nil { 2676 fields = append(fields, chainbase.FieldDeletedAt) 2677 } 2678 if m.addunit_exp != nil { 2679 fields = append(fields, chainbase.FieldUnitExp) 2680 } 2681 return fields 2682 } 2683 2684 // AddedField returns the numeric value that was incremented/decremented on a field 2685 // with the given name. The second boolean return value indicates that this field 2686 // was not set, or was not defined in the schema. 2687 func (m *ChainBaseMutation) AddedField(name string) (ent.Value, bool) { 2688 switch name { 2689 case chainbase.FieldCreatedAt: 2690 return m.AddedCreatedAt() 2691 case chainbase.FieldUpdatedAt: 2692 return m.AddedUpdatedAt() 2693 case chainbase.FieldDeletedAt: 2694 return m.AddedDeletedAt() 2695 case chainbase.FieldUnitExp: 2696 return m.AddedUnitExp() 2697 } 2698 return nil, false 2699 } 2700 2701 // AddField adds the value to the field with the given name. It returns an error if 2702 // the field is not defined in the schema, or if the type mismatched the field 2703 // type. 2704 func (m *ChainBaseMutation) AddField(name string, value ent.Value) error { 2705 switch name { 2706 case chainbase.FieldCreatedAt: 2707 v, ok := value.(int32) 2708 if !ok { 2709 return fmt.Errorf("unexpected type %T for field %s", value, name) 2710 } 2711 m.AddCreatedAt(v) 2712 return nil 2713 case chainbase.FieldUpdatedAt: 2714 v, ok := value.(int32) 2715 if !ok { 2716 return fmt.Errorf("unexpected type %T for field %s", value, name) 2717 } 2718 m.AddUpdatedAt(v) 2719 return nil 2720 case chainbase.FieldDeletedAt: 2721 v, ok := value.(int32) 2722 if !ok { 2723 return fmt.Errorf("unexpected type %T for field %s", value, name) 2724 } 2725 m.AddDeletedAt(v) 2726 return nil 2727 case chainbase.FieldUnitExp: 2728 v, ok := value.(int32) 2729 if !ok { 2730 return fmt.Errorf("unexpected type %T for field %s", value, name) 2731 } 2732 m.AddUnitExp(v) 2733 return nil 2734 } 2735 return fmt.Errorf("unknown ChainBase numeric field %s", name) 2736 } 2737 2738 // ClearedFields returns all nullable fields that were cleared during this 2739 // mutation. 2740 func (m *ChainBaseMutation) ClearedFields() []string { 2741 var fields []string 2742 if m.FieldCleared(chainbase.FieldName) { 2743 fields = append(fields, chainbase.FieldName) 2744 } 2745 if m.FieldCleared(chainbase.FieldLogo) { 2746 fields = append(fields, chainbase.FieldLogo) 2747 } 2748 if m.FieldCleared(chainbase.FieldNativeUnit) { 2749 fields = append(fields, chainbase.FieldNativeUnit) 2750 } 2751 if m.FieldCleared(chainbase.FieldAtomicUnit) { 2752 fields = append(fields, chainbase.FieldAtomicUnit) 2753 } 2754 if m.FieldCleared(chainbase.FieldUnitExp) { 2755 fields = append(fields, chainbase.FieldUnitExp) 2756 } 2757 if m.FieldCleared(chainbase.FieldEnv) { 2758 fields = append(fields, chainbase.FieldEnv) 2759 } 2760 if m.FieldCleared(chainbase.FieldChainID) { 2761 fields = append(fields, chainbase.FieldChainID) 2762 } 2763 if m.FieldCleared(chainbase.FieldNickname) { 2764 fields = append(fields, chainbase.FieldNickname) 2765 } 2766 if m.FieldCleared(chainbase.FieldGasType) { 2767 fields = append(fields, chainbase.FieldGasType) 2768 } 2769 return fields 2770 } 2771 2772 // FieldCleared returns a boolean indicating if a field with the given name was 2773 // cleared in this mutation. 2774 func (m *ChainBaseMutation) FieldCleared(name string) bool { 2775 _, ok := m.clearedFields[name] 2776 return ok 2777 } 2778 2779 // ClearField clears the value of the field with the given name. It returns an 2780 // error if the field is not defined in the schema. 2781 func (m *ChainBaseMutation) ClearField(name string) error { 2782 switch name { 2783 case chainbase.FieldName: 2784 m.ClearName() 2785 return nil 2786 case chainbase.FieldLogo: 2787 m.ClearLogo() 2788 return nil 2789 case chainbase.FieldNativeUnit: 2790 m.ClearNativeUnit() 2791 return nil 2792 case chainbase.FieldAtomicUnit: 2793 m.ClearAtomicUnit() 2794 return nil 2795 case chainbase.FieldUnitExp: 2796 m.ClearUnitExp() 2797 return nil 2798 case chainbase.FieldEnv: 2799 m.ClearEnv() 2800 return nil 2801 case chainbase.FieldChainID: 2802 m.ClearChainID() 2803 return nil 2804 case chainbase.FieldNickname: 2805 m.ClearNickname() 2806 return nil 2807 case chainbase.FieldGasType: 2808 m.ClearGasType() 2809 return nil 2810 } 2811 return fmt.Errorf("unknown ChainBase nullable field %s", name) 2812 } 2813 2814 // ResetField resets all changes in the mutation for the field with the given name. 2815 // It returns an error if the field is not defined in the schema. 2816 func (m *ChainBaseMutation) ResetField(name string) error { 2817 switch name { 2818 case chainbase.FieldCreatedAt: 2819 m.ResetCreatedAt() 2820 return nil 2821 case chainbase.FieldUpdatedAt: 2822 m.ResetUpdatedAt() 2823 return nil 2824 case chainbase.FieldDeletedAt: 2825 m.ResetDeletedAt() 2826 return nil 2827 case chainbase.FieldEntID: 2828 m.ResetEntID() 2829 return nil 2830 case chainbase.FieldName: 2831 m.ResetName() 2832 return nil 2833 case chainbase.FieldLogo: 2834 m.ResetLogo() 2835 return nil 2836 case chainbase.FieldNativeUnit: 2837 m.ResetNativeUnit() 2838 return nil 2839 case chainbase.FieldAtomicUnit: 2840 m.ResetAtomicUnit() 2841 return nil 2842 case chainbase.FieldUnitExp: 2843 m.ResetUnitExp() 2844 return nil 2845 case chainbase.FieldEnv: 2846 m.ResetEnv() 2847 return nil 2848 case chainbase.FieldChainID: 2849 m.ResetChainID() 2850 return nil 2851 case chainbase.FieldNickname: 2852 m.ResetNickname() 2853 return nil 2854 case chainbase.FieldGasType: 2855 m.ResetGasType() 2856 return nil 2857 } 2858 return fmt.Errorf("unknown ChainBase field %s", name) 2859 } 2860 2861 // AddedEdges returns all edge names that were set/added in this mutation. 2862 func (m *ChainBaseMutation) AddedEdges() []string { 2863 edges := make([]string, 0, 0) 2864 return edges 2865 } 2866 2867 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 2868 // name in this mutation. 2869 func (m *ChainBaseMutation) AddedIDs(name string) []ent.Value { 2870 return nil 2871 } 2872 2873 // RemovedEdges returns all edge names that were removed in this mutation. 2874 func (m *ChainBaseMutation) RemovedEdges() []string { 2875 edges := make([]string, 0, 0) 2876 return edges 2877 } 2878 2879 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 2880 // the given name in this mutation. 2881 func (m *ChainBaseMutation) RemovedIDs(name string) []ent.Value { 2882 return nil 2883 } 2884 2885 // ClearedEdges returns all edge names that were cleared in this mutation. 2886 func (m *ChainBaseMutation) ClearedEdges() []string { 2887 edges := make([]string, 0, 0) 2888 return edges 2889 } 2890 2891 // EdgeCleared returns a boolean which indicates if the edge with the given name 2892 // was cleared in this mutation. 2893 func (m *ChainBaseMutation) EdgeCleared(name string) bool { 2894 return false 2895 } 2896 2897 // ClearEdge clears the value of the edge with the given name. It returns an error 2898 // if that edge is not defined in the schema. 2899 func (m *ChainBaseMutation) ClearEdge(name string) error { 2900 return fmt.Errorf("unknown ChainBase unique edge %s", name) 2901 } 2902 2903 // ResetEdge resets all changes to the edge with the given name in this mutation. 2904 // It returns an error if the edge is not defined in the schema. 2905 func (m *ChainBaseMutation) ResetEdge(name string) error { 2906 return fmt.Errorf("unknown ChainBase edge %s", name) 2907 } 2908 2909 // CoinBaseMutation represents an operation that mutates the CoinBase nodes in the graph. 2910 type CoinBaseMutation struct { 2911 config 2912 op Op 2913 typ string 2914 id *uint32 2915 created_at *uint32 2916 addcreated_at *int32 2917 updated_at *uint32 2918 addupdated_at *int32 2919 deleted_at *uint32 2920 adddeleted_at *int32 2921 ent_id *uuid.UUID 2922 name *string 2923 logo *string 2924 presale *bool 2925 unit *string 2926 env *string 2927 reserved_amount *decimal.Decimal 2928 for_pay *bool 2929 disabled *bool 2930 clearedFields map[string]struct{} 2931 done bool 2932 oldValue func(context.Context) (*CoinBase, error) 2933 predicates []predicate.CoinBase 2934 } 2935 2936 var _ ent.Mutation = (*CoinBaseMutation)(nil) 2937 2938 // coinbaseOption allows management of the mutation configuration using functional options. 2939 type coinbaseOption func(*CoinBaseMutation) 2940 2941 // newCoinBaseMutation creates new mutation for the CoinBase entity. 2942 func newCoinBaseMutation(c config, op Op, opts ...coinbaseOption) *CoinBaseMutation { 2943 m := &CoinBaseMutation{ 2944 config: c, 2945 op: op, 2946 typ: TypeCoinBase, 2947 clearedFields: make(map[string]struct{}), 2948 } 2949 for _, opt := range opts { 2950 opt(m) 2951 } 2952 return m 2953 } 2954 2955 // withCoinBaseID sets the ID field of the mutation. 2956 func withCoinBaseID(id uint32) coinbaseOption { 2957 return func(m *CoinBaseMutation) { 2958 var ( 2959 err error 2960 once sync.Once 2961 value *CoinBase 2962 ) 2963 m.oldValue = func(ctx context.Context) (*CoinBase, error) { 2964 once.Do(func() { 2965 if m.done { 2966 err = errors.New("querying old values post mutation is not allowed") 2967 } else { 2968 value, err = m.Client().CoinBase.Get(ctx, id) 2969 } 2970 }) 2971 return value, err 2972 } 2973 m.id = &id 2974 } 2975 } 2976 2977 // withCoinBase sets the old CoinBase of the mutation. 2978 func withCoinBase(node *CoinBase) coinbaseOption { 2979 return func(m *CoinBaseMutation) { 2980 m.oldValue = func(context.Context) (*CoinBase, error) { 2981 return node, nil 2982 } 2983 m.id = &node.ID 2984 } 2985 } 2986 2987 // Client returns a new `ent.Client` from the mutation. If the mutation was 2988 // executed in a transaction (ent.Tx), a transactional client is returned. 2989 func (m CoinBaseMutation) Client() *Client { 2990 client := &Client{config: m.config} 2991 client.init() 2992 return client 2993 } 2994 2995 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 2996 // it returns an error otherwise. 2997 func (m CoinBaseMutation) Tx() (*Tx, error) { 2998 if _, ok := m.driver.(*txDriver); !ok { 2999 return nil, errors.New("ent: mutation is not running in a transaction") 3000 } 3001 tx := &Tx{config: m.config} 3002 tx.init() 3003 return tx, nil 3004 } 3005 3006 // SetID sets the value of the id field. Note that this 3007 // operation is only accepted on creation of CoinBase entities. 3008 func (m *CoinBaseMutation) SetID(id uint32) { 3009 m.id = &id 3010 } 3011 3012 // ID returns the ID value in the mutation. Note that the ID is only available 3013 // if it was provided to the builder or after it was returned from the database. 3014 func (m *CoinBaseMutation) ID() (id uint32, exists bool) { 3015 if m.id == nil { 3016 return 3017 } 3018 return *m.id, true 3019 } 3020 3021 // IDs queries the database and returns the entity ids that match the mutation's predicate. 3022 // That means, if the mutation is applied within a transaction with an isolation level such 3023 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 3024 // or updated by the mutation. 3025 func (m *CoinBaseMutation) IDs(ctx context.Context) ([]uint32, error) { 3026 switch { 3027 case m.op.Is(OpUpdateOne | OpDeleteOne): 3028 id, exists := m.ID() 3029 if exists { 3030 return []uint32{id}, nil 3031 } 3032 fallthrough 3033 case m.op.Is(OpUpdate | OpDelete): 3034 return m.Client().CoinBase.Query().Where(m.predicates...).IDs(ctx) 3035 default: 3036 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 3037 } 3038 } 3039 3040 // SetCreatedAt sets the "created_at" field. 3041 func (m *CoinBaseMutation) SetCreatedAt(u uint32) { 3042 m.created_at = &u 3043 m.addcreated_at = nil 3044 } 3045 3046 // CreatedAt returns the value of the "created_at" field in the mutation. 3047 func (m *CoinBaseMutation) CreatedAt() (r uint32, exists bool) { 3048 v := m.created_at 3049 if v == nil { 3050 return 3051 } 3052 return *v, true 3053 } 3054 3055 // OldCreatedAt returns the old "created_at" field's value of the CoinBase entity. 3056 // If the CoinBase object wasn't provided to the builder, the object is fetched from the database. 3057 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 3058 func (m *CoinBaseMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 3059 if !m.op.Is(OpUpdateOne) { 3060 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 3061 } 3062 if m.id == nil || m.oldValue == nil { 3063 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 3064 } 3065 oldValue, err := m.oldValue(ctx) 3066 if err != nil { 3067 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 3068 } 3069 return oldValue.CreatedAt, nil 3070 } 3071 3072 // AddCreatedAt adds u to the "created_at" field. 3073 func (m *CoinBaseMutation) AddCreatedAt(u int32) { 3074 if m.addcreated_at != nil { 3075 *m.addcreated_at += u 3076 } else { 3077 m.addcreated_at = &u 3078 } 3079 } 3080 3081 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 3082 func (m *CoinBaseMutation) AddedCreatedAt() (r int32, exists bool) { 3083 v := m.addcreated_at 3084 if v == nil { 3085 return 3086 } 3087 return *v, true 3088 } 3089 3090 // ResetCreatedAt resets all changes to the "created_at" field. 3091 func (m *CoinBaseMutation) ResetCreatedAt() { 3092 m.created_at = nil 3093 m.addcreated_at = nil 3094 } 3095 3096 // SetUpdatedAt sets the "updated_at" field. 3097 func (m *CoinBaseMutation) SetUpdatedAt(u uint32) { 3098 m.updated_at = &u 3099 m.addupdated_at = nil 3100 } 3101 3102 // UpdatedAt returns the value of the "updated_at" field in the mutation. 3103 func (m *CoinBaseMutation) UpdatedAt() (r uint32, exists bool) { 3104 v := m.updated_at 3105 if v == nil { 3106 return 3107 } 3108 return *v, true 3109 } 3110 3111 // OldUpdatedAt returns the old "updated_at" field's value of the CoinBase entity. 3112 // If the CoinBase object wasn't provided to the builder, the object is fetched from the database. 3113 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 3114 func (m *CoinBaseMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 3115 if !m.op.Is(OpUpdateOne) { 3116 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 3117 } 3118 if m.id == nil || m.oldValue == nil { 3119 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 3120 } 3121 oldValue, err := m.oldValue(ctx) 3122 if err != nil { 3123 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 3124 } 3125 return oldValue.UpdatedAt, nil 3126 } 3127 3128 // AddUpdatedAt adds u to the "updated_at" field. 3129 func (m *CoinBaseMutation) AddUpdatedAt(u int32) { 3130 if m.addupdated_at != nil { 3131 *m.addupdated_at += u 3132 } else { 3133 m.addupdated_at = &u 3134 } 3135 } 3136 3137 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 3138 func (m *CoinBaseMutation) AddedUpdatedAt() (r int32, exists bool) { 3139 v := m.addupdated_at 3140 if v == nil { 3141 return 3142 } 3143 return *v, true 3144 } 3145 3146 // ResetUpdatedAt resets all changes to the "updated_at" field. 3147 func (m *CoinBaseMutation) ResetUpdatedAt() { 3148 m.updated_at = nil 3149 m.addupdated_at = nil 3150 } 3151 3152 // SetDeletedAt sets the "deleted_at" field. 3153 func (m *CoinBaseMutation) SetDeletedAt(u uint32) { 3154 m.deleted_at = &u 3155 m.adddeleted_at = nil 3156 } 3157 3158 // DeletedAt returns the value of the "deleted_at" field in the mutation. 3159 func (m *CoinBaseMutation) DeletedAt() (r uint32, exists bool) { 3160 v := m.deleted_at 3161 if v == nil { 3162 return 3163 } 3164 return *v, true 3165 } 3166 3167 // OldDeletedAt returns the old "deleted_at" field's value of the CoinBase entity. 3168 // If the CoinBase object wasn't provided to the builder, the object is fetched from the database. 3169 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 3170 func (m *CoinBaseMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 3171 if !m.op.Is(OpUpdateOne) { 3172 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 3173 } 3174 if m.id == nil || m.oldValue == nil { 3175 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 3176 } 3177 oldValue, err := m.oldValue(ctx) 3178 if err != nil { 3179 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 3180 } 3181 return oldValue.DeletedAt, nil 3182 } 3183 3184 // AddDeletedAt adds u to the "deleted_at" field. 3185 func (m *CoinBaseMutation) AddDeletedAt(u int32) { 3186 if m.adddeleted_at != nil { 3187 *m.adddeleted_at += u 3188 } else { 3189 m.adddeleted_at = &u 3190 } 3191 } 3192 3193 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 3194 func (m *CoinBaseMutation) AddedDeletedAt() (r int32, exists bool) { 3195 v := m.adddeleted_at 3196 if v == nil { 3197 return 3198 } 3199 return *v, true 3200 } 3201 3202 // ResetDeletedAt resets all changes to the "deleted_at" field. 3203 func (m *CoinBaseMutation) ResetDeletedAt() { 3204 m.deleted_at = nil 3205 m.adddeleted_at = nil 3206 } 3207 3208 // SetEntID sets the "ent_id" field. 3209 func (m *CoinBaseMutation) SetEntID(u uuid.UUID) { 3210 m.ent_id = &u 3211 } 3212 3213 // EntID returns the value of the "ent_id" field in the mutation. 3214 func (m *CoinBaseMutation) EntID() (r uuid.UUID, exists bool) { 3215 v := m.ent_id 3216 if v == nil { 3217 return 3218 } 3219 return *v, true 3220 } 3221 3222 // OldEntID returns the old "ent_id" field's value of the CoinBase entity. 3223 // If the CoinBase object wasn't provided to the builder, the object is fetched from the database. 3224 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 3225 func (m *CoinBaseMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 3226 if !m.op.Is(OpUpdateOne) { 3227 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 3228 } 3229 if m.id == nil || m.oldValue == nil { 3230 return v, errors.New("OldEntID requires an ID field in the mutation") 3231 } 3232 oldValue, err := m.oldValue(ctx) 3233 if err != nil { 3234 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 3235 } 3236 return oldValue.EntID, nil 3237 } 3238 3239 // ResetEntID resets all changes to the "ent_id" field. 3240 func (m *CoinBaseMutation) ResetEntID() { 3241 m.ent_id = nil 3242 } 3243 3244 // SetName sets the "name" field. 3245 func (m *CoinBaseMutation) SetName(s string) { 3246 m.name = &s 3247 } 3248 3249 // Name returns the value of the "name" field in the mutation. 3250 func (m *CoinBaseMutation) Name() (r string, exists bool) { 3251 v := m.name 3252 if v == nil { 3253 return 3254 } 3255 return *v, true 3256 } 3257 3258 // OldName returns the old "name" field's value of the CoinBase entity. 3259 // If the CoinBase object wasn't provided to the builder, the object is fetched from the database. 3260 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 3261 func (m *CoinBaseMutation) OldName(ctx context.Context) (v string, err error) { 3262 if !m.op.Is(OpUpdateOne) { 3263 return v, errors.New("OldName is only allowed on UpdateOne operations") 3264 } 3265 if m.id == nil || m.oldValue == nil { 3266 return v, errors.New("OldName requires an ID field in the mutation") 3267 } 3268 oldValue, err := m.oldValue(ctx) 3269 if err != nil { 3270 return v, fmt.Errorf("querying old value for OldName: %w", err) 3271 } 3272 return oldValue.Name, nil 3273 } 3274 3275 // ClearName clears the value of the "name" field. 3276 func (m *CoinBaseMutation) ClearName() { 3277 m.name = nil 3278 m.clearedFields[coinbase.FieldName] = struct{}{} 3279 } 3280 3281 // NameCleared returns if the "name" field was cleared in this mutation. 3282 func (m *CoinBaseMutation) NameCleared() bool { 3283 _, ok := m.clearedFields[coinbase.FieldName] 3284 return ok 3285 } 3286 3287 // ResetName resets all changes to the "name" field. 3288 func (m *CoinBaseMutation) ResetName() { 3289 m.name = nil 3290 delete(m.clearedFields, coinbase.FieldName) 3291 } 3292 3293 // SetLogo sets the "logo" field. 3294 func (m *CoinBaseMutation) SetLogo(s string) { 3295 m.logo = &s 3296 } 3297 3298 // Logo returns the value of the "logo" field in the mutation. 3299 func (m *CoinBaseMutation) Logo() (r string, exists bool) { 3300 v := m.logo 3301 if v == nil { 3302 return 3303 } 3304 return *v, true 3305 } 3306 3307 // OldLogo returns the old "logo" field's value of the CoinBase entity. 3308 // If the CoinBase object wasn't provided to the builder, the object is fetched from the database. 3309 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 3310 func (m *CoinBaseMutation) OldLogo(ctx context.Context) (v string, err error) { 3311 if !m.op.Is(OpUpdateOne) { 3312 return v, errors.New("OldLogo is only allowed on UpdateOne operations") 3313 } 3314 if m.id == nil || m.oldValue == nil { 3315 return v, errors.New("OldLogo requires an ID field in the mutation") 3316 } 3317 oldValue, err := m.oldValue(ctx) 3318 if err != nil { 3319 return v, fmt.Errorf("querying old value for OldLogo: %w", err) 3320 } 3321 return oldValue.Logo, nil 3322 } 3323 3324 // ClearLogo clears the value of the "logo" field. 3325 func (m *CoinBaseMutation) ClearLogo() { 3326 m.logo = nil 3327 m.clearedFields[coinbase.FieldLogo] = struct{}{} 3328 } 3329 3330 // LogoCleared returns if the "logo" field was cleared in this mutation. 3331 func (m *CoinBaseMutation) LogoCleared() bool { 3332 _, ok := m.clearedFields[coinbase.FieldLogo] 3333 return ok 3334 } 3335 3336 // ResetLogo resets all changes to the "logo" field. 3337 func (m *CoinBaseMutation) ResetLogo() { 3338 m.logo = nil 3339 delete(m.clearedFields, coinbase.FieldLogo) 3340 } 3341 3342 // SetPresale sets the "presale" field. 3343 func (m *CoinBaseMutation) SetPresale(b bool) { 3344 m.presale = &b 3345 } 3346 3347 // Presale returns the value of the "presale" field in the mutation. 3348 func (m *CoinBaseMutation) Presale() (r bool, exists bool) { 3349 v := m.presale 3350 if v == nil { 3351 return 3352 } 3353 return *v, true 3354 } 3355 3356 // OldPresale returns the old "presale" field's value of the CoinBase entity. 3357 // If the CoinBase object wasn't provided to the builder, the object is fetched from the database. 3358 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 3359 func (m *CoinBaseMutation) OldPresale(ctx context.Context) (v bool, err error) { 3360 if !m.op.Is(OpUpdateOne) { 3361 return v, errors.New("OldPresale is only allowed on UpdateOne operations") 3362 } 3363 if m.id == nil || m.oldValue == nil { 3364 return v, errors.New("OldPresale requires an ID field in the mutation") 3365 } 3366 oldValue, err := m.oldValue(ctx) 3367 if err != nil { 3368 return v, fmt.Errorf("querying old value for OldPresale: %w", err) 3369 } 3370 return oldValue.Presale, nil 3371 } 3372 3373 // ClearPresale clears the value of the "presale" field. 3374 func (m *CoinBaseMutation) ClearPresale() { 3375 m.presale = nil 3376 m.clearedFields[coinbase.FieldPresale] = struct{}{} 3377 } 3378 3379 // PresaleCleared returns if the "presale" field was cleared in this mutation. 3380 func (m *CoinBaseMutation) PresaleCleared() bool { 3381 _, ok := m.clearedFields[coinbase.FieldPresale] 3382 return ok 3383 } 3384 3385 // ResetPresale resets all changes to the "presale" field. 3386 func (m *CoinBaseMutation) ResetPresale() { 3387 m.presale = nil 3388 delete(m.clearedFields, coinbase.FieldPresale) 3389 } 3390 3391 // SetUnit sets the "unit" field. 3392 func (m *CoinBaseMutation) SetUnit(s string) { 3393 m.unit = &s 3394 } 3395 3396 // Unit returns the value of the "unit" field in the mutation. 3397 func (m *CoinBaseMutation) Unit() (r string, exists bool) { 3398 v := m.unit 3399 if v == nil { 3400 return 3401 } 3402 return *v, true 3403 } 3404 3405 // OldUnit returns the old "unit" field's value of the CoinBase entity. 3406 // If the CoinBase object wasn't provided to the builder, the object is fetched from the database. 3407 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 3408 func (m *CoinBaseMutation) OldUnit(ctx context.Context) (v string, err error) { 3409 if !m.op.Is(OpUpdateOne) { 3410 return v, errors.New("OldUnit is only allowed on UpdateOne operations") 3411 } 3412 if m.id == nil || m.oldValue == nil { 3413 return v, errors.New("OldUnit requires an ID field in the mutation") 3414 } 3415 oldValue, err := m.oldValue(ctx) 3416 if err != nil { 3417 return v, fmt.Errorf("querying old value for OldUnit: %w", err) 3418 } 3419 return oldValue.Unit, nil 3420 } 3421 3422 // ClearUnit clears the value of the "unit" field. 3423 func (m *CoinBaseMutation) ClearUnit() { 3424 m.unit = nil 3425 m.clearedFields[coinbase.FieldUnit] = struct{}{} 3426 } 3427 3428 // UnitCleared returns if the "unit" field was cleared in this mutation. 3429 func (m *CoinBaseMutation) UnitCleared() bool { 3430 _, ok := m.clearedFields[coinbase.FieldUnit] 3431 return ok 3432 } 3433 3434 // ResetUnit resets all changes to the "unit" field. 3435 func (m *CoinBaseMutation) ResetUnit() { 3436 m.unit = nil 3437 delete(m.clearedFields, coinbase.FieldUnit) 3438 } 3439 3440 // SetEnv sets the "env" field. 3441 func (m *CoinBaseMutation) SetEnv(s string) { 3442 m.env = &s 3443 } 3444 3445 // Env returns the value of the "env" field in the mutation. 3446 func (m *CoinBaseMutation) Env() (r string, exists bool) { 3447 v := m.env 3448 if v == nil { 3449 return 3450 } 3451 return *v, true 3452 } 3453 3454 // OldEnv returns the old "env" field's value of the CoinBase entity. 3455 // If the CoinBase object wasn't provided to the builder, the object is fetched from the database. 3456 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 3457 func (m *CoinBaseMutation) OldEnv(ctx context.Context) (v string, err error) { 3458 if !m.op.Is(OpUpdateOne) { 3459 return v, errors.New("OldEnv is only allowed on UpdateOne operations") 3460 } 3461 if m.id == nil || m.oldValue == nil { 3462 return v, errors.New("OldEnv requires an ID field in the mutation") 3463 } 3464 oldValue, err := m.oldValue(ctx) 3465 if err != nil { 3466 return v, fmt.Errorf("querying old value for OldEnv: %w", err) 3467 } 3468 return oldValue.Env, nil 3469 } 3470 3471 // ClearEnv clears the value of the "env" field. 3472 func (m *CoinBaseMutation) ClearEnv() { 3473 m.env = nil 3474 m.clearedFields[coinbase.FieldEnv] = struct{}{} 3475 } 3476 3477 // EnvCleared returns if the "env" field was cleared in this mutation. 3478 func (m *CoinBaseMutation) EnvCleared() bool { 3479 _, ok := m.clearedFields[coinbase.FieldEnv] 3480 return ok 3481 } 3482 3483 // ResetEnv resets all changes to the "env" field. 3484 func (m *CoinBaseMutation) ResetEnv() { 3485 m.env = nil 3486 delete(m.clearedFields, coinbase.FieldEnv) 3487 } 3488 3489 // SetReservedAmount sets the "reserved_amount" field. 3490 func (m *CoinBaseMutation) SetReservedAmount(d decimal.Decimal) { 3491 m.reserved_amount = &d 3492 } 3493 3494 // ReservedAmount returns the value of the "reserved_amount" field in the mutation. 3495 func (m *CoinBaseMutation) ReservedAmount() (r decimal.Decimal, exists bool) { 3496 v := m.reserved_amount 3497 if v == nil { 3498 return 3499 } 3500 return *v, true 3501 } 3502 3503 // OldReservedAmount returns the old "reserved_amount" field's value of the CoinBase entity. 3504 // If the CoinBase object wasn't provided to the builder, the object is fetched from the database. 3505 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 3506 func (m *CoinBaseMutation) OldReservedAmount(ctx context.Context) (v decimal.Decimal, err error) { 3507 if !m.op.Is(OpUpdateOne) { 3508 return v, errors.New("OldReservedAmount is only allowed on UpdateOne operations") 3509 } 3510 if m.id == nil || m.oldValue == nil { 3511 return v, errors.New("OldReservedAmount requires an ID field in the mutation") 3512 } 3513 oldValue, err := m.oldValue(ctx) 3514 if err != nil { 3515 return v, fmt.Errorf("querying old value for OldReservedAmount: %w", err) 3516 } 3517 return oldValue.ReservedAmount, nil 3518 } 3519 3520 // ClearReservedAmount clears the value of the "reserved_amount" field. 3521 func (m *CoinBaseMutation) ClearReservedAmount() { 3522 m.reserved_amount = nil 3523 m.clearedFields[coinbase.FieldReservedAmount] = struct{}{} 3524 } 3525 3526 // ReservedAmountCleared returns if the "reserved_amount" field was cleared in this mutation. 3527 func (m *CoinBaseMutation) ReservedAmountCleared() bool { 3528 _, ok := m.clearedFields[coinbase.FieldReservedAmount] 3529 return ok 3530 } 3531 3532 // ResetReservedAmount resets all changes to the "reserved_amount" field. 3533 func (m *CoinBaseMutation) ResetReservedAmount() { 3534 m.reserved_amount = nil 3535 delete(m.clearedFields, coinbase.FieldReservedAmount) 3536 } 3537 3538 // SetForPay sets the "for_pay" field. 3539 func (m *CoinBaseMutation) SetForPay(b bool) { 3540 m.for_pay = &b 3541 } 3542 3543 // ForPay returns the value of the "for_pay" field in the mutation. 3544 func (m *CoinBaseMutation) ForPay() (r bool, exists bool) { 3545 v := m.for_pay 3546 if v == nil { 3547 return 3548 } 3549 return *v, true 3550 } 3551 3552 // OldForPay returns the old "for_pay" field's value of the CoinBase entity. 3553 // If the CoinBase object wasn't provided to the builder, the object is fetched from the database. 3554 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 3555 func (m *CoinBaseMutation) OldForPay(ctx context.Context) (v bool, err error) { 3556 if !m.op.Is(OpUpdateOne) { 3557 return v, errors.New("OldForPay is only allowed on UpdateOne operations") 3558 } 3559 if m.id == nil || m.oldValue == nil { 3560 return v, errors.New("OldForPay requires an ID field in the mutation") 3561 } 3562 oldValue, err := m.oldValue(ctx) 3563 if err != nil { 3564 return v, fmt.Errorf("querying old value for OldForPay: %w", err) 3565 } 3566 return oldValue.ForPay, nil 3567 } 3568 3569 // ClearForPay clears the value of the "for_pay" field. 3570 func (m *CoinBaseMutation) ClearForPay() { 3571 m.for_pay = nil 3572 m.clearedFields[coinbase.FieldForPay] = struct{}{} 3573 } 3574 3575 // ForPayCleared returns if the "for_pay" field was cleared in this mutation. 3576 func (m *CoinBaseMutation) ForPayCleared() bool { 3577 _, ok := m.clearedFields[coinbase.FieldForPay] 3578 return ok 3579 } 3580 3581 // ResetForPay resets all changes to the "for_pay" field. 3582 func (m *CoinBaseMutation) ResetForPay() { 3583 m.for_pay = nil 3584 delete(m.clearedFields, coinbase.FieldForPay) 3585 } 3586 3587 // SetDisabled sets the "disabled" field. 3588 func (m *CoinBaseMutation) SetDisabled(b bool) { 3589 m.disabled = &b 3590 } 3591 3592 // Disabled returns the value of the "disabled" field in the mutation. 3593 func (m *CoinBaseMutation) Disabled() (r bool, exists bool) { 3594 v := m.disabled 3595 if v == nil { 3596 return 3597 } 3598 return *v, true 3599 } 3600 3601 // OldDisabled returns the old "disabled" field's value of the CoinBase entity. 3602 // If the CoinBase object wasn't provided to the builder, the object is fetched from the database. 3603 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 3604 func (m *CoinBaseMutation) OldDisabled(ctx context.Context) (v bool, err error) { 3605 if !m.op.Is(OpUpdateOne) { 3606 return v, errors.New("OldDisabled is only allowed on UpdateOne operations") 3607 } 3608 if m.id == nil || m.oldValue == nil { 3609 return v, errors.New("OldDisabled requires an ID field in the mutation") 3610 } 3611 oldValue, err := m.oldValue(ctx) 3612 if err != nil { 3613 return v, fmt.Errorf("querying old value for OldDisabled: %w", err) 3614 } 3615 return oldValue.Disabled, nil 3616 } 3617 3618 // ClearDisabled clears the value of the "disabled" field. 3619 func (m *CoinBaseMutation) ClearDisabled() { 3620 m.disabled = nil 3621 m.clearedFields[coinbase.FieldDisabled] = struct{}{} 3622 } 3623 3624 // DisabledCleared returns if the "disabled" field was cleared in this mutation. 3625 func (m *CoinBaseMutation) DisabledCleared() bool { 3626 _, ok := m.clearedFields[coinbase.FieldDisabled] 3627 return ok 3628 } 3629 3630 // ResetDisabled resets all changes to the "disabled" field. 3631 func (m *CoinBaseMutation) ResetDisabled() { 3632 m.disabled = nil 3633 delete(m.clearedFields, coinbase.FieldDisabled) 3634 } 3635 3636 // Where appends a list predicates to the CoinBaseMutation builder. 3637 func (m *CoinBaseMutation) Where(ps ...predicate.CoinBase) { 3638 m.predicates = append(m.predicates, ps...) 3639 } 3640 3641 // Op returns the operation name. 3642 func (m *CoinBaseMutation) Op() Op { 3643 return m.op 3644 } 3645 3646 // Type returns the node type of this mutation (CoinBase). 3647 func (m *CoinBaseMutation) Type() string { 3648 return m.typ 3649 } 3650 3651 // Fields returns all fields that were changed during this mutation. Note that in 3652 // order to get all numeric fields that were incremented/decremented, call 3653 // AddedFields(). 3654 func (m *CoinBaseMutation) Fields() []string { 3655 fields := make([]string, 0, 12) 3656 if m.created_at != nil { 3657 fields = append(fields, coinbase.FieldCreatedAt) 3658 } 3659 if m.updated_at != nil { 3660 fields = append(fields, coinbase.FieldUpdatedAt) 3661 } 3662 if m.deleted_at != nil { 3663 fields = append(fields, coinbase.FieldDeletedAt) 3664 } 3665 if m.ent_id != nil { 3666 fields = append(fields, coinbase.FieldEntID) 3667 } 3668 if m.name != nil { 3669 fields = append(fields, coinbase.FieldName) 3670 } 3671 if m.logo != nil { 3672 fields = append(fields, coinbase.FieldLogo) 3673 } 3674 if m.presale != nil { 3675 fields = append(fields, coinbase.FieldPresale) 3676 } 3677 if m.unit != nil { 3678 fields = append(fields, coinbase.FieldUnit) 3679 } 3680 if m.env != nil { 3681 fields = append(fields, coinbase.FieldEnv) 3682 } 3683 if m.reserved_amount != nil { 3684 fields = append(fields, coinbase.FieldReservedAmount) 3685 } 3686 if m.for_pay != nil { 3687 fields = append(fields, coinbase.FieldForPay) 3688 } 3689 if m.disabled != nil { 3690 fields = append(fields, coinbase.FieldDisabled) 3691 } 3692 return fields 3693 } 3694 3695 // Field returns the value of a field with the given name. The second boolean 3696 // return value indicates that this field was not set, or was not defined in the 3697 // schema. 3698 func (m *CoinBaseMutation) Field(name string) (ent.Value, bool) { 3699 switch name { 3700 case coinbase.FieldCreatedAt: 3701 return m.CreatedAt() 3702 case coinbase.FieldUpdatedAt: 3703 return m.UpdatedAt() 3704 case coinbase.FieldDeletedAt: 3705 return m.DeletedAt() 3706 case coinbase.FieldEntID: 3707 return m.EntID() 3708 case coinbase.FieldName: 3709 return m.Name() 3710 case coinbase.FieldLogo: 3711 return m.Logo() 3712 case coinbase.FieldPresale: 3713 return m.Presale() 3714 case coinbase.FieldUnit: 3715 return m.Unit() 3716 case coinbase.FieldEnv: 3717 return m.Env() 3718 case coinbase.FieldReservedAmount: 3719 return m.ReservedAmount() 3720 case coinbase.FieldForPay: 3721 return m.ForPay() 3722 case coinbase.FieldDisabled: 3723 return m.Disabled() 3724 } 3725 return nil, false 3726 } 3727 3728 // OldField returns the old value of the field from the database. An error is 3729 // returned if the mutation operation is not UpdateOne, or the query to the 3730 // database failed. 3731 func (m *CoinBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 3732 switch name { 3733 case coinbase.FieldCreatedAt: 3734 return m.OldCreatedAt(ctx) 3735 case coinbase.FieldUpdatedAt: 3736 return m.OldUpdatedAt(ctx) 3737 case coinbase.FieldDeletedAt: 3738 return m.OldDeletedAt(ctx) 3739 case coinbase.FieldEntID: 3740 return m.OldEntID(ctx) 3741 case coinbase.FieldName: 3742 return m.OldName(ctx) 3743 case coinbase.FieldLogo: 3744 return m.OldLogo(ctx) 3745 case coinbase.FieldPresale: 3746 return m.OldPresale(ctx) 3747 case coinbase.FieldUnit: 3748 return m.OldUnit(ctx) 3749 case coinbase.FieldEnv: 3750 return m.OldEnv(ctx) 3751 case coinbase.FieldReservedAmount: 3752 return m.OldReservedAmount(ctx) 3753 case coinbase.FieldForPay: 3754 return m.OldForPay(ctx) 3755 case coinbase.FieldDisabled: 3756 return m.OldDisabled(ctx) 3757 } 3758 return nil, fmt.Errorf("unknown CoinBase field %s", name) 3759 } 3760 3761 // SetField sets the value of a field with the given name. It returns an error if 3762 // the field is not defined in the schema, or if the type mismatched the field 3763 // type. 3764 func (m *CoinBaseMutation) SetField(name string, value ent.Value) error { 3765 switch name { 3766 case coinbase.FieldCreatedAt: 3767 v, ok := value.(uint32) 3768 if !ok { 3769 return fmt.Errorf("unexpected type %T for field %s", value, name) 3770 } 3771 m.SetCreatedAt(v) 3772 return nil 3773 case coinbase.FieldUpdatedAt: 3774 v, ok := value.(uint32) 3775 if !ok { 3776 return fmt.Errorf("unexpected type %T for field %s", value, name) 3777 } 3778 m.SetUpdatedAt(v) 3779 return nil 3780 case coinbase.FieldDeletedAt: 3781 v, ok := value.(uint32) 3782 if !ok { 3783 return fmt.Errorf("unexpected type %T for field %s", value, name) 3784 } 3785 m.SetDeletedAt(v) 3786 return nil 3787 case coinbase.FieldEntID: 3788 v, ok := value.(uuid.UUID) 3789 if !ok { 3790 return fmt.Errorf("unexpected type %T for field %s", value, name) 3791 } 3792 m.SetEntID(v) 3793 return nil 3794 case coinbase.FieldName: 3795 v, ok := value.(string) 3796 if !ok { 3797 return fmt.Errorf("unexpected type %T for field %s", value, name) 3798 } 3799 m.SetName(v) 3800 return nil 3801 case coinbase.FieldLogo: 3802 v, ok := value.(string) 3803 if !ok { 3804 return fmt.Errorf("unexpected type %T for field %s", value, name) 3805 } 3806 m.SetLogo(v) 3807 return nil 3808 case coinbase.FieldPresale: 3809 v, ok := value.(bool) 3810 if !ok { 3811 return fmt.Errorf("unexpected type %T for field %s", value, name) 3812 } 3813 m.SetPresale(v) 3814 return nil 3815 case coinbase.FieldUnit: 3816 v, ok := value.(string) 3817 if !ok { 3818 return fmt.Errorf("unexpected type %T for field %s", value, name) 3819 } 3820 m.SetUnit(v) 3821 return nil 3822 case coinbase.FieldEnv: 3823 v, ok := value.(string) 3824 if !ok { 3825 return fmt.Errorf("unexpected type %T for field %s", value, name) 3826 } 3827 m.SetEnv(v) 3828 return nil 3829 case coinbase.FieldReservedAmount: 3830 v, ok := value.(decimal.Decimal) 3831 if !ok { 3832 return fmt.Errorf("unexpected type %T for field %s", value, name) 3833 } 3834 m.SetReservedAmount(v) 3835 return nil 3836 case coinbase.FieldForPay: 3837 v, ok := value.(bool) 3838 if !ok { 3839 return fmt.Errorf("unexpected type %T for field %s", value, name) 3840 } 3841 m.SetForPay(v) 3842 return nil 3843 case coinbase.FieldDisabled: 3844 v, ok := value.(bool) 3845 if !ok { 3846 return fmt.Errorf("unexpected type %T for field %s", value, name) 3847 } 3848 m.SetDisabled(v) 3849 return nil 3850 } 3851 return fmt.Errorf("unknown CoinBase field %s", name) 3852 } 3853 3854 // AddedFields returns all numeric fields that were incremented/decremented during 3855 // this mutation. 3856 func (m *CoinBaseMutation) AddedFields() []string { 3857 var fields []string 3858 if m.addcreated_at != nil { 3859 fields = append(fields, coinbase.FieldCreatedAt) 3860 } 3861 if m.addupdated_at != nil { 3862 fields = append(fields, coinbase.FieldUpdatedAt) 3863 } 3864 if m.adddeleted_at != nil { 3865 fields = append(fields, coinbase.FieldDeletedAt) 3866 } 3867 return fields 3868 } 3869 3870 // AddedField returns the numeric value that was incremented/decremented on a field 3871 // with the given name. The second boolean return value indicates that this field 3872 // was not set, or was not defined in the schema. 3873 func (m *CoinBaseMutation) AddedField(name string) (ent.Value, bool) { 3874 switch name { 3875 case coinbase.FieldCreatedAt: 3876 return m.AddedCreatedAt() 3877 case coinbase.FieldUpdatedAt: 3878 return m.AddedUpdatedAt() 3879 case coinbase.FieldDeletedAt: 3880 return m.AddedDeletedAt() 3881 } 3882 return nil, false 3883 } 3884 3885 // AddField adds the value to the field with the given name. It returns an error if 3886 // the field is not defined in the schema, or if the type mismatched the field 3887 // type. 3888 func (m *CoinBaseMutation) AddField(name string, value ent.Value) error { 3889 switch name { 3890 case coinbase.FieldCreatedAt: 3891 v, ok := value.(int32) 3892 if !ok { 3893 return fmt.Errorf("unexpected type %T for field %s", value, name) 3894 } 3895 m.AddCreatedAt(v) 3896 return nil 3897 case coinbase.FieldUpdatedAt: 3898 v, ok := value.(int32) 3899 if !ok { 3900 return fmt.Errorf("unexpected type %T for field %s", value, name) 3901 } 3902 m.AddUpdatedAt(v) 3903 return nil 3904 case coinbase.FieldDeletedAt: 3905 v, ok := value.(int32) 3906 if !ok { 3907 return fmt.Errorf("unexpected type %T for field %s", value, name) 3908 } 3909 m.AddDeletedAt(v) 3910 return nil 3911 } 3912 return fmt.Errorf("unknown CoinBase numeric field %s", name) 3913 } 3914 3915 // ClearedFields returns all nullable fields that were cleared during this 3916 // mutation. 3917 func (m *CoinBaseMutation) ClearedFields() []string { 3918 var fields []string 3919 if m.FieldCleared(coinbase.FieldName) { 3920 fields = append(fields, coinbase.FieldName) 3921 } 3922 if m.FieldCleared(coinbase.FieldLogo) { 3923 fields = append(fields, coinbase.FieldLogo) 3924 } 3925 if m.FieldCleared(coinbase.FieldPresale) { 3926 fields = append(fields, coinbase.FieldPresale) 3927 } 3928 if m.FieldCleared(coinbase.FieldUnit) { 3929 fields = append(fields, coinbase.FieldUnit) 3930 } 3931 if m.FieldCleared(coinbase.FieldEnv) { 3932 fields = append(fields, coinbase.FieldEnv) 3933 } 3934 if m.FieldCleared(coinbase.FieldReservedAmount) { 3935 fields = append(fields, coinbase.FieldReservedAmount) 3936 } 3937 if m.FieldCleared(coinbase.FieldForPay) { 3938 fields = append(fields, coinbase.FieldForPay) 3939 } 3940 if m.FieldCleared(coinbase.FieldDisabled) { 3941 fields = append(fields, coinbase.FieldDisabled) 3942 } 3943 return fields 3944 } 3945 3946 // FieldCleared returns a boolean indicating if a field with the given name was 3947 // cleared in this mutation. 3948 func (m *CoinBaseMutation) FieldCleared(name string) bool { 3949 _, ok := m.clearedFields[name] 3950 return ok 3951 } 3952 3953 // ClearField clears the value of the field with the given name. It returns an 3954 // error if the field is not defined in the schema. 3955 func (m *CoinBaseMutation) ClearField(name string) error { 3956 switch name { 3957 case coinbase.FieldName: 3958 m.ClearName() 3959 return nil 3960 case coinbase.FieldLogo: 3961 m.ClearLogo() 3962 return nil 3963 case coinbase.FieldPresale: 3964 m.ClearPresale() 3965 return nil 3966 case coinbase.FieldUnit: 3967 m.ClearUnit() 3968 return nil 3969 case coinbase.FieldEnv: 3970 m.ClearEnv() 3971 return nil 3972 case coinbase.FieldReservedAmount: 3973 m.ClearReservedAmount() 3974 return nil 3975 case coinbase.FieldForPay: 3976 m.ClearForPay() 3977 return nil 3978 case coinbase.FieldDisabled: 3979 m.ClearDisabled() 3980 return nil 3981 } 3982 return fmt.Errorf("unknown CoinBase nullable field %s", name) 3983 } 3984 3985 // ResetField resets all changes in the mutation for the field with the given name. 3986 // It returns an error if the field is not defined in the schema. 3987 func (m *CoinBaseMutation) ResetField(name string) error { 3988 switch name { 3989 case coinbase.FieldCreatedAt: 3990 m.ResetCreatedAt() 3991 return nil 3992 case coinbase.FieldUpdatedAt: 3993 m.ResetUpdatedAt() 3994 return nil 3995 case coinbase.FieldDeletedAt: 3996 m.ResetDeletedAt() 3997 return nil 3998 case coinbase.FieldEntID: 3999 m.ResetEntID() 4000 return nil 4001 case coinbase.FieldName: 4002 m.ResetName() 4003 return nil 4004 case coinbase.FieldLogo: 4005 m.ResetLogo() 4006 return nil 4007 case coinbase.FieldPresale: 4008 m.ResetPresale() 4009 return nil 4010 case coinbase.FieldUnit: 4011 m.ResetUnit() 4012 return nil 4013 case coinbase.FieldEnv: 4014 m.ResetEnv() 4015 return nil 4016 case coinbase.FieldReservedAmount: 4017 m.ResetReservedAmount() 4018 return nil 4019 case coinbase.FieldForPay: 4020 m.ResetForPay() 4021 return nil 4022 case coinbase.FieldDisabled: 4023 m.ResetDisabled() 4024 return nil 4025 } 4026 return fmt.Errorf("unknown CoinBase field %s", name) 4027 } 4028 4029 // AddedEdges returns all edge names that were set/added in this mutation. 4030 func (m *CoinBaseMutation) AddedEdges() []string { 4031 edges := make([]string, 0, 0) 4032 return edges 4033 } 4034 4035 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 4036 // name in this mutation. 4037 func (m *CoinBaseMutation) AddedIDs(name string) []ent.Value { 4038 return nil 4039 } 4040 4041 // RemovedEdges returns all edge names that were removed in this mutation. 4042 func (m *CoinBaseMutation) RemovedEdges() []string { 4043 edges := make([]string, 0, 0) 4044 return edges 4045 } 4046 4047 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 4048 // the given name in this mutation. 4049 func (m *CoinBaseMutation) RemovedIDs(name string) []ent.Value { 4050 return nil 4051 } 4052 4053 // ClearedEdges returns all edge names that were cleared in this mutation. 4054 func (m *CoinBaseMutation) ClearedEdges() []string { 4055 edges := make([]string, 0, 0) 4056 return edges 4057 } 4058 4059 // EdgeCleared returns a boolean which indicates if the edge with the given name 4060 // was cleared in this mutation. 4061 func (m *CoinBaseMutation) EdgeCleared(name string) bool { 4062 return false 4063 } 4064 4065 // ClearEdge clears the value of the edge with the given name. It returns an error 4066 // if that edge is not defined in the schema. 4067 func (m *CoinBaseMutation) ClearEdge(name string) error { 4068 return fmt.Errorf("unknown CoinBase unique edge %s", name) 4069 } 4070 4071 // ResetEdge resets all changes to the edge with the given name in this mutation. 4072 // It returns an error if the edge is not defined in the schema. 4073 func (m *CoinBaseMutation) ResetEdge(name string) error { 4074 return fmt.Errorf("unknown CoinBase edge %s", name) 4075 } 4076 4077 // CoinDescriptionMutation represents an operation that mutates the CoinDescription nodes in the graph. 4078 type CoinDescriptionMutation struct { 4079 config 4080 op Op 4081 typ string 4082 id *uint32 4083 created_at *uint32 4084 addcreated_at *int32 4085 updated_at *uint32 4086 addupdated_at *int32 4087 deleted_at *uint32 4088 adddeleted_at *int32 4089 ent_id *uuid.UUID 4090 app_id *uuid.UUID 4091 coin_type_id *uuid.UUID 4092 used_for *string 4093 title *string 4094 message *string 4095 clearedFields map[string]struct{} 4096 done bool 4097 oldValue func(context.Context) (*CoinDescription, error) 4098 predicates []predicate.CoinDescription 4099 } 4100 4101 var _ ent.Mutation = (*CoinDescriptionMutation)(nil) 4102 4103 // coindescriptionOption allows management of the mutation configuration using functional options. 4104 type coindescriptionOption func(*CoinDescriptionMutation) 4105 4106 // newCoinDescriptionMutation creates new mutation for the CoinDescription entity. 4107 func newCoinDescriptionMutation(c config, op Op, opts ...coindescriptionOption) *CoinDescriptionMutation { 4108 m := &CoinDescriptionMutation{ 4109 config: c, 4110 op: op, 4111 typ: TypeCoinDescription, 4112 clearedFields: make(map[string]struct{}), 4113 } 4114 for _, opt := range opts { 4115 opt(m) 4116 } 4117 return m 4118 } 4119 4120 // withCoinDescriptionID sets the ID field of the mutation. 4121 func withCoinDescriptionID(id uint32) coindescriptionOption { 4122 return func(m *CoinDescriptionMutation) { 4123 var ( 4124 err error 4125 once sync.Once 4126 value *CoinDescription 4127 ) 4128 m.oldValue = func(ctx context.Context) (*CoinDescription, error) { 4129 once.Do(func() { 4130 if m.done { 4131 err = errors.New("querying old values post mutation is not allowed") 4132 } else { 4133 value, err = m.Client().CoinDescription.Get(ctx, id) 4134 } 4135 }) 4136 return value, err 4137 } 4138 m.id = &id 4139 } 4140 } 4141 4142 // withCoinDescription sets the old CoinDescription of the mutation. 4143 func withCoinDescription(node *CoinDescription) coindescriptionOption { 4144 return func(m *CoinDescriptionMutation) { 4145 m.oldValue = func(context.Context) (*CoinDescription, error) { 4146 return node, nil 4147 } 4148 m.id = &node.ID 4149 } 4150 } 4151 4152 // Client returns a new `ent.Client` from the mutation. If the mutation was 4153 // executed in a transaction (ent.Tx), a transactional client is returned. 4154 func (m CoinDescriptionMutation) Client() *Client { 4155 client := &Client{config: m.config} 4156 client.init() 4157 return client 4158 } 4159 4160 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 4161 // it returns an error otherwise. 4162 func (m CoinDescriptionMutation) Tx() (*Tx, error) { 4163 if _, ok := m.driver.(*txDriver); !ok { 4164 return nil, errors.New("ent: mutation is not running in a transaction") 4165 } 4166 tx := &Tx{config: m.config} 4167 tx.init() 4168 return tx, nil 4169 } 4170 4171 // SetID sets the value of the id field. Note that this 4172 // operation is only accepted on creation of CoinDescription entities. 4173 func (m *CoinDescriptionMutation) SetID(id uint32) { 4174 m.id = &id 4175 } 4176 4177 // ID returns the ID value in the mutation. Note that the ID is only available 4178 // if it was provided to the builder or after it was returned from the database. 4179 func (m *CoinDescriptionMutation) ID() (id uint32, exists bool) { 4180 if m.id == nil { 4181 return 4182 } 4183 return *m.id, true 4184 } 4185 4186 // IDs queries the database and returns the entity ids that match the mutation's predicate. 4187 // That means, if the mutation is applied within a transaction with an isolation level such 4188 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 4189 // or updated by the mutation. 4190 func (m *CoinDescriptionMutation) IDs(ctx context.Context) ([]uint32, error) { 4191 switch { 4192 case m.op.Is(OpUpdateOne | OpDeleteOne): 4193 id, exists := m.ID() 4194 if exists { 4195 return []uint32{id}, nil 4196 } 4197 fallthrough 4198 case m.op.Is(OpUpdate | OpDelete): 4199 return m.Client().CoinDescription.Query().Where(m.predicates...).IDs(ctx) 4200 default: 4201 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 4202 } 4203 } 4204 4205 // SetCreatedAt sets the "created_at" field. 4206 func (m *CoinDescriptionMutation) SetCreatedAt(u uint32) { 4207 m.created_at = &u 4208 m.addcreated_at = nil 4209 } 4210 4211 // CreatedAt returns the value of the "created_at" field in the mutation. 4212 func (m *CoinDescriptionMutation) CreatedAt() (r uint32, exists bool) { 4213 v := m.created_at 4214 if v == nil { 4215 return 4216 } 4217 return *v, true 4218 } 4219 4220 // OldCreatedAt returns the old "created_at" field's value of the CoinDescription entity. 4221 // If the CoinDescription object wasn't provided to the builder, the object is fetched from the database. 4222 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 4223 func (m *CoinDescriptionMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 4224 if !m.op.Is(OpUpdateOne) { 4225 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 4226 } 4227 if m.id == nil || m.oldValue == nil { 4228 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 4229 } 4230 oldValue, err := m.oldValue(ctx) 4231 if err != nil { 4232 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 4233 } 4234 return oldValue.CreatedAt, nil 4235 } 4236 4237 // AddCreatedAt adds u to the "created_at" field. 4238 func (m *CoinDescriptionMutation) AddCreatedAt(u int32) { 4239 if m.addcreated_at != nil { 4240 *m.addcreated_at += u 4241 } else { 4242 m.addcreated_at = &u 4243 } 4244 } 4245 4246 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 4247 func (m *CoinDescriptionMutation) AddedCreatedAt() (r int32, exists bool) { 4248 v := m.addcreated_at 4249 if v == nil { 4250 return 4251 } 4252 return *v, true 4253 } 4254 4255 // ResetCreatedAt resets all changes to the "created_at" field. 4256 func (m *CoinDescriptionMutation) ResetCreatedAt() { 4257 m.created_at = nil 4258 m.addcreated_at = nil 4259 } 4260 4261 // SetUpdatedAt sets the "updated_at" field. 4262 func (m *CoinDescriptionMutation) SetUpdatedAt(u uint32) { 4263 m.updated_at = &u 4264 m.addupdated_at = nil 4265 } 4266 4267 // UpdatedAt returns the value of the "updated_at" field in the mutation. 4268 func (m *CoinDescriptionMutation) UpdatedAt() (r uint32, exists bool) { 4269 v := m.updated_at 4270 if v == nil { 4271 return 4272 } 4273 return *v, true 4274 } 4275 4276 // OldUpdatedAt returns the old "updated_at" field's value of the CoinDescription entity. 4277 // If the CoinDescription object wasn't provided to the builder, the object is fetched from the database. 4278 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 4279 func (m *CoinDescriptionMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 4280 if !m.op.Is(OpUpdateOne) { 4281 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 4282 } 4283 if m.id == nil || m.oldValue == nil { 4284 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 4285 } 4286 oldValue, err := m.oldValue(ctx) 4287 if err != nil { 4288 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 4289 } 4290 return oldValue.UpdatedAt, nil 4291 } 4292 4293 // AddUpdatedAt adds u to the "updated_at" field. 4294 func (m *CoinDescriptionMutation) AddUpdatedAt(u int32) { 4295 if m.addupdated_at != nil { 4296 *m.addupdated_at += u 4297 } else { 4298 m.addupdated_at = &u 4299 } 4300 } 4301 4302 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 4303 func (m *CoinDescriptionMutation) AddedUpdatedAt() (r int32, exists bool) { 4304 v := m.addupdated_at 4305 if v == nil { 4306 return 4307 } 4308 return *v, true 4309 } 4310 4311 // ResetUpdatedAt resets all changes to the "updated_at" field. 4312 func (m *CoinDescriptionMutation) ResetUpdatedAt() { 4313 m.updated_at = nil 4314 m.addupdated_at = nil 4315 } 4316 4317 // SetDeletedAt sets the "deleted_at" field. 4318 func (m *CoinDescriptionMutation) SetDeletedAt(u uint32) { 4319 m.deleted_at = &u 4320 m.adddeleted_at = nil 4321 } 4322 4323 // DeletedAt returns the value of the "deleted_at" field in the mutation. 4324 func (m *CoinDescriptionMutation) DeletedAt() (r uint32, exists bool) { 4325 v := m.deleted_at 4326 if v == nil { 4327 return 4328 } 4329 return *v, true 4330 } 4331 4332 // OldDeletedAt returns the old "deleted_at" field's value of the CoinDescription entity. 4333 // If the CoinDescription object wasn't provided to the builder, the object is fetched from the database. 4334 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 4335 func (m *CoinDescriptionMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 4336 if !m.op.Is(OpUpdateOne) { 4337 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 4338 } 4339 if m.id == nil || m.oldValue == nil { 4340 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 4341 } 4342 oldValue, err := m.oldValue(ctx) 4343 if err != nil { 4344 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 4345 } 4346 return oldValue.DeletedAt, nil 4347 } 4348 4349 // AddDeletedAt adds u to the "deleted_at" field. 4350 func (m *CoinDescriptionMutation) AddDeletedAt(u int32) { 4351 if m.adddeleted_at != nil { 4352 *m.adddeleted_at += u 4353 } else { 4354 m.adddeleted_at = &u 4355 } 4356 } 4357 4358 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 4359 func (m *CoinDescriptionMutation) AddedDeletedAt() (r int32, exists bool) { 4360 v := m.adddeleted_at 4361 if v == nil { 4362 return 4363 } 4364 return *v, true 4365 } 4366 4367 // ResetDeletedAt resets all changes to the "deleted_at" field. 4368 func (m *CoinDescriptionMutation) ResetDeletedAt() { 4369 m.deleted_at = nil 4370 m.adddeleted_at = nil 4371 } 4372 4373 // SetEntID sets the "ent_id" field. 4374 func (m *CoinDescriptionMutation) SetEntID(u uuid.UUID) { 4375 m.ent_id = &u 4376 } 4377 4378 // EntID returns the value of the "ent_id" field in the mutation. 4379 func (m *CoinDescriptionMutation) EntID() (r uuid.UUID, exists bool) { 4380 v := m.ent_id 4381 if v == nil { 4382 return 4383 } 4384 return *v, true 4385 } 4386 4387 // OldEntID returns the old "ent_id" field's value of the CoinDescription entity. 4388 // If the CoinDescription object wasn't provided to the builder, the object is fetched from the database. 4389 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 4390 func (m *CoinDescriptionMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 4391 if !m.op.Is(OpUpdateOne) { 4392 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 4393 } 4394 if m.id == nil || m.oldValue == nil { 4395 return v, errors.New("OldEntID requires an ID field in the mutation") 4396 } 4397 oldValue, err := m.oldValue(ctx) 4398 if err != nil { 4399 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 4400 } 4401 return oldValue.EntID, nil 4402 } 4403 4404 // ResetEntID resets all changes to the "ent_id" field. 4405 func (m *CoinDescriptionMutation) ResetEntID() { 4406 m.ent_id = nil 4407 } 4408 4409 // SetAppID sets the "app_id" field. 4410 func (m *CoinDescriptionMutation) SetAppID(u uuid.UUID) { 4411 m.app_id = &u 4412 } 4413 4414 // AppID returns the value of the "app_id" field in the mutation. 4415 func (m *CoinDescriptionMutation) AppID() (r uuid.UUID, exists bool) { 4416 v := m.app_id 4417 if v == nil { 4418 return 4419 } 4420 return *v, true 4421 } 4422 4423 // OldAppID returns the old "app_id" field's value of the CoinDescription entity. 4424 // If the CoinDescription object wasn't provided to the builder, the object is fetched from the database. 4425 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 4426 func (m *CoinDescriptionMutation) OldAppID(ctx context.Context) (v uuid.UUID, err error) { 4427 if !m.op.Is(OpUpdateOne) { 4428 return v, errors.New("OldAppID is only allowed on UpdateOne operations") 4429 } 4430 if m.id == nil || m.oldValue == nil { 4431 return v, errors.New("OldAppID requires an ID field in the mutation") 4432 } 4433 oldValue, err := m.oldValue(ctx) 4434 if err != nil { 4435 return v, fmt.Errorf("querying old value for OldAppID: %w", err) 4436 } 4437 return oldValue.AppID, nil 4438 } 4439 4440 // ClearAppID clears the value of the "app_id" field. 4441 func (m *CoinDescriptionMutation) ClearAppID() { 4442 m.app_id = nil 4443 m.clearedFields[coindescription.FieldAppID] = struct{}{} 4444 } 4445 4446 // AppIDCleared returns if the "app_id" field was cleared in this mutation. 4447 func (m *CoinDescriptionMutation) AppIDCleared() bool { 4448 _, ok := m.clearedFields[coindescription.FieldAppID] 4449 return ok 4450 } 4451 4452 // ResetAppID resets all changes to the "app_id" field. 4453 func (m *CoinDescriptionMutation) ResetAppID() { 4454 m.app_id = nil 4455 delete(m.clearedFields, coindescription.FieldAppID) 4456 } 4457 4458 // SetCoinTypeID sets the "coin_type_id" field. 4459 func (m *CoinDescriptionMutation) SetCoinTypeID(u uuid.UUID) { 4460 m.coin_type_id = &u 4461 } 4462 4463 // CoinTypeID returns the value of the "coin_type_id" field in the mutation. 4464 func (m *CoinDescriptionMutation) CoinTypeID() (r uuid.UUID, exists bool) { 4465 v := m.coin_type_id 4466 if v == nil { 4467 return 4468 } 4469 return *v, true 4470 } 4471 4472 // OldCoinTypeID returns the old "coin_type_id" field's value of the CoinDescription entity. 4473 // If the CoinDescription object wasn't provided to the builder, the object is fetched from the database. 4474 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 4475 func (m *CoinDescriptionMutation) OldCoinTypeID(ctx context.Context) (v uuid.UUID, err error) { 4476 if !m.op.Is(OpUpdateOne) { 4477 return v, errors.New("OldCoinTypeID is only allowed on UpdateOne operations") 4478 } 4479 if m.id == nil || m.oldValue == nil { 4480 return v, errors.New("OldCoinTypeID requires an ID field in the mutation") 4481 } 4482 oldValue, err := m.oldValue(ctx) 4483 if err != nil { 4484 return v, fmt.Errorf("querying old value for OldCoinTypeID: %w", err) 4485 } 4486 return oldValue.CoinTypeID, nil 4487 } 4488 4489 // ClearCoinTypeID clears the value of the "coin_type_id" field. 4490 func (m *CoinDescriptionMutation) ClearCoinTypeID() { 4491 m.coin_type_id = nil 4492 m.clearedFields[coindescription.FieldCoinTypeID] = struct{}{} 4493 } 4494 4495 // CoinTypeIDCleared returns if the "coin_type_id" field was cleared in this mutation. 4496 func (m *CoinDescriptionMutation) CoinTypeIDCleared() bool { 4497 _, ok := m.clearedFields[coindescription.FieldCoinTypeID] 4498 return ok 4499 } 4500 4501 // ResetCoinTypeID resets all changes to the "coin_type_id" field. 4502 func (m *CoinDescriptionMutation) ResetCoinTypeID() { 4503 m.coin_type_id = nil 4504 delete(m.clearedFields, coindescription.FieldCoinTypeID) 4505 } 4506 4507 // SetUsedFor sets the "used_for" field. 4508 func (m *CoinDescriptionMutation) SetUsedFor(s string) { 4509 m.used_for = &s 4510 } 4511 4512 // UsedFor returns the value of the "used_for" field in the mutation. 4513 func (m *CoinDescriptionMutation) UsedFor() (r string, exists bool) { 4514 v := m.used_for 4515 if v == nil { 4516 return 4517 } 4518 return *v, true 4519 } 4520 4521 // OldUsedFor returns the old "used_for" field's value of the CoinDescription entity. 4522 // If the CoinDescription object wasn't provided to the builder, the object is fetched from the database. 4523 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 4524 func (m *CoinDescriptionMutation) OldUsedFor(ctx context.Context) (v string, err error) { 4525 if !m.op.Is(OpUpdateOne) { 4526 return v, errors.New("OldUsedFor is only allowed on UpdateOne operations") 4527 } 4528 if m.id == nil || m.oldValue == nil { 4529 return v, errors.New("OldUsedFor requires an ID field in the mutation") 4530 } 4531 oldValue, err := m.oldValue(ctx) 4532 if err != nil { 4533 return v, fmt.Errorf("querying old value for OldUsedFor: %w", err) 4534 } 4535 return oldValue.UsedFor, nil 4536 } 4537 4538 // ClearUsedFor clears the value of the "used_for" field. 4539 func (m *CoinDescriptionMutation) ClearUsedFor() { 4540 m.used_for = nil 4541 m.clearedFields[coindescription.FieldUsedFor] = struct{}{} 4542 } 4543 4544 // UsedForCleared returns if the "used_for" field was cleared in this mutation. 4545 func (m *CoinDescriptionMutation) UsedForCleared() bool { 4546 _, ok := m.clearedFields[coindescription.FieldUsedFor] 4547 return ok 4548 } 4549 4550 // ResetUsedFor resets all changes to the "used_for" field. 4551 func (m *CoinDescriptionMutation) ResetUsedFor() { 4552 m.used_for = nil 4553 delete(m.clearedFields, coindescription.FieldUsedFor) 4554 } 4555 4556 // SetTitle sets the "title" field. 4557 func (m *CoinDescriptionMutation) SetTitle(s string) { 4558 m.title = &s 4559 } 4560 4561 // Title returns the value of the "title" field in the mutation. 4562 func (m *CoinDescriptionMutation) Title() (r string, exists bool) { 4563 v := m.title 4564 if v == nil { 4565 return 4566 } 4567 return *v, true 4568 } 4569 4570 // OldTitle returns the old "title" field's value of the CoinDescription entity. 4571 // If the CoinDescription object wasn't provided to the builder, the object is fetched from the database. 4572 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 4573 func (m *CoinDescriptionMutation) OldTitle(ctx context.Context) (v string, err error) { 4574 if !m.op.Is(OpUpdateOne) { 4575 return v, errors.New("OldTitle is only allowed on UpdateOne operations") 4576 } 4577 if m.id == nil || m.oldValue == nil { 4578 return v, errors.New("OldTitle requires an ID field in the mutation") 4579 } 4580 oldValue, err := m.oldValue(ctx) 4581 if err != nil { 4582 return v, fmt.Errorf("querying old value for OldTitle: %w", err) 4583 } 4584 return oldValue.Title, nil 4585 } 4586 4587 // ClearTitle clears the value of the "title" field. 4588 func (m *CoinDescriptionMutation) ClearTitle() { 4589 m.title = nil 4590 m.clearedFields[coindescription.FieldTitle] = struct{}{} 4591 } 4592 4593 // TitleCleared returns if the "title" field was cleared in this mutation. 4594 func (m *CoinDescriptionMutation) TitleCleared() bool { 4595 _, ok := m.clearedFields[coindescription.FieldTitle] 4596 return ok 4597 } 4598 4599 // ResetTitle resets all changes to the "title" field. 4600 func (m *CoinDescriptionMutation) ResetTitle() { 4601 m.title = nil 4602 delete(m.clearedFields, coindescription.FieldTitle) 4603 } 4604 4605 // SetMessage sets the "message" field. 4606 func (m *CoinDescriptionMutation) SetMessage(s string) { 4607 m.message = &s 4608 } 4609 4610 // Message returns the value of the "message" field in the mutation. 4611 func (m *CoinDescriptionMutation) Message() (r string, exists bool) { 4612 v := m.message 4613 if v == nil { 4614 return 4615 } 4616 return *v, true 4617 } 4618 4619 // OldMessage returns the old "message" field's value of the CoinDescription entity. 4620 // If the CoinDescription object wasn't provided to the builder, the object is fetched from the database. 4621 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 4622 func (m *CoinDescriptionMutation) OldMessage(ctx context.Context) (v string, err error) { 4623 if !m.op.Is(OpUpdateOne) { 4624 return v, errors.New("OldMessage is only allowed on UpdateOne operations") 4625 } 4626 if m.id == nil || m.oldValue == nil { 4627 return v, errors.New("OldMessage requires an ID field in the mutation") 4628 } 4629 oldValue, err := m.oldValue(ctx) 4630 if err != nil { 4631 return v, fmt.Errorf("querying old value for OldMessage: %w", err) 4632 } 4633 return oldValue.Message, nil 4634 } 4635 4636 // ClearMessage clears the value of the "message" field. 4637 func (m *CoinDescriptionMutation) ClearMessage() { 4638 m.message = nil 4639 m.clearedFields[coindescription.FieldMessage] = struct{}{} 4640 } 4641 4642 // MessageCleared returns if the "message" field was cleared in this mutation. 4643 func (m *CoinDescriptionMutation) MessageCleared() bool { 4644 _, ok := m.clearedFields[coindescription.FieldMessage] 4645 return ok 4646 } 4647 4648 // ResetMessage resets all changes to the "message" field. 4649 func (m *CoinDescriptionMutation) ResetMessage() { 4650 m.message = nil 4651 delete(m.clearedFields, coindescription.FieldMessage) 4652 } 4653 4654 // Where appends a list predicates to the CoinDescriptionMutation builder. 4655 func (m *CoinDescriptionMutation) Where(ps ...predicate.CoinDescription) { 4656 m.predicates = append(m.predicates, ps...) 4657 } 4658 4659 // Op returns the operation name. 4660 func (m *CoinDescriptionMutation) Op() Op { 4661 return m.op 4662 } 4663 4664 // Type returns the node type of this mutation (CoinDescription). 4665 func (m *CoinDescriptionMutation) Type() string { 4666 return m.typ 4667 } 4668 4669 // Fields returns all fields that were changed during this mutation. Note that in 4670 // order to get all numeric fields that were incremented/decremented, call 4671 // AddedFields(). 4672 func (m *CoinDescriptionMutation) Fields() []string { 4673 fields := make([]string, 0, 9) 4674 if m.created_at != nil { 4675 fields = append(fields, coindescription.FieldCreatedAt) 4676 } 4677 if m.updated_at != nil { 4678 fields = append(fields, coindescription.FieldUpdatedAt) 4679 } 4680 if m.deleted_at != nil { 4681 fields = append(fields, coindescription.FieldDeletedAt) 4682 } 4683 if m.ent_id != nil { 4684 fields = append(fields, coindescription.FieldEntID) 4685 } 4686 if m.app_id != nil { 4687 fields = append(fields, coindescription.FieldAppID) 4688 } 4689 if m.coin_type_id != nil { 4690 fields = append(fields, coindescription.FieldCoinTypeID) 4691 } 4692 if m.used_for != nil { 4693 fields = append(fields, coindescription.FieldUsedFor) 4694 } 4695 if m.title != nil { 4696 fields = append(fields, coindescription.FieldTitle) 4697 } 4698 if m.message != nil { 4699 fields = append(fields, coindescription.FieldMessage) 4700 } 4701 return fields 4702 } 4703 4704 // Field returns the value of a field with the given name. The second boolean 4705 // return value indicates that this field was not set, or was not defined in the 4706 // schema. 4707 func (m *CoinDescriptionMutation) Field(name string) (ent.Value, bool) { 4708 switch name { 4709 case coindescription.FieldCreatedAt: 4710 return m.CreatedAt() 4711 case coindescription.FieldUpdatedAt: 4712 return m.UpdatedAt() 4713 case coindescription.FieldDeletedAt: 4714 return m.DeletedAt() 4715 case coindescription.FieldEntID: 4716 return m.EntID() 4717 case coindescription.FieldAppID: 4718 return m.AppID() 4719 case coindescription.FieldCoinTypeID: 4720 return m.CoinTypeID() 4721 case coindescription.FieldUsedFor: 4722 return m.UsedFor() 4723 case coindescription.FieldTitle: 4724 return m.Title() 4725 case coindescription.FieldMessage: 4726 return m.Message() 4727 } 4728 return nil, false 4729 } 4730 4731 // OldField returns the old value of the field from the database. An error is 4732 // returned if the mutation operation is not UpdateOne, or the query to the 4733 // database failed. 4734 func (m *CoinDescriptionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 4735 switch name { 4736 case coindescription.FieldCreatedAt: 4737 return m.OldCreatedAt(ctx) 4738 case coindescription.FieldUpdatedAt: 4739 return m.OldUpdatedAt(ctx) 4740 case coindescription.FieldDeletedAt: 4741 return m.OldDeletedAt(ctx) 4742 case coindescription.FieldEntID: 4743 return m.OldEntID(ctx) 4744 case coindescription.FieldAppID: 4745 return m.OldAppID(ctx) 4746 case coindescription.FieldCoinTypeID: 4747 return m.OldCoinTypeID(ctx) 4748 case coindescription.FieldUsedFor: 4749 return m.OldUsedFor(ctx) 4750 case coindescription.FieldTitle: 4751 return m.OldTitle(ctx) 4752 case coindescription.FieldMessage: 4753 return m.OldMessage(ctx) 4754 } 4755 return nil, fmt.Errorf("unknown CoinDescription field %s", name) 4756 } 4757 4758 // SetField sets the value of a field with the given name. It returns an error if 4759 // the field is not defined in the schema, or if the type mismatched the field 4760 // type. 4761 func (m *CoinDescriptionMutation) SetField(name string, value ent.Value) error { 4762 switch name { 4763 case coindescription.FieldCreatedAt: 4764 v, ok := value.(uint32) 4765 if !ok { 4766 return fmt.Errorf("unexpected type %T for field %s", value, name) 4767 } 4768 m.SetCreatedAt(v) 4769 return nil 4770 case coindescription.FieldUpdatedAt: 4771 v, ok := value.(uint32) 4772 if !ok { 4773 return fmt.Errorf("unexpected type %T for field %s", value, name) 4774 } 4775 m.SetUpdatedAt(v) 4776 return nil 4777 case coindescription.FieldDeletedAt: 4778 v, ok := value.(uint32) 4779 if !ok { 4780 return fmt.Errorf("unexpected type %T for field %s", value, name) 4781 } 4782 m.SetDeletedAt(v) 4783 return nil 4784 case coindescription.FieldEntID: 4785 v, ok := value.(uuid.UUID) 4786 if !ok { 4787 return fmt.Errorf("unexpected type %T for field %s", value, name) 4788 } 4789 m.SetEntID(v) 4790 return nil 4791 case coindescription.FieldAppID: 4792 v, ok := value.(uuid.UUID) 4793 if !ok { 4794 return fmt.Errorf("unexpected type %T for field %s", value, name) 4795 } 4796 m.SetAppID(v) 4797 return nil 4798 case coindescription.FieldCoinTypeID: 4799 v, ok := value.(uuid.UUID) 4800 if !ok { 4801 return fmt.Errorf("unexpected type %T for field %s", value, name) 4802 } 4803 m.SetCoinTypeID(v) 4804 return nil 4805 case coindescription.FieldUsedFor: 4806 v, ok := value.(string) 4807 if !ok { 4808 return fmt.Errorf("unexpected type %T for field %s", value, name) 4809 } 4810 m.SetUsedFor(v) 4811 return nil 4812 case coindescription.FieldTitle: 4813 v, ok := value.(string) 4814 if !ok { 4815 return fmt.Errorf("unexpected type %T for field %s", value, name) 4816 } 4817 m.SetTitle(v) 4818 return nil 4819 case coindescription.FieldMessage: 4820 v, ok := value.(string) 4821 if !ok { 4822 return fmt.Errorf("unexpected type %T for field %s", value, name) 4823 } 4824 m.SetMessage(v) 4825 return nil 4826 } 4827 return fmt.Errorf("unknown CoinDescription field %s", name) 4828 } 4829 4830 // AddedFields returns all numeric fields that were incremented/decremented during 4831 // this mutation. 4832 func (m *CoinDescriptionMutation) AddedFields() []string { 4833 var fields []string 4834 if m.addcreated_at != nil { 4835 fields = append(fields, coindescription.FieldCreatedAt) 4836 } 4837 if m.addupdated_at != nil { 4838 fields = append(fields, coindescription.FieldUpdatedAt) 4839 } 4840 if m.adddeleted_at != nil { 4841 fields = append(fields, coindescription.FieldDeletedAt) 4842 } 4843 return fields 4844 } 4845 4846 // AddedField returns the numeric value that was incremented/decremented on a field 4847 // with the given name. The second boolean return value indicates that this field 4848 // was not set, or was not defined in the schema. 4849 func (m *CoinDescriptionMutation) AddedField(name string) (ent.Value, bool) { 4850 switch name { 4851 case coindescription.FieldCreatedAt: 4852 return m.AddedCreatedAt() 4853 case coindescription.FieldUpdatedAt: 4854 return m.AddedUpdatedAt() 4855 case coindescription.FieldDeletedAt: 4856 return m.AddedDeletedAt() 4857 } 4858 return nil, false 4859 } 4860 4861 // AddField adds the value to the field with the given name. It returns an error if 4862 // the field is not defined in the schema, or if the type mismatched the field 4863 // type. 4864 func (m *CoinDescriptionMutation) AddField(name string, value ent.Value) error { 4865 switch name { 4866 case coindescription.FieldCreatedAt: 4867 v, ok := value.(int32) 4868 if !ok { 4869 return fmt.Errorf("unexpected type %T for field %s", value, name) 4870 } 4871 m.AddCreatedAt(v) 4872 return nil 4873 case coindescription.FieldUpdatedAt: 4874 v, ok := value.(int32) 4875 if !ok { 4876 return fmt.Errorf("unexpected type %T for field %s", value, name) 4877 } 4878 m.AddUpdatedAt(v) 4879 return nil 4880 case coindescription.FieldDeletedAt: 4881 v, ok := value.(int32) 4882 if !ok { 4883 return fmt.Errorf("unexpected type %T for field %s", value, name) 4884 } 4885 m.AddDeletedAt(v) 4886 return nil 4887 } 4888 return fmt.Errorf("unknown CoinDescription numeric field %s", name) 4889 } 4890 4891 // ClearedFields returns all nullable fields that were cleared during this 4892 // mutation. 4893 func (m *CoinDescriptionMutation) ClearedFields() []string { 4894 var fields []string 4895 if m.FieldCleared(coindescription.FieldAppID) { 4896 fields = append(fields, coindescription.FieldAppID) 4897 } 4898 if m.FieldCleared(coindescription.FieldCoinTypeID) { 4899 fields = append(fields, coindescription.FieldCoinTypeID) 4900 } 4901 if m.FieldCleared(coindescription.FieldUsedFor) { 4902 fields = append(fields, coindescription.FieldUsedFor) 4903 } 4904 if m.FieldCleared(coindescription.FieldTitle) { 4905 fields = append(fields, coindescription.FieldTitle) 4906 } 4907 if m.FieldCleared(coindescription.FieldMessage) { 4908 fields = append(fields, coindescription.FieldMessage) 4909 } 4910 return fields 4911 } 4912 4913 // FieldCleared returns a boolean indicating if a field with the given name was 4914 // cleared in this mutation. 4915 func (m *CoinDescriptionMutation) FieldCleared(name string) bool { 4916 _, ok := m.clearedFields[name] 4917 return ok 4918 } 4919 4920 // ClearField clears the value of the field with the given name. It returns an 4921 // error if the field is not defined in the schema. 4922 func (m *CoinDescriptionMutation) ClearField(name string) error { 4923 switch name { 4924 case coindescription.FieldAppID: 4925 m.ClearAppID() 4926 return nil 4927 case coindescription.FieldCoinTypeID: 4928 m.ClearCoinTypeID() 4929 return nil 4930 case coindescription.FieldUsedFor: 4931 m.ClearUsedFor() 4932 return nil 4933 case coindescription.FieldTitle: 4934 m.ClearTitle() 4935 return nil 4936 case coindescription.FieldMessage: 4937 m.ClearMessage() 4938 return nil 4939 } 4940 return fmt.Errorf("unknown CoinDescription nullable field %s", name) 4941 } 4942 4943 // ResetField resets all changes in the mutation for the field with the given name. 4944 // It returns an error if the field is not defined in the schema. 4945 func (m *CoinDescriptionMutation) ResetField(name string) error { 4946 switch name { 4947 case coindescription.FieldCreatedAt: 4948 m.ResetCreatedAt() 4949 return nil 4950 case coindescription.FieldUpdatedAt: 4951 m.ResetUpdatedAt() 4952 return nil 4953 case coindescription.FieldDeletedAt: 4954 m.ResetDeletedAt() 4955 return nil 4956 case coindescription.FieldEntID: 4957 m.ResetEntID() 4958 return nil 4959 case coindescription.FieldAppID: 4960 m.ResetAppID() 4961 return nil 4962 case coindescription.FieldCoinTypeID: 4963 m.ResetCoinTypeID() 4964 return nil 4965 case coindescription.FieldUsedFor: 4966 m.ResetUsedFor() 4967 return nil 4968 case coindescription.FieldTitle: 4969 m.ResetTitle() 4970 return nil 4971 case coindescription.FieldMessage: 4972 m.ResetMessage() 4973 return nil 4974 } 4975 return fmt.Errorf("unknown CoinDescription field %s", name) 4976 } 4977 4978 // AddedEdges returns all edge names that were set/added in this mutation. 4979 func (m *CoinDescriptionMutation) AddedEdges() []string { 4980 edges := make([]string, 0, 0) 4981 return edges 4982 } 4983 4984 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 4985 // name in this mutation. 4986 func (m *CoinDescriptionMutation) AddedIDs(name string) []ent.Value { 4987 return nil 4988 } 4989 4990 // RemovedEdges returns all edge names that were removed in this mutation. 4991 func (m *CoinDescriptionMutation) RemovedEdges() []string { 4992 edges := make([]string, 0, 0) 4993 return edges 4994 } 4995 4996 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 4997 // the given name in this mutation. 4998 func (m *CoinDescriptionMutation) RemovedIDs(name string) []ent.Value { 4999 return nil 5000 } 5001 5002 // ClearedEdges returns all edge names that were cleared in this mutation. 5003 func (m *CoinDescriptionMutation) ClearedEdges() []string { 5004 edges := make([]string, 0, 0) 5005 return edges 5006 } 5007 5008 // EdgeCleared returns a boolean which indicates if the edge with the given name 5009 // was cleared in this mutation. 5010 func (m *CoinDescriptionMutation) EdgeCleared(name string) bool { 5011 return false 5012 } 5013 5014 // ClearEdge clears the value of the edge with the given name. It returns an error 5015 // if that edge is not defined in the schema. 5016 func (m *CoinDescriptionMutation) ClearEdge(name string) error { 5017 return fmt.Errorf("unknown CoinDescription unique edge %s", name) 5018 } 5019 5020 // ResetEdge resets all changes to the edge with the given name in this mutation. 5021 // It returns an error if the edge is not defined in the schema. 5022 func (m *CoinDescriptionMutation) ResetEdge(name string) error { 5023 return fmt.Errorf("unknown CoinDescription edge %s", name) 5024 } 5025 5026 // CoinExtraMutation represents an operation that mutates the CoinExtra nodes in the graph. 5027 type CoinExtraMutation struct { 5028 config 5029 op Op 5030 typ string 5031 id *uint32 5032 created_at *uint32 5033 addcreated_at *int32 5034 updated_at *uint32 5035 addupdated_at *int32 5036 deleted_at *uint32 5037 adddeleted_at *int32 5038 ent_id *uuid.UUID 5039 coin_type_id *uuid.UUID 5040 home_page *string 5041 specs *string 5042 stable_usd *bool 5043 clearedFields map[string]struct{} 5044 done bool 5045 oldValue func(context.Context) (*CoinExtra, error) 5046 predicates []predicate.CoinExtra 5047 } 5048 5049 var _ ent.Mutation = (*CoinExtraMutation)(nil) 5050 5051 // coinextraOption allows management of the mutation configuration using functional options. 5052 type coinextraOption func(*CoinExtraMutation) 5053 5054 // newCoinExtraMutation creates new mutation for the CoinExtra entity. 5055 func newCoinExtraMutation(c config, op Op, opts ...coinextraOption) *CoinExtraMutation { 5056 m := &CoinExtraMutation{ 5057 config: c, 5058 op: op, 5059 typ: TypeCoinExtra, 5060 clearedFields: make(map[string]struct{}), 5061 } 5062 for _, opt := range opts { 5063 opt(m) 5064 } 5065 return m 5066 } 5067 5068 // withCoinExtraID sets the ID field of the mutation. 5069 func withCoinExtraID(id uint32) coinextraOption { 5070 return func(m *CoinExtraMutation) { 5071 var ( 5072 err error 5073 once sync.Once 5074 value *CoinExtra 5075 ) 5076 m.oldValue = func(ctx context.Context) (*CoinExtra, error) { 5077 once.Do(func() { 5078 if m.done { 5079 err = errors.New("querying old values post mutation is not allowed") 5080 } else { 5081 value, err = m.Client().CoinExtra.Get(ctx, id) 5082 } 5083 }) 5084 return value, err 5085 } 5086 m.id = &id 5087 } 5088 } 5089 5090 // withCoinExtra sets the old CoinExtra of the mutation. 5091 func withCoinExtra(node *CoinExtra) coinextraOption { 5092 return func(m *CoinExtraMutation) { 5093 m.oldValue = func(context.Context) (*CoinExtra, error) { 5094 return node, nil 5095 } 5096 m.id = &node.ID 5097 } 5098 } 5099 5100 // Client returns a new `ent.Client` from the mutation. If the mutation was 5101 // executed in a transaction (ent.Tx), a transactional client is returned. 5102 func (m CoinExtraMutation) Client() *Client { 5103 client := &Client{config: m.config} 5104 client.init() 5105 return client 5106 } 5107 5108 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 5109 // it returns an error otherwise. 5110 func (m CoinExtraMutation) Tx() (*Tx, error) { 5111 if _, ok := m.driver.(*txDriver); !ok { 5112 return nil, errors.New("ent: mutation is not running in a transaction") 5113 } 5114 tx := &Tx{config: m.config} 5115 tx.init() 5116 return tx, nil 5117 } 5118 5119 // SetID sets the value of the id field. Note that this 5120 // operation is only accepted on creation of CoinExtra entities. 5121 func (m *CoinExtraMutation) SetID(id uint32) { 5122 m.id = &id 5123 } 5124 5125 // ID returns the ID value in the mutation. Note that the ID is only available 5126 // if it was provided to the builder or after it was returned from the database. 5127 func (m *CoinExtraMutation) ID() (id uint32, exists bool) { 5128 if m.id == nil { 5129 return 5130 } 5131 return *m.id, true 5132 } 5133 5134 // IDs queries the database and returns the entity ids that match the mutation's predicate. 5135 // That means, if the mutation is applied within a transaction with an isolation level such 5136 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 5137 // or updated by the mutation. 5138 func (m *CoinExtraMutation) IDs(ctx context.Context) ([]uint32, error) { 5139 switch { 5140 case m.op.Is(OpUpdateOne | OpDeleteOne): 5141 id, exists := m.ID() 5142 if exists { 5143 return []uint32{id}, nil 5144 } 5145 fallthrough 5146 case m.op.Is(OpUpdate | OpDelete): 5147 return m.Client().CoinExtra.Query().Where(m.predicates...).IDs(ctx) 5148 default: 5149 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 5150 } 5151 } 5152 5153 // SetCreatedAt sets the "created_at" field. 5154 func (m *CoinExtraMutation) SetCreatedAt(u uint32) { 5155 m.created_at = &u 5156 m.addcreated_at = nil 5157 } 5158 5159 // CreatedAt returns the value of the "created_at" field in the mutation. 5160 func (m *CoinExtraMutation) CreatedAt() (r uint32, exists bool) { 5161 v := m.created_at 5162 if v == nil { 5163 return 5164 } 5165 return *v, true 5166 } 5167 5168 // OldCreatedAt returns the old "created_at" field's value of the CoinExtra entity. 5169 // If the CoinExtra object wasn't provided to the builder, the object is fetched from the database. 5170 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5171 func (m *CoinExtraMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 5172 if !m.op.Is(OpUpdateOne) { 5173 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 5174 } 5175 if m.id == nil || m.oldValue == nil { 5176 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 5177 } 5178 oldValue, err := m.oldValue(ctx) 5179 if err != nil { 5180 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 5181 } 5182 return oldValue.CreatedAt, nil 5183 } 5184 5185 // AddCreatedAt adds u to the "created_at" field. 5186 func (m *CoinExtraMutation) AddCreatedAt(u int32) { 5187 if m.addcreated_at != nil { 5188 *m.addcreated_at += u 5189 } else { 5190 m.addcreated_at = &u 5191 } 5192 } 5193 5194 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 5195 func (m *CoinExtraMutation) AddedCreatedAt() (r int32, exists bool) { 5196 v := m.addcreated_at 5197 if v == nil { 5198 return 5199 } 5200 return *v, true 5201 } 5202 5203 // ResetCreatedAt resets all changes to the "created_at" field. 5204 func (m *CoinExtraMutation) ResetCreatedAt() { 5205 m.created_at = nil 5206 m.addcreated_at = nil 5207 } 5208 5209 // SetUpdatedAt sets the "updated_at" field. 5210 func (m *CoinExtraMutation) SetUpdatedAt(u uint32) { 5211 m.updated_at = &u 5212 m.addupdated_at = nil 5213 } 5214 5215 // UpdatedAt returns the value of the "updated_at" field in the mutation. 5216 func (m *CoinExtraMutation) UpdatedAt() (r uint32, exists bool) { 5217 v := m.updated_at 5218 if v == nil { 5219 return 5220 } 5221 return *v, true 5222 } 5223 5224 // OldUpdatedAt returns the old "updated_at" field's value of the CoinExtra entity. 5225 // If the CoinExtra object wasn't provided to the builder, the object is fetched from the database. 5226 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5227 func (m *CoinExtraMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 5228 if !m.op.Is(OpUpdateOne) { 5229 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 5230 } 5231 if m.id == nil || m.oldValue == nil { 5232 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 5233 } 5234 oldValue, err := m.oldValue(ctx) 5235 if err != nil { 5236 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 5237 } 5238 return oldValue.UpdatedAt, nil 5239 } 5240 5241 // AddUpdatedAt adds u to the "updated_at" field. 5242 func (m *CoinExtraMutation) AddUpdatedAt(u int32) { 5243 if m.addupdated_at != nil { 5244 *m.addupdated_at += u 5245 } else { 5246 m.addupdated_at = &u 5247 } 5248 } 5249 5250 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 5251 func (m *CoinExtraMutation) AddedUpdatedAt() (r int32, exists bool) { 5252 v := m.addupdated_at 5253 if v == nil { 5254 return 5255 } 5256 return *v, true 5257 } 5258 5259 // ResetUpdatedAt resets all changes to the "updated_at" field. 5260 func (m *CoinExtraMutation) ResetUpdatedAt() { 5261 m.updated_at = nil 5262 m.addupdated_at = nil 5263 } 5264 5265 // SetDeletedAt sets the "deleted_at" field. 5266 func (m *CoinExtraMutation) SetDeletedAt(u uint32) { 5267 m.deleted_at = &u 5268 m.adddeleted_at = nil 5269 } 5270 5271 // DeletedAt returns the value of the "deleted_at" field in the mutation. 5272 func (m *CoinExtraMutation) DeletedAt() (r uint32, exists bool) { 5273 v := m.deleted_at 5274 if v == nil { 5275 return 5276 } 5277 return *v, true 5278 } 5279 5280 // OldDeletedAt returns the old "deleted_at" field's value of the CoinExtra entity. 5281 // If the CoinExtra object wasn't provided to the builder, the object is fetched from the database. 5282 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5283 func (m *CoinExtraMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 5284 if !m.op.Is(OpUpdateOne) { 5285 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 5286 } 5287 if m.id == nil || m.oldValue == nil { 5288 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 5289 } 5290 oldValue, err := m.oldValue(ctx) 5291 if err != nil { 5292 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 5293 } 5294 return oldValue.DeletedAt, nil 5295 } 5296 5297 // AddDeletedAt adds u to the "deleted_at" field. 5298 func (m *CoinExtraMutation) AddDeletedAt(u int32) { 5299 if m.adddeleted_at != nil { 5300 *m.adddeleted_at += u 5301 } else { 5302 m.adddeleted_at = &u 5303 } 5304 } 5305 5306 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 5307 func (m *CoinExtraMutation) AddedDeletedAt() (r int32, exists bool) { 5308 v := m.adddeleted_at 5309 if v == nil { 5310 return 5311 } 5312 return *v, true 5313 } 5314 5315 // ResetDeletedAt resets all changes to the "deleted_at" field. 5316 func (m *CoinExtraMutation) ResetDeletedAt() { 5317 m.deleted_at = nil 5318 m.adddeleted_at = nil 5319 } 5320 5321 // SetEntID sets the "ent_id" field. 5322 func (m *CoinExtraMutation) SetEntID(u uuid.UUID) { 5323 m.ent_id = &u 5324 } 5325 5326 // EntID returns the value of the "ent_id" field in the mutation. 5327 func (m *CoinExtraMutation) EntID() (r uuid.UUID, exists bool) { 5328 v := m.ent_id 5329 if v == nil { 5330 return 5331 } 5332 return *v, true 5333 } 5334 5335 // OldEntID returns the old "ent_id" field's value of the CoinExtra entity. 5336 // If the CoinExtra object wasn't provided to the builder, the object is fetched from the database. 5337 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5338 func (m *CoinExtraMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 5339 if !m.op.Is(OpUpdateOne) { 5340 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 5341 } 5342 if m.id == nil || m.oldValue == nil { 5343 return v, errors.New("OldEntID requires an ID field in the mutation") 5344 } 5345 oldValue, err := m.oldValue(ctx) 5346 if err != nil { 5347 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 5348 } 5349 return oldValue.EntID, nil 5350 } 5351 5352 // ResetEntID resets all changes to the "ent_id" field. 5353 func (m *CoinExtraMutation) ResetEntID() { 5354 m.ent_id = nil 5355 } 5356 5357 // SetCoinTypeID sets the "coin_type_id" field. 5358 func (m *CoinExtraMutation) SetCoinTypeID(u uuid.UUID) { 5359 m.coin_type_id = &u 5360 } 5361 5362 // CoinTypeID returns the value of the "coin_type_id" field in the mutation. 5363 func (m *CoinExtraMutation) CoinTypeID() (r uuid.UUID, exists bool) { 5364 v := m.coin_type_id 5365 if v == nil { 5366 return 5367 } 5368 return *v, true 5369 } 5370 5371 // OldCoinTypeID returns the old "coin_type_id" field's value of the CoinExtra entity. 5372 // If the CoinExtra object wasn't provided to the builder, the object is fetched from the database. 5373 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5374 func (m *CoinExtraMutation) OldCoinTypeID(ctx context.Context) (v uuid.UUID, err error) { 5375 if !m.op.Is(OpUpdateOne) { 5376 return v, errors.New("OldCoinTypeID is only allowed on UpdateOne operations") 5377 } 5378 if m.id == nil || m.oldValue == nil { 5379 return v, errors.New("OldCoinTypeID requires an ID field in the mutation") 5380 } 5381 oldValue, err := m.oldValue(ctx) 5382 if err != nil { 5383 return v, fmt.Errorf("querying old value for OldCoinTypeID: %w", err) 5384 } 5385 return oldValue.CoinTypeID, nil 5386 } 5387 5388 // ClearCoinTypeID clears the value of the "coin_type_id" field. 5389 func (m *CoinExtraMutation) ClearCoinTypeID() { 5390 m.coin_type_id = nil 5391 m.clearedFields[coinextra.FieldCoinTypeID] = struct{}{} 5392 } 5393 5394 // CoinTypeIDCleared returns if the "coin_type_id" field was cleared in this mutation. 5395 func (m *CoinExtraMutation) CoinTypeIDCleared() bool { 5396 _, ok := m.clearedFields[coinextra.FieldCoinTypeID] 5397 return ok 5398 } 5399 5400 // ResetCoinTypeID resets all changes to the "coin_type_id" field. 5401 func (m *CoinExtraMutation) ResetCoinTypeID() { 5402 m.coin_type_id = nil 5403 delete(m.clearedFields, coinextra.FieldCoinTypeID) 5404 } 5405 5406 // SetHomePage sets the "home_page" field. 5407 func (m *CoinExtraMutation) SetHomePage(s string) { 5408 m.home_page = &s 5409 } 5410 5411 // HomePage returns the value of the "home_page" field in the mutation. 5412 func (m *CoinExtraMutation) HomePage() (r string, exists bool) { 5413 v := m.home_page 5414 if v == nil { 5415 return 5416 } 5417 return *v, true 5418 } 5419 5420 // OldHomePage returns the old "home_page" field's value of the CoinExtra entity. 5421 // If the CoinExtra object wasn't provided to the builder, the object is fetched from the database. 5422 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5423 func (m *CoinExtraMutation) OldHomePage(ctx context.Context) (v string, err error) { 5424 if !m.op.Is(OpUpdateOne) { 5425 return v, errors.New("OldHomePage is only allowed on UpdateOne operations") 5426 } 5427 if m.id == nil || m.oldValue == nil { 5428 return v, errors.New("OldHomePage requires an ID field in the mutation") 5429 } 5430 oldValue, err := m.oldValue(ctx) 5431 if err != nil { 5432 return v, fmt.Errorf("querying old value for OldHomePage: %w", err) 5433 } 5434 return oldValue.HomePage, nil 5435 } 5436 5437 // ClearHomePage clears the value of the "home_page" field. 5438 func (m *CoinExtraMutation) ClearHomePage() { 5439 m.home_page = nil 5440 m.clearedFields[coinextra.FieldHomePage] = struct{}{} 5441 } 5442 5443 // HomePageCleared returns if the "home_page" field was cleared in this mutation. 5444 func (m *CoinExtraMutation) HomePageCleared() bool { 5445 _, ok := m.clearedFields[coinextra.FieldHomePage] 5446 return ok 5447 } 5448 5449 // ResetHomePage resets all changes to the "home_page" field. 5450 func (m *CoinExtraMutation) ResetHomePage() { 5451 m.home_page = nil 5452 delete(m.clearedFields, coinextra.FieldHomePage) 5453 } 5454 5455 // SetSpecs sets the "specs" field. 5456 func (m *CoinExtraMutation) SetSpecs(s string) { 5457 m.specs = &s 5458 } 5459 5460 // Specs returns the value of the "specs" field in the mutation. 5461 func (m *CoinExtraMutation) Specs() (r string, exists bool) { 5462 v := m.specs 5463 if v == nil { 5464 return 5465 } 5466 return *v, true 5467 } 5468 5469 // OldSpecs returns the old "specs" field's value of the CoinExtra entity. 5470 // If the CoinExtra object wasn't provided to the builder, the object is fetched from the database. 5471 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5472 func (m *CoinExtraMutation) OldSpecs(ctx context.Context) (v string, err error) { 5473 if !m.op.Is(OpUpdateOne) { 5474 return v, errors.New("OldSpecs is only allowed on UpdateOne operations") 5475 } 5476 if m.id == nil || m.oldValue == nil { 5477 return v, errors.New("OldSpecs requires an ID field in the mutation") 5478 } 5479 oldValue, err := m.oldValue(ctx) 5480 if err != nil { 5481 return v, fmt.Errorf("querying old value for OldSpecs: %w", err) 5482 } 5483 return oldValue.Specs, nil 5484 } 5485 5486 // ClearSpecs clears the value of the "specs" field. 5487 func (m *CoinExtraMutation) ClearSpecs() { 5488 m.specs = nil 5489 m.clearedFields[coinextra.FieldSpecs] = struct{}{} 5490 } 5491 5492 // SpecsCleared returns if the "specs" field was cleared in this mutation. 5493 func (m *CoinExtraMutation) SpecsCleared() bool { 5494 _, ok := m.clearedFields[coinextra.FieldSpecs] 5495 return ok 5496 } 5497 5498 // ResetSpecs resets all changes to the "specs" field. 5499 func (m *CoinExtraMutation) ResetSpecs() { 5500 m.specs = nil 5501 delete(m.clearedFields, coinextra.FieldSpecs) 5502 } 5503 5504 // SetStableUsd sets the "stable_usd" field. 5505 func (m *CoinExtraMutation) SetStableUsd(b bool) { 5506 m.stable_usd = &b 5507 } 5508 5509 // StableUsd returns the value of the "stable_usd" field in the mutation. 5510 func (m *CoinExtraMutation) StableUsd() (r bool, exists bool) { 5511 v := m.stable_usd 5512 if v == nil { 5513 return 5514 } 5515 return *v, true 5516 } 5517 5518 // OldStableUsd returns the old "stable_usd" field's value of the CoinExtra entity. 5519 // If the CoinExtra object wasn't provided to the builder, the object is fetched from the database. 5520 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 5521 func (m *CoinExtraMutation) OldStableUsd(ctx context.Context) (v bool, err error) { 5522 if !m.op.Is(OpUpdateOne) { 5523 return v, errors.New("OldStableUsd is only allowed on UpdateOne operations") 5524 } 5525 if m.id == nil || m.oldValue == nil { 5526 return v, errors.New("OldStableUsd requires an ID field in the mutation") 5527 } 5528 oldValue, err := m.oldValue(ctx) 5529 if err != nil { 5530 return v, fmt.Errorf("querying old value for OldStableUsd: %w", err) 5531 } 5532 return oldValue.StableUsd, nil 5533 } 5534 5535 // ClearStableUsd clears the value of the "stable_usd" field. 5536 func (m *CoinExtraMutation) ClearStableUsd() { 5537 m.stable_usd = nil 5538 m.clearedFields[coinextra.FieldStableUsd] = struct{}{} 5539 } 5540 5541 // StableUsdCleared returns if the "stable_usd" field was cleared in this mutation. 5542 func (m *CoinExtraMutation) StableUsdCleared() bool { 5543 _, ok := m.clearedFields[coinextra.FieldStableUsd] 5544 return ok 5545 } 5546 5547 // ResetStableUsd resets all changes to the "stable_usd" field. 5548 func (m *CoinExtraMutation) ResetStableUsd() { 5549 m.stable_usd = nil 5550 delete(m.clearedFields, coinextra.FieldStableUsd) 5551 } 5552 5553 // Where appends a list predicates to the CoinExtraMutation builder. 5554 func (m *CoinExtraMutation) Where(ps ...predicate.CoinExtra) { 5555 m.predicates = append(m.predicates, ps...) 5556 } 5557 5558 // Op returns the operation name. 5559 func (m *CoinExtraMutation) Op() Op { 5560 return m.op 5561 } 5562 5563 // Type returns the node type of this mutation (CoinExtra). 5564 func (m *CoinExtraMutation) Type() string { 5565 return m.typ 5566 } 5567 5568 // Fields returns all fields that were changed during this mutation. Note that in 5569 // order to get all numeric fields that were incremented/decremented, call 5570 // AddedFields(). 5571 func (m *CoinExtraMutation) Fields() []string { 5572 fields := make([]string, 0, 8) 5573 if m.created_at != nil { 5574 fields = append(fields, coinextra.FieldCreatedAt) 5575 } 5576 if m.updated_at != nil { 5577 fields = append(fields, coinextra.FieldUpdatedAt) 5578 } 5579 if m.deleted_at != nil { 5580 fields = append(fields, coinextra.FieldDeletedAt) 5581 } 5582 if m.ent_id != nil { 5583 fields = append(fields, coinextra.FieldEntID) 5584 } 5585 if m.coin_type_id != nil { 5586 fields = append(fields, coinextra.FieldCoinTypeID) 5587 } 5588 if m.home_page != nil { 5589 fields = append(fields, coinextra.FieldHomePage) 5590 } 5591 if m.specs != nil { 5592 fields = append(fields, coinextra.FieldSpecs) 5593 } 5594 if m.stable_usd != nil { 5595 fields = append(fields, coinextra.FieldStableUsd) 5596 } 5597 return fields 5598 } 5599 5600 // Field returns the value of a field with the given name. The second boolean 5601 // return value indicates that this field was not set, or was not defined in the 5602 // schema. 5603 func (m *CoinExtraMutation) Field(name string) (ent.Value, bool) { 5604 switch name { 5605 case coinextra.FieldCreatedAt: 5606 return m.CreatedAt() 5607 case coinextra.FieldUpdatedAt: 5608 return m.UpdatedAt() 5609 case coinextra.FieldDeletedAt: 5610 return m.DeletedAt() 5611 case coinextra.FieldEntID: 5612 return m.EntID() 5613 case coinextra.FieldCoinTypeID: 5614 return m.CoinTypeID() 5615 case coinextra.FieldHomePage: 5616 return m.HomePage() 5617 case coinextra.FieldSpecs: 5618 return m.Specs() 5619 case coinextra.FieldStableUsd: 5620 return m.StableUsd() 5621 } 5622 return nil, false 5623 } 5624 5625 // OldField returns the old value of the field from the database. An error is 5626 // returned if the mutation operation is not UpdateOne, or the query to the 5627 // database failed. 5628 func (m *CoinExtraMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 5629 switch name { 5630 case coinextra.FieldCreatedAt: 5631 return m.OldCreatedAt(ctx) 5632 case coinextra.FieldUpdatedAt: 5633 return m.OldUpdatedAt(ctx) 5634 case coinextra.FieldDeletedAt: 5635 return m.OldDeletedAt(ctx) 5636 case coinextra.FieldEntID: 5637 return m.OldEntID(ctx) 5638 case coinextra.FieldCoinTypeID: 5639 return m.OldCoinTypeID(ctx) 5640 case coinextra.FieldHomePage: 5641 return m.OldHomePage(ctx) 5642 case coinextra.FieldSpecs: 5643 return m.OldSpecs(ctx) 5644 case coinextra.FieldStableUsd: 5645 return m.OldStableUsd(ctx) 5646 } 5647 return nil, fmt.Errorf("unknown CoinExtra field %s", name) 5648 } 5649 5650 // SetField sets the value of a field with the given name. It returns an error if 5651 // the field is not defined in the schema, or if the type mismatched the field 5652 // type. 5653 func (m *CoinExtraMutation) SetField(name string, value ent.Value) error { 5654 switch name { 5655 case coinextra.FieldCreatedAt: 5656 v, ok := value.(uint32) 5657 if !ok { 5658 return fmt.Errorf("unexpected type %T for field %s", value, name) 5659 } 5660 m.SetCreatedAt(v) 5661 return nil 5662 case coinextra.FieldUpdatedAt: 5663 v, ok := value.(uint32) 5664 if !ok { 5665 return fmt.Errorf("unexpected type %T for field %s", value, name) 5666 } 5667 m.SetUpdatedAt(v) 5668 return nil 5669 case coinextra.FieldDeletedAt: 5670 v, ok := value.(uint32) 5671 if !ok { 5672 return fmt.Errorf("unexpected type %T for field %s", value, name) 5673 } 5674 m.SetDeletedAt(v) 5675 return nil 5676 case coinextra.FieldEntID: 5677 v, ok := value.(uuid.UUID) 5678 if !ok { 5679 return fmt.Errorf("unexpected type %T for field %s", value, name) 5680 } 5681 m.SetEntID(v) 5682 return nil 5683 case coinextra.FieldCoinTypeID: 5684 v, ok := value.(uuid.UUID) 5685 if !ok { 5686 return fmt.Errorf("unexpected type %T for field %s", value, name) 5687 } 5688 m.SetCoinTypeID(v) 5689 return nil 5690 case coinextra.FieldHomePage: 5691 v, ok := value.(string) 5692 if !ok { 5693 return fmt.Errorf("unexpected type %T for field %s", value, name) 5694 } 5695 m.SetHomePage(v) 5696 return nil 5697 case coinextra.FieldSpecs: 5698 v, ok := value.(string) 5699 if !ok { 5700 return fmt.Errorf("unexpected type %T for field %s", value, name) 5701 } 5702 m.SetSpecs(v) 5703 return nil 5704 case coinextra.FieldStableUsd: 5705 v, ok := value.(bool) 5706 if !ok { 5707 return fmt.Errorf("unexpected type %T for field %s", value, name) 5708 } 5709 m.SetStableUsd(v) 5710 return nil 5711 } 5712 return fmt.Errorf("unknown CoinExtra field %s", name) 5713 } 5714 5715 // AddedFields returns all numeric fields that were incremented/decremented during 5716 // this mutation. 5717 func (m *CoinExtraMutation) AddedFields() []string { 5718 var fields []string 5719 if m.addcreated_at != nil { 5720 fields = append(fields, coinextra.FieldCreatedAt) 5721 } 5722 if m.addupdated_at != nil { 5723 fields = append(fields, coinextra.FieldUpdatedAt) 5724 } 5725 if m.adddeleted_at != nil { 5726 fields = append(fields, coinextra.FieldDeletedAt) 5727 } 5728 return fields 5729 } 5730 5731 // AddedField returns the numeric value that was incremented/decremented on a field 5732 // with the given name. The second boolean return value indicates that this field 5733 // was not set, or was not defined in the schema. 5734 func (m *CoinExtraMutation) AddedField(name string) (ent.Value, bool) { 5735 switch name { 5736 case coinextra.FieldCreatedAt: 5737 return m.AddedCreatedAt() 5738 case coinextra.FieldUpdatedAt: 5739 return m.AddedUpdatedAt() 5740 case coinextra.FieldDeletedAt: 5741 return m.AddedDeletedAt() 5742 } 5743 return nil, false 5744 } 5745 5746 // AddField adds the value to the field with the given name. It returns an error if 5747 // the field is not defined in the schema, or if the type mismatched the field 5748 // type. 5749 func (m *CoinExtraMutation) AddField(name string, value ent.Value) error { 5750 switch name { 5751 case coinextra.FieldCreatedAt: 5752 v, ok := value.(int32) 5753 if !ok { 5754 return fmt.Errorf("unexpected type %T for field %s", value, name) 5755 } 5756 m.AddCreatedAt(v) 5757 return nil 5758 case coinextra.FieldUpdatedAt: 5759 v, ok := value.(int32) 5760 if !ok { 5761 return fmt.Errorf("unexpected type %T for field %s", value, name) 5762 } 5763 m.AddUpdatedAt(v) 5764 return nil 5765 case coinextra.FieldDeletedAt: 5766 v, ok := value.(int32) 5767 if !ok { 5768 return fmt.Errorf("unexpected type %T for field %s", value, name) 5769 } 5770 m.AddDeletedAt(v) 5771 return nil 5772 } 5773 return fmt.Errorf("unknown CoinExtra numeric field %s", name) 5774 } 5775 5776 // ClearedFields returns all nullable fields that were cleared during this 5777 // mutation. 5778 func (m *CoinExtraMutation) ClearedFields() []string { 5779 var fields []string 5780 if m.FieldCleared(coinextra.FieldCoinTypeID) { 5781 fields = append(fields, coinextra.FieldCoinTypeID) 5782 } 5783 if m.FieldCleared(coinextra.FieldHomePage) { 5784 fields = append(fields, coinextra.FieldHomePage) 5785 } 5786 if m.FieldCleared(coinextra.FieldSpecs) { 5787 fields = append(fields, coinextra.FieldSpecs) 5788 } 5789 if m.FieldCleared(coinextra.FieldStableUsd) { 5790 fields = append(fields, coinextra.FieldStableUsd) 5791 } 5792 return fields 5793 } 5794 5795 // FieldCleared returns a boolean indicating if a field with the given name was 5796 // cleared in this mutation. 5797 func (m *CoinExtraMutation) FieldCleared(name string) bool { 5798 _, ok := m.clearedFields[name] 5799 return ok 5800 } 5801 5802 // ClearField clears the value of the field with the given name. It returns an 5803 // error if the field is not defined in the schema. 5804 func (m *CoinExtraMutation) ClearField(name string) error { 5805 switch name { 5806 case coinextra.FieldCoinTypeID: 5807 m.ClearCoinTypeID() 5808 return nil 5809 case coinextra.FieldHomePage: 5810 m.ClearHomePage() 5811 return nil 5812 case coinextra.FieldSpecs: 5813 m.ClearSpecs() 5814 return nil 5815 case coinextra.FieldStableUsd: 5816 m.ClearStableUsd() 5817 return nil 5818 } 5819 return fmt.Errorf("unknown CoinExtra nullable field %s", name) 5820 } 5821 5822 // ResetField resets all changes in the mutation for the field with the given name. 5823 // It returns an error if the field is not defined in the schema. 5824 func (m *CoinExtraMutation) ResetField(name string) error { 5825 switch name { 5826 case coinextra.FieldCreatedAt: 5827 m.ResetCreatedAt() 5828 return nil 5829 case coinextra.FieldUpdatedAt: 5830 m.ResetUpdatedAt() 5831 return nil 5832 case coinextra.FieldDeletedAt: 5833 m.ResetDeletedAt() 5834 return nil 5835 case coinextra.FieldEntID: 5836 m.ResetEntID() 5837 return nil 5838 case coinextra.FieldCoinTypeID: 5839 m.ResetCoinTypeID() 5840 return nil 5841 case coinextra.FieldHomePage: 5842 m.ResetHomePage() 5843 return nil 5844 case coinextra.FieldSpecs: 5845 m.ResetSpecs() 5846 return nil 5847 case coinextra.FieldStableUsd: 5848 m.ResetStableUsd() 5849 return nil 5850 } 5851 return fmt.Errorf("unknown CoinExtra field %s", name) 5852 } 5853 5854 // AddedEdges returns all edge names that were set/added in this mutation. 5855 func (m *CoinExtraMutation) AddedEdges() []string { 5856 edges := make([]string, 0, 0) 5857 return edges 5858 } 5859 5860 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 5861 // name in this mutation. 5862 func (m *CoinExtraMutation) AddedIDs(name string) []ent.Value { 5863 return nil 5864 } 5865 5866 // RemovedEdges returns all edge names that were removed in this mutation. 5867 func (m *CoinExtraMutation) RemovedEdges() []string { 5868 edges := make([]string, 0, 0) 5869 return edges 5870 } 5871 5872 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 5873 // the given name in this mutation. 5874 func (m *CoinExtraMutation) RemovedIDs(name string) []ent.Value { 5875 return nil 5876 } 5877 5878 // ClearedEdges returns all edge names that were cleared in this mutation. 5879 func (m *CoinExtraMutation) ClearedEdges() []string { 5880 edges := make([]string, 0, 0) 5881 return edges 5882 } 5883 5884 // EdgeCleared returns a boolean which indicates if the edge with the given name 5885 // was cleared in this mutation. 5886 func (m *CoinExtraMutation) EdgeCleared(name string) bool { 5887 return false 5888 } 5889 5890 // ClearEdge clears the value of the edge with the given name. It returns an error 5891 // if that edge is not defined in the schema. 5892 func (m *CoinExtraMutation) ClearEdge(name string) error { 5893 return fmt.Errorf("unknown CoinExtra unique edge %s", name) 5894 } 5895 5896 // ResetEdge resets all changes to the edge with the given name in this mutation. 5897 // It returns an error if the edge is not defined in the schema. 5898 func (m *CoinExtraMutation) ResetEdge(name string) error { 5899 return fmt.Errorf("unknown CoinExtra edge %s", name) 5900 } 5901 5902 // CoinFiatMutation represents an operation that mutates the CoinFiat nodes in the graph. 5903 type CoinFiatMutation struct { 5904 config 5905 op Op 5906 typ string 5907 id *uint32 5908 created_at *uint32 5909 addcreated_at *int32 5910 updated_at *uint32 5911 addupdated_at *int32 5912 deleted_at *uint32 5913 adddeleted_at *int32 5914 ent_id *uuid.UUID 5915 coin_type_id *uuid.UUID 5916 fiat_id *uuid.UUID 5917 feed_type *string 5918 clearedFields map[string]struct{} 5919 done bool 5920 oldValue func(context.Context) (*CoinFiat, error) 5921 predicates []predicate.CoinFiat 5922 } 5923 5924 var _ ent.Mutation = (*CoinFiatMutation)(nil) 5925 5926 // coinfiatOption allows management of the mutation configuration using functional options. 5927 type coinfiatOption func(*CoinFiatMutation) 5928 5929 // newCoinFiatMutation creates new mutation for the CoinFiat entity. 5930 func newCoinFiatMutation(c config, op Op, opts ...coinfiatOption) *CoinFiatMutation { 5931 m := &CoinFiatMutation{ 5932 config: c, 5933 op: op, 5934 typ: TypeCoinFiat, 5935 clearedFields: make(map[string]struct{}), 5936 } 5937 for _, opt := range opts { 5938 opt(m) 5939 } 5940 return m 5941 } 5942 5943 // withCoinFiatID sets the ID field of the mutation. 5944 func withCoinFiatID(id uint32) coinfiatOption { 5945 return func(m *CoinFiatMutation) { 5946 var ( 5947 err error 5948 once sync.Once 5949 value *CoinFiat 5950 ) 5951 m.oldValue = func(ctx context.Context) (*CoinFiat, error) { 5952 once.Do(func() { 5953 if m.done { 5954 err = errors.New("querying old values post mutation is not allowed") 5955 } else { 5956 value, err = m.Client().CoinFiat.Get(ctx, id) 5957 } 5958 }) 5959 return value, err 5960 } 5961 m.id = &id 5962 } 5963 } 5964 5965 // withCoinFiat sets the old CoinFiat of the mutation. 5966 func withCoinFiat(node *CoinFiat) coinfiatOption { 5967 return func(m *CoinFiatMutation) { 5968 m.oldValue = func(context.Context) (*CoinFiat, error) { 5969 return node, nil 5970 } 5971 m.id = &node.ID 5972 } 5973 } 5974 5975 // Client returns a new `ent.Client` from the mutation. If the mutation was 5976 // executed in a transaction (ent.Tx), a transactional client is returned. 5977 func (m CoinFiatMutation) Client() *Client { 5978 client := &Client{config: m.config} 5979 client.init() 5980 return client 5981 } 5982 5983 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 5984 // it returns an error otherwise. 5985 func (m CoinFiatMutation) Tx() (*Tx, error) { 5986 if _, ok := m.driver.(*txDriver); !ok { 5987 return nil, errors.New("ent: mutation is not running in a transaction") 5988 } 5989 tx := &Tx{config: m.config} 5990 tx.init() 5991 return tx, nil 5992 } 5993 5994 // SetID sets the value of the id field. Note that this 5995 // operation is only accepted on creation of CoinFiat entities. 5996 func (m *CoinFiatMutation) SetID(id uint32) { 5997 m.id = &id 5998 } 5999 6000 // ID returns the ID value in the mutation. Note that the ID is only available 6001 // if it was provided to the builder or after it was returned from the database. 6002 func (m *CoinFiatMutation) ID() (id uint32, exists bool) { 6003 if m.id == nil { 6004 return 6005 } 6006 return *m.id, true 6007 } 6008 6009 // IDs queries the database and returns the entity ids that match the mutation's predicate. 6010 // That means, if the mutation is applied within a transaction with an isolation level such 6011 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 6012 // or updated by the mutation. 6013 func (m *CoinFiatMutation) IDs(ctx context.Context) ([]uint32, error) { 6014 switch { 6015 case m.op.Is(OpUpdateOne | OpDeleteOne): 6016 id, exists := m.ID() 6017 if exists { 6018 return []uint32{id}, nil 6019 } 6020 fallthrough 6021 case m.op.Is(OpUpdate | OpDelete): 6022 return m.Client().CoinFiat.Query().Where(m.predicates...).IDs(ctx) 6023 default: 6024 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 6025 } 6026 } 6027 6028 // SetCreatedAt sets the "created_at" field. 6029 func (m *CoinFiatMutation) SetCreatedAt(u uint32) { 6030 m.created_at = &u 6031 m.addcreated_at = nil 6032 } 6033 6034 // CreatedAt returns the value of the "created_at" field in the mutation. 6035 func (m *CoinFiatMutation) CreatedAt() (r uint32, exists bool) { 6036 v := m.created_at 6037 if v == nil { 6038 return 6039 } 6040 return *v, true 6041 } 6042 6043 // OldCreatedAt returns the old "created_at" field's value of the CoinFiat entity. 6044 // If the CoinFiat object wasn't provided to the builder, the object is fetched from the database. 6045 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 6046 func (m *CoinFiatMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 6047 if !m.op.Is(OpUpdateOne) { 6048 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 6049 } 6050 if m.id == nil || m.oldValue == nil { 6051 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 6052 } 6053 oldValue, err := m.oldValue(ctx) 6054 if err != nil { 6055 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 6056 } 6057 return oldValue.CreatedAt, nil 6058 } 6059 6060 // AddCreatedAt adds u to the "created_at" field. 6061 func (m *CoinFiatMutation) AddCreatedAt(u int32) { 6062 if m.addcreated_at != nil { 6063 *m.addcreated_at += u 6064 } else { 6065 m.addcreated_at = &u 6066 } 6067 } 6068 6069 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 6070 func (m *CoinFiatMutation) AddedCreatedAt() (r int32, exists bool) { 6071 v := m.addcreated_at 6072 if v == nil { 6073 return 6074 } 6075 return *v, true 6076 } 6077 6078 // ResetCreatedAt resets all changes to the "created_at" field. 6079 func (m *CoinFiatMutation) ResetCreatedAt() { 6080 m.created_at = nil 6081 m.addcreated_at = nil 6082 } 6083 6084 // SetUpdatedAt sets the "updated_at" field. 6085 func (m *CoinFiatMutation) SetUpdatedAt(u uint32) { 6086 m.updated_at = &u 6087 m.addupdated_at = nil 6088 } 6089 6090 // UpdatedAt returns the value of the "updated_at" field in the mutation. 6091 func (m *CoinFiatMutation) UpdatedAt() (r uint32, exists bool) { 6092 v := m.updated_at 6093 if v == nil { 6094 return 6095 } 6096 return *v, true 6097 } 6098 6099 // OldUpdatedAt returns the old "updated_at" field's value of the CoinFiat entity. 6100 // If the CoinFiat object wasn't provided to the builder, the object is fetched from the database. 6101 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 6102 func (m *CoinFiatMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 6103 if !m.op.Is(OpUpdateOne) { 6104 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 6105 } 6106 if m.id == nil || m.oldValue == nil { 6107 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 6108 } 6109 oldValue, err := m.oldValue(ctx) 6110 if err != nil { 6111 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 6112 } 6113 return oldValue.UpdatedAt, nil 6114 } 6115 6116 // AddUpdatedAt adds u to the "updated_at" field. 6117 func (m *CoinFiatMutation) AddUpdatedAt(u int32) { 6118 if m.addupdated_at != nil { 6119 *m.addupdated_at += u 6120 } else { 6121 m.addupdated_at = &u 6122 } 6123 } 6124 6125 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 6126 func (m *CoinFiatMutation) AddedUpdatedAt() (r int32, exists bool) { 6127 v := m.addupdated_at 6128 if v == nil { 6129 return 6130 } 6131 return *v, true 6132 } 6133 6134 // ResetUpdatedAt resets all changes to the "updated_at" field. 6135 func (m *CoinFiatMutation) ResetUpdatedAt() { 6136 m.updated_at = nil 6137 m.addupdated_at = nil 6138 } 6139 6140 // SetDeletedAt sets the "deleted_at" field. 6141 func (m *CoinFiatMutation) SetDeletedAt(u uint32) { 6142 m.deleted_at = &u 6143 m.adddeleted_at = nil 6144 } 6145 6146 // DeletedAt returns the value of the "deleted_at" field in the mutation. 6147 func (m *CoinFiatMutation) DeletedAt() (r uint32, exists bool) { 6148 v := m.deleted_at 6149 if v == nil { 6150 return 6151 } 6152 return *v, true 6153 } 6154 6155 // OldDeletedAt returns the old "deleted_at" field's value of the CoinFiat entity. 6156 // If the CoinFiat object wasn't provided to the builder, the object is fetched from the database. 6157 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 6158 func (m *CoinFiatMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 6159 if !m.op.Is(OpUpdateOne) { 6160 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 6161 } 6162 if m.id == nil || m.oldValue == nil { 6163 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 6164 } 6165 oldValue, err := m.oldValue(ctx) 6166 if err != nil { 6167 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 6168 } 6169 return oldValue.DeletedAt, nil 6170 } 6171 6172 // AddDeletedAt adds u to the "deleted_at" field. 6173 func (m *CoinFiatMutation) AddDeletedAt(u int32) { 6174 if m.adddeleted_at != nil { 6175 *m.adddeleted_at += u 6176 } else { 6177 m.adddeleted_at = &u 6178 } 6179 } 6180 6181 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 6182 func (m *CoinFiatMutation) AddedDeletedAt() (r int32, exists bool) { 6183 v := m.adddeleted_at 6184 if v == nil { 6185 return 6186 } 6187 return *v, true 6188 } 6189 6190 // ResetDeletedAt resets all changes to the "deleted_at" field. 6191 func (m *CoinFiatMutation) ResetDeletedAt() { 6192 m.deleted_at = nil 6193 m.adddeleted_at = nil 6194 } 6195 6196 // SetEntID sets the "ent_id" field. 6197 func (m *CoinFiatMutation) SetEntID(u uuid.UUID) { 6198 m.ent_id = &u 6199 } 6200 6201 // EntID returns the value of the "ent_id" field in the mutation. 6202 func (m *CoinFiatMutation) EntID() (r uuid.UUID, exists bool) { 6203 v := m.ent_id 6204 if v == nil { 6205 return 6206 } 6207 return *v, true 6208 } 6209 6210 // OldEntID returns the old "ent_id" field's value of the CoinFiat entity. 6211 // If the CoinFiat object wasn't provided to the builder, the object is fetched from the database. 6212 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 6213 func (m *CoinFiatMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 6214 if !m.op.Is(OpUpdateOne) { 6215 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 6216 } 6217 if m.id == nil || m.oldValue == nil { 6218 return v, errors.New("OldEntID requires an ID field in the mutation") 6219 } 6220 oldValue, err := m.oldValue(ctx) 6221 if err != nil { 6222 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 6223 } 6224 return oldValue.EntID, nil 6225 } 6226 6227 // ResetEntID resets all changes to the "ent_id" field. 6228 func (m *CoinFiatMutation) ResetEntID() { 6229 m.ent_id = nil 6230 } 6231 6232 // SetCoinTypeID sets the "coin_type_id" field. 6233 func (m *CoinFiatMutation) SetCoinTypeID(u uuid.UUID) { 6234 m.coin_type_id = &u 6235 } 6236 6237 // CoinTypeID returns the value of the "coin_type_id" field in the mutation. 6238 func (m *CoinFiatMutation) CoinTypeID() (r uuid.UUID, exists bool) { 6239 v := m.coin_type_id 6240 if v == nil { 6241 return 6242 } 6243 return *v, true 6244 } 6245 6246 // OldCoinTypeID returns the old "coin_type_id" field's value of the CoinFiat entity. 6247 // If the CoinFiat object wasn't provided to the builder, the object is fetched from the database. 6248 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 6249 func (m *CoinFiatMutation) OldCoinTypeID(ctx context.Context) (v uuid.UUID, err error) { 6250 if !m.op.Is(OpUpdateOne) { 6251 return v, errors.New("OldCoinTypeID is only allowed on UpdateOne operations") 6252 } 6253 if m.id == nil || m.oldValue == nil { 6254 return v, errors.New("OldCoinTypeID requires an ID field in the mutation") 6255 } 6256 oldValue, err := m.oldValue(ctx) 6257 if err != nil { 6258 return v, fmt.Errorf("querying old value for OldCoinTypeID: %w", err) 6259 } 6260 return oldValue.CoinTypeID, nil 6261 } 6262 6263 // ClearCoinTypeID clears the value of the "coin_type_id" field. 6264 func (m *CoinFiatMutation) ClearCoinTypeID() { 6265 m.coin_type_id = nil 6266 m.clearedFields[coinfiat.FieldCoinTypeID] = struct{}{} 6267 } 6268 6269 // CoinTypeIDCleared returns if the "coin_type_id" field was cleared in this mutation. 6270 func (m *CoinFiatMutation) CoinTypeIDCleared() bool { 6271 _, ok := m.clearedFields[coinfiat.FieldCoinTypeID] 6272 return ok 6273 } 6274 6275 // ResetCoinTypeID resets all changes to the "coin_type_id" field. 6276 func (m *CoinFiatMutation) ResetCoinTypeID() { 6277 m.coin_type_id = nil 6278 delete(m.clearedFields, coinfiat.FieldCoinTypeID) 6279 } 6280 6281 // SetFiatID sets the "fiat_id" field. 6282 func (m *CoinFiatMutation) SetFiatID(u uuid.UUID) { 6283 m.fiat_id = &u 6284 } 6285 6286 // FiatID returns the value of the "fiat_id" field in the mutation. 6287 func (m *CoinFiatMutation) FiatID() (r uuid.UUID, exists bool) { 6288 v := m.fiat_id 6289 if v == nil { 6290 return 6291 } 6292 return *v, true 6293 } 6294 6295 // OldFiatID returns the old "fiat_id" field's value of the CoinFiat entity. 6296 // If the CoinFiat object wasn't provided to the builder, the object is fetched from the database. 6297 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 6298 func (m *CoinFiatMutation) OldFiatID(ctx context.Context) (v uuid.UUID, err error) { 6299 if !m.op.Is(OpUpdateOne) { 6300 return v, errors.New("OldFiatID is only allowed on UpdateOne operations") 6301 } 6302 if m.id == nil || m.oldValue == nil { 6303 return v, errors.New("OldFiatID requires an ID field in the mutation") 6304 } 6305 oldValue, err := m.oldValue(ctx) 6306 if err != nil { 6307 return v, fmt.Errorf("querying old value for OldFiatID: %w", err) 6308 } 6309 return oldValue.FiatID, nil 6310 } 6311 6312 // ClearFiatID clears the value of the "fiat_id" field. 6313 func (m *CoinFiatMutation) ClearFiatID() { 6314 m.fiat_id = nil 6315 m.clearedFields[coinfiat.FieldFiatID] = struct{}{} 6316 } 6317 6318 // FiatIDCleared returns if the "fiat_id" field was cleared in this mutation. 6319 func (m *CoinFiatMutation) FiatIDCleared() bool { 6320 _, ok := m.clearedFields[coinfiat.FieldFiatID] 6321 return ok 6322 } 6323 6324 // ResetFiatID resets all changes to the "fiat_id" field. 6325 func (m *CoinFiatMutation) ResetFiatID() { 6326 m.fiat_id = nil 6327 delete(m.clearedFields, coinfiat.FieldFiatID) 6328 } 6329 6330 // SetFeedType sets the "feed_type" field. 6331 func (m *CoinFiatMutation) SetFeedType(s string) { 6332 m.feed_type = &s 6333 } 6334 6335 // FeedType returns the value of the "feed_type" field in the mutation. 6336 func (m *CoinFiatMutation) FeedType() (r string, exists bool) { 6337 v := m.feed_type 6338 if v == nil { 6339 return 6340 } 6341 return *v, true 6342 } 6343 6344 // OldFeedType returns the old "feed_type" field's value of the CoinFiat entity. 6345 // If the CoinFiat object wasn't provided to the builder, the object is fetched from the database. 6346 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 6347 func (m *CoinFiatMutation) OldFeedType(ctx context.Context) (v string, err error) { 6348 if !m.op.Is(OpUpdateOne) { 6349 return v, errors.New("OldFeedType is only allowed on UpdateOne operations") 6350 } 6351 if m.id == nil || m.oldValue == nil { 6352 return v, errors.New("OldFeedType requires an ID field in the mutation") 6353 } 6354 oldValue, err := m.oldValue(ctx) 6355 if err != nil { 6356 return v, fmt.Errorf("querying old value for OldFeedType: %w", err) 6357 } 6358 return oldValue.FeedType, nil 6359 } 6360 6361 // ClearFeedType clears the value of the "feed_type" field. 6362 func (m *CoinFiatMutation) ClearFeedType() { 6363 m.feed_type = nil 6364 m.clearedFields[coinfiat.FieldFeedType] = struct{}{} 6365 } 6366 6367 // FeedTypeCleared returns if the "feed_type" field was cleared in this mutation. 6368 func (m *CoinFiatMutation) FeedTypeCleared() bool { 6369 _, ok := m.clearedFields[coinfiat.FieldFeedType] 6370 return ok 6371 } 6372 6373 // ResetFeedType resets all changes to the "feed_type" field. 6374 func (m *CoinFiatMutation) ResetFeedType() { 6375 m.feed_type = nil 6376 delete(m.clearedFields, coinfiat.FieldFeedType) 6377 } 6378 6379 // Where appends a list predicates to the CoinFiatMutation builder. 6380 func (m *CoinFiatMutation) Where(ps ...predicate.CoinFiat) { 6381 m.predicates = append(m.predicates, ps...) 6382 } 6383 6384 // Op returns the operation name. 6385 func (m *CoinFiatMutation) Op() Op { 6386 return m.op 6387 } 6388 6389 // Type returns the node type of this mutation (CoinFiat). 6390 func (m *CoinFiatMutation) Type() string { 6391 return m.typ 6392 } 6393 6394 // Fields returns all fields that were changed during this mutation. Note that in 6395 // order to get all numeric fields that were incremented/decremented, call 6396 // AddedFields(). 6397 func (m *CoinFiatMutation) Fields() []string { 6398 fields := make([]string, 0, 7) 6399 if m.created_at != nil { 6400 fields = append(fields, coinfiat.FieldCreatedAt) 6401 } 6402 if m.updated_at != nil { 6403 fields = append(fields, coinfiat.FieldUpdatedAt) 6404 } 6405 if m.deleted_at != nil { 6406 fields = append(fields, coinfiat.FieldDeletedAt) 6407 } 6408 if m.ent_id != nil { 6409 fields = append(fields, coinfiat.FieldEntID) 6410 } 6411 if m.coin_type_id != nil { 6412 fields = append(fields, coinfiat.FieldCoinTypeID) 6413 } 6414 if m.fiat_id != nil { 6415 fields = append(fields, coinfiat.FieldFiatID) 6416 } 6417 if m.feed_type != nil { 6418 fields = append(fields, coinfiat.FieldFeedType) 6419 } 6420 return fields 6421 } 6422 6423 // Field returns the value of a field with the given name. The second boolean 6424 // return value indicates that this field was not set, or was not defined in the 6425 // schema. 6426 func (m *CoinFiatMutation) Field(name string) (ent.Value, bool) { 6427 switch name { 6428 case coinfiat.FieldCreatedAt: 6429 return m.CreatedAt() 6430 case coinfiat.FieldUpdatedAt: 6431 return m.UpdatedAt() 6432 case coinfiat.FieldDeletedAt: 6433 return m.DeletedAt() 6434 case coinfiat.FieldEntID: 6435 return m.EntID() 6436 case coinfiat.FieldCoinTypeID: 6437 return m.CoinTypeID() 6438 case coinfiat.FieldFiatID: 6439 return m.FiatID() 6440 case coinfiat.FieldFeedType: 6441 return m.FeedType() 6442 } 6443 return nil, false 6444 } 6445 6446 // OldField returns the old value of the field from the database. An error is 6447 // returned if the mutation operation is not UpdateOne, or the query to the 6448 // database failed. 6449 func (m *CoinFiatMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 6450 switch name { 6451 case coinfiat.FieldCreatedAt: 6452 return m.OldCreatedAt(ctx) 6453 case coinfiat.FieldUpdatedAt: 6454 return m.OldUpdatedAt(ctx) 6455 case coinfiat.FieldDeletedAt: 6456 return m.OldDeletedAt(ctx) 6457 case coinfiat.FieldEntID: 6458 return m.OldEntID(ctx) 6459 case coinfiat.FieldCoinTypeID: 6460 return m.OldCoinTypeID(ctx) 6461 case coinfiat.FieldFiatID: 6462 return m.OldFiatID(ctx) 6463 case coinfiat.FieldFeedType: 6464 return m.OldFeedType(ctx) 6465 } 6466 return nil, fmt.Errorf("unknown CoinFiat field %s", name) 6467 } 6468 6469 // SetField sets the value of a field with the given name. It returns an error if 6470 // the field is not defined in the schema, or if the type mismatched the field 6471 // type. 6472 func (m *CoinFiatMutation) SetField(name string, value ent.Value) error { 6473 switch name { 6474 case coinfiat.FieldCreatedAt: 6475 v, ok := value.(uint32) 6476 if !ok { 6477 return fmt.Errorf("unexpected type %T for field %s", value, name) 6478 } 6479 m.SetCreatedAt(v) 6480 return nil 6481 case coinfiat.FieldUpdatedAt: 6482 v, ok := value.(uint32) 6483 if !ok { 6484 return fmt.Errorf("unexpected type %T for field %s", value, name) 6485 } 6486 m.SetUpdatedAt(v) 6487 return nil 6488 case coinfiat.FieldDeletedAt: 6489 v, ok := value.(uint32) 6490 if !ok { 6491 return fmt.Errorf("unexpected type %T for field %s", value, name) 6492 } 6493 m.SetDeletedAt(v) 6494 return nil 6495 case coinfiat.FieldEntID: 6496 v, ok := value.(uuid.UUID) 6497 if !ok { 6498 return fmt.Errorf("unexpected type %T for field %s", value, name) 6499 } 6500 m.SetEntID(v) 6501 return nil 6502 case coinfiat.FieldCoinTypeID: 6503 v, ok := value.(uuid.UUID) 6504 if !ok { 6505 return fmt.Errorf("unexpected type %T for field %s", value, name) 6506 } 6507 m.SetCoinTypeID(v) 6508 return nil 6509 case coinfiat.FieldFiatID: 6510 v, ok := value.(uuid.UUID) 6511 if !ok { 6512 return fmt.Errorf("unexpected type %T for field %s", value, name) 6513 } 6514 m.SetFiatID(v) 6515 return nil 6516 case coinfiat.FieldFeedType: 6517 v, ok := value.(string) 6518 if !ok { 6519 return fmt.Errorf("unexpected type %T for field %s", value, name) 6520 } 6521 m.SetFeedType(v) 6522 return nil 6523 } 6524 return fmt.Errorf("unknown CoinFiat field %s", name) 6525 } 6526 6527 // AddedFields returns all numeric fields that were incremented/decremented during 6528 // this mutation. 6529 func (m *CoinFiatMutation) AddedFields() []string { 6530 var fields []string 6531 if m.addcreated_at != nil { 6532 fields = append(fields, coinfiat.FieldCreatedAt) 6533 } 6534 if m.addupdated_at != nil { 6535 fields = append(fields, coinfiat.FieldUpdatedAt) 6536 } 6537 if m.adddeleted_at != nil { 6538 fields = append(fields, coinfiat.FieldDeletedAt) 6539 } 6540 return fields 6541 } 6542 6543 // AddedField returns the numeric value that was incremented/decremented on a field 6544 // with the given name. The second boolean return value indicates that this field 6545 // was not set, or was not defined in the schema. 6546 func (m *CoinFiatMutation) AddedField(name string) (ent.Value, bool) { 6547 switch name { 6548 case coinfiat.FieldCreatedAt: 6549 return m.AddedCreatedAt() 6550 case coinfiat.FieldUpdatedAt: 6551 return m.AddedUpdatedAt() 6552 case coinfiat.FieldDeletedAt: 6553 return m.AddedDeletedAt() 6554 } 6555 return nil, false 6556 } 6557 6558 // AddField adds the value to the field with the given name. It returns an error if 6559 // the field is not defined in the schema, or if the type mismatched the field 6560 // type. 6561 func (m *CoinFiatMutation) AddField(name string, value ent.Value) error { 6562 switch name { 6563 case coinfiat.FieldCreatedAt: 6564 v, ok := value.(int32) 6565 if !ok { 6566 return fmt.Errorf("unexpected type %T for field %s", value, name) 6567 } 6568 m.AddCreatedAt(v) 6569 return nil 6570 case coinfiat.FieldUpdatedAt: 6571 v, ok := value.(int32) 6572 if !ok { 6573 return fmt.Errorf("unexpected type %T for field %s", value, name) 6574 } 6575 m.AddUpdatedAt(v) 6576 return nil 6577 case coinfiat.FieldDeletedAt: 6578 v, ok := value.(int32) 6579 if !ok { 6580 return fmt.Errorf("unexpected type %T for field %s", value, name) 6581 } 6582 m.AddDeletedAt(v) 6583 return nil 6584 } 6585 return fmt.Errorf("unknown CoinFiat numeric field %s", name) 6586 } 6587 6588 // ClearedFields returns all nullable fields that were cleared during this 6589 // mutation. 6590 func (m *CoinFiatMutation) ClearedFields() []string { 6591 var fields []string 6592 if m.FieldCleared(coinfiat.FieldCoinTypeID) { 6593 fields = append(fields, coinfiat.FieldCoinTypeID) 6594 } 6595 if m.FieldCleared(coinfiat.FieldFiatID) { 6596 fields = append(fields, coinfiat.FieldFiatID) 6597 } 6598 if m.FieldCleared(coinfiat.FieldFeedType) { 6599 fields = append(fields, coinfiat.FieldFeedType) 6600 } 6601 return fields 6602 } 6603 6604 // FieldCleared returns a boolean indicating if a field with the given name was 6605 // cleared in this mutation. 6606 func (m *CoinFiatMutation) FieldCleared(name string) bool { 6607 _, ok := m.clearedFields[name] 6608 return ok 6609 } 6610 6611 // ClearField clears the value of the field with the given name. It returns an 6612 // error if the field is not defined in the schema. 6613 func (m *CoinFiatMutation) ClearField(name string) error { 6614 switch name { 6615 case coinfiat.FieldCoinTypeID: 6616 m.ClearCoinTypeID() 6617 return nil 6618 case coinfiat.FieldFiatID: 6619 m.ClearFiatID() 6620 return nil 6621 case coinfiat.FieldFeedType: 6622 m.ClearFeedType() 6623 return nil 6624 } 6625 return fmt.Errorf("unknown CoinFiat nullable field %s", name) 6626 } 6627 6628 // ResetField resets all changes in the mutation for the field with the given name. 6629 // It returns an error if the field is not defined in the schema. 6630 func (m *CoinFiatMutation) ResetField(name string) error { 6631 switch name { 6632 case coinfiat.FieldCreatedAt: 6633 m.ResetCreatedAt() 6634 return nil 6635 case coinfiat.FieldUpdatedAt: 6636 m.ResetUpdatedAt() 6637 return nil 6638 case coinfiat.FieldDeletedAt: 6639 m.ResetDeletedAt() 6640 return nil 6641 case coinfiat.FieldEntID: 6642 m.ResetEntID() 6643 return nil 6644 case coinfiat.FieldCoinTypeID: 6645 m.ResetCoinTypeID() 6646 return nil 6647 case coinfiat.FieldFiatID: 6648 m.ResetFiatID() 6649 return nil 6650 case coinfiat.FieldFeedType: 6651 m.ResetFeedType() 6652 return nil 6653 } 6654 return fmt.Errorf("unknown CoinFiat field %s", name) 6655 } 6656 6657 // AddedEdges returns all edge names that were set/added in this mutation. 6658 func (m *CoinFiatMutation) AddedEdges() []string { 6659 edges := make([]string, 0, 0) 6660 return edges 6661 } 6662 6663 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 6664 // name in this mutation. 6665 func (m *CoinFiatMutation) AddedIDs(name string) []ent.Value { 6666 return nil 6667 } 6668 6669 // RemovedEdges returns all edge names that were removed in this mutation. 6670 func (m *CoinFiatMutation) RemovedEdges() []string { 6671 edges := make([]string, 0, 0) 6672 return edges 6673 } 6674 6675 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 6676 // the given name in this mutation. 6677 func (m *CoinFiatMutation) RemovedIDs(name string) []ent.Value { 6678 return nil 6679 } 6680 6681 // ClearedEdges returns all edge names that were cleared in this mutation. 6682 func (m *CoinFiatMutation) ClearedEdges() []string { 6683 edges := make([]string, 0, 0) 6684 return edges 6685 } 6686 6687 // EdgeCleared returns a boolean which indicates if the edge with the given name 6688 // was cleared in this mutation. 6689 func (m *CoinFiatMutation) EdgeCleared(name string) bool { 6690 return false 6691 } 6692 6693 // ClearEdge clears the value of the edge with the given name. It returns an error 6694 // if that edge is not defined in the schema. 6695 func (m *CoinFiatMutation) ClearEdge(name string) error { 6696 return fmt.Errorf("unknown CoinFiat unique edge %s", name) 6697 } 6698 6699 // ResetEdge resets all changes to the edge with the given name in this mutation. 6700 // It returns an error if the edge is not defined in the schema. 6701 func (m *CoinFiatMutation) ResetEdge(name string) error { 6702 return fmt.Errorf("unknown CoinFiat edge %s", name) 6703 } 6704 6705 // CoinFiatCurrencyMutation represents an operation that mutates the CoinFiatCurrency nodes in the graph. 6706 type CoinFiatCurrencyMutation struct { 6707 config 6708 op Op 6709 typ string 6710 id *uint32 6711 created_at *uint32 6712 addcreated_at *int32 6713 updated_at *uint32 6714 addupdated_at *int32 6715 deleted_at *uint32 6716 adddeleted_at *int32 6717 ent_id *uuid.UUID 6718 coin_type_id *uuid.UUID 6719 fiat_id *uuid.UUID 6720 feed_type *string 6721 market_value_low *decimal.Decimal 6722 market_value_high *decimal.Decimal 6723 clearedFields map[string]struct{} 6724 done bool 6725 oldValue func(context.Context) (*CoinFiatCurrency, error) 6726 predicates []predicate.CoinFiatCurrency 6727 } 6728 6729 var _ ent.Mutation = (*CoinFiatCurrencyMutation)(nil) 6730 6731 // coinfiatcurrencyOption allows management of the mutation configuration using functional options. 6732 type coinfiatcurrencyOption func(*CoinFiatCurrencyMutation) 6733 6734 // newCoinFiatCurrencyMutation creates new mutation for the CoinFiatCurrency entity. 6735 func newCoinFiatCurrencyMutation(c config, op Op, opts ...coinfiatcurrencyOption) *CoinFiatCurrencyMutation { 6736 m := &CoinFiatCurrencyMutation{ 6737 config: c, 6738 op: op, 6739 typ: TypeCoinFiatCurrency, 6740 clearedFields: make(map[string]struct{}), 6741 } 6742 for _, opt := range opts { 6743 opt(m) 6744 } 6745 return m 6746 } 6747 6748 // withCoinFiatCurrencyID sets the ID field of the mutation. 6749 func withCoinFiatCurrencyID(id uint32) coinfiatcurrencyOption { 6750 return func(m *CoinFiatCurrencyMutation) { 6751 var ( 6752 err error 6753 once sync.Once 6754 value *CoinFiatCurrency 6755 ) 6756 m.oldValue = func(ctx context.Context) (*CoinFiatCurrency, error) { 6757 once.Do(func() { 6758 if m.done { 6759 err = errors.New("querying old values post mutation is not allowed") 6760 } else { 6761 value, err = m.Client().CoinFiatCurrency.Get(ctx, id) 6762 } 6763 }) 6764 return value, err 6765 } 6766 m.id = &id 6767 } 6768 } 6769 6770 // withCoinFiatCurrency sets the old CoinFiatCurrency of the mutation. 6771 func withCoinFiatCurrency(node *CoinFiatCurrency) coinfiatcurrencyOption { 6772 return func(m *CoinFiatCurrencyMutation) { 6773 m.oldValue = func(context.Context) (*CoinFiatCurrency, error) { 6774 return node, nil 6775 } 6776 m.id = &node.ID 6777 } 6778 } 6779 6780 // Client returns a new `ent.Client` from the mutation. If the mutation was 6781 // executed in a transaction (ent.Tx), a transactional client is returned. 6782 func (m CoinFiatCurrencyMutation) Client() *Client { 6783 client := &Client{config: m.config} 6784 client.init() 6785 return client 6786 } 6787 6788 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 6789 // it returns an error otherwise. 6790 func (m CoinFiatCurrencyMutation) Tx() (*Tx, error) { 6791 if _, ok := m.driver.(*txDriver); !ok { 6792 return nil, errors.New("ent: mutation is not running in a transaction") 6793 } 6794 tx := &Tx{config: m.config} 6795 tx.init() 6796 return tx, nil 6797 } 6798 6799 // SetID sets the value of the id field. Note that this 6800 // operation is only accepted on creation of CoinFiatCurrency entities. 6801 func (m *CoinFiatCurrencyMutation) SetID(id uint32) { 6802 m.id = &id 6803 } 6804 6805 // ID returns the ID value in the mutation. Note that the ID is only available 6806 // if it was provided to the builder or after it was returned from the database. 6807 func (m *CoinFiatCurrencyMutation) ID() (id uint32, exists bool) { 6808 if m.id == nil { 6809 return 6810 } 6811 return *m.id, true 6812 } 6813 6814 // IDs queries the database and returns the entity ids that match the mutation's predicate. 6815 // That means, if the mutation is applied within a transaction with an isolation level such 6816 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 6817 // or updated by the mutation. 6818 func (m *CoinFiatCurrencyMutation) IDs(ctx context.Context) ([]uint32, error) { 6819 switch { 6820 case m.op.Is(OpUpdateOne | OpDeleteOne): 6821 id, exists := m.ID() 6822 if exists { 6823 return []uint32{id}, nil 6824 } 6825 fallthrough 6826 case m.op.Is(OpUpdate | OpDelete): 6827 return m.Client().CoinFiatCurrency.Query().Where(m.predicates...).IDs(ctx) 6828 default: 6829 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 6830 } 6831 } 6832 6833 // SetCreatedAt sets the "created_at" field. 6834 func (m *CoinFiatCurrencyMutation) SetCreatedAt(u uint32) { 6835 m.created_at = &u 6836 m.addcreated_at = nil 6837 } 6838 6839 // CreatedAt returns the value of the "created_at" field in the mutation. 6840 func (m *CoinFiatCurrencyMutation) CreatedAt() (r uint32, exists bool) { 6841 v := m.created_at 6842 if v == nil { 6843 return 6844 } 6845 return *v, true 6846 } 6847 6848 // OldCreatedAt returns the old "created_at" field's value of the CoinFiatCurrency entity. 6849 // If the CoinFiatCurrency object wasn't provided to the builder, the object is fetched from the database. 6850 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 6851 func (m *CoinFiatCurrencyMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 6852 if !m.op.Is(OpUpdateOne) { 6853 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 6854 } 6855 if m.id == nil || m.oldValue == nil { 6856 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 6857 } 6858 oldValue, err := m.oldValue(ctx) 6859 if err != nil { 6860 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 6861 } 6862 return oldValue.CreatedAt, nil 6863 } 6864 6865 // AddCreatedAt adds u to the "created_at" field. 6866 func (m *CoinFiatCurrencyMutation) AddCreatedAt(u int32) { 6867 if m.addcreated_at != nil { 6868 *m.addcreated_at += u 6869 } else { 6870 m.addcreated_at = &u 6871 } 6872 } 6873 6874 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 6875 func (m *CoinFiatCurrencyMutation) AddedCreatedAt() (r int32, exists bool) { 6876 v := m.addcreated_at 6877 if v == nil { 6878 return 6879 } 6880 return *v, true 6881 } 6882 6883 // ResetCreatedAt resets all changes to the "created_at" field. 6884 func (m *CoinFiatCurrencyMutation) ResetCreatedAt() { 6885 m.created_at = nil 6886 m.addcreated_at = nil 6887 } 6888 6889 // SetUpdatedAt sets the "updated_at" field. 6890 func (m *CoinFiatCurrencyMutation) SetUpdatedAt(u uint32) { 6891 m.updated_at = &u 6892 m.addupdated_at = nil 6893 } 6894 6895 // UpdatedAt returns the value of the "updated_at" field in the mutation. 6896 func (m *CoinFiatCurrencyMutation) UpdatedAt() (r uint32, exists bool) { 6897 v := m.updated_at 6898 if v == nil { 6899 return 6900 } 6901 return *v, true 6902 } 6903 6904 // OldUpdatedAt returns the old "updated_at" field's value of the CoinFiatCurrency entity. 6905 // If the CoinFiatCurrency object wasn't provided to the builder, the object is fetched from the database. 6906 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 6907 func (m *CoinFiatCurrencyMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 6908 if !m.op.Is(OpUpdateOne) { 6909 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 6910 } 6911 if m.id == nil || m.oldValue == nil { 6912 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 6913 } 6914 oldValue, err := m.oldValue(ctx) 6915 if err != nil { 6916 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 6917 } 6918 return oldValue.UpdatedAt, nil 6919 } 6920 6921 // AddUpdatedAt adds u to the "updated_at" field. 6922 func (m *CoinFiatCurrencyMutation) AddUpdatedAt(u int32) { 6923 if m.addupdated_at != nil { 6924 *m.addupdated_at += u 6925 } else { 6926 m.addupdated_at = &u 6927 } 6928 } 6929 6930 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 6931 func (m *CoinFiatCurrencyMutation) AddedUpdatedAt() (r int32, exists bool) { 6932 v := m.addupdated_at 6933 if v == nil { 6934 return 6935 } 6936 return *v, true 6937 } 6938 6939 // ResetUpdatedAt resets all changes to the "updated_at" field. 6940 func (m *CoinFiatCurrencyMutation) ResetUpdatedAt() { 6941 m.updated_at = nil 6942 m.addupdated_at = nil 6943 } 6944 6945 // SetDeletedAt sets the "deleted_at" field. 6946 func (m *CoinFiatCurrencyMutation) SetDeletedAt(u uint32) { 6947 m.deleted_at = &u 6948 m.adddeleted_at = nil 6949 } 6950 6951 // DeletedAt returns the value of the "deleted_at" field in the mutation. 6952 func (m *CoinFiatCurrencyMutation) DeletedAt() (r uint32, exists bool) { 6953 v := m.deleted_at 6954 if v == nil { 6955 return 6956 } 6957 return *v, true 6958 } 6959 6960 // OldDeletedAt returns the old "deleted_at" field's value of the CoinFiatCurrency entity. 6961 // If the CoinFiatCurrency object wasn't provided to the builder, the object is fetched from the database. 6962 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 6963 func (m *CoinFiatCurrencyMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 6964 if !m.op.Is(OpUpdateOne) { 6965 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 6966 } 6967 if m.id == nil || m.oldValue == nil { 6968 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 6969 } 6970 oldValue, err := m.oldValue(ctx) 6971 if err != nil { 6972 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 6973 } 6974 return oldValue.DeletedAt, nil 6975 } 6976 6977 // AddDeletedAt adds u to the "deleted_at" field. 6978 func (m *CoinFiatCurrencyMutation) AddDeletedAt(u int32) { 6979 if m.adddeleted_at != nil { 6980 *m.adddeleted_at += u 6981 } else { 6982 m.adddeleted_at = &u 6983 } 6984 } 6985 6986 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 6987 func (m *CoinFiatCurrencyMutation) AddedDeletedAt() (r int32, exists bool) { 6988 v := m.adddeleted_at 6989 if v == nil { 6990 return 6991 } 6992 return *v, true 6993 } 6994 6995 // ResetDeletedAt resets all changes to the "deleted_at" field. 6996 func (m *CoinFiatCurrencyMutation) ResetDeletedAt() { 6997 m.deleted_at = nil 6998 m.adddeleted_at = nil 6999 } 7000 7001 // SetEntID sets the "ent_id" field. 7002 func (m *CoinFiatCurrencyMutation) SetEntID(u uuid.UUID) { 7003 m.ent_id = &u 7004 } 7005 7006 // EntID returns the value of the "ent_id" field in the mutation. 7007 func (m *CoinFiatCurrencyMutation) EntID() (r uuid.UUID, exists bool) { 7008 v := m.ent_id 7009 if v == nil { 7010 return 7011 } 7012 return *v, true 7013 } 7014 7015 // OldEntID returns the old "ent_id" field's value of the CoinFiatCurrency entity. 7016 // If the CoinFiatCurrency object wasn't provided to the builder, the object is fetched from the database. 7017 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 7018 func (m *CoinFiatCurrencyMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 7019 if !m.op.Is(OpUpdateOne) { 7020 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 7021 } 7022 if m.id == nil || m.oldValue == nil { 7023 return v, errors.New("OldEntID requires an ID field in the mutation") 7024 } 7025 oldValue, err := m.oldValue(ctx) 7026 if err != nil { 7027 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 7028 } 7029 return oldValue.EntID, nil 7030 } 7031 7032 // ResetEntID resets all changes to the "ent_id" field. 7033 func (m *CoinFiatCurrencyMutation) ResetEntID() { 7034 m.ent_id = nil 7035 } 7036 7037 // SetCoinTypeID sets the "coin_type_id" field. 7038 func (m *CoinFiatCurrencyMutation) SetCoinTypeID(u uuid.UUID) { 7039 m.coin_type_id = &u 7040 } 7041 7042 // CoinTypeID returns the value of the "coin_type_id" field in the mutation. 7043 func (m *CoinFiatCurrencyMutation) CoinTypeID() (r uuid.UUID, exists bool) { 7044 v := m.coin_type_id 7045 if v == nil { 7046 return 7047 } 7048 return *v, true 7049 } 7050 7051 // OldCoinTypeID returns the old "coin_type_id" field's value of the CoinFiatCurrency entity. 7052 // If the CoinFiatCurrency object wasn't provided to the builder, the object is fetched from the database. 7053 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 7054 func (m *CoinFiatCurrencyMutation) OldCoinTypeID(ctx context.Context) (v uuid.UUID, err error) { 7055 if !m.op.Is(OpUpdateOne) { 7056 return v, errors.New("OldCoinTypeID is only allowed on UpdateOne operations") 7057 } 7058 if m.id == nil || m.oldValue == nil { 7059 return v, errors.New("OldCoinTypeID requires an ID field in the mutation") 7060 } 7061 oldValue, err := m.oldValue(ctx) 7062 if err != nil { 7063 return v, fmt.Errorf("querying old value for OldCoinTypeID: %w", err) 7064 } 7065 return oldValue.CoinTypeID, nil 7066 } 7067 7068 // ClearCoinTypeID clears the value of the "coin_type_id" field. 7069 func (m *CoinFiatCurrencyMutation) ClearCoinTypeID() { 7070 m.coin_type_id = nil 7071 m.clearedFields[coinfiatcurrency.FieldCoinTypeID] = struct{}{} 7072 } 7073 7074 // CoinTypeIDCleared returns if the "coin_type_id" field was cleared in this mutation. 7075 func (m *CoinFiatCurrencyMutation) CoinTypeIDCleared() bool { 7076 _, ok := m.clearedFields[coinfiatcurrency.FieldCoinTypeID] 7077 return ok 7078 } 7079 7080 // ResetCoinTypeID resets all changes to the "coin_type_id" field. 7081 func (m *CoinFiatCurrencyMutation) ResetCoinTypeID() { 7082 m.coin_type_id = nil 7083 delete(m.clearedFields, coinfiatcurrency.FieldCoinTypeID) 7084 } 7085 7086 // SetFiatID sets the "fiat_id" field. 7087 func (m *CoinFiatCurrencyMutation) SetFiatID(u uuid.UUID) { 7088 m.fiat_id = &u 7089 } 7090 7091 // FiatID returns the value of the "fiat_id" field in the mutation. 7092 func (m *CoinFiatCurrencyMutation) FiatID() (r uuid.UUID, exists bool) { 7093 v := m.fiat_id 7094 if v == nil { 7095 return 7096 } 7097 return *v, true 7098 } 7099 7100 // OldFiatID returns the old "fiat_id" field's value of the CoinFiatCurrency entity. 7101 // If the CoinFiatCurrency object wasn't provided to the builder, the object is fetched from the database. 7102 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 7103 func (m *CoinFiatCurrencyMutation) OldFiatID(ctx context.Context) (v uuid.UUID, err error) { 7104 if !m.op.Is(OpUpdateOne) { 7105 return v, errors.New("OldFiatID is only allowed on UpdateOne operations") 7106 } 7107 if m.id == nil || m.oldValue == nil { 7108 return v, errors.New("OldFiatID requires an ID field in the mutation") 7109 } 7110 oldValue, err := m.oldValue(ctx) 7111 if err != nil { 7112 return v, fmt.Errorf("querying old value for OldFiatID: %w", err) 7113 } 7114 return oldValue.FiatID, nil 7115 } 7116 7117 // ClearFiatID clears the value of the "fiat_id" field. 7118 func (m *CoinFiatCurrencyMutation) ClearFiatID() { 7119 m.fiat_id = nil 7120 m.clearedFields[coinfiatcurrency.FieldFiatID] = struct{}{} 7121 } 7122 7123 // FiatIDCleared returns if the "fiat_id" field was cleared in this mutation. 7124 func (m *CoinFiatCurrencyMutation) FiatIDCleared() bool { 7125 _, ok := m.clearedFields[coinfiatcurrency.FieldFiatID] 7126 return ok 7127 } 7128 7129 // ResetFiatID resets all changes to the "fiat_id" field. 7130 func (m *CoinFiatCurrencyMutation) ResetFiatID() { 7131 m.fiat_id = nil 7132 delete(m.clearedFields, coinfiatcurrency.FieldFiatID) 7133 } 7134 7135 // SetFeedType sets the "feed_type" field. 7136 func (m *CoinFiatCurrencyMutation) SetFeedType(s string) { 7137 m.feed_type = &s 7138 } 7139 7140 // FeedType returns the value of the "feed_type" field in the mutation. 7141 func (m *CoinFiatCurrencyMutation) FeedType() (r string, exists bool) { 7142 v := m.feed_type 7143 if v == nil { 7144 return 7145 } 7146 return *v, true 7147 } 7148 7149 // OldFeedType returns the old "feed_type" field's value of the CoinFiatCurrency entity. 7150 // If the CoinFiatCurrency object wasn't provided to the builder, the object is fetched from the database. 7151 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 7152 func (m *CoinFiatCurrencyMutation) OldFeedType(ctx context.Context) (v string, err error) { 7153 if !m.op.Is(OpUpdateOne) { 7154 return v, errors.New("OldFeedType is only allowed on UpdateOne operations") 7155 } 7156 if m.id == nil || m.oldValue == nil { 7157 return v, errors.New("OldFeedType requires an ID field in the mutation") 7158 } 7159 oldValue, err := m.oldValue(ctx) 7160 if err != nil { 7161 return v, fmt.Errorf("querying old value for OldFeedType: %w", err) 7162 } 7163 return oldValue.FeedType, nil 7164 } 7165 7166 // ClearFeedType clears the value of the "feed_type" field. 7167 func (m *CoinFiatCurrencyMutation) ClearFeedType() { 7168 m.feed_type = nil 7169 m.clearedFields[coinfiatcurrency.FieldFeedType] = struct{}{} 7170 } 7171 7172 // FeedTypeCleared returns if the "feed_type" field was cleared in this mutation. 7173 func (m *CoinFiatCurrencyMutation) FeedTypeCleared() bool { 7174 _, ok := m.clearedFields[coinfiatcurrency.FieldFeedType] 7175 return ok 7176 } 7177 7178 // ResetFeedType resets all changes to the "feed_type" field. 7179 func (m *CoinFiatCurrencyMutation) ResetFeedType() { 7180 m.feed_type = nil 7181 delete(m.clearedFields, coinfiatcurrency.FieldFeedType) 7182 } 7183 7184 // SetMarketValueLow sets the "market_value_low" field. 7185 func (m *CoinFiatCurrencyMutation) SetMarketValueLow(d decimal.Decimal) { 7186 m.market_value_low = &d 7187 } 7188 7189 // MarketValueLow returns the value of the "market_value_low" field in the mutation. 7190 func (m *CoinFiatCurrencyMutation) MarketValueLow() (r decimal.Decimal, exists bool) { 7191 v := m.market_value_low 7192 if v == nil { 7193 return 7194 } 7195 return *v, true 7196 } 7197 7198 // OldMarketValueLow returns the old "market_value_low" field's value of the CoinFiatCurrency entity. 7199 // If the CoinFiatCurrency object wasn't provided to the builder, the object is fetched from the database. 7200 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 7201 func (m *CoinFiatCurrencyMutation) OldMarketValueLow(ctx context.Context) (v decimal.Decimal, err error) { 7202 if !m.op.Is(OpUpdateOne) { 7203 return v, errors.New("OldMarketValueLow is only allowed on UpdateOne operations") 7204 } 7205 if m.id == nil || m.oldValue == nil { 7206 return v, errors.New("OldMarketValueLow requires an ID field in the mutation") 7207 } 7208 oldValue, err := m.oldValue(ctx) 7209 if err != nil { 7210 return v, fmt.Errorf("querying old value for OldMarketValueLow: %w", err) 7211 } 7212 return oldValue.MarketValueLow, nil 7213 } 7214 7215 // ClearMarketValueLow clears the value of the "market_value_low" field. 7216 func (m *CoinFiatCurrencyMutation) ClearMarketValueLow() { 7217 m.market_value_low = nil 7218 m.clearedFields[coinfiatcurrency.FieldMarketValueLow] = struct{}{} 7219 } 7220 7221 // MarketValueLowCleared returns if the "market_value_low" field was cleared in this mutation. 7222 func (m *CoinFiatCurrencyMutation) MarketValueLowCleared() bool { 7223 _, ok := m.clearedFields[coinfiatcurrency.FieldMarketValueLow] 7224 return ok 7225 } 7226 7227 // ResetMarketValueLow resets all changes to the "market_value_low" field. 7228 func (m *CoinFiatCurrencyMutation) ResetMarketValueLow() { 7229 m.market_value_low = nil 7230 delete(m.clearedFields, coinfiatcurrency.FieldMarketValueLow) 7231 } 7232 7233 // SetMarketValueHigh sets the "market_value_high" field. 7234 func (m *CoinFiatCurrencyMutation) SetMarketValueHigh(d decimal.Decimal) { 7235 m.market_value_high = &d 7236 } 7237 7238 // MarketValueHigh returns the value of the "market_value_high" field in the mutation. 7239 func (m *CoinFiatCurrencyMutation) MarketValueHigh() (r decimal.Decimal, exists bool) { 7240 v := m.market_value_high 7241 if v == nil { 7242 return 7243 } 7244 return *v, true 7245 } 7246 7247 // OldMarketValueHigh returns the old "market_value_high" field's value of the CoinFiatCurrency entity. 7248 // If the CoinFiatCurrency object wasn't provided to the builder, the object is fetched from the database. 7249 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 7250 func (m *CoinFiatCurrencyMutation) OldMarketValueHigh(ctx context.Context) (v decimal.Decimal, err error) { 7251 if !m.op.Is(OpUpdateOne) { 7252 return v, errors.New("OldMarketValueHigh is only allowed on UpdateOne operations") 7253 } 7254 if m.id == nil || m.oldValue == nil { 7255 return v, errors.New("OldMarketValueHigh requires an ID field in the mutation") 7256 } 7257 oldValue, err := m.oldValue(ctx) 7258 if err != nil { 7259 return v, fmt.Errorf("querying old value for OldMarketValueHigh: %w", err) 7260 } 7261 return oldValue.MarketValueHigh, nil 7262 } 7263 7264 // ClearMarketValueHigh clears the value of the "market_value_high" field. 7265 func (m *CoinFiatCurrencyMutation) ClearMarketValueHigh() { 7266 m.market_value_high = nil 7267 m.clearedFields[coinfiatcurrency.FieldMarketValueHigh] = struct{}{} 7268 } 7269 7270 // MarketValueHighCleared returns if the "market_value_high" field was cleared in this mutation. 7271 func (m *CoinFiatCurrencyMutation) MarketValueHighCleared() bool { 7272 _, ok := m.clearedFields[coinfiatcurrency.FieldMarketValueHigh] 7273 return ok 7274 } 7275 7276 // ResetMarketValueHigh resets all changes to the "market_value_high" field. 7277 func (m *CoinFiatCurrencyMutation) ResetMarketValueHigh() { 7278 m.market_value_high = nil 7279 delete(m.clearedFields, coinfiatcurrency.FieldMarketValueHigh) 7280 } 7281 7282 // Where appends a list predicates to the CoinFiatCurrencyMutation builder. 7283 func (m *CoinFiatCurrencyMutation) Where(ps ...predicate.CoinFiatCurrency) { 7284 m.predicates = append(m.predicates, ps...) 7285 } 7286 7287 // Op returns the operation name. 7288 func (m *CoinFiatCurrencyMutation) Op() Op { 7289 return m.op 7290 } 7291 7292 // Type returns the node type of this mutation (CoinFiatCurrency). 7293 func (m *CoinFiatCurrencyMutation) Type() string { 7294 return m.typ 7295 } 7296 7297 // Fields returns all fields that were changed during this mutation. Note that in 7298 // order to get all numeric fields that were incremented/decremented, call 7299 // AddedFields(). 7300 func (m *CoinFiatCurrencyMutation) Fields() []string { 7301 fields := make([]string, 0, 9) 7302 if m.created_at != nil { 7303 fields = append(fields, coinfiatcurrency.FieldCreatedAt) 7304 } 7305 if m.updated_at != nil { 7306 fields = append(fields, coinfiatcurrency.FieldUpdatedAt) 7307 } 7308 if m.deleted_at != nil { 7309 fields = append(fields, coinfiatcurrency.FieldDeletedAt) 7310 } 7311 if m.ent_id != nil { 7312 fields = append(fields, coinfiatcurrency.FieldEntID) 7313 } 7314 if m.coin_type_id != nil { 7315 fields = append(fields, coinfiatcurrency.FieldCoinTypeID) 7316 } 7317 if m.fiat_id != nil { 7318 fields = append(fields, coinfiatcurrency.FieldFiatID) 7319 } 7320 if m.feed_type != nil { 7321 fields = append(fields, coinfiatcurrency.FieldFeedType) 7322 } 7323 if m.market_value_low != nil { 7324 fields = append(fields, coinfiatcurrency.FieldMarketValueLow) 7325 } 7326 if m.market_value_high != nil { 7327 fields = append(fields, coinfiatcurrency.FieldMarketValueHigh) 7328 } 7329 return fields 7330 } 7331 7332 // Field returns the value of a field with the given name. The second boolean 7333 // return value indicates that this field was not set, or was not defined in the 7334 // schema. 7335 func (m *CoinFiatCurrencyMutation) Field(name string) (ent.Value, bool) { 7336 switch name { 7337 case coinfiatcurrency.FieldCreatedAt: 7338 return m.CreatedAt() 7339 case coinfiatcurrency.FieldUpdatedAt: 7340 return m.UpdatedAt() 7341 case coinfiatcurrency.FieldDeletedAt: 7342 return m.DeletedAt() 7343 case coinfiatcurrency.FieldEntID: 7344 return m.EntID() 7345 case coinfiatcurrency.FieldCoinTypeID: 7346 return m.CoinTypeID() 7347 case coinfiatcurrency.FieldFiatID: 7348 return m.FiatID() 7349 case coinfiatcurrency.FieldFeedType: 7350 return m.FeedType() 7351 case coinfiatcurrency.FieldMarketValueLow: 7352 return m.MarketValueLow() 7353 case coinfiatcurrency.FieldMarketValueHigh: 7354 return m.MarketValueHigh() 7355 } 7356 return nil, false 7357 } 7358 7359 // OldField returns the old value of the field from the database. An error is 7360 // returned if the mutation operation is not UpdateOne, or the query to the 7361 // database failed. 7362 func (m *CoinFiatCurrencyMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 7363 switch name { 7364 case coinfiatcurrency.FieldCreatedAt: 7365 return m.OldCreatedAt(ctx) 7366 case coinfiatcurrency.FieldUpdatedAt: 7367 return m.OldUpdatedAt(ctx) 7368 case coinfiatcurrency.FieldDeletedAt: 7369 return m.OldDeletedAt(ctx) 7370 case coinfiatcurrency.FieldEntID: 7371 return m.OldEntID(ctx) 7372 case coinfiatcurrency.FieldCoinTypeID: 7373 return m.OldCoinTypeID(ctx) 7374 case coinfiatcurrency.FieldFiatID: 7375 return m.OldFiatID(ctx) 7376 case coinfiatcurrency.FieldFeedType: 7377 return m.OldFeedType(ctx) 7378 case coinfiatcurrency.FieldMarketValueLow: 7379 return m.OldMarketValueLow(ctx) 7380 case coinfiatcurrency.FieldMarketValueHigh: 7381 return m.OldMarketValueHigh(ctx) 7382 } 7383 return nil, fmt.Errorf("unknown CoinFiatCurrency field %s", name) 7384 } 7385 7386 // SetField sets the value of a field with the given name. It returns an error if 7387 // the field is not defined in the schema, or if the type mismatched the field 7388 // type. 7389 func (m *CoinFiatCurrencyMutation) SetField(name string, value ent.Value) error { 7390 switch name { 7391 case coinfiatcurrency.FieldCreatedAt: 7392 v, ok := value.(uint32) 7393 if !ok { 7394 return fmt.Errorf("unexpected type %T for field %s", value, name) 7395 } 7396 m.SetCreatedAt(v) 7397 return nil 7398 case coinfiatcurrency.FieldUpdatedAt: 7399 v, ok := value.(uint32) 7400 if !ok { 7401 return fmt.Errorf("unexpected type %T for field %s", value, name) 7402 } 7403 m.SetUpdatedAt(v) 7404 return nil 7405 case coinfiatcurrency.FieldDeletedAt: 7406 v, ok := value.(uint32) 7407 if !ok { 7408 return fmt.Errorf("unexpected type %T for field %s", value, name) 7409 } 7410 m.SetDeletedAt(v) 7411 return nil 7412 case coinfiatcurrency.FieldEntID: 7413 v, ok := value.(uuid.UUID) 7414 if !ok { 7415 return fmt.Errorf("unexpected type %T for field %s", value, name) 7416 } 7417 m.SetEntID(v) 7418 return nil 7419 case coinfiatcurrency.FieldCoinTypeID: 7420 v, ok := value.(uuid.UUID) 7421 if !ok { 7422 return fmt.Errorf("unexpected type %T for field %s", value, name) 7423 } 7424 m.SetCoinTypeID(v) 7425 return nil 7426 case coinfiatcurrency.FieldFiatID: 7427 v, ok := value.(uuid.UUID) 7428 if !ok { 7429 return fmt.Errorf("unexpected type %T for field %s", value, name) 7430 } 7431 m.SetFiatID(v) 7432 return nil 7433 case coinfiatcurrency.FieldFeedType: 7434 v, ok := value.(string) 7435 if !ok { 7436 return fmt.Errorf("unexpected type %T for field %s", value, name) 7437 } 7438 m.SetFeedType(v) 7439 return nil 7440 case coinfiatcurrency.FieldMarketValueLow: 7441 v, ok := value.(decimal.Decimal) 7442 if !ok { 7443 return fmt.Errorf("unexpected type %T for field %s", value, name) 7444 } 7445 m.SetMarketValueLow(v) 7446 return nil 7447 case coinfiatcurrency.FieldMarketValueHigh: 7448 v, ok := value.(decimal.Decimal) 7449 if !ok { 7450 return fmt.Errorf("unexpected type %T for field %s", value, name) 7451 } 7452 m.SetMarketValueHigh(v) 7453 return nil 7454 } 7455 return fmt.Errorf("unknown CoinFiatCurrency field %s", name) 7456 } 7457 7458 // AddedFields returns all numeric fields that were incremented/decremented during 7459 // this mutation. 7460 func (m *CoinFiatCurrencyMutation) AddedFields() []string { 7461 var fields []string 7462 if m.addcreated_at != nil { 7463 fields = append(fields, coinfiatcurrency.FieldCreatedAt) 7464 } 7465 if m.addupdated_at != nil { 7466 fields = append(fields, coinfiatcurrency.FieldUpdatedAt) 7467 } 7468 if m.adddeleted_at != nil { 7469 fields = append(fields, coinfiatcurrency.FieldDeletedAt) 7470 } 7471 return fields 7472 } 7473 7474 // AddedField returns the numeric value that was incremented/decremented on a field 7475 // with the given name. The second boolean return value indicates that this field 7476 // was not set, or was not defined in the schema. 7477 func (m *CoinFiatCurrencyMutation) AddedField(name string) (ent.Value, bool) { 7478 switch name { 7479 case coinfiatcurrency.FieldCreatedAt: 7480 return m.AddedCreatedAt() 7481 case coinfiatcurrency.FieldUpdatedAt: 7482 return m.AddedUpdatedAt() 7483 case coinfiatcurrency.FieldDeletedAt: 7484 return m.AddedDeletedAt() 7485 } 7486 return nil, false 7487 } 7488 7489 // AddField adds the value to the field with the given name. It returns an error if 7490 // the field is not defined in the schema, or if the type mismatched the field 7491 // type. 7492 func (m *CoinFiatCurrencyMutation) AddField(name string, value ent.Value) error { 7493 switch name { 7494 case coinfiatcurrency.FieldCreatedAt: 7495 v, ok := value.(int32) 7496 if !ok { 7497 return fmt.Errorf("unexpected type %T for field %s", value, name) 7498 } 7499 m.AddCreatedAt(v) 7500 return nil 7501 case coinfiatcurrency.FieldUpdatedAt: 7502 v, ok := value.(int32) 7503 if !ok { 7504 return fmt.Errorf("unexpected type %T for field %s", value, name) 7505 } 7506 m.AddUpdatedAt(v) 7507 return nil 7508 case coinfiatcurrency.FieldDeletedAt: 7509 v, ok := value.(int32) 7510 if !ok { 7511 return fmt.Errorf("unexpected type %T for field %s", value, name) 7512 } 7513 m.AddDeletedAt(v) 7514 return nil 7515 } 7516 return fmt.Errorf("unknown CoinFiatCurrency numeric field %s", name) 7517 } 7518 7519 // ClearedFields returns all nullable fields that were cleared during this 7520 // mutation. 7521 func (m *CoinFiatCurrencyMutation) ClearedFields() []string { 7522 var fields []string 7523 if m.FieldCleared(coinfiatcurrency.FieldCoinTypeID) { 7524 fields = append(fields, coinfiatcurrency.FieldCoinTypeID) 7525 } 7526 if m.FieldCleared(coinfiatcurrency.FieldFiatID) { 7527 fields = append(fields, coinfiatcurrency.FieldFiatID) 7528 } 7529 if m.FieldCleared(coinfiatcurrency.FieldFeedType) { 7530 fields = append(fields, coinfiatcurrency.FieldFeedType) 7531 } 7532 if m.FieldCleared(coinfiatcurrency.FieldMarketValueLow) { 7533 fields = append(fields, coinfiatcurrency.FieldMarketValueLow) 7534 } 7535 if m.FieldCleared(coinfiatcurrency.FieldMarketValueHigh) { 7536 fields = append(fields, coinfiatcurrency.FieldMarketValueHigh) 7537 } 7538 return fields 7539 } 7540 7541 // FieldCleared returns a boolean indicating if a field with the given name was 7542 // cleared in this mutation. 7543 func (m *CoinFiatCurrencyMutation) FieldCleared(name string) bool { 7544 _, ok := m.clearedFields[name] 7545 return ok 7546 } 7547 7548 // ClearField clears the value of the field with the given name. It returns an 7549 // error if the field is not defined in the schema. 7550 func (m *CoinFiatCurrencyMutation) ClearField(name string) error { 7551 switch name { 7552 case coinfiatcurrency.FieldCoinTypeID: 7553 m.ClearCoinTypeID() 7554 return nil 7555 case coinfiatcurrency.FieldFiatID: 7556 m.ClearFiatID() 7557 return nil 7558 case coinfiatcurrency.FieldFeedType: 7559 m.ClearFeedType() 7560 return nil 7561 case coinfiatcurrency.FieldMarketValueLow: 7562 m.ClearMarketValueLow() 7563 return nil 7564 case coinfiatcurrency.FieldMarketValueHigh: 7565 m.ClearMarketValueHigh() 7566 return nil 7567 } 7568 return fmt.Errorf("unknown CoinFiatCurrency nullable field %s", name) 7569 } 7570 7571 // ResetField resets all changes in the mutation for the field with the given name. 7572 // It returns an error if the field is not defined in the schema. 7573 func (m *CoinFiatCurrencyMutation) ResetField(name string) error { 7574 switch name { 7575 case coinfiatcurrency.FieldCreatedAt: 7576 m.ResetCreatedAt() 7577 return nil 7578 case coinfiatcurrency.FieldUpdatedAt: 7579 m.ResetUpdatedAt() 7580 return nil 7581 case coinfiatcurrency.FieldDeletedAt: 7582 m.ResetDeletedAt() 7583 return nil 7584 case coinfiatcurrency.FieldEntID: 7585 m.ResetEntID() 7586 return nil 7587 case coinfiatcurrency.FieldCoinTypeID: 7588 m.ResetCoinTypeID() 7589 return nil 7590 case coinfiatcurrency.FieldFiatID: 7591 m.ResetFiatID() 7592 return nil 7593 case coinfiatcurrency.FieldFeedType: 7594 m.ResetFeedType() 7595 return nil 7596 case coinfiatcurrency.FieldMarketValueLow: 7597 m.ResetMarketValueLow() 7598 return nil 7599 case coinfiatcurrency.FieldMarketValueHigh: 7600 m.ResetMarketValueHigh() 7601 return nil 7602 } 7603 return fmt.Errorf("unknown CoinFiatCurrency field %s", name) 7604 } 7605 7606 // AddedEdges returns all edge names that were set/added in this mutation. 7607 func (m *CoinFiatCurrencyMutation) AddedEdges() []string { 7608 edges := make([]string, 0, 0) 7609 return edges 7610 } 7611 7612 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 7613 // name in this mutation. 7614 func (m *CoinFiatCurrencyMutation) AddedIDs(name string) []ent.Value { 7615 return nil 7616 } 7617 7618 // RemovedEdges returns all edge names that were removed in this mutation. 7619 func (m *CoinFiatCurrencyMutation) RemovedEdges() []string { 7620 edges := make([]string, 0, 0) 7621 return edges 7622 } 7623 7624 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 7625 // the given name in this mutation. 7626 func (m *CoinFiatCurrencyMutation) RemovedIDs(name string) []ent.Value { 7627 return nil 7628 } 7629 7630 // ClearedEdges returns all edge names that were cleared in this mutation. 7631 func (m *CoinFiatCurrencyMutation) ClearedEdges() []string { 7632 edges := make([]string, 0, 0) 7633 return edges 7634 } 7635 7636 // EdgeCleared returns a boolean which indicates if the edge with the given name 7637 // was cleared in this mutation. 7638 func (m *CoinFiatCurrencyMutation) EdgeCleared(name string) bool { 7639 return false 7640 } 7641 7642 // ClearEdge clears the value of the edge with the given name. It returns an error 7643 // if that edge is not defined in the schema. 7644 func (m *CoinFiatCurrencyMutation) ClearEdge(name string) error { 7645 return fmt.Errorf("unknown CoinFiatCurrency unique edge %s", name) 7646 } 7647 7648 // ResetEdge resets all changes to the edge with the given name in this mutation. 7649 // It returns an error if the edge is not defined in the schema. 7650 func (m *CoinFiatCurrencyMutation) ResetEdge(name string) error { 7651 return fmt.Errorf("unknown CoinFiatCurrency edge %s", name) 7652 } 7653 7654 // CoinFiatCurrencyHistoryMutation represents an operation that mutates the CoinFiatCurrencyHistory nodes in the graph. 7655 type CoinFiatCurrencyHistoryMutation struct { 7656 config 7657 op Op 7658 typ string 7659 id *uint32 7660 created_at *uint32 7661 addcreated_at *int32 7662 updated_at *uint32 7663 addupdated_at *int32 7664 deleted_at *uint32 7665 adddeleted_at *int32 7666 ent_id *uuid.UUID 7667 coin_type_id *uuid.UUID 7668 fiat_id *uuid.UUID 7669 feed_type *string 7670 market_value_low *decimal.Decimal 7671 market_value_high *decimal.Decimal 7672 clearedFields map[string]struct{} 7673 done bool 7674 oldValue func(context.Context) (*CoinFiatCurrencyHistory, error) 7675 predicates []predicate.CoinFiatCurrencyHistory 7676 } 7677 7678 var _ ent.Mutation = (*CoinFiatCurrencyHistoryMutation)(nil) 7679 7680 // coinfiatcurrencyhistoryOption allows management of the mutation configuration using functional options. 7681 type coinfiatcurrencyhistoryOption func(*CoinFiatCurrencyHistoryMutation) 7682 7683 // newCoinFiatCurrencyHistoryMutation creates new mutation for the CoinFiatCurrencyHistory entity. 7684 func newCoinFiatCurrencyHistoryMutation(c config, op Op, opts ...coinfiatcurrencyhistoryOption) *CoinFiatCurrencyHistoryMutation { 7685 m := &CoinFiatCurrencyHistoryMutation{ 7686 config: c, 7687 op: op, 7688 typ: TypeCoinFiatCurrencyHistory, 7689 clearedFields: make(map[string]struct{}), 7690 } 7691 for _, opt := range opts { 7692 opt(m) 7693 } 7694 return m 7695 } 7696 7697 // withCoinFiatCurrencyHistoryID sets the ID field of the mutation. 7698 func withCoinFiatCurrencyHistoryID(id uint32) coinfiatcurrencyhistoryOption { 7699 return func(m *CoinFiatCurrencyHistoryMutation) { 7700 var ( 7701 err error 7702 once sync.Once 7703 value *CoinFiatCurrencyHistory 7704 ) 7705 m.oldValue = func(ctx context.Context) (*CoinFiatCurrencyHistory, error) { 7706 once.Do(func() { 7707 if m.done { 7708 err = errors.New("querying old values post mutation is not allowed") 7709 } else { 7710 value, err = m.Client().CoinFiatCurrencyHistory.Get(ctx, id) 7711 } 7712 }) 7713 return value, err 7714 } 7715 m.id = &id 7716 } 7717 } 7718 7719 // withCoinFiatCurrencyHistory sets the old CoinFiatCurrencyHistory of the mutation. 7720 func withCoinFiatCurrencyHistory(node *CoinFiatCurrencyHistory) coinfiatcurrencyhistoryOption { 7721 return func(m *CoinFiatCurrencyHistoryMutation) { 7722 m.oldValue = func(context.Context) (*CoinFiatCurrencyHistory, error) { 7723 return node, nil 7724 } 7725 m.id = &node.ID 7726 } 7727 } 7728 7729 // Client returns a new `ent.Client` from the mutation. If the mutation was 7730 // executed in a transaction (ent.Tx), a transactional client is returned. 7731 func (m CoinFiatCurrencyHistoryMutation) Client() *Client { 7732 client := &Client{config: m.config} 7733 client.init() 7734 return client 7735 } 7736 7737 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 7738 // it returns an error otherwise. 7739 func (m CoinFiatCurrencyHistoryMutation) Tx() (*Tx, error) { 7740 if _, ok := m.driver.(*txDriver); !ok { 7741 return nil, errors.New("ent: mutation is not running in a transaction") 7742 } 7743 tx := &Tx{config: m.config} 7744 tx.init() 7745 return tx, nil 7746 } 7747 7748 // SetID sets the value of the id field. Note that this 7749 // operation is only accepted on creation of CoinFiatCurrencyHistory entities. 7750 func (m *CoinFiatCurrencyHistoryMutation) SetID(id uint32) { 7751 m.id = &id 7752 } 7753 7754 // ID returns the ID value in the mutation. Note that the ID is only available 7755 // if it was provided to the builder or after it was returned from the database. 7756 func (m *CoinFiatCurrencyHistoryMutation) ID() (id uint32, exists bool) { 7757 if m.id == nil { 7758 return 7759 } 7760 return *m.id, true 7761 } 7762 7763 // IDs queries the database and returns the entity ids that match the mutation's predicate. 7764 // That means, if the mutation is applied within a transaction with an isolation level such 7765 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 7766 // or updated by the mutation. 7767 func (m *CoinFiatCurrencyHistoryMutation) IDs(ctx context.Context) ([]uint32, error) { 7768 switch { 7769 case m.op.Is(OpUpdateOne | OpDeleteOne): 7770 id, exists := m.ID() 7771 if exists { 7772 return []uint32{id}, nil 7773 } 7774 fallthrough 7775 case m.op.Is(OpUpdate | OpDelete): 7776 return m.Client().CoinFiatCurrencyHistory.Query().Where(m.predicates...).IDs(ctx) 7777 default: 7778 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 7779 } 7780 } 7781 7782 // SetCreatedAt sets the "created_at" field. 7783 func (m *CoinFiatCurrencyHistoryMutation) SetCreatedAt(u uint32) { 7784 m.created_at = &u 7785 m.addcreated_at = nil 7786 } 7787 7788 // CreatedAt returns the value of the "created_at" field in the mutation. 7789 func (m *CoinFiatCurrencyHistoryMutation) CreatedAt() (r uint32, exists bool) { 7790 v := m.created_at 7791 if v == nil { 7792 return 7793 } 7794 return *v, true 7795 } 7796 7797 // OldCreatedAt returns the old "created_at" field's value of the CoinFiatCurrencyHistory entity. 7798 // If the CoinFiatCurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 7799 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 7800 func (m *CoinFiatCurrencyHistoryMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 7801 if !m.op.Is(OpUpdateOne) { 7802 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 7803 } 7804 if m.id == nil || m.oldValue == nil { 7805 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 7806 } 7807 oldValue, err := m.oldValue(ctx) 7808 if err != nil { 7809 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 7810 } 7811 return oldValue.CreatedAt, nil 7812 } 7813 7814 // AddCreatedAt adds u to the "created_at" field. 7815 func (m *CoinFiatCurrencyHistoryMutation) AddCreatedAt(u int32) { 7816 if m.addcreated_at != nil { 7817 *m.addcreated_at += u 7818 } else { 7819 m.addcreated_at = &u 7820 } 7821 } 7822 7823 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 7824 func (m *CoinFiatCurrencyHistoryMutation) AddedCreatedAt() (r int32, exists bool) { 7825 v := m.addcreated_at 7826 if v == nil { 7827 return 7828 } 7829 return *v, true 7830 } 7831 7832 // ResetCreatedAt resets all changes to the "created_at" field. 7833 func (m *CoinFiatCurrencyHistoryMutation) ResetCreatedAt() { 7834 m.created_at = nil 7835 m.addcreated_at = nil 7836 } 7837 7838 // SetUpdatedAt sets the "updated_at" field. 7839 func (m *CoinFiatCurrencyHistoryMutation) SetUpdatedAt(u uint32) { 7840 m.updated_at = &u 7841 m.addupdated_at = nil 7842 } 7843 7844 // UpdatedAt returns the value of the "updated_at" field in the mutation. 7845 func (m *CoinFiatCurrencyHistoryMutation) UpdatedAt() (r uint32, exists bool) { 7846 v := m.updated_at 7847 if v == nil { 7848 return 7849 } 7850 return *v, true 7851 } 7852 7853 // OldUpdatedAt returns the old "updated_at" field's value of the CoinFiatCurrencyHistory entity. 7854 // If the CoinFiatCurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 7855 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 7856 func (m *CoinFiatCurrencyHistoryMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 7857 if !m.op.Is(OpUpdateOne) { 7858 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 7859 } 7860 if m.id == nil || m.oldValue == nil { 7861 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 7862 } 7863 oldValue, err := m.oldValue(ctx) 7864 if err != nil { 7865 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 7866 } 7867 return oldValue.UpdatedAt, nil 7868 } 7869 7870 // AddUpdatedAt adds u to the "updated_at" field. 7871 func (m *CoinFiatCurrencyHistoryMutation) AddUpdatedAt(u int32) { 7872 if m.addupdated_at != nil { 7873 *m.addupdated_at += u 7874 } else { 7875 m.addupdated_at = &u 7876 } 7877 } 7878 7879 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 7880 func (m *CoinFiatCurrencyHistoryMutation) AddedUpdatedAt() (r int32, exists bool) { 7881 v := m.addupdated_at 7882 if v == nil { 7883 return 7884 } 7885 return *v, true 7886 } 7887 7888 // ResetUpdatedAt resets all changes to the "updated_at" field. 7889 func (m *CoinFiatCurrencyHistoryMutation) ResetUpdatedAt() { 7890 m.updated_at = nil 7891 m.addupdated_at = nil 7892 } 7893 7894 // SetDeletedAt sets the "deleted_at" field. 7895 func (m *CoinFiatCurrencyHistoryMutation) SetDeletedAt(u uint32) { 7896 m.deleted_at = &u 7897 m.adddeleted_at = nil 7898 } 7899 7900 // DeletedAt returns the value of the "deleted_at" field in the mutation. 7901 func (m *CoinFiatCurrencyHistoryMutation) DeletedAt() (r uint32, exists bool) { 7902 v := m.deleted_at 7903 if v == nil { 7904 return 7905 } 7906 return *v, true 7907 } 7908 7909 // OldDeletedAt returns the old "deleted_at" field's value of the CoinFiatCurrencyHistory entity. 7910 // If the CoinFiatCurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 7911 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 7912 func (m *CoinFiatCurrencyHistoryMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 7913 if !m.op.Is(OpUpdateOne) { 7914 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 7915 } 7916 if m.id == nil || m.oldValue == nil { 7917 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 7918 } 7919 oldValue, err := m.oldValue(ctx) 7920 if err != nil { 7921 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 7922 } 7923 return oldValue.DeletedAt, nil 7924 } 7925 7926 // AddDeletedAt adds u to the "deleted_at" field. 7927 func (m *CoinFiatCurrencyHistoryMutation) AddDeletedAt(u int32) { 7928 if m.adddeleted_at != nil { 7929 *m.adddeleted_at += u 7930 } else { 7931 m.adddeleted_at = &u 7932 } 7933 } 7934 7935 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 7936 func (m *CoinFiatCurrencyHistoryMutation) AddedDeletedAt() (r int32, exists bool) { 7937 v := m.adddeleted_at 7938 if v == nil { 7939 return 7940 } 7941 return *v, true 7942 } 7943 7944 // ResetDeletedAt resets all changes to the "deleted_at" field. 7945 func (m *CoinFiatCurrencyHistoryMutation) ResetDeletedAt() { 7946 m.deleted_at = nil 7947 m.adddeleted_at = nil 7948 } 7949 7950 // SetEntID sets the "ent_id" field. 7951 func (m *CoinFiatCurrencyHistoryMutation) SetEntID(u uuid.UUID) { 7952 m.ent_id = &u 7953 } 7954 7955 // EntID returns the value of the "ent_id" field in the mutation. 7956 func (m *CoinFiatCurrencyHistoryMutation) EntID() (r uuid.UUID, exists bool) { 7957 v := m.ent_id 7958 if v == nil { 7959 return 7960 } 7961 return *v, true 7962 } 7963 7964 // OldEntID returns the old "ent_id" field's value of the CoinFiatCurrencyHistory entity. 7965 // If the CoinFiatCurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 7966 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 7967 func (m *CoinFiatCurrencyHistoryMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 7968 if !m.op.Is(OpUpdateOne) { 7969 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 7970 } 7971 if m.id == nil || m.oldValue == nil { 7972 return v, errors.New("OldEntID requires an ID field in the mutation") 7973 } 7974 oldValue, err := m.oldValue(ctx) 7975 if err != nil { 7976 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 7977 } 7978 return oldValue.EntID, nil 7979 } 7980 7981 // ResetEntID resets all changes to the "ent_id" field. 7982 func (m *CoinFiatCurrencyHistoryMutation) ResetEntID() { 7983 m.ent_id = nil 7984 } 7985 7986 // SetCoinTypeID sets the "coin_type_id" field. 7987 func (m *CoinFiatCurrencyHistoryMutation) SetCoinTypeID(u uuid.UUID) { 7988 m.coin_type_id = &u 7989 } 7990 7991 // CoinTypeID returns the value of the "coin_type_id" field in the mutation. 7992 func (m *CoinFiatCurrencyHistoryMutation) CoinTypeID() (r uuid.UUID, exists bool) { 7993 v := m.coin_type_id 7994 if v == nil { 7995 return 7996 } 7997 return *v, true 7998 } 7999 8000 // OldCoinTypeID returns the old "coin_type_id" field's value of the CoinFiatCurrencyHistory entity. 8001 // If the CoinFiatCurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 8002 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 8003 func (m *CoinFiatCurrencyHistoryMutation) OldCoinTypeID(ctx context.Context) (v uuid.UUID, err error) { 8004 if !m.op.Is(OpUpdateOne) { 8005 return v, errors.New("OldCoinTypeID is only allowed on UpdateOne operations") 8006 } 8007 if m.id == nil || m.oldValue == nil { 8008 return v, errors.New("OldCoinTypeID requires an ID field in the mutation") 8009 } 8010 oldValue, err := m.oldValue(ctx) 8011 if err != nil { 8012 return v, fmt.Errorf("querying old value for OldCoinTypeID: %w", err) 8013 } 8014 return oldValue.CoinTypeID, nil 8015 } 8016 8017 // ClearCoinTypeID clears the value of the "coin_type_id" field. 8018 func (m *CoinFiatCurrencyHistoryMutation) ClearCoinTypeID() { 8019 m.coin_type_id = nil 8020 m.clearedFields[coinfiatcurrencyhistory.FieldCoinTypeID] = struct{}{} 8021 } 8022 8023 // CoinTypeIDCleared returns if the "coin_type_id" field was cleared in this mutation. 8024 func (m *CoinFiatCurrencyHistoryMutation) CoinTypeIDCleared() bool { 8025 _, ok := m.clearedFields[coinfiatcurrencyhistory.FieldCoinTypeID] 8026 return ok 8027 } 8028 8029 // ResetCoinTypeID resets all changes to the "coin_type_id" field. 8030 func (m *CoinFiatCurrencyHistoryMutation) ResetCoinTypeID() { 8031 m.coin_type_id = nil 8032 delete(m.clearedFields, coinfiatcurrencyhistory.FieldCoinTypeID) 8033 } 8034 8035 // SetFiatID sets the "fiat_id" field. 8036 func (m *CoinFiatCurrencyHistoryMutation) SetFiatID(u uuid.UUID) { 8037 m.fiat_id = &u 8038 } 8039 8040 // FiatID returns the value of the "fiat_id" field in the mutation. 8041 func (m *CoinFiatCurrencyHistoryMutation) FiatID() (r uuid.UUID, exists bool) { 8042 v := m.fiat_id 8043 if v == nil { 8044 return 8045 } 8046 return *v, true 8047 } 8048 8049 // OldFiatID returns the old "fiat_id" field's value of the CoinFiatCurrencyHistory entity. 8050 // If the CoinFiatCurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 8051 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 8052 func (m *CoinFiatCurrencyHistoryMutation) OldFiatID(ctx context.Context) (v uuid.UUID, err error) { 8053 if !m.op.Is(OpUpdateOne) { 8054 return v, errors.New("OldFiatID is only allowed on UpdateOne operations") 8055 } 8056 if m.id == nil || m.oldValue == nil { 8057 return v, errors.New("OldFiatID requires an ID field in the mutation") 8058 } 8059 oldValue, err := m.oldValue(ctx) 8060 if err != nil { 8061 return v, fmt.Errorf("querying old value for OldFiatID: %w", err) 8062 } 8063 return oldValue.FiatID, nil 8064 } 8065 8066 // ClearFiatID clears the value of the "fiat_id" field. 8067 func (m *CoinFiatCurrencyHistoryMutation) ClearFiatID() { 8068 m.fiat_id = nil 8069 m.clearedFields[coinfiatcurrencyhistory.FieldFiatID] = struct{}{} 8070 } 8071 8072 // FiatIDCleared returns if the "fiat_id" field was cleared in this mutation. 8073 func (m *CoinFiatCurrencyHistoryMutation) FiatIDCleared() bool { 8074 _, ok := m.clearedFields[coinfiatcurrencyhistory.FieldFiatID] 8075 return ok 8076 } 8077 8078 // ResetFiatID resets all changes to the "fiat_id" field. 8079 func (m *CoinFiatCurrencyHistoryMutation) ResetFiatID() { 8080 m.fiat_id = nil 8081 delete(m.clearedFields, coinfiatcurrencyhistory.FieldFiatID) 8082 } 8083 8084 // SetFeedType sets the "feed_type" field. 8085 func (m *CoinFiatCurrencyHistoryMutation) SetFeedType(s string) { 8086 m.feed_type = &s 8087 } 8088 8089 // FeedType returns the value of the "feed_type" field in the mutation. 8090 func (m *CoinFiatCurrencyHistoryMutation) FeedType() (r string, exists bool) { 8091 v := m.feed_type 8092 if v == nil { 8093 return 8094 } 8095 return *v, true 8096 } 8097 8098 // OldFeedType returns the old "feed_type" field's value of the CoinFiatCurrencyHistory entity. 8099 // If the CoinFiatCurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 8100 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 8101 func (m *CoinFiatCurrencyHistoryMutation) OldFeedType(ctx context.Context) (v string, err error) { 8102 if !m.op.Is(OpUpdateOne) { 8103 return v, errors.New("OldFeedType is only allowed on UpdateOne operations") 8104 } 8105 if m.id == nil || m.oldValue == nil { 8106 return v, errors.New("OldFeedType requires an ID field in the mutation") 8107 } 8108 oldValue, err := m.oldValue(ctx) 8109 if err != nil { 8110 return v, fmt.Errorf("querying old value for OldFeedType: %w", err) 8111 } 8112 return oldValue.FeedType, nil 8113 } 8114 8115 // ClearFeedType clears the value of the "feed_type" field. 8116 func (m *CoinFiatCurrencyHistoryMutation) ClearFeedType() { 8117 m.feed_type = nil 8118 m.clearedFields[coinfiatcurrencyhistory.FieldFeedType] = struct{}{} 8119 } 8120 8121 // FeedTypeCleared returns if the "feed_type" field was cleared in this mutation. 8122 func (m *CoinFiatCurrencyHistoryMutation) FeedTypeCleared() bool { 8123 _, ok := m.clearedFields[coinfiatcurrencyhistory.FieldFeedType] 8124 return ok 8125 } 8126 8127 // ResetFeedType resets all changes to the "feed_type" field. 8128 func (m *CoinFiatCurrencyHistoryMutation) ResetFeedType() { 8129 m.feed_type = nil 8130 delete(m.clearedFields, coinfiatcurrencyhistory.FieldFeedType) 8131 } 8132 8133 // SetMarketValueLow sets the "market_value_low" field. 8134 func (m *CoinFiatCurrencyHistoryMutation) SetMarketValueLow(d decimal.Decimal) { 8135 m.market_value_low = &d 8136 } 8137 8138 // MarketValueLow returns the value of the "market_value_low" field in the mutation. 8139 func (m *CoinFiatCurrencyHistoryMutation) MarketValueLow() (r decimal.Decimal, exists bool) { 8140 v := m.market_value_low 8141 if v == nil { 8142 return 8143 } 8144 return *v, true 8145 } 8146 8147 // OldMarketValueLow returns the old "market_value_low" field's value of the CoinFiatCurrencyHistory entity. 8148 // If the CoinFiatCurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 8149 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 8150 func (m *CoinFiatCurrencyHistoryMutation) OldMarketValueLow(ctx context.Context) (v decimal.Decimal, err error) { 8151 if !m.op.Is(OpUpdateOne) { 8152 return v, errors.New("OldMarketValueLow is only allowed on UpdateOne operations") 8153 } 8154 if m.id == nil || m.oldValue == nil { 8155 return v, errors.New("OldMarketValueLow requires an ID field in the mutation") 8156 } 8157 oldValue, err := m.oldValue(ctx) 8158 if err != nil { 8159 return v, fmt.Errorf("querying old value for OldMarketValueLow: %w", err) 8160 } 8161 return oldValue.MarketValueLow, nil 8162 } 8163 8164 // ClearMarketValueLow clears the value of the "market_value_low" field. 8165 func (m *CoinFiatCurrencyHistoryMutation) ClearMarketValueLow() { 8166 m.market_value_low = nil 8167 m.clearedFields[coinfiatcurrencyhistory.FieldMarketValueLow] = struct{}{} 8168 } 8169 8170 // MarketValueLowCleared returns if the "market_value_low" field was cleared in this mutation. 8171 func (m *CoinFiatCurrencyHistoryMutation) MarketValueLowCleared() bool { 8172 _, ok := m.clearedFields[coinfiatcurrencyhistory.FieldMarketValueLow] 8173 return ok 8174 } 8175 8176 // ResetMarketValueLow resets all changes to the "market_value_low" field. 8177 func (m *CoinFiatCurrencyHistoryMutation) ResetMarketValueLow() { 8178 m.market_value_low = nil 8179 delete(m.clearedFields, coinfiatcurrencyhistory.FieldMarketValueLow) 8180 } 8181 8182 // SetMarketValueHigh sets the "market_value_high" field. 8183 func (m *CoinFiatCurrencyHistoryMutation) SetMarketValueHigh(d decimal.Decimal) { 8184 m.market_value_high = &d 8185 } 8186 8187 // MarketValueHigh returns the value of the "market_value_high" field in the mutation. 8188 func (m *CoinFiatCurrencyHistoryMutation) MarketValueHigh() (r decimal.Decimal, exists bool) { 8189 v := m.market_value_high 8190 if v == nil { 8191 return 8192 } 8193 return *v, true 8194 } 8195 8196 // OldMarketValueHigh returns the old "market_value_high" field's value of the CoinFiatCurrencyHistory entity. 8197 // If the CoinFiatCurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 8198 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 8199 func (m *CoinFiatCurrencyHistoryMutation) OldMarketValueHigh(ctx context.Context) (v decimal.Decimal, err error) { 8200 if !m.op.Is(OpUpdateOne) { 8201 return v, errors.New("OldMarketValueHigh is only allowed on UpdateOne operations") 8202 } 8203 if m.id == nil || m.oldValue == nil { 8204 return v, errors.New("OldMarketValueHigh requires an ID field in the mutation") 8205 } 8206 oldValue, err := m.oldValue(ctx) 8207 if err != nil { 8208 return v, fmt.Errorf("querying old value for OldMarketValueHigh: %w", err) 8209 } 8210 return oldValue.MarketValueHigh, nil 8211 } 8212 8213 // ClearMarketValueHigh clears the value of the "market_value_high" field. 8214 func (m *CoinFiatCurrencyHistoryMutation) ClearMarketValueHigh() { 8215 m.market_value_high = nil 8216 m.clearedFields[coinfiatcurrencyhistory.FieldMarketValueHigh] = struct{}{} 8217 } 8218 8219 // MarketValueHighCleared returns if the "market_value_high" field was cleared in this mutation. 8220 func (m *CoinFiatCurrencyHistoryMutation) MarketValueHighCleared() bool { 8221 _, ok := m.clearedFields[coinfiatcurrencyhistory.FieldMarketValueHigh] 8222 return ok 8223 } 8224 8225 // ResetMarketValueHigh resets all changes to the "market_value_high" field. 8226 func (m *CoinFiatCurrencyHistoryMutation) ResetMarketValueHigh() { 8227 m.market_value_high = nil 8228 delete(m.clearedFields, coinfiatcurrencyhistory.FieldMarketValueHigh) 8229 } 8230 8231 // Where appends a list predicates to the CoinFiatCurrencyHistoryMutation builder. 8232 func (m *CoinFiatCurrencyHistoryMutation) Where(ps ...predicate.CoinFiatCurrencyHistory) { 8233 m.predicates = append(m.predicates, ps...) 8234 } 8235 8236 // Op returns the operation name. 8237 func (m *CoinFiatCurrencyHistoryMutation) Op() Op { 8238 return m.op 8239 } 8240 8241 // Type returns the node type of this mutation (CoinFiatCurrencyHistory). 8242 func (m *CoinFiatCurrencyHistoryMutation) Type() string { 8243 return m.typ 8244 } 8245 8246 // Fields returns all fields that were changed during this mutation. Note that in 8247 // order to get all numeric fields that were incremented/decremented, call 8248 // AddedFields(). 8249 func (m *CoinFiatCurrencyHistoryMutation) Fields() []string { 8250 fields := make([]string, 0, 9) 8251 if m.created_at != nil { 8252 fields = append(fields, coinfiatcurrencyhistory.FieldCreatedAt) 8253 } 8254 if m.updated_at != nil { 8255 fields = append(fields, coinfiatcurrencyhistory.FieldUpdatedAt) 8256 } 8257 if m.deleted_at != nil { 8258 fields = append(fields, coinfiatcurrencyhistory.FieldDeletedAt) 8259 } 8260 if m.ent_id != nil { 8261 fields = append(fields, coinfiatcurrencyhistory.FieldEntID) 8262 } 8263 if m.coin_type_id != nil { 8264 fields = append(fields, coinfiatcurrencyhistory.FieldCoinTypeID) 8265 } 8266 if m.fiat_id != nil { 8267 fields = append(fields, coinfiatcurrencyhistory.FieldFiatID) 8268 } 8269 if m.feed_type != nil { 8270 fields = append(fields, coinfiatcurrencyhistory.FieldFeedType) 8271 } 8272 if m.market_value_low != nil { 8273 fields = append(fields, coinfiatcurrencyhistory.FieldMarketValueLow) 8274 } 8275 if m.market_value_high != nil { 8276 fields = append(fields, coinfiatcurrencyhistory.FieldMarketValueHigh) 8277 } 8278 return fields 8279 } 8280 8281 // Field returns the value of a field with the given name. The second boolean 8282 // return value indicates that this field was not set, or was not defined in the 8283 // schema. 8284 func (m *CoinFiatCurrencyHistoryMutation) Field(name string) (ent.Value, bool) { 8285 switch name { 8286 case coinfiatcurrencyhistory.FieldCreatedAt: 8287 return m.CreatedAt() 8288 case coinfiatcurrencyhistory.FieldUpdatedAt: 8289 return m.UpdatedAt() 8290 case coinfiatcurrencyhistory.FieldDeletedAt: 8291 return m.DeletedAt() 8292 case coinfiatcurrencyhistory.FieldEntID: 8293 return m.EntID() 8294 case coinfiatcurrencyhistory.FieldCoinTypeID: 8295 return m.CoinTypeID() 8296 case coinfiatcurrencyhistory.FieldFiatID: 8297 return m.FiatID() 8298 case coinfiatcurrencyhistory.FieldFeedType: 8299 return m.FeedType() 8300 case coinfiatcurrencyhistory.FieldMarketValueLow: 8301 return m.MarketValueLow() 8302 case coinfiatcurrencyhistory.FieldMarketValueHigh: 8303 return m.MarketValueHigh() 8304 } 8305 return nil, false 8306 } 8307 8308 // OldField returns the old value of the field from the database. An error is 8309 // returned if the mutation operation is not UpdateOne, or the query to the 8310 // database failed. 8311 func (m *CoinFiatCurrencyHistoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 8312 switch name { 8313 case coinfiatcurrencyhistory.FieldCreatedAt: 8314 return m.OldCreatedAt(ctx) 8315 case coinfiatcurrencyhistory.FieldUpdatedAt: 8316 return m.OldUpdatedAt(ctx) 8317 case coinfiatcurrencyhistory.FieldDeletedAt: 8318 return m.OldDeletedAt(ctx) 8319 case coinfiatcurrencyhistory.FieldEntID: 8320 return m.OldEntID(ctx) 8321 case coinfiatcurrencyhistory.FieldCoinTypeID: 8322 return m.OldCoinTypeID(ctx) 8323 case coinfiatcurrencyhistory.FieldFiatID: 8324 return m.OldFiatID(ctx) 8325 case coinfiatcurrencyhistory.FieldFeedType: 8326 return m.OldFeedType(ctx) 8327 case coinfiatcurrencyhistory.FieldMarketValueLow: 8328 return m.OldMarketValueLow(ctx) 8329 case coinfiatcurrencyhistory.FieldMarketValueHigh: 8330 return m.OldMarketValueHigh(ctx) 8331 } 8332 return nil, fmt.Errorf("unknown CoinFiatCurrencyHistory field %s", name) 8333 } 8334 8335 // SetField sets the value of a field with the given name. It returns an error if 8336 // the field is not defined in the schema, or if the type mismatched the field 8337 // type. 8338 func (m *CoinFiatCurrencyHistoryMutation) SetField(name string, value ent.Value) error { 8339 switch name { 8340 case coinfiatcurrencyhistory.FieldCreatedAt: 8341 v, ok := value.(uint32) 8342 if !ok { 8343 return fmt.Errorf("unexpected type %T for field %s", value, name) 8344 } 8345 m.SetCreatedAt(v) 8346 return nil 8347 case coinfiatcurrencyhistory.FieldUpdatedAt: 8348 v, ok := value.(uint32) 8349 if !ok { 8350 return fmt.Errorf("unexpected type %T for field %s", value, name) 8351 } 8352 m.SetUpdatedAt(v) 8353 return nil 8354 case coinfiatcurrencyhistory.FieldDeletedAt: 8355 v, ok := value.(uint32) 8356 if !ok { 8357 return fmt.Errorf("unexpected type %T for field %s", value, name) 8358 } 8359 m.SetDeletedAt(v) 8360 return nil 8361 case coinfiatcurrencyhistory.FieldEntID: 8362 v, ok := value.(uuid.UUID) 8363 if !ok { 8364 return fmt.Errorf("unexpected type %T for field %s", value, name) 8365 } 8366 m.SetEntID(v) 8367 return nil 8368 case coinfiatcurrencyhistory.FieldCoinTypeID: 8369 v, ok := value.(uuid.UUID) 8370 if !ok { 8371 return fmt.Errorf("unexpected type %T for field %s", value, name) 8372 } 8373 m.SetCoinTypeID(v) 8374 return nil 8375 case coinfiatcurrencyhistory.FieldFiatID: 8376 v, ok := value.(uuid.UUID) 8377 if !ok { 8378 return fmt.Errorf("unexpected type %T for field %s", value, name) 8379 } 8380 m.SetFiatID(v) 8381 return nil 8382 case coinfiatcurrencyhistory.FieldFeedType: 8383 v, ok := value.(string) 8384 if !ok { 8385 return fmt.Errorf("unexpected type %T for field %s", value, name) 8386 } 8387 m.SetFeedType(v) 8388 return nil 8389 case coinfiatcurrencyhistory.FieldMarketValueLow: 8390 v, ok := value.(decimal.Decimal) 8391 if !ok { 8392 return fmt.Errorf("unexpected type %T for field %s", value, name) 8393 } 8394 m.SetMarketValueLow(v) 8395 return nil 8396 case coinfiatcurrencyhistory.FieldMarketValueHigh: 8397 v, ok := value.(decimal.Decimal) 8398 if !ok { 8399 return fmt.Errorf("unexpected type %T for field %s", value, name) 8400 } 8401 m.SetMarketValueHigh(v) 8402 return nil 8403 } 8404 return fmt.Errorf("unknown CoinFiatCurrencyHistory field %s", name) 8405 } 8406 8407 // AddedFields returns all numeric fields that were incremented/decremented during 8408 // this mutation. 8409 func (m *CoinFiatCurrencyHistoryMutation) AddedFields() []string { 8410 var fields []string 8411 if m.addcreated_at != nil { 8412 fields = append(fields, coinfiatcurrencyhistory.FieldCreatedAt) 8413 } 8414 if m.addupdated_at != nil { 8415 fields = append(fields, coinfiatcurrencyhistory.FieldUpdatedAt) 8416 } 8417 if m.adddeleted_at != nil { 8418 fields = append(fields, coinfiatcurrencyhistory.FieldDeletedAt) 8419 } 8420 return fields 8421 } 8422 8423 // AddedField returns the numeric value that was incremented/decremented on a field 8424 // with the given name. The second boolean return value indicates that this field 8425 // was not set, or was not defined in the schema. 8426 func (m *CoinFiatCurrencyHistoryMutation) AddedField(name string) (ent.Value, bool) { 8427 switch name { 8428 case coinfiatcurrencyhistory.FieldCreatedAt: 8429 return m.AddedCreatedAt() 8430 case coinfiatcurrencyhistory.FieldUpdatedAt: 8431 return m.AddedUpdatedAt() 8432 case coinfiatcurrencyhistory.FieldDeletedAt: 8433 return m.AddedDeletedAt() 8434 } 8435 return nil, false 8436 } 8437 8438 // AddField adds the value to the field with the given name. It returns an error if 8439 // the field is not defined in the schema, or if the type mismatched the field 8440 // type. 8441 func (m *CoinFiatCurrencyHistoryMutation) AddField(name string, value ent.Value) error { 8442 switch name { 8443 case coinfiatcurrencyhistory.FieldCreatedAt: 8444 v, ok := value.(int32) 8445 if !ok { 8446 return fmt.Errorf("unexpected type %T for field %s", value, name) 8447 } 8448 m.AddCreatedAt(v) 8449 return nil 8450 case coinfiatcurrencyhistory.FieldUpdatedAt: 8451 v, ok := value.(int32) 8452 if !ok { 8453 return fmt.Errorf("unexpected type %T for field %s", value, name) 8454 } 8455 m.AddUpdatedAt(v) 8456 return nil 8457 case coinfiatcurrencyhistory.FieldDeletedAt: 8458 v, ok := value.(int32) 8459 if !ok { 8460 return fmt.Errorf("unexpected type %T for field %s", value, name) 8461 } 8462 m.AddDeletedAt(v) 8463 return nil 8464 } 8465 return fmt.Errorf("unknown CoinFiatCurrencyHistory numeric field %s", name) 8466 } 8467 8468 // ClearedFields returns all nullable fields that were cleared during this 8469 // mutation. 8470 func (m *CoinFiatCurrencyHistoryMutation) ClearedFields() []string { 8471 var fields []string 8472 if m.FieldCleared(coinfiatcurrencyhistory.FieldCoinTypeID) { 8473 fields = append(fields, coinfiatcurrencyhistory.FieldCoinTypeID) 8474 } 8475 if m.FieldCleared(coinfiatcurrencyhistory.FieldFiatID) { 8476 fields = append(fields, coinfiatcurrencyhistory.FieldFiatID) 8477 } 8478 if m.FieldCleared(coinfiatcurrencyhistory.FieldFeedType) { 8479 fields = append(fields, coinfiatcurrencyhistory.FieldFeedType) 8480 } 8481 if m.FieldCleared(coinfiatcurrencyhistory.FieldMarketValueLow) { 8482 fields = append(fields, coinfiatcurrencyhistory.FieldMarketValueLow) 8483 } 8484 if m.FieldCleared(coinfiatcurrencyhistory.FieldMarketValueHigh) { 8485 fields = append(fields, coinfiatcurrencyhistory.FieldMarketValueHigh) 8486 } 8487 return fields 8488 } 8489 8490 // FieldCleared returns a boolean indicating if a field with the given name was 8491 // cleared in this mutation. 8492 func (m *CoinFiatCurrencyHistoryMutation) FieldCleared(name string) bool { 8493 _, ok := m.clearedFields[name] 8494 return ok 8495 } 8496 8497 // ClearField clears the value of the field with the given name. It returns an 8498 // error if the field is not defined in the schema. 8499 func (m *CoinFiatCurrencyHistoryMutation) ClearField(name string) error { 8500 switch name { 8501 case coinfiatcurrencyhistory.FieldCoinTypeID: 8502 m.ClearCoinTypeID() 8503 return nil 8504 case coinfiatcurrencyhistory.FieldFiatID: 8505 m.ClearFiatID() 8506 return nil 8507 case coinfiatcurrencyhistory.FieldFeedType: 8508 m.ClearFeedType() 8509 return nil 8510 case coinfiatcurrencyhistory.FieldMarketValueLow: 8511 m.ClearMarketValueLow() 8512 return nil 8513 case coinfiatcurrencyhistory.FieldMarketValueHigh: 8514 m.ClearMarketValueHigh() 8515 return nil 8516 } 8517 return fmt.Errorf("unknown CoinFiatCurrencyHistory nullable field %s", name) 8518 } 8519 8520 // ResetField resets all changes in the mutation for the field with the given name. 8521 // It returns an error if the field is not defined in the schema. 8522 func (m *CoinFiatCurrencyHistoryMutation) ResetField(name string) error { 8523 switch name { 8524 case coinfiatcurrencyhistory.FieldCreatedAt: 8525 m.ResetCreatedAt() 8526 return nil 8527 case coinfiatcurrencyhistory.FieldUpdatedAt: 8528 m.ResetUpdatedAt() 8529 return nil 8530 case coinfiatcurrencyhistory.FieldDeletedAt: 8531 m.ResetDeletedAt() 8532 return nil 8533 case coinfiatcurrencyhistory.FieldEntID: 8534 m.ResetEntID() 8535 return nil 8536 case coinfiatcurrencyhistory.FieldCoinTypeID: 8537 m.ResetCoinTypeID() 8538 return nil 8539 case coinfiatcurrencyhistory.FieldFiatID: 8540 m.ResetFiatID() 8541 return nil 8542 case coinfiatcurrencyhistory.FieldFeedType: 8543 m.ResetFeedType() 8544 return nil 8545 case coinfiatcurrencyhistory.FieldMarketValueLow: 8546 m.ResetMarketValueLow() 8547 return nil 8548 case coinfiatcurrencyhistory.FieldMarketValueHigh: 8549 m.ResetMarketValueHigh() 8550 return nil 8551 } 8552 return fmt.Errorf("unknown CoinFiatCurrencyHistory field %s", name) 8553 } 8554 8555 // AddedEdges returns all edge names that were set/added in this mutation. 8556 func (m *CoinFiatCurrencyHistoryMutation) AddedEdges() []string { 8557 edges := make([]string, 0, 0) 8558 return edges 8559 } 8560 8561 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 8562 // name in this mutation. 8563 func (m *CoinFiatCurrencyHistoryMutation) AddedIDs(name string) []ent.Value { 8564 return nil 8565 } 8566 8567 // RemovedEdges returns all edge names that were removed in this mutation. 8568 func (m *CoinFiatCurrencyHistoryMutation) RemovedEdges() []string { 8569 edges := make([]string, 0, 0) 8570 return edges 8571 } 8572 8573 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 8574 // the given name in this mutation. 8575 func (m *CoinFiatCurrencyHistoryMutation) RemovedIDs(name string) []ent.Value { 8576 return nil 8577 } 8578 8579 // ClearedEdges returns all edge names that were cleared in this mutation. 8580 func (m *CoinFiatCurrencyHistoryMutation) ClearedEdges() []string { 8581 edges := make([]string, 0, 0) 8582 return edges 8583 } 8584 8585 // EdgeCleared returns a boolean which indicates if the edge with the given name 8586 // was cleared in this mutation. 8587 func (m *CoinFiatCurrencyHistoryMutation) EdgeCleared(name string) bool { 8588 return false 8589 } 8590 8591 // ClearEdge clears the value of the edge with the given name. It returns an error 8592 // if that edge is not defined in the schema. 8593 func (m *CoinFiatCurrencyHistoryMutation) ClearEdge(name string) error { 8594 return fmt.Errorf("unknown CoinFiatCurrencyHistory unique edge %s", name) 8595 } 8596 8597 // ResetEdge resets all changes to the edge with the given name in this mutation. 8598 // It returns an error if the edge is not defined in the schema. 8599 func (m *CoinFiatCurrencyHistoryMutation) ResetEdge(name string) error { 8600 return fmt.Errorf("unknown CoinFiatCurrencyHistory edge %s", name) 8601 } 8602 8603 // CoinUsedForMutation represents an operation that mutates the CoinUsedFor nodes in the graph. 8604 type CoinUsedForMutation struct { 8605 config 8606 op Op 8607 typ string 8608 id *uint32 8609 created_at *uint32 8610 addcreated_at *int32 8611 updated_at *uint32 8612 addupdated_at *int32 8613 deleted_at *uint32 8614 adddeleted_at *int32 8615 ent_id *uuid.UUID 8616 coin_type_id *uuid.UUID 8617 used_for *string 8618 priority *uint32 8619 addpriority *int32 8620 clearedFields map[string]struct{} 8621 done bool 8622 oldValue func(context.Context) (*CoinUsedFor, error) 8623 predicates []predicate.CoinUsedFor 8624 } 8625 8626 var _ ent.Mutation = (*CoinUsedForMutation)(nil) 8627 8628 // coinusedforOption allows management of the mutation configuration using functional options. 8629 type coinusedforOption func(*CoinUsedForMutation) 8630 8631 // newCoinUsedForMutation creates new mutation for the CoinUsedFor entity. 8632 func newCoinUsedForMutation(c config, op Op, opts ...coinusedforOption) *CoinUsedForMutation { 8633 m := &CoinUsedForMutation{ 8634 config: c, 8635 op: op, 8636 typ: TypeCoinUsedFor, 8637 clearedFields: make(map[string]struct{}), 8638 } 8639 for _, opt := range opts { 8640 opt(m) 8641 } 8642 return m 8643 } 8644 8645 // withCoinUsedForID sets the ID field of the mutation. 8646 func withCoinUsedForID(id uint32) coinusedforOption { 8647 return func(m *CoinUsedForMutation) { 8648 var ( 8649 err error 8650 once sync.Once 8651 value *CoinUsedFor 8652 ) 8653 m.oldValue = func(ctx context.Context) (*CoinUsedFor, error) { 8654 once.Do(func() { 8655 if m.done { 8656 err = errors.New("querying old values post mutation is not allowed") 8657 } else { 8658 value, err = m.Client().CoinUsedFor.Get(ctx, id) 8659 } 8660 }) 8661 return value, err 8662 } 8663 m.id = &id 8664 } 8665 } 8666 8667 // withCoinUsedFor sets the old CoinUsedFor of the mutation. 8668 func withCoinUsedFor(node *CoinUsedFor) coinusedforOption { 8669 return func(m *CoinUsedForMutation) { 8670 m.oldValue = func(context.Context) (*CoinUsedFor, error) { 8671 return node, nil 8672 } 8673 m.id = &node.ID 8674 } 8675 } 8676 8677 // Client returns a new `ent.Client` from the mutation. If the mutation was 8678 // executed in a transaction (ent.Tx), a transactional client is returned. 8679 func (m CoinUsedForMutation) Client() *Client { 8680 client := &Client{config: m.config} 8681 client.init() 8682 return client 8683 } 8684 8685 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 8686 // it returns an error otherwise. 8687 func (m CoinUsedForMutation) Tx() (*Tx, error) { 8688 if _, ok := m.driver.(*txDriver); !ok { 8689 return nil, errors.New("ent: mutation is not running in a transaction") 8690 } 8691 tx := &Tx{config: m.config} 8692 tx.init() 8693 return tx, nil 8694 } 8695 8696 // SetID sets the value of the id field. Note that this 8697 // operation is only accepted on creation of CoinUsedFor entities. 8698 func (m *CoinUsedForMutation) SetID(id uint32) { 8699 m.id = &id 8700 } 8701 8702 // ID returns the ID value in the mutation. Note that the ID is only available 8703 // if it was provided to the builder or after it was returned from the database. 8704 func (m *CoinUsedForMutation) ID() (id uint32, exists bool) { 8705 if m.id == nil { 8706 return 8707 } 8708 return *m.id, true 8709 } 8710 8711 // IDs queries the database and returns the entity ids that match the mutation's predicate. 8712 // That means, if the mutation is applied within a transaction with an isolation level such 8713 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 8714 // or updated by the mutation. 8715 func (m *CoinUsedForMutation) IDs(ctx context.Context) ([]uint32, error) { 8716 switch { 8717 case m.op.Is(OpUpdateOne | OpDeleteOne): 8718 id, exists := m.ID() 8719 if exists { 8720 return []uint32{id}, nil 8721 } 8722 fallthrough 8723 case m.op.Is(OpUpdate | OpDelete): 8724 return m.Client().CoinUsedFor.Query().Where(m.predicates...).IDs(ctx) 8725 default: 8726 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 8727 } 8728 } 8729 8730 // SetCreatedAt sets the "created_at" field. 8731 func (m *CoinUsedForMutation) SetCreatedAt(u uint32) { 8732 m.created_at = &u 8733 m.addcreated_at = nil 8734 } 8735 8736 // CreatedAt returns the value of the "created_at" field in the mutation. 8737 func (m *CoinUsedForMutation) CreatedAt() (r uint32, exists bool) { 8738 v := m.created_at 8739 if v == nil { 8740 return 8741 } 8742 return *v, true 8743 } 8744 8745 // OldCreatedAt returns the old "created_at" field's value of the CoinUsedFor entity. 8746 // If the CoinUsedFor object wasn't provided to the builder, the object is fetched from the database. 8747 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 8748 func (m *CoinUsedForMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 8749 if !m.op.Is(OpUpdateOne) { 8750 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 8751 } 8752 if m.id == nil || m.oldValue == nil { 8753 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 8754 } 8755 oldValue, err := m.oldValue(ctx) 8756 if err != nil { 8757 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 8758 } 8759 return oldValue.CreatedAt, nil 8760 } 8761 8762 // AddCreatedAt adds u to the "created_at" field. 8763 func (m *CoinUsedForMutation) AddCreatedAt(u int32) { 8764 if m.addcreated_at != nil { 8765 *m.addcreated_at += u 8766 } else { 8767 m.addcreated_at = &u 8768 } 8769 } 8770 8771 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 8772 func (m *CoinUsedForMutation) AddedCreatedAt() (r int32, exists bool) { 8773 v := m.addcreated_at 8774 if v == nil { 8775 return 8776 } 8777 return *v, true 8778 } 8779 8780 // ResetCreatedAt resets all changes to the "created_at" field. 8781 func (m *CoinUsedForMutation) ResetCreatedAt() { 8782 m.created_at = nil 8783 m.addcreated_at = nil 8784 } 8785 8786 // SetUpdatedAt sets the "updated_at" field. 8787 func (m *CoinUsedForMutation) SetUpdatedAt(u uint32) { 8788 m.updated_at = &u 8789 m.addupdated_at = nil 8790 } 8791 8792 // UpdatedAt returns the value of the "updated_at" field in the mutation. 8793 func (m *CoinUsedForMutation) UpdatedAt() (r uint32, exists bool) { 8794 v := m.updated_at 8795 if v == nil { 8796 return 8797 } 8798 return *v, true 8799 } 8800 8801 // OldUpdatedAt returns the old "updated_at" field's value of the CoinUsedFor entity. 8802 // If the CoinUsedFor object wasn't provided to the builder, the object is fetched from the database. 8803 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 8804 func (m *CoinUsedForMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 8805 if !m.op.Is(OpUpdateOne) { 8806 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 8807 } 8808 if m.id == nil || m.oldValue == nil { 8809 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 8810 } 8811 oldValue, err := m.oldValue(ctx) 8812 if err != nil { 8813 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 8814 } 8815 return oldValue.UpdatedAt, nil 8816 } 8817 8818 // AddUpdatedAt adds u to the "updated_at" field. 8819 func (m *CoinUsedForMutation) AddUpdatedAt(u int32) { 8820 if m.addupdated_at != nil { 8821 *m.addupdated_at += u 8822 } else { 8823 m.addupdated_at = &u 8824 } 8825 } 8826 8827 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 8828 func (m *CoinUsedForMutation) AddedUpdatedAt() (r int32, exists bool) { 8829 v := m.addupdated_at 8830 if v == nil { 8831 return 8832 } 8833 return *v, true 8834 } 8835 8836 // ResetUpdatedAt resets all changes to the "updated_at" field. 8837 func (m *CoinUsedForMutation) ResetUpdatedAt() { 8838 m.updated_at = nil 8839 m.addupdated_at = nil 8840 } 8841 8842 // SetDeletedAt sets the "deleted_at" field. 8843 func (m *CoinUsedForMutation) SetDeletedAt(u uint32) { 8844 m.deleted_at = &u 8845 m.adddeleted_at = nil 8846 } 8847 8848 // DeletedAt returns the value of the "deleted_at" field in the mutation. 8849 func (m *CoinUsedForMutation) DeletedAt() (r uint32, exists bool) { 8850 v := m.deleted_at 8851 if v == nil { 8852 return 8853 } 8854 return *v, true 8855 } 8856 8857 // OldDeletedAt returns the old "deleted_at" field's value of the CoinUsedFor entity. 8858 // If the CoinUsedFor object wasn't provided to the builder, the object is fetched from the database. 8859 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 8860 func (m *CoinUsedForMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 8861 if !m.op.Is(OpUpdateOne) { 8862 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 8863 } 8864 if m.id == nil || m.oldValue == nil { 8865 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 8866 } 8867 oldValue, err := m.oldValue(ctx) 8868 if err != nil { 8869 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 8870 } 8871 return oldValue.DeletedAt, nil 8872 } 8873 8874 // AddDeletedAt adds u to the "deleted_at" field. 8875 func (m *CoinUsedForMutation) AddDeletedAt(u int32) { 8876 if m.adddeleted_at != nil { 8877 *m.adddeleted_at += u 8878 } else { 8879 m.adddeleted_at = &u 8880 } 8881 } 8882 8883 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 8884 func (m *CoinUsedForMutation) AddedDeletedAt() (r int32, exists bool) { 8885 v := m.adddeleted_at 8886 if v == nil { 8887 return 8888 } 8889 return *v, true 8890 } 8891 8892 // ResetDeletedAt resets all changes to the "deleted_at" field. 8893 func (m *CoinUsedForMutation) ResetDeletedAt() { 8894 m.deleted_at = nil 8895 m.adddeleted_at = nil 8896 } 8897 8898 // SetEntID sets the "ent_id" field. 8899 func (m *CoinUsedForMutation) SetEntID(u uuid.UUID) { 8900 m.ent_id = &u 8901 } 8902 8903 // EntID returns the value of the "ent_id" field in the mutation. 8904 func (m *CoinUsedForMutation) EntID() (r uuid.UUID, exists bool) { 8905 v := m.ent_id 8906 if v == nil { 8907 return 8908 } 8909 return *v, true 8910 } 8911 8912 // OldEntID returns the old "ent_id" field's value of the CoinUsedFor entity. 8913 // If the CoinUsedFor object wasn't provided to the builder, the object is fetched from the database. 8914 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 8915 func (m *CoinUsedForMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 8916 if !m.op.Is(OpUpdateOne) { 8917 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 8918 } 8919 if m.id == nil || m.oldValue == nil { 8920 return v, errors.New("OldEntID requires an ID field in the mutation") 8921 } 8922 oldValue, err := m.oldValue(ctx) 8923 if err != nil { 8924 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 8925 } 8926 return oldValue.EntID, nil 8927 } 8928 8929 // ResetEntID resets all changes to the "ent_id" field. 8930 func (m *CoinUsedForMutation) ResetEntID() { 8931 m.ent_id = nil 8932 } 8933 8934 // SetCoinTypeID sets the "coin_type_id" field. 8935 func (m *CoinUsedForMutation) SetCoinTypeID(u uuid.UUID) { 8936 m.coin_type_id = &u 8937 } 8938 8939 // CoinTypeID returns the value of the "coin_type_id" field in the mutation. 8940 func (m *CoinUsedForMutation) CoinTypeID() (r uuid.UUID, exists bool) { 8941 v := m.coin_type_id 8942 if v == nil { 8943 return 8944 } 8945 return *v, true 8946 } 8947 8948 // OldCoinTypeID returns the old "coin_type_id" field's value of the CoinUsedFor entity. 8949 // If the CoinUsedFor object wasn't provided to the builder, the object is fetched from the database. 8950 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 8951 func (m *CoinUsedForMutation) OldCoinTypeID(ctx context.Context) (v uuid.UUID, err error) { 8952 if !m.op.Is(OpUpdateOne) { 8953 return v, errors.New("OldCoinTypeID is only allowed on UpdateOne operations") 8954 } 8955 if m.id == nil || m.oldValue == nil { 8956 return v, errors.New("OldCoinTypeID requires an ID field in the mutation") 8957 } 8958 oldValue, err := m.oldValue(ctx) 8959 if err != nil { 8960 return v, fmt.Errorf("querying old value for OldCoinTypeID: %w", err) 8961 } 8962 return oldValue.CoinTypeID, nil 8963 } 8964 8965 // ClearCoinTypeID clears the value of the "coin_type_id" field. 8966 func (m *CoinUsedForMutation) ClearCoinTypeID() { 8967 m.coin_type_id = nil 8968 m.clearedFields[coinusedfor.FieldCoinTypeID] = struct{}{} 8969 } 8970 8971 // CoinTypeIDCleared returns if the "coin_type_id" field was cleared in this mutation. 8972 func (m *CoinUsedForMutation) CoinTypeIDCleared() bool { 8973 _, ok := m.clearedFields[coinusedfor.FieldCoinTypeID] 8974 return ok 8975 } 8976 8977 // ResetCoinTypeID resets all changes to the "coin_type_id" field. 8978 func (m *CoinUsedForMutation) ResetCoinTypeID() { 8979 m.coin_type_id = nil 8980 delete(m.clearedFields, coinusedfor.FieldCoinTypeID) 8981 } 8982 8983 // SetUsedFor sets the "used_for" field. 8984 func (m *CoinUsedForMutation) SetUsedFor(s string) { 8985 m.used_for = &s 8986 } 8987 8988 // UsedFor returns the value of the "used_for" field in the mutation. 8989 func (m *CoinUsedForMutation) UsedFor() (r string, exists bool) { 8990 v := m.used_for 8991 if v == nil { 8992 return 8993 } 8994 return *v, true 8995 } 8996 8997 // OldUsedFor returns the old "used_for" field's value of the CoinUsedFor entity. 8998 // If the CoinUsedFor object wasn't provided to the builder, the object is fetched from the database. 8999 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 9000 func (m *CoinUsedForMutation) OldUsedFor(ctx context.Context) (v string, err error) { 9001 if !m.op.Is(OpUpdateOne) { 9002 return v, errors.New("OldUsedFor is only allowed on UpdateOne operations") 9003 } 9004 if m.id == nil || m.oldValue == nil { 9005 return v, errors.New("OldUsedFor requires an ID field in the mutation") 9006 } 9007 oldValue, err := m.oldValue(ctx) 9008 if err != nil { 9009 return v, fmt.Errorf("querying old value for OldUsedFor: %w", err) 9010 } 9011 return oldValue.UsedFor, nil 9012 } 9013 9014 // ClearUsedFor clears the value of the "used_for" field. 9015 func (m *CoinUsedForMutation) ClearUsedFor() { 9016 m.used_for = nil 9017 m.clearedFields[coinusedfor.FieldUsedFor] = struct{}{} 9018 } 9019 9020 // UsedForCleared returns if the "used_for" field was cleared in this mutation. 9021 func (m *CoinUsedForMutation) UsedForCleared() bool { 9022 _, ok := m.clearedFields[coinusedfor.FieldUsedFor] 9023 return ok 9024 } 9025 9026 // ResetUsedFor resets all changes to the "used_for" field. 9027 func (m *CoinUsedForMutation) ResetUsedFor() { 9028 m.used_for = nil 9029 delete(m.clearedFields, coinusedfor.FieldUsedFor) 9030 } 9031 9032 // SetPriority sets the "priority" field. 9033 func (m *CoinUsedForMutation) SetPriority(u uint32) { 9034 m.priority = &u 9035 m.addpriority = nil 9036 } 9037 9038 // Priority returns the value of the "priority" field in the mutation. 9039 func (m *CoinUsedForMutation) Priority() (r uint32, exists bool) { 9040 v := m.priority 9041 if v == nil { 9042 return 9043 } 9044 return *v, true 9045 } 9046 9047 // OldPriority returns the old "priority" field's value of the CoinUsedFor entity. 9048 // If the CoinUsedFor object wasn't provided to the builder, the object is fetched from the database. 9049 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 9050 func (m *CoinUsedForMutation) OldPriority(ctx context.Context) (v uint32, err error) { 9051 if !m.op.Is(OpUpdateOne) { 9052 return v, errors.New("OldPriority is only allowed on UpdateOne operations") 9053 } 9054 if m.id == nil || m.oldValue == nil { 9055 return v, errors.New("OldPriority requires an ID field in the mutation") 9056 } 9057 oldValue, err := m.oldValue(ctx) 9058 if err != nil { 9059 return v, fmt.Errorf("querying old value for OldPriority: %w", err) 9060 } 9061 return oldValue.Priority, nil 9062 } 9063 9064 // AddPriority adds u to the "priority" field. 9065 func (m *CoinUsedForMutation) AddPriority(u int32) { 9066 if m.addpriority != nil { 9067 *m.addpriority += u 9068 } else { 9069 m.addpriority = &u 9070 } 9071 } 9072 9073 // AddedPriority returns the value that was added to the "priority" field in this mutation. 9074 func (m *CoinUsedForMutation) AddedPriority() (r int32, exists bool) { 9075 v := m.addpriority 9076 if v == nil { 9077 return 9078 } 9079 return *v, true 9080 } 9081 9082 // ClearPriority clears the value of the "priority" field. 9083 func (m *CoinUsedForMutation) ClearPriority() { 9084 m.priority = nil 9085 m.addpriority = nil 9086 m.clearedFields[coinusedfor.FieldPriority] = struct{}{} 9087 } 9088 9089 // PriorityCleared returns if the "priority" field was cleared in this mutation. 9090 func (m *CoinUsedForMutation) PriorityCleared() bool { 9091 _, ok := m.clearedFields[coinusedfor.FieldPriority] 9092 return ok 9093 } 9094 9095 // ResetPriority resets all changes to the "priority" field. 9096 func (m *CoinUsedForMutation) ResetPriority() { 9097 m.priority = nil 9098 m.addpriority = nil 9099 delete(m.clearedFields, coinusedfor.FieldPriority) 9100 } 9101 9102 // Where appends a list predicates to the CoinUsedForMutation builder. 9103 func (m *CoinUsedForMutation) Where(ps ...predicate.CoinUsedFor) { 9104 m.predicates = append(m.predicates, ps...) 9105 } 9106 9107 // Op returns the operation name. 9108 func (m *CoinUsedForMutation) Op() Op { 9109 return m.op 9110 } 9111 9112 // Type returns the node type of this mutation (CoinUsedFor). 9113 func (m *CoinUsedForMutation) Type() string { 9114 return m.typ 9115 } 9116 9117 // Fields returns all fields that were changed during this mutation. Note that in 9118 // order to get all numeric fields that were incremented/decremented, call 9119 // AddedFields(). 9120 func (m *CoinUsedForMutation) Fields() []string { 9121 fields := make([]string, 0, 7) 9122 if m.created_at != nil { 9123 fields = append(fields, coinusedfor.FieldCreatedAt) 9124 } 9125 if m.updated_at != nil { 9126 fields = append(fields, coinusedfor.FieldUpdatedAt) 9127 } 9128 if m.deleted_at != nil { 9129 fields = append(fields, coinusedfor.FieldDeletedAt) 9130 } 9131 if m.ent_id != nil { 9132 fields = append(fields, coinusedfor.FieldEntID) 9133 } 9134 if m.coin_type_id != nil { 9135 fields = append(fields, coinusedfor.FieldCoinTypeID) 9136 } 9137 if m.used_for != nil { 9138 fields = append(fields, coinusedfor.FieldUsedFor) 9139 } 9140 if m.priority != nil { 9141 fields = append(fields, coinusedfor.FieldPriority) 9142 } 9143 return fields 9144 } 9145 9146 // Field returns the value of a field with the given name. The second boolean 9147 // return value indicates that this field was not set, or was not defined in the 9148 // schema. 9149 func (m *CoinUsedForMutation) Field(name string) (ent.Value, bool) { 9150 switch name { 9151 case coinusedfor.FieldCreatedAt: 9152 return m.CreatedAt() 9153 case coinusedfor.FieldUpdatedAt: 9154 return m.UpdatedAt() 9155 case coinusedfor.FieldDeletedAt: 9156 return m.DeletedAt() 9157 case coinusedfor.FieldEntID: 9158 return m.EntID() 9159 case coinusedfor.FieldCoinTypeID: 9160 return m.CoinTypeID() 9161 case coinusedfor.FieldUsedFor: 9162 return m.UsedFor() 9163 case coinusedfor.FieldPriority: 9164 return m.Priority() 9165 } 9166 return nil, false 9167 } 9168 9169 // OldField returns the old value of the field from the database. An error is 9170 // returned if the mutation operation is not UpdateOne, or the query to the 9171 // database failed. 9172 func (m *CoinUsedForMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 9173 switch name { 9174 case coinusedfor.FieldCreatedAt: 9175 return m.OldCreatedAt(ctx) 9176 case coinusedfor.FieldUpdatedAt: 9177 return m.OldUpdatedAt(ctx) 9178 case coinusedfor.FieldDeletedAt: 9179 return m.OldDeletedAt(ctx) 9180 case coinusedfor.FieldEntID: 9181 return m.OldEntID(ctx) 9182 case coinusedfor.FieldCoinTypeID: 9183 return m.OldCoinTypeID(ctx) 9184 case coinusedfor.FieldUsedFor: 9185 return m.OldUsedFor(ctx) 9186 case coinusedfor.FieldPriority: 9187 return m.OldPriority(ctx) 9188 } 9189 return nil, fmt.Errorf("unknown CoinUsedFor field %s", name) 9190 } 9191 9192 // SetField sets the value of a field with the given name. It returns an error if 9193 // the field is not defined in the schema, or if the type mismatched the field 9194 // type. 9195 func (m *CoinUsedForMutation) SetField(name string, value ent.Value) error { 9196 switch name { 9197 case coinusedfor.FieldCreatedAt: 9198 v, ok := value.(uint32) 9199 if !ok { 9200 return fmt.Errorf("unexpected type %T for field %s", value, name) 9201 } 9202 m.SetCreatedAt(v) 9203 return nil 9204 case coinusedfor.FieldUpdatedAt: 9205 v, ok := value.(uint32) 9206 if !ok { 9207 return fmt.Errorf("unexpected type %T for field %s", value, name) 9208 } 9209 m.SetUpdatedAt(v) 9210 return nil 9211 case coinusedfor.FieldDeletedAt: 9212 v, ok := value.(uint32) 9213 if !ok { 9214 return fmt.Errorf("unexpected type %T for field %s", value, name) 9215 } 9216 m.SetDeletedAt(v) 9217 return nil 9218 case coinusedfor.FieldEntID: 9219 v, ok := value.(uuid.UUID) 9220 if !ok { 9221 return fmt.Errorf("unexpected type %T for field %s", value, name) 9222 } 9223 m.SetEntID(v) 9224 return nil 9225 case coinusedfor.FieldCoinTypeID: 9226 v, ok := value.(uuid.UUID) 9227 if !ok { 9228 return fmt.Errorf("unexpected type %T for field %s", value, name) 9229 } 9230 m.SetCoinTypeID(v) 9231 return nil 9232 case coinusedfor.FieldUsedFor: 9233 v, ok := value.(string) 9234 if !ok { 9235 return fmt.Errorf("unexpected type %T for field %s", value, name) 9236 } 9237 m.SetUsedFor(v) 9238 return nil 9239 case coinusedfor.FieldPriority: 9240 v, ok := value.(uint32) 9241 if !ok { 9242 return fmt.Errorf("unexpected type %T for field %s", value, name) 9243 } 9244 m.SetPriority(v) 9245 return nil 9246 } 9247 return fmt.Errorf("unknown CoinUsedFor field %s", name) 9248 } 9249 9250 // AddedFields returns all numeric fields that were incremented/decremented during 9251 // this mutation. 9252 func (m *CoinUsedForMutation) AddedFields() []string { 9253 var fields []string 9254 if m.addcreated_at != nil { 9255 fields = append(fields, coinusedfor.FieldCreatedAt) 9256 } 9257 if m.addupdated_at != nil { 9258 fields = append(fields, coinusedfor.FieldUpdatedAt) 9259 } 9260 if m.adddeleted_at != nil { 9261 fields = append(fields, coinusedfor.FieldDeletedAt) 9262 } 9263 if m.addpriority != nil { 9264 fields = append(fields, coinusedfor.FieldPriority) 9265 } 9266 return fields 9267 } 9268 9269 // AddedField returns the numeric value that was incremented/decremented on a field 9270 // with the given name. The second boolean return value indicates that this field 9271 // was not set, or was not defined in the schema. 9272 func (m *CoinUsedForMutation) AddedField(name string) (ent.Value, bool) { 9273 switch name { 9274 case coinusedfor.FieldCreatedAt: 9275 return m.AddedCreatedAt() 9276 case coinusedfor.FieldUpdatedAt: 9277 return m.AddedUpdatedAt() 9278 case coinusedfor.FieldDeletedAt: 9279 return m.AddedDeletedAt() 9280 case coinusedfor.FieldPriority: 9281 return m.AddedPriority() 9282 } 9283 return nil, false 9284 } 9285 9286 // AddField adds the value to the field with the given name. It returns an error if 9287 // the field is not defined in the schema, or if the type mismatched the field 9288 // type. 9289 func (m *CoinUsedForMutation) AddField(name string, value ent.Value) error { 9290 switch name { 9291 case coinusedfor.FieldCreatedAt: 9292 v, ok := value.(int32) 9293 if !ok { 9294 return fmt.Errorf("unexpected type %T for field %s", value, name) 9295 } 9296 m.AddCreatedAt(v) 9297 return nil 9298 case coinusedfor.FieldUpdatedAt: 9299 v, ok := value.(int32) 9300 if !ok { 9301 return fmt.Errorf("unexpected type %T for field %s", value, name) 9302 } 9303 m.AddUpdatedAt(v) 9304 return nil 9305 case coinusedfor.FieldDeletedAt: 9306 v, ok := value.(int32) 9307 if !ok { 9308 return fmt.Errorf("unexpected type %T for field %s", value, name) 9309 } 9310 m.AddDeletedAt(v) 9311 return nil 9312 case coinusedfor.FieldPriority: 9313 v, ok := value.(int32) 9314 if !ok { 9315 return fmt.Errorf("unexpected type %T for field %s", value, name) 9316 } 9317 m.AddPriority(v) 9318 return nil 9319 } 9320 return fmt.Errorf("unknown CoinUsedFor numeric field %s", name) 9321 } 9322 9323 // ClearedFields returns all nullable fields that were cleared during this 9324 // mutation. 9325 func (m *CoinUsedForMutation) ClearedFields() []string { 9326 var fields []string 9327 if m.FieldCleared(coinusedfor.FieldCoinTypeID) { 9328 fields = append(fields, coinusedfor.FieldCoinTypeID) 9329 } 9330 if m.FieldCleared(coinusedfor.FieldUsedFor) { 9331 fields = append(fields, coinusedfor.FieldUsedFor) 9332 } 9333 if m.FieldCleared(coinusedfor.FieldPriority) { 9334 fields = append(fields, coinusedfor.FieldPriority) 9335 } 9336 return fields 9337 } 9338 9339 // FieldCleared returns a boolean indicating if a field with the given name was 9340 // cleared in this mutation. 9341 func (m *CoinUsedForMutation) FieldCleared(name string) bool { 9342 _, ok := m.clearedFields[name] 9343 return ok 9344 } 9345 9346 // ClearField clears the value of the field with the given name. It returns an 9347 // error if the field is not defined in the schema. 9348 func (m *CoinUsedForMutation) ClearField(name string) error { 9349 switch name { 9350 case coinusedfor.FieldCoinTypeID: 9351 m.ClearCoinTypeID() 9352 return nil 9353 case coinusedfor.FieldUsedFor: 9354 m.ClearUsedFor() 9355 return nil 9356 case coinusedfor.FieldPriority: 9357 m.ClearPriority() 9358 return nil 9359 } 9360 return fmt.Errorf("unknown CoinUsedFor nullable field %s", name) 9361 } 9362 9363 // ResetField resets all changes in the mutation for the field with the given name. 9364 // It returns an error if the field is not defined in the schema. 9365 func (m *CoinUsedForMutation) ResetField(name string) error { 9366 switch name { 9367 case coinusedfor.FieldCreatedAt: 9368 m.ResetCreatedAt() 9369 return nil 9370 case coinusedfor.FieldUpdatedAt: 9371 m.ResetUpdatedAt() 9372 return nil 9373 case coinusedfor.FieldDeletedAt: 9374 m.ResetDeletedAt() 9375 return nil 9376 case coinusedfor.FieldEntID: 9377 m.ResetEntID() 9378 return nil 9379 case coinusedfor.FieldCoinTypeID: 9380 m.ResetCoinTypeID() 9381 return nil 9382 case coinusedfor.FieldUsedFor: 9383 m.ResetUsedFor() 9384 return nil 9385 case coinusedfor.FieldPriority: 9386 m.ResetPriority() 9387 return nil 9388 } 9389 return fmt.Errorf("unknown CoinUsedFor field %s", name) 9390 } 9391 9392 // AddedEdges returns all edge names that were set/added in this mutation. 9393 func (m *CoinUsedForMutation) AddedEdges() []string { 9394 edges := make([]string, 0, 0) 9395 return edges 9396 } 9397 9398 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 9399 // name in this mutation. 9400 func (m *CoinUsedForMutation) AddedIDs(name string) []ent.Value { 9401 return nil 9402 } 9403 9404 // RemovedEdges returns all edge names that were removed in this mutation. 9405 func (m *CoinUsedForMutation) RemovedEdges() []string { 9406 edges := make([]string, 0, 0) 9407 return edges 9408 } 9409 9410 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 9411 // the given name in this mutation. 9412 func (m *CoinUsedForMutation) RemovedIDs(name string) []ent.Value { 9413 return nil 9414 } 9415 9416 // ClearedEdges returns all edge names that were cleared in this mutation. 9417 func (m *CoinUsedForMutation) ClearedEdges() []string { 9418 edges := make([]string, 0, 0) 9419 return edges 9420 } 9421 9422 // EdgeCleared returns a boolean which indicates if the edge with the given name 9423 // was cleared in this mutation. 9424 func (m *CoinUsedForMutation) EdgeCleared(name string) bool { 9425 return false 9426 } 9427 9428 // ClearEdge clears the value of the edge with the given name. It returns an error 9429 // if that edge is not defined in the schema. 9430 func (m *CoinUsedForMutation) ClearEdge(name string) error { 9431 return fmt.Errorf("unknown CoinUsedFor unique edge %s", name) 9432 } 9433 9434 // ResetEdge resets all changes to the edge with the given name in this mutation. 9435 // It returns an error if the edge is not defined in the schema. 9436 func (m *CoinUsedForMutation) ResetEdge(name string) error { 9437 return fmt.Errorf("unknown CoinUsedFor edge %s", name) 9438 } 9439 9440 // CurrencyMutation represents an operation that mutates the Currency nodes in the graph. 9441 type CurrencyMutation struct { 9442 config 9443 op Op 9444 typ string 9445 id *uint32 9446 created_at *uint32 9447 addcreated_at *int32 9448 updated_at *uint32 9449 addupdated_at *int32 9450 deleted_at *uint32 9451 adddeleted_at *int32 9452 ent_id *uuid.UUID 9453 coin_type_id *uuid.UUID 9454 feed_type *string 9455 market_value_high *decimal.Decimal 9456 market_value_low *decimal.Decimal 9457 clearedFields map[string]struct{} 9458 done bool 9459 oldValue func(context.Context) (*Currency, error) 9460 predicates []predicate.Currency 9461 } 9462 9463 var _ ent.Mutation = (*CurrencyMutation)(nil) 9464 9465 // currencyOption allows management of the mutation configuration using functional options. 9466 type currencyOption func(*CurrencyMutation) 9467 9468 // newCurrencyMutation creates new mutation for the Currency entity. 9469 func newCurrencyMutation(c config, op Op, opts ...currencyOption) *CurrencyMutation { 9470 m := &CurrencyMutation{ 9471 config: c, 9472 op: op, 9473 typ: TypeCurrency, 9474 clearedFields: make(map[string]struct{}), 9475 } 9476 for _, opt := range opts { 9477 opt(m) 9478 } 9479 return m 9480 } 9481 9482 // withCurrencyID sets the ID field of the mutation. 9483 func withCurrencyID(id uint32) currencyOption { 9484 return func(m *CurrencyMutation) { 9485 var ( 9486 err error 9487 once sync.Once 9488 value *Currency 9489 ) 9490 m.oldValue = func(ctx context.Context) (*Currency, error) { 9491 once.Do(func() { 9492 if m.done { 9493 err = errors.New("querying old values post mutation is not allowed") 9494 } else { 9495 value, err = m.Client().Currency.Get(ctx, id) 9496 } 9497 }) 9498 return value, err 9499 } 9500 m.id = &id 9501 } 9502 } 9503 9504 // withCurrency sets the old Currency of the mutation. 9505 func withCurrency(node *Currency) currencyOption { 9506 return func(m *CurrencyMutation) { 9507 m.oldValue = func(context.Context) (*Currency, error) { 9508 return node, nil 9509 } 9510 m.id = &node.ID 9511 } 9512 } 9513 9514 // Client returns a new `ent.Client` from the mutation. If the mutation was 9515 // executed in a transaction (ent.Tx), a transactional client is returned. 9516 func (m CurrencyMutation) Client() *Client { 9517 client := &Client{config: m.config} 9518 client.init() 9519 return client 9520 } 9521 9522 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 9523 // it returns an error otherwise. 9524 func (m CurrencyMutation) Tx() (*Tx, error) { 9525 if _, ok := m.driver.(*txDriver); !ok { 9526 return nil, errors.New("ent: mutation is not running in a transaction") 9527 } 9528 tx := &Tx{config: m.config} 9529 tx.init() 9530 return tx, nil 9531 } 9532 9533 // SetID sets the value of the id field. Note that this 9534 // operation is only accepted on creation of Currency entities. 9535 func (m *CurrencyMutation) SetID(id uint32) { 9536 m.id = &id 9537 } 9538 9539 // ID returns the ID value in the mutation. Note that the ID is only available 9540 // if it was provided to the builder or after it was returned from the database. 9541 func (m *CurrencyMutation) ID() (id uint32, exists bool) { 9542 if m.id == nil { 9543 return 9544 } 9545 return *m.id, true 9546 } 9547 9548 // IDs queries the database and returns the entity ids that match the mutation's predicate. 9549 // That means, if the mutation is applied within a transaction with an isolation level such 9550 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 9551 // or updated by the mutation. 9552 func (m *CurrencyMutation) IDs(ctx context.Context) ([]uint32, error) { 9553 switch { 9554 case m.op.Is(OpUpdateOne | OpDeleteOne): 9555 id, exists := m.ID() 9556 if exists { 9557 return []uint32{id}, nil 9558 } 9559 fallthrough 9560 case m.op.Is(OpUpdate | OpDelete): 9561 return m.Client().Currency.Query().Where(m.predicates...).IDs(ctx) 9562 default: 9563 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 9564 } 9565 } 9566 9567 // SetCreatedAt sets the "created_at" field. 9568 func (m *CurrencyMutation) SetCreatedAt(u uint32) { 9569 m.created_at = &u 9570 m.addcreated_at = nil 9571 } 9572 9573 // CreatedAt returns the value of the "created_at" field in the mutation. 9574 func (m *CurrencyMutation) CreatedAt() (r uint32, exists bool) { 9575 v := m.created_at 9576 if v == nil { 9577 return 9578 } 9579 return *v, true 9580 } 9581 9582 // OldCreatedAt returns the old "created_at" field's value of the Currency entity. 9583 // If the Currency object wasn't provided to the builder, the object is fetched from the database. 9584 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 9585 func (m *CurrencyMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 9586 if !m.op.Is(OpUpdateOne) { 9587 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 9588 } 9589 if m.id == nil || m.oldValue == nil { 9590 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 9591 } 9592 oldValue, err := m.oldValue(ctx) 9593 if err != nil { 9594 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 9595 } 9596 return oldValue.CreatedAt, nil 9597 } 9598 9599 // AddCreatedAt adds u to the "created_at" field. 9600 func (m *CurrencyMutation) AddCreatedAt(u int32) { 9601 if m.addcreated_at != nil { 9602 *m.addcreated_at += u 9603 } else { 9604 m.addcreated_at = &u 9605 } 9606 } 9607 9608 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 9609 func (m *CurrencyMutation) AddedCreatedAt() (r int32, exists bool) { 9610 v := m.addcreated_at 9611 if v == nil { 9612 return 9613 } 9614 return *v, true 9615 } 9616 9617 // ResetCreatedAt resets all changes to the "created_at" field. 9618 func (m *CurrencyMutation) ResetCreatedAt() { 9619 m.created_at = nil 9620 m.addcreated_at = nil 9621 } 9622 9623 // SetUpdatedAt sets the "updated_at" field. 9624 func (m *CurrencyMutation) SetUpdatedAt(u uint32) { 9625 m.updated_at = &u 9626 m.addupdated_at = nil 9627 } 9628 9629 // UpdatedAt returns the value of the "updated_at" field in the mutation. 9630 func (m *CurrencyMutation) UpdatedAt() (r uint32, exists bool) { 9631 v := m.updated_at 9632 if v == nil { 9633 return 9634 } 9635 return *v, true 9636 } 9637 9638 // OldUpdatedAt returns the old "updated_at" field's value of the Currency entity. 9639 // If the Currency object wasn't provided to the builder, the object is fetched from the database. 9640 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 9641 func (m *CurrencyMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 9642 if !m.op.Is(OpUpdateOne) { 9643 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 9644 } 9645 if m.id == nil || m.oldValue == nil { 9646 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 9647 } 9648 oldValue, err := m.oldValue(ctx) 9649 if err != nil { 9650 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 9651 } 9652 return oldValue.UpdatedAt, nil 9653 } 9654 9655 // AddUpdatedAt adds u to the "updated_at" field. 9656 func (m *CurrencyMutation) AddUpdatedAt(u int32) { 9657 if m.addupdated_at != nil { 9658 *m.addupdated_at += u 9659 } else { 9660 m.addupdated_at = &u 9661 } 9662 } 9663 9664 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 9665 func (m *CurrencyMutation) AddedUpdatedAt() (r int32, exists bool) { 9666 v := m.addupdated_at 9667 if v == nil { 9668 return 9669 } 9670 return *v, true 9671 } 9672 9673 // ResetUpdatedAt resets all changes to the "updated_at" field. 9674 func (m *CurrencyMutation) ResetUpdatedAt() { 9675 m.updated_at = nil 9676 m.addupdated_at = nil 9677 } 9678 9679 // SetDeletedAt sets the "deleted_at" field. 9680 func (m *CurrencyMutation) SetDeletedAt(u uint32) { 9681 m.deleted_at = &u 9682 m.adddeleted_at = nil 9683 } 9684 9685 // DeletedAt returns the value of the "deleted_at" field in the mutation. 9686 func (m *CurrencyMutation) DeletedAt() (r uint32, exists bool) { 9687 v := m.deleted_at 9688 if v == nil { 9689 return 9690 } 9691 return *v, true 9692 } 9693 9694 // OldDeletedAt returns the old "deleted_at" field's value of the Currency entity. 9695 // If the Currency object wasn't provided to the builder, the object is fetched from the database. 9696 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 9697 func (m *CurrencyMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 9698 if !m.op.Is(OpUpdateOne) { 9699 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 9700 } 9701 if m.id == nil || m.oldValue == nil { 9702 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 9703 } 9704 oldValue, err := m.oldValue(ctx) 9705 if err != nil { 9706 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 9707 } 9708 return oldValue.DeletedAt, nil 9709 } 9710 9711 // AddDeletedAt adds u to the "deleted_at" field. 9712 func (m *CurrencyMutation) AddDeletedAt(u int32) { 9713 if m.adddeleted_at != nil { 9714 *m.adddeleted_at += u 9715 } else { 9716 m.adddeleted_at = &u 9717 } 9718 } 9719 9720 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 9721 func (m *CurrencyMutation) AddedDeletedAt() (r int32, exists bool) { 9722 v := m.adddeleted_at 9723 if v == nil { 9724 return 9725 } 9726 return *v, true 9727 } 9728 9729 // ResetDeletedAt resets all changes to the "deleted_at" field. 9730 func (m *CurrencyMutation) ResetDeletedAt() { 9731 m.deleted_at = nil 9732 m.adddeleted_at = nil 9733 } 9734 9735 // SetEntID sets the "ent_id" field. 9736 func (m *CurrencyMutation) SetEntID(u uuid.UUID) { 9737 m.ent_id = &u 9738 } 9739 9740 // EntID returns the value of the "ent_id" field in the mutation. 9741 func (m *CurrencyMutation) EntID() (r uuid.UUID, exists bool) { 9742 v := m.ent_id 9743 if v == nil { 9744 return 9745 } 9746 return *v, true 9747 } 9748 9749 // OldEntID returns the old "ent_id" field's value of the Currency entity. 9750 // If the Currency object wasn't provided to the builder, the object is fetched from the database. 9751 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 9752 func (m *CurrencyMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 9753 if !m.op.Is(OpUpdateOne) { 9754 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 9755 } 9756 if m.id == nil || m.oldValue == nil { 9757 return v, errors.New("OldEntID requires an ID field in the mutation") 9758 } 9759 oldValue, err := m.oldValue(ctx) 9760 if err != nil { 9761 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 9762 } 9763 return oldValue.EntID, nil 9764 } 9765 9766 // ResetEntID resets all changes to the "ent_id" field. 9767 func (m *CurrencyMutation) ResetEntID() { 9768 m.ent_id = nil 9769 } 9770 9771 // SetCoinTypeID sets the "coin_type_id" field. 9772 func (m *CurrencyMutation) SetCoinTypeID(u uuid.UUID) { 9773 m.coin_type_id = &u 9774 } 9775 9776 // CoinTypeID returns the value of the "coin_type_id" field in the mutation. 9777 func (m *CurrencyMutation) CoinTypeID() (r uuid.UUID, exists bool) { 9778 v := m.coin_type_id 9779 if v == nil { 9780 return 9781 } 9782 return *v, true 9783 } 9784 9785 // OldCoinTypeID returns the old "coin_type_id" field's value of the Currency entity. 9786 // If the Currency object wasn't provided to the builder, the object is fetched from the database. 9787 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 9788 func (m *CurrencyMutation) OldCoinTypeID(ctx context.Context) (v uuid.UUID, err error) { 9789 if !m.op.Is(OpUpdateOne) { 9790 return v, errors.New("OldCoinTypeID is only allowed on UpdateOne operations") 9791 } 9792 if m.id == nil || m.oldValue == nil { 9793 return v, errors.New("OldCoinTypeID requires an ID field in the mutation") 9794 } 9795 oldValue, err := m.oldValue(ctx) 9796 if err != nil { 9797 return v, fmt.Errorf("querying old value for OldCoinTypeID: %w", err) 9798 } 9799 return oldValue.CoinTypeID, nil 9800 } 9801 9802 // ClearCoinTypeID clears the value of the "coin_type_id" field. 9803 func (m *CurrencyMutation) ClearCoinTypeID() { 9804 m.coin_type_id = nil 9805 m.clearedFields[currency.FieldCoinTypeID] = struct{}{} 9806 } 9807 9808 // CoinTypeIDCleared returns if the "coin_type_id" field was cleared in this mutation. 9809 func (m *CurrencyMutation) CoinTypeIDCleared() bool { 9810 _, ok := m.clearedFields[currency.FieldCoinTypeID] 9811 return ok 9812 } 9813 9814 // ResetCoinTypeID resets all changes to the "coin_type_id" field. 9815 func (m *CurrencyMutation) ResetCoinTypeID() { 9816 m.coin_type_id = nil 9817 delete(m.clearedFields, currency.FieldCoinTypeID) 9818 } 9819 9820 // SetFeedType sets the "feed_type" field. 9821 func (m *CurrencyMutation) SetFeedType(s string) { 9822 m.feed_type = &s 9823 } 9824 9825 // FeedType returns the value of the "feed_type" field in the mutation. 9826 func (m *CurrencyMutation) FeedType() (r string, exists bool) { 9827 v := m.feed_type 9828 if v == nil { 9829 return 9830 } 9831 return *v, true 9832 } 9833 9834 // OldFeedType returns the old "feed_type" field's value of the Currency entity. 9835 // If the Currency object wasn't provided to the builder, the object is fetched from the database. 9836 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 9837 func (m *CurrencyMutation) OldFeedType(ctx context.Context) (v string, err error) { 9838 if !m.op.Is(OpUpdateOne) { 9839 return v, errors.New("OldFeedType is only allowed on UpdateOne operations") 9840 } 9841 if m.id == nil || m.oldValue == nil { 9842 return v, errors.New("OldFeedType requires an ID field in the mutation") 9843 } 9844 oldValue, err := m.oldValue(ctx) 9845 if err != nil { 9846 return v, fmt.Errorf("querying old value for OldFeedType: %w", err) 9847 } 9848 return oldValue.FeedType, nil 9849 } 9850 9851 // ClearFeedType clears the value of the "feed_type" field. 9852 func (m *CurrencyMutation) ClearFeedType() { 9853 m.feed_type = nil 9854 m.clearedFields[currency.FieldFeedType] = struct{}{} 9855 } 9856 9857 // FeedTypeCleared returns if the "feed_type" field was cleared in this mutation. 9858 func (m *CurrencyMutation) FeedTypeCleared() bool { 9859 _, ok := m.clearedFields[currency.FieldFeedType] 9860 return ok 9861 } 9862 9863 // ResetFeedType resets all changes to the "feed_type" field. 9864 func (m *CurrencyMutation) ResetFeedType() { 9865 m.feed_type = nil 9866 delete(m.clearedFields, currency.FieldFeedType) 9867 } 9868 9869 // SetMarketValueHigh sets the "market_value_high" field. 9870 func (m *CurrencyMutation) SetMarketValueHigh(d decimal.Decimal) { 9871 m.market_value_high = &d 9872 } 9873 9874 // MarketValueHigh returns the value of the "market_value_high" field in the mutation. 9875 func (m *CurrencyMutation) MarketValueHigh() (r decimal.Decimal, exists bool) { 9876 v := m.market_value_high 9877 if v == nil { 9878 return 9879 } 9880 return *v, true 9881 } 9882 9883 // OldMarketValueHigh returns the old "market_value_high" field's value of the Currency entity. 9884 // If the Currency object wasn't provided to the builder, the object is fetched from the database. 9885 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 9886 func (m *CurrencyMutation) OldMarketValueHigh(ctx context.Context) (v decimal.Decimal, err error) { 9887 if !m.op.Is(OpUpdateOne) { 9888 return v, errors.New("OldMarketValueHigh is only allowed on UpdateOne operations") 9889 } 9890 if m.id == nil || m.oldValue == nil { 9891 return v, errors.New("OldMarketValueHigh requires an ID field in the mutation") 9892 } 9893 oldValue, err := m.oldValue(ctx) 9894 if err != nil { 9895 return v, fmt.Errorf("querying old value for OldMarketValueHigh: %w", err) 9896 } 9897 return oldValue.MarketValueHigh, nil 9898 } 9899 9900 // ClearMarketValueHigh clears the value of the "market_value_high" field. 9901 func (m *CurrencyMutation) ClearMarketValueHigh() { 9902 m.market_value_high = nil 9903 m.clearedFields[currency.FieldMarketValueHigh] = struct{}{} 9904 } 9905 9906 // MarketValueHighCleared returns if the "market_value_high" field was cleared in this mutation. 9907 func (m *CurrencyMutation) MarketValueHighCleared() bool { 9908 _, ok := m.clearedFields[currency.FieldMarketValueHigh] 9909 return ok 9910 } 9911 9912 // ResetMarketValueHigh resets all changes to the "market_value_high" field. 9913 func (m *CurrencyMutation) ResetMarketValueHigh() { 9914 m.market_value_high = nil 9915 delete(m.clearedFields, currency.FieldMarketValueHigh) 9916 } 9917 9918 // SetMarketValueLow sets the "market_value_low" field. 9919 func (m *CurrencyMutation) SetMarketValueLow(d decimal.Decimal) { 9920 m.market_value_low = &d 9921 } 9922 9923 // MarketValueLow returns the value of the "market_value_low" field in the mutation. 9924 func (m *CurrencyMutation) MarketValueLow() (r decimal.Decimal, exists bool) { 9925 v := m.market_value_low 9926 if v == nil { 9927 return 9928 } 9929 return *v, true 9930 } 9931 9932 // OldMarketValueLow returns the old "market_value_low" field's value of the Currency entity. 9933 // If the Currency object wasn't provided to the builder, the object is fetched from the database. 9934 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 9935 func (m *CurrencyMutation) OldMarketValueLow(ctx context.Context) (v decimal.Decimal, err error) { 9936 if !m.op.Is(OpUpdateOne) { 9937 return v, errors.New("OldMarketValueLow is only allowed on UpdateOne operations") 9938 } 9939 if m.id == nil || m.oldValue == nil { 9940 return v, errors.New("OldMarketValueLow requires an ID field in the mutation") 9941 } 9942 oldValue, err := m.oldValue(ctx) 9943 if err != nil { 9944 return v, fmt.Errorf("querying old value for OldMarketValueLow: %w", err) 9945 } 9946 return oldValue.MarketValueLow, nil 9947 } 9948 9949 // ClearMarketValueLow clears the value of the "market_value_low" field. 9950 func (m *CurrencyMutation) ClearMarketValueLow() { 9951 m.market_value_low = nil 9952 m.clearedFields[currency.FieldMarketValueLow] = struct{}{} 9953 } 9954 9955 // MarketValueLowCleared returns if the "market_value_low" field was cleared in this mutation. 9956 func (m *CurrencyMutation) MarketValueLowCleared() bool { 9957 _, ok := m.clearedFields[currency.FieldMarketValueLow] 9958 return ok 9959 } 9960 9961 // ResetMarketValueLow resets all changes to the "market_value_low" field. 9962 func (m *CurrencyMutation) ResetMarketValueLow() { 9963 m.market_value_low = nil 9964 delete(m.clearedFields, currency.FieldMarketValueLow) 9965 } 9966 9967 // Where appends a list predicates to the CurrencyMutation builder. 9968 func (m *CurrencyMutation) Where(ps ...predicate.Currency) { 9969 m.predicates = append(m.predicates, ps...) 9970 } 9971 9972 // Op returns the operation name. 9973 func (m *CurrencyMutation) Op() Op { 9974 return m.op 9975 } 9976 9977 // Type returns the node type of this mutation (Currency). 9978 func (m *CurrencyMutation) Type() string { 9979 return m.typ 9980 } 9981 9982 // Fields returns all fields that were changed during this mutation. Note that in 9983 // order to get all numeric fields that were incremented/decremented, call 9984 // AddedFields(). 9985 func (m *CurrencyMutation) Fields() []string { 9986 fields := make([]string, 0, 8) 9987 if m.created_at != nil { 9988 fields = append(fields, currency.FieldCreatedAt) 9989 } 9990 if m.updated_at != nil { 9991 fields = append(fields, currency.FieldUpdatedAt) 9992 } 9993 if m.deleted_at != nil { 9994 fields = append(fields, currency.FieldDeletedAt) 9995 } 9996 if m.ent_id != nil { 9997 fields = append(fields, currency.FieldEntID) 9998 } 9999 if m.coin_type_id != nil { 10000 fields = append(fields, currency.FieldCoinTypeID) 10001 } 10002 if m.feed_type != nil { 10003 fields = append(fields, currency.FieldFeedType) 10004 } 10005 if m.market_value_high != nil { 10006 fields = append(fields, currency.FieldMarketValueHigh) 10007 } 10008 if m.market_value_low != nil { 10009 fields = append(fields, currency.FieldMarketValueLow) 10010 } 10011 return fields 10012 } 10013 10014 // Field returns the value of a field with the given name. The second boolean 10015 // return value indicates that this field was not set, or was not defined in the 10016 // schema. 10017 func (m *CurrencyMutation) Field(name string) (ent.Value, bool) { 10018 switch name { 10019 case currency.FieldCreatedAt: 10020 return m.CreatedAt() 10021 case currency.FieldUpdatedAt: 10022 return m.UpdatedAt() 10023 case currency.FieldDeletedAt: 10024 return m.DeletedAt() 10025 case currency.FieldEntID: 10026 return m.EntID() 10027 case currency.FieldCoinTypeID: 10028 return m.CoinTypeID() 10029 case currency.FieldFeedType: 10030 return m.FeedType() 10031 case currency.FieldMarketValueHigh: 10032 return m.MarketValueHigh() 10033 case currency.FieldMarketValueLow: 10034 return m.MarketValueLow() 10035 } 10036 return nil, false 10037 } 10038 10039 // OldField returns the old value of the field from the database. An error is 10040 // returned if the mutation operation is not UpdateOne, or the query to the 10041 // database failed. 10042 func (m *CurrencyMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 10043 switch name { 10044 case currency.FieldCreatedAt: 10045 return m.OldCreatedAt(ctx) 10046 case currency.FieldUpdatedAt: 10047 return m.OldUpdatedAt(ctx) 10048 case currency.FieldDeletedAt: 10049 return m.OldDeletedAt(ctx) 10050 case currency.FieldEntID: 10051 return m.OldEntID(ctx) 10052 case currency.FieldCoinTypeID: 10053 return m.OldCoinTypeID(ctx) 10054 case currency.FieldFeedType: 10055 return m.OldFeedType(ctx) 10056 case currency.FieldMarketValueHigh: 10057 return m.OldMarketValueHigh(ctx) 10058 case currency.FieldMarketValueLow: 10059 return m.OldMarketValueLow(ctx) 10060 } 10061 return nil, fmt.Errorf("unknown Currency field %s", name) 10062 } 10063 10064 // SetField sets the value of a field with the given name. It returns an error if 10065 // the field is not defined in the schema, or if the type mismatched the field 10066 // type. 10067 func (m *CurrencyMutation) SetField(name string, value ent.Value) error { 10068 switch name { 10069 case currency.FieldCreatedAt: 10070 v, ok := value.(uint32) 10071 if !ok { 10072 return fmt.Errorf("unexpected type %T for field %s", value, name) 10073 } 10074 m.SetCreatedAt(v) 10075 return nil 10076 case currency.FieldUpdatedAt: 10077 v, ok := value.(uint32) 10078 if !ok { 10079 return fmt.Errorf("unexpected type %T for field %s", value, name) 10080 } 10081 m.SetUpdatedAt(v) 10082 return nil 10083 case currency.FieldDeletedAt: 10084 v, ok := value.(uint32) 10085 if !ok { 10086 return fmt.Errorf("unexpected type %T for field %s", value, name) 10087 } 10088 m.SetDeletedAt(v) 10089 return nil 10090 case currency.FieldEntID: 10091 v, ok := value.(uuid.UUID) 10092 if !ok { 10093 return fmt.Errorf("unexpected type %T for field %s", value, name) 10094 } 10095 m.SetEntID(v) 10096 return nil 10097 case currency.FieldCoinTypeID: 10098 v, ok := value.(uuid.UUID) 10099 if !ok { 10100 return fmt.Errorf("unexpected type %T for field %s", value, name) 10101 } 10102 m.SetCoinTypeID(v) 10103 return nil 10104 case currency.FieldFeedType: 10105 v, ok := value.(string) 10106 if !ok { 10107 return fmt.Errorf("unexpected type %T for field %s", value, name) 10108 } 10109 m.SetFeedType(v) 10110 return nil 10111 case currency.FieldMarketValueHigh: 10112 v, ok := value.(decimal.Decimal) 10113 if !ok { 10114 return fmt.Errorf("unexpected type %T for field %s", value, name) 10115 } 10116 m.SetMarketValueHigh(v) 10117 return nil 10118 case currency.FieldMarketValueLow: 10119 v, ok := value.(decimal.Decimal) 10120 if !ok { 10121 return fmt.Errorf("unexpected type %T for field %s", value, name) 10122 } 10123 m.SetMarketValueLow(v) 10124 return nil 10125 } 10126 return fmt.Errorf("unknown Currency field %s", name) 10127 } 10128 10129 // AddedFields returns all numeric fields that were incremented/decremented during 10130 // this mutation. 10131 func (m *CurrencyMutation) AddedFields() []string { 10132 var fields []string 10133 if m.addcreated_at != nil { 10134 fields = append(fields, currency.FieldCreatedAt) 10135 } 10136 if m.addupdated_at != nil { 10137 fields = append(fields, currency.FieldUpdatedAt) 10138 } 10139 if m.adddeleted_at != nil { 10140 fields = append(fields, currency.FieldDeletedAt) 10141 } 10142 return fields 10143 } 10144 10145 // AddedField returns the numeric value that was incremented/decremented on a field 10146 // with the given name. The second boolean return value indicates that this field 10147 // was not set, or was not defined in the schema. 10148 func (m *CurrencyMutation) AddedField(name string) (ent.Value, bool) { 10149 switch name { 10150 case currency.FieldCreatedAt: 10151 return m.AddedCreatedAt() 10152 case currency.FieldUpdatedAt: 10153 return m.AddedUpdatedAt() 10154 case currency.FieldDeletedAt: 10155 return m.AddedDeletedAt() 10156 } 10157 return nil, false 10158 } 10159 10160 // AddField adds the value to the field with the given name. It returns an error if 10161 // the field is not defined in the schema, or if the type mismatched the field 10162 // type. 10163 func (m *CurrencyMutation) AddField(name string, value ent.Value) error { 10164 switch name { 10165 case currency.FieldCreatedAt: 10166 v, ok := value.(int32) 10167 if !ok { 10168 return fmt.Errorf("unexpected type %T for field %s", value, name) 10169 } 10170 m.AddCreatedAt(v) 10171 return nil 10172 case currency.FieldUpdatedAt: 10173 v, ok := value.(int32) 10174 if !ok { 10175 return fmt.Errorf("unexpected type %T for field %s", value, name) 10176 } 10177 m.AddUpdatedAt(v) 10178 return nil 10179 case currency.FieldDeletedAt: 10180 v, ok := value.(int32) 10181 if !ok { 10182 return fmt.Errorf("unexpected type %T for field %s", value, name) 10183 } 10184 m.AddDeletedAt(v) 10185 return nil 10186 } 10187 return fmt.Errorf("unknown Currency numeric field %s", name) 10188 } 10189 10190 // ClearedFields returns all nullable fields that were cleared during this 10191 // mutation. 10192 func (m *CurrencyMutation) ClearedFields() []string { 10193 var fields []string 10194 if m.FieldCleared(currency.FieldCoinTypeID) { 10195 fields = append(fields, currency.FieldCoinTypeID) 10196 } 10197 if m.FieldCleared(currency.FieldFeedType) { 10198 fields = append(fields, currency.FieldFeedType) 10199 } 10200 if m.FieldCleared(currency.FieldMarketValueHigh) { 10201 fields = append(fields, currency.FieldMarketValueHigh) 10202 } 10203 if m.FieldCleared(currency.FieldMarketValueLow) { 10204 fields = append(fields, currency.FieldMarketValueLow) 10205 } 10206 return fields 10207 } 10208 10209 // FieldCleared returns a boolean indicating if a field with the given name was 10210 // cleared in this mutation. 10211 func (m *CurrencyMutation) FieldCleared(name string) bool { 10212 _, ok := m.clearedFields[name] 10213 return ok 10214 } 10215 10216 // ClearField clears the value of the field with the given name. It returns an 10217 // error if the field is not defined in the schema. 10218 func (m *CurrencyMutation) ClearField(name string) error { 10219 switch name { 10220 case currency.FieldCoinTypeID: 10221 m.ClearCoinTypeID() 10222 return nil 10223 case currency.FieldFeedType: 10224 m.ClearFeedType() 10225 return nil 10226 case currency.FieldMarketValueHigh: 10227 m.ClearMarketValueHigh() 10228 return nil 10229 case currency.FieldMarketValueLow: 10230 m.ClearMarketValueLow() 10231 return nil 10232 } 10233 return fmt.Errorf("unknown Currency nullable field %s", name) 10234 } 10235 10236 // ResetField resets all changes in the mutation for the field with the given name. 10237 // It returns an error if the field is not defined in the schema. 10238 func (m *CurrencyMutation) ResetField(name string) error { 10239 switch name { 10240 case currency.FieldCreatedAt: 10241 m.ResetCreatedAt() 10242 return nil 10243 case currency.FieldUpdatedAt: 10244 m.ResetUpdatedAt() 10245 return nil 10246 case currency.FieldDeletedAt: 10247 m.ResetDeletedAt() 10248 return nil 10249 case currency.FieldEntID: 10250 m.ResetEntID() 10251 return nil 10252 case currency.FieldCoinTypeID: 10253 m.ResetCoinTypeID() 10254 return nil 10255 case currency.FieldFeedType: 10256 m.ResetFeedType() 10257 return nil 10258 case currency.FieldMarketValueHigh: 10259 m.ResetMarketValueHigh() 10260 return nil 10261 case currency.FieldMarketValueLow: 10262 m.ResetMarketValueLow() 10263 return nil 10264 } 10265 return fmt.Errorf("unknown Currency field %s", name) 10266 } 10267 10268 // AddedEdges returns all edge names that were set/added in this mutation. 10269 func (m *CurrencyMutation) AddedEdges() []string { 10270 edges := make([]string, 0, 0) 10271 return edges 10272 } 10273 10274 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 10275 // name in this mutation. 10276 func (m *CurrencyMutation) AddedIDs(name string) []ent.Value { 10277 return nil 10278 } 10279 10280 // RemovedEdges returns all edge names that were removed in this mutation. 10281 func (m *CurrencyMutation) RemovedEdges() []string { 10282 edges := make([]string, 0, 0) 10283 return edges 10284 } 10285 10286 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 10287 // the given name in this mutation. 10288 func (m *CurrencyMutation) RemovedIDs(name string) []ent.Value { 10289 return nil 10290 } 10291 10292 // ClearedEdges returns all edge names that were cleared in this mutation. 10293 func (m *CurrencyMutation) ClearedEdges() []string { 10294 edges := make([]string, 0, 0) 10295 return edges 10296 } 10297 10298 // EdgeCleared returns a boolean which indicates if the edge with the given name 10299 // was cleared in this mutation. 10300 func (m *CurrencyMutation) EdgeCleared(name string) bool { 10301 return false 10302 } 10303 10304 // ClearEdge clears the value of the edge with the given name. It returns an error 10305 // if that edge is not defined in the schema. 10306 func (m *CurrencyMutation) ClearEdge(name string) error { 10307 return fmt.Errorf("unknown Currency unique edge %s", name) 10308 } 10309 10310 // ResetEdge resets all changes to the edge with the given name in this mutation. 10311 // It returns an error if the edge is not defined in the schema. 10312 func (m *CurrencyMutation) ResetEdge(name string) error { 10313 return fmt.Errorf("unknown Currency edge %s", name) 10314 } 10315 10316 // CurrencyFeedMutation represents an operation that mutates the CurrencyFeed nodes in the graph. 10317 type CurrencyFeedMutation struct { 10318 config 10319 op Op 10320 typ string 10321 id *uint32 10322 created_at *uint32 10323 addcreated_at *int32 10324 updated_at *uint32 10325 addupdated_at *int32 10326 deleted_at *uint32 10327 adddeleted_at *int32 10328 ent_id *uuid.UUID 10329 coin_type_id *uuid.UUID 10330 feed_type *string 10331 feed_coin_name *string 10332 disabled *bool 10333 clearedFields map[string]struct{} 10334 done bool 10335 oldValue func(context.Context) (*CurrencyFeed, error) 10336 predicates []predicate.CurrencyFeed 10337 } 10338 10339 var _ ent.Mutation = (*CurrencyFeedMutation)(nil) 10340 10341 // currencyfeedOption allows management of the mutation configuration using functional options. 10342 type currencyfeedOption func(*CurrencyFeedMutation) 10343 10344 // newCurrencyFeedMutation creates new mutation for the CurrencyFeed entity. 10345 func newCurrencyFeedMutation(c config, op Op, opts ...currencyfeedOption) *CurrencyFeedMutation { 10346 m := &CurrencyFeedMutation{ 10347 config: c, 10348 op: op, 10349 typ: TypeCurrencyFeed, 10350 clearedFields: make(map[string]struct{}), 10351 } 10352 for _, opt := range opts { 10353 opt(m) 10354 } 10355 return m 10356 } 10357 10358 // withCurrencyFeedID sets the ID field of the mutation. 10359 func withCurrencyFeedID(id uint32) currencyfeedOption { 10360 return func(m *CurrencyFeedMutation) { 10361 var ( 10362 err error 10363 once sync.Once 10364 value *CurrencyFeed 10365 ) 10366 m.oldValue = func(ctx context.Context) (*CurrencyFeed, error) { 10367 once.Do(func() { 10368 if m.done { 10369 err = errors.New("querying old values post mutation is not allowed") 10370 } else { 10371 value, err = m.Client().CurrencyFeed.Get(ctx, id) 10372 } 10373 }) 10374 return value, err 10375 } 10376 m.id = &id 10377 } 10378 } 10379 10380 // withCurrencyFeed sets the old CurrencyFeed of the mutation. 10381 func withCurrencyFeed(node *CurrencyFeed) currencyfeedOption { 10382 return func(m *CurrencyFeedMutation) { 10383 m.oldValue = func(context.Context) (*CurrencyFeed, error) { 10384 return node, nil 10385 } 10386 m.id = &node.ID 10387 } 10388 } 10389 10390 // Client returns a new `ent.Client` from the mutation. If the mutation was 10391 // executed in a transaction (ent.Tx), a transactional client is returned. 10392 func (m CurrencyFeedMutation) Client() *Client { 10393 client := &Client{config: m.config} 10394 client.init() 10395 return client 10396 } 10397 10398 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 10399 // it returns an error otherwise. 10400 func (m CurrencyFeedMutation) Tx() (*Tx, error) { 10401 if _, ok := m.driver.(*txDriver); !ok { 10402 return nil, errors.New("ent: mutation is not running in a transaction") 10403 } 10404 tx := &Tx{config: m.config} 10405 tx.init() 10406 return tx, nil 10407 } 10408 10409 // SetID sets the value of the id field. Note that this 10410 // operation is only accepted on creation of CurrencyFeed entities. 10411 func (m *CurrencyFeedMutation) SetID(id uint32) { 10412 m.id = &id 10413 } 10414 10415 // ID returns the ID value in the mutation. Note that the ID is only available 10416 // if it was provided to the builder or after it was returned from the database. 10417 func (m *CurrencyFeedMutation) ID() (id uint32, exists bool) { 10418 if m.id == nil { 10419 return 10420 } 10421 return *m.id, true 10422 } 10423 10424 // IDs queries the database and returns the entity ids that match the mutation's predicate. 10425 // That means, if the mutation is applied within a transaction with an isolation level such 10426 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 10427 // or updated by the mutation. 10428 func (m *CurrencyFeedMutation) IDs(ctx context.Context) ([]uint32, error) { 10429 switch { 10430 case m.op.Is(OpUpdateOne | OpDeleteOne): 10431 id, exists := m.ID() 10432 if exists { 10433 return []uint32{id}, nil 10434 } 10435 fallthrough 10436 case m.op.Is(OpUpdate | OpDelete): 10437 return m.Client().CurrencyFeed.Query().Where(m.predicates...).IDs(ctx) 10438 default: 10439 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 10440 } 10441 } 10442 10443 // SetCreatedAt sets the "created_at" field. 10444 func (m *CurrencyFeedMutation) SetCreatedAt(u uint32) { 10445 m.created_at = &u 10446 m.addcreated_at = nil 10447 } 10448 10449 // CreatedAt returns the value of the "created_at" field in the mutation. 10450 func (m *CurrencyFeedMutation) CreatedAt() (r uint32, exists bool) { 10451 v := m.created_at 10452 if v == nil { 10453 return 10454 } 10455 return *v, true 10456 } 10457 10458 // OldCreatedAt returns the old "created_at" field's value of the CurrencyFeed entity. 10459 // If the CurrencyFeed object wasn't provided to the builder, the object is fetched from the database. 10460 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 10461 func (m *CurrencyFeedMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 10462 if !m.op.Is(OpUpdateOne) { 10463 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 10464 } 10465 if m.id == nil || m.oldValue == nil { 10466 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 10467 } 10468 oldValue, err := m.oldValue(ctx) 10469 if err != nil { 10470 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 10471 } 10472 return oldValue.CreatedAt, nil 10473 } 10474 10475 // AddCreatedAt adds u to the "created_at" field. 10476 func (m *CurrencyFeedMutation) AddCreatedAt(u int32) { 10477 if m.addcreated_at != nil { 10478 *m.addcreated_at += u 10479 } else { 10480 m.addcreated_at = &u 10481 } 10482 } 10483 10484 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 10485 func (m *CurrencyFeedMutation) AddedCreatedAt() (r int32, exists bool) { 10486 v := m.addcreated_at 10487 if v == nil { 10488 return 10489 } 10490 return *v, true 10491 } 10492 10493 // ResetCreatedAt resets all changes to the "created_at" field. 10494 func (m *CurrencyFeedMutation) ResetCreatedAt() { 10495 m.created_at = nil 10496 m.addcreated_at = nil 10497 } 10498 10499 // SetUpdatedAt sets the "updated_at" field. 10500 func (m *CurrencyFeedMutation) SetUpdatedAt(u uint32) { 10501 m.updated_at = &u 10502 m.addupdated_at = nil 10503 } 10504 10505 // UpdatedAt returns the value of the "updated_at" field in the mutation. 10506 func (m *CurrencyFeedMutation) UpdatedAt() (r uint32, exists bool) { 10507 v := m.updated_at 10508 if v == nil { 10509 return 10510 } 10511 return *v, true 10512 } 10513 10514 // OldUpdatedAt returns the old "updated_at" field's value of the CurrencyFeed entity. 10515 // If the CurrencyFeed object wasn't provided to the builder, the object is fetched from the database. 10516 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 10517 func (m *CurrencyFeedMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 10518 if !m.op.Is(OpUpdateOne) { 10519 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 10520 } 10521 if m.id == nil || m.oldValue == nil { 10522 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 10523 } 10524 oldValue, err := m.oldValue(ctx) 10525 if err != nil { 10526 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 10527 } 10528 return oldValue.UpdatedAt, nil 10529 } 10530 10531 // AddUpdatedAt adds u to the "updated_at" field. 10532 func (m *CurrencyFeedMutation) AddUpdatedAt(u int32) { 10533 if m.addupdated_at != nil { 10534 *m.addupdated_at += u 10535 } else { 10536 m.addupdated_at = &u 10537 } 10538 } 10539 10540 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 10541 func (m *CurrencyFeedMutation) AddedUpdatedAt() (r int32, exists bool) { 10542 v := m.addupdated_at 10543 if v == nil { 10544 return 10545 } 10546 return *v, true 10547 } 10548 10549 // ResetUpdatedAt resets all changes to the "updated_at" field. 10550 func (m *CurrencyFeedMutation) ResetUpdatedAt() { 10551 m.updated_at = nil 10552 m.addupdated_at = nil 10553 } 10554 10555 // SetDeletedAt sets the "deleted_at" field. 10556 func (m *CurrencyFeedMutation) SetDeletedAt(u uint32) { 10557 m.deleted_at = &u 10558 m.adddeleted_at = nil 10559 } 10560 10561 // DeletedAt returns the value of the "deleted_at" field in the mutation. 10562 func (m *CurrencyFeedMutation) DeletedAt() (r uint32, exists bool) { 10563 v := m.deleted_at 10564 if v == nil { 10565 return 10566 } 10567 return *v, true 10568 } 10569 10570 // OldDeletedAt returns the old "deleted_at" field's value of the CurrencyFeed entity. 10571 // If the CurrencyFeed object wasn't provided to the builder, the object is fetched from the database. 10572 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 10573 func (m *CurrencyFeedMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 10574 if !m.op.Is(OpUpdateOne) { 10575 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 10576 } 10577 if m.id == nil || m.oldValue == nil { 10578 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 10579 } 10580 oldValue, err := m.oldValue(ctx) 10581 if err != nil { 10582 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 10583 } 10584 return oldValue.DeletedAt, nil 10585 } 10586 10587 // AddDeletedAt adds u to the "deleted_at" field. 10588 func (m *CurrencyFeedMutation) AddDeletedAt(u int32) { 10589 if m.adddeleted_at != nil { 10590 *m.adddeleted_at += u 10591 } else { 10592 m.adddeleted_at = &u 10593 } 10594 } 10595 10596 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 10597 func (m *CurrencyFeedMutation) AddedDeletedAt() (r int32, exists bool) { 10598 v := m.adddeleted_at 10599 if v == nil { 10600 return 10601 } 10602 return *v, true 10603 } 10604 10605 // ResetDeletedAt resets all changes to the "deleted_at" field. 10606 func (m *CurrencyFeedMutation) ResetDeletedAt() { 10607 m.deleted_at = nil 10608 m.adddeleted_at = nil 10609 } 10610 10611 // SetEntID sets the "ent_id" field. 10612 func (m *CurrencyFeedMutation) SetEntID(u uuid.UUID) { 10613 m.ent_id = &u 10614 } 10615 10616 // EntID returns the value of the "ent_id" field in the mutation. 10617 func (m *CurrencyFeedMutation) EntID() (r uuid.UUID, exists bool) { 10618 v := m.ent_id 10619 if v == nil { 10620 return 10621 } 10622 return *v, true 10623 } 10624 10625 // OldEntID returns the old "ent_id" field's value of the CurrencyFeed entity. 10626 // If the CurrencyFeed object wasn't provided to the builder, the object is fetched from the database. 10627 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 10628 func (m *CurrencyFeedMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 10629 if !m.op.Is(OpUpdateOne) { 10630 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 10631 } 10632 if m.id == nil || m.oldValue == nil { 10633 return v, errors.New("OldEntID requires an ID field in the mutation") 10634 } 10635 oldValue, err := m.oldValue(ctx) 10636 if err != nil { 10637 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 10638 } 10639 return oldValue.EntID, nil 10640 } 10641 10642 // ResetEntID resets all changes to the "ent_id" field. 10643 func (m *CurrencyFeedMutation) ResetEntID() { 10644 m.ent_id = nil 10645 } 10646 10647 // SetCoinTypeID sets the "coin_type_id" field. 10648 func (m *CurrencyFeedMutation) SetCoinTypeID(u uuid.UUID) { 10649 m.coin_type_id = &u 10650 } 10651 10652 // CoinTypeID returns the value of the "coin_type_id" field in the mutation. 10653 func (m *CurrencyFeedMutation) CoinTypeID() (r uuid.UUID, exists bool) { 10654 v := m.coin_type_id 10655 if v == nil { 10656 return 10657 } 10658 return *v, true 10659 } 10660 10661 // OldCoinTypeID returns the old "coin_type_id" field's value of the CurrencyFeed entity. 10662 // If the CurrencyFeed object wasn't provided to the builder, the object is fetched from the database. 10663 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 10664 func (m *CurrencyFeedMutation) OldCoinTypeID(ctx context.Context) (v uuid.UUID, err error) { 10665 if !m.op.Is(OpUpdateOne) { 10666 return v, errors.New("OldCoinTypeID is only allowed on UpdateOne operations") 10667 } 10668 if m.id == nil || m.oldValue == nil { 10669 return v, errors.New("OldCoinTypeID requires an ID field in the mutation") 10670 } 10671 oldValue, err := m.oldValue(ctx) 10672 if err != nil { 10673 return v, fmt.Errorf("querying old value for OldCoinTypeID: %w", err) 10674 } 10675 return oldValue.CoinTypeID, nil 10676 } 10677 10678 // ClearCoinTypeID clears the value of the "coin_type_id" field. 10679 func (m *CurrencyFeedMutation) ClearCoinTypeID() { 10680 m.coin_type_id = nil 10681 m.clearedFields[currencyfeed.FieldCoinTypeID] = struct{}{} 10682 } 10683 10684 // CoinTypeIDCleared returns if the "coin_type_id" field was cleared in this mutation. 10685 func (m *CurrencyFeedMutation) CoinTypeIDCleared() bool { 10686 _, ok := m.clearedFields[currencyfeed.FieldCoinTypeID] 10687 return ok 10688 } 10689 10690 // ResetCoinTypeID resets all changes to the "coin_type_id" field. 10691 func (m *CurrencyFeedMutation) ResetCoinTypeID() { 10692 m.coin_type_id = nil 10693 delete(m.clearedFields, currencyfeed.FieldCoinTypeID) 10694 } 10695 10696 // SetFeedType sets the "feed_type" field. 10697 func (m *CurrencyFeedMutation) SetFeedType(s string) { 10698 m.feed_type = &s 10699 } 10700 10701 // FeedType returns the value of the "feed_type" field in the mutation. 10702 func (m *CurrencyFeedMutation) FeedType() (r string, exists bool) { 10703 v := m.feed_type 10704 if v == nil { 10705 return 10706 } 10707 return *v, true 10708 } 10709 10710 // OldFeedType returns the old "feed_type" field's value of the CurrencyFeed entity. 10711 // If the CurrencyFeed object wasn't provided to the builder, the object is fetched from the database. 10712 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 10713 func (m *CurrencyFeedMutation) OldFeedType(ctx context.Context) (v string, err error) { 10714 if !m.op.Is(OpUpdateOne) { 10715 return v, errors.New("OldFeedType is only allowed on UpdateOne operations") 10716 } 10717 if m.id == nil || m.oldValue == nil { 10718 return v, errors.New("OldFeedType requires an ID field in the mutation") 10719 } 10720 oldValue, err := m.oldValue(ctx) 10721 if err != nil { 10722 return v, fmt.Errorf("querying old value for OldFeedType: %w", err) 10723 } 10724 return oldValue.FeedType, nil 10725 } 10726 10727 // ClearFeedType clears the value of the "feed_type" field. 10728 func (m *CurrencyFeedMutation) ClearFeedType() { 10729 m.feed_type = nil 10730 m.clearedFields[currencyfeed.FieldFeedType] = struct{}{} 10731 } 10732 10733 // FeedTypeCleared returns if the "feed_type" field was cleared in this mutation. 10734 func (m *CurrencyFeedMutation) FeedTypeCleared() bool { 10735 _, ok := m.clearedFields[currencyfeed.FieldFeedType] 10736 return ok 10737 } 10738 10739 // ResetFeedType resets all changes to the "feed_type" field. 10740 func (m *CurrencyFeedMutation) ResetFeedType() { 10741 m.feed_type = nil 10742 delete(m.clearedFields, currencyfeed.FieldFeedType) 10743 } 10744 10745 // SetFeedCoinName sets the "feed_coin_name" field. 10746 func (m *CurrencyFeedMutation) SetFeedCoinName(s string) { 10747 m.feed_coin_name = &s 10748 } 10749 10750 // FeedCoinName returns the value of the "feed_coin_name" field in the mutation. 10751 func (m *CurrencyFeedMutation) FeedCoinName() (r string, exists bool) { 10752 v := m.feed_coin_name 10753 if v == nil { 10754 return 10755 } 10756 return *v, true 10757 } 10758 10759 // OldFeedCoinName returns the old "feed_coin_name" field's value of the CurrencyFeed entity. 10760 // If the CurrencyFeed object wasn't provided to the builder, the object is fetched from the database. 10761 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 10762 func (m *CurrencyFeedMutation) OldFeedCoinName(ctx context.Context) (v string, err error) { 10763 if !m.op.Is(OpUpdateOne) { 10764 return v, errors.New("OldFeedCoinName is only allowed on UpdateOne operations") 10765 } 10766 if m.id == nil || m.oldValue == nil { 10767 return v, errors.New("OldFeedCoinName requires an ID field in the mutation") 10768 } 10769 oldValue, err := m.oldValue(ctx) 10770 if err != nil { 10771 return v, fmt.Errorf("querying old value for OldFeedCoinName: %w", err) 10772 } 10773 return oldValue.FeedCoinName, nil 10774 } 10775 10776 // ClearFeedCoinName clears the value of the "feed_coin_name" field. 10777 func (m *CurrencyFeedMutation) ClearFeedCoinName() { 10778 m.feed_coin_name = nil 10779 m.clearedFields[currencyfeed.FieldFeedCoinName] = struct{}{} 10780 } 10781 10782 // FeedCoinNameCleared returns if the "feed_coin_name" field was cleared in this mutation. 10783 func (m *CurrencyFeedMutation) FeedCoinNameCleared() bool { 10784 _, ok := m.clearedFields[currencyfeed.FieldFeedCoinName] 10785 return ok 10786 } 10787 10788 // ResetFeedCoinName resets all changes to the "feed_coin_name" field. 10789 func (m *CurrencyFeedMutation) ResetFeedCoinName() { 10790 m.feed_coin_name = nil 10791 delete(m.clearedFields, currencyfeed.FieldFeedCoinName) 10792 } 10793 10794 // SetDisabled sets the "disabled" field. 10795 func (m *CurrencyFeedMutation) SetDisabled(b bool) { 10796 m.disabled = &b 10797 } 10798 10799 // Disabled returns the value of the "disabled" field in the mutation. 10800 func (m *CurrencyFeedMutation) Disabled() (r bool, exists bool) { 10801 v := m.disabled 10802 if v == nil { 10803 return 10804 } 10805 return *v, true 10806 } 10807 10808 // OldDisabled returns the old "disabled" field's value of the CurrencyFeed entity. 10809 // If the CurrencyFeed object wasn't provided to the builder, the object is fetched from the database. 10810 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 10811 func (m *CurrencyFeedMutation) OldDisabled(ctx context.Context) (v bool, err error) { 10812 if !m.op.Is(OpUpdateOne) { 10813 return v, errors.New("OldDisabled is only allowed on UpdateOne operations") 10814 } 10815 if m.id == nil || m.oldValue == nil { 10816 return v, errors.New("OldDisabled requires an ID field in the mutation") 10817 } 10818 oldValue, err := m.oldValue(ctx) 10819 if err != nil { 10820 return v, fmt.Errorf("querying old value for OldDisabled: %w", err) 10821 } 10822 return oldValue.Disabled, nil 10823 } 10824 10825 // ClearDisabled clears the value of the "disabled" field. 10826 func (m *CurrencyFeedMutation) ClearDisabled() { 10827 m.disabled = nil 10828 m.clearedFields[currencyfeed.FieldDisabled] = struct{}{} 10829 } 10830 10831 // DisabledCleared returns if the "disabled" field was cleared in this mutation. 10832 func (m *CurrencyFeedMutation) DisabledCleared() bool { 10833 _, ok := m.clearedFields[currencyfeed.FieldDisabled] 10834 return ok 10835 } 10836 10837 // ResetDisabled resets all changes to the "disabled" field. 10838 func (m *CurrencyFeedMutation) ResetDisabled() { 10839 m.disabled = nil 10840 delete(m.clearedFields, currencyfeed.FieldDisabled) 10841 } 10842 10843 // Where appends a list predicates to the CurrencyFeedMutation builder. 10844 func (m *CurrencyFeedMutation) Where(ps ...predicate.CurrencyFeed) { 10845 m.predicates = append(m.predicates, ps...) 10846 } 10847 10848 // Op returns the operation name. 10849 func (m *CurrencyFeedMutation) Op() Op { 10850 return m.op 10851 } 10852 10853 // Type returns the node type of this mutation (CurrencyFeed). 10854 func (m *CurrencyFeedMutation) Type() string { 10855 return m.typ 10856 } 10857 10858 // Fields returns all fields that were changed during this mutation. Note that in 10859 // order to get all numeric fields that were incremented/decremented, call 10860 // AddedFields(). 10861 func (m *CurrencyFeedMutation) Fields() []string { 10862 fields := make([]string, 0, 8) 10863 if m.created_at != nil { 10864 fields = append(fields, currencyfeed.FieldCreatedAt) 10865 } 10866 if m.updated_at != nil { 10867 fields = append(fields, currencyfeed.FieldUpdatedAt) 10868 } 10869 if m.deleted_at != nil { 10870 fields = append(fields, currencyfeed.FieldDeletedAt) 10871 } 10872 if m.ent_id != nil { 10873 fields = append(fields, currencyfeed.FieldEntID) 10874 } 10875 if m.coin_type_id != nil { 10876 fields = append(fields, currencyfeed.FieldCoinTypeID) 10877 } 10878 if m.feed_type != nil { 10879 fields = append(fields, currencyfeed.FieldFeedType) 10880 } 10881 if m.feed_coin_name != nil { 10882 fields = append(fields, currencyfeed.FieldFeedCoinName) 10883 } 10884 if m.disabled != nil { 10885 fields = append(fields, currencyfeed.FieldDisabled) 10886 } 10887 return fields 10888 } 10889 10890 // Field returns the value of a field with the given name. The second boolean 10891 // return value indicates that this field was not set, or was not defined in the 10892 // schema. 10893 func (m *CurrencyFeedMutation) Field(name string) (ent.Value, bool) { 10894 switch name { 10895 case currencyfeed.FieldCreatedAt: 10896 return m.CreatedAt() 10897 case currencyfeed.FieldUpdatedAt: 10898 return m.UpdatedAt() 10899 case currencyfeed.FieldDeletedAt: 10900 return m.DeletedAt() 10901 case currencyfeed.FieldEntID: 10902 return m.EntID() 10903 case currencyfeed.FieldCoinTypeID: 10904 return m.CoinTypeID() 10905 case currencyfeed.FieldFeedType: 10906 return m.FeedType() 10907 case currencyfeed.FieldFeedCoinName: 10908 return m.FeedCoinName() 10909 case currencyfeed.FieldDisabled: 10910 return m.Disabled() 10911 } 10912 return nil, false 10913 } 10914 10915 // OldField returns the old value of the field from the database. An error is 10916 // returned if the mutation operation is not UpdateOne, or the query to the 10917 // database failed. 10918 func (m *CurrencyFeedMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 10919 switch name { 10920 case currencyfeed.FieldCreatedAt: 10921 return m.OldCreatedAt(ctx) 10922 case currencyfeed.FieldUpdatedAt: 10923 return m.OldUpdatedAt(ctx) 10924 case currencyfeed.FieldDeletedAt: 10925 return m.OldDeletedAt(ctx) 10926 case currencyfeed.FieldEntID: 10927 return m.OldEntID(ctx) 10928 case currencyfeed.FieldCoinTypeID: 10929 return m.OldCoinTypeID(ctx) 10930 case currencyfeed.FieldFeedType: 10931 return m.OldFeedType(ctx) 10932 case currencyfeed.FieldFeedCoinName: 10933 return m.OldFeedCoinName(ctx) 10934 case currencyfeed.FieldDisabled: 10935 return m.OldDisabled(ctx) 10936 } 10937 return nil, fmt.Errorf("unknown CurrencyFeed field %s", name) 10938 } 10939 10940 // SetField sets the value of a field with the given name. It returns an error if 10941 // the field is not defined in the schema, or if the type mismatched the field 10942 // type. 10943 func (m *CurrencyFeedMutation) SetField(name string, value ent.Value) error { 10944 switch name { 10945 case currencyfeed.FieldCreatedAt: 10946 v, ok := value.(uint32) 10947 if !ok { 10948 return fmt.Errorf("unexpected type %T for field %s", value, name) 10949 } 10950 m.SetCreatedAt(v) 10951 return nil 10952 case currencyfeed.FieldUpdatedAt: 10953 v, ok := value.(uint32) 10954 if !ok { 10955 return fmt.Errorf("unexpected type %T for field %s", value, name) 10956 } 10957 m.SetUpdatedAt(v) 10958 return nil 10959 case currencyfeed.FieldDeletedAt: 10960 v, ok := value.(uint32) 10961 if !ok { 10962 return fmt.Errorf("unexpected type %T for field %s", value, name) 10963 } 10964 m.SetDeletedAt(v) 10965 return nil 10966 case currencyfeed.FieldEntID: 10967 v, ok := value.(uuid.UUID) 10968 if !ok { 10969 return fmt.Errorf("unexpected type %T for field %s", value, name) 10970 } 10971 m.SetEntID(v) 10972 return nil 10973 case currencyfeed.FieldCoinTypeID: 10974 v, ok := value.(uuid.UUID) 10975 if !ok { 10976 return fmt.Errorf("unexpected type %T for field %s", value, name) 10977 } 10978 m.SetCoinTypeID(v) 10979 return nil 10980 case currencyfeed.FieldFeedType: 10981 v, ok := value.(string) 10982 if !ok { 10983 return fmt.Errorf("unexpected type %T for field %s", value, name) 10984 } 10985 m.SetFeedType(v) 10986 return nil 10987 case currencyfeed.FieldFeedCoinName: 10988 v, ok := value.(string) 10989 if !ok { 10990 return fmt.Errorf("unexpected type %T for field %s", value, name) 10991 } 10992 m.SetFeedCoinName(v) 10993 return nil 10994 case currencyfeed.FieldDisabled: 10995 v, ok := value.(bool) 10996 if !ok { 10997 return fmt.Errorf("unexpected type %T for field %s", value, name) 10998 } 10999 m.SetDisabled(v) 11000 return nil 11001 } 11002 return fmt.Errorf("unknown CurrencyFeed field %s", name) 11003 } 11004 11005 // AddedFields returns all numeric fields that were incremented/decremented during 11006 // this mutation. 11007 func (m *CurrencyFeedMutation) AddedFields() []string { 11008 var fields []string 11009 if m.addcreated_at != nil { 11010 fields = append(fields, currencyfeed.FieldCreatedAt) 11011 } 11012 if m.addupdated_at != nil { 11013 fields = append(fields, currencyfeed.FieldUpdatedAt) 11014 } 11015 if m.adddeleted_at != nil { 11016 fields = append(fields, currencyfeed.FieldDeletedAt) 11017 } 11018 return fields 11019 } 11020 11021 // AddedField returns the numeric value that was incremented/decremented on a field 11022 // with the given name. The second boolean return value indicates that this field 11023 // was not set, or was not defined in the schema. 11024 func (m *CurrencyFeedMutation) AddedField(name string) (ent.Value, bool) { 11025 switch name { 11026 case currencyfeed.FieldCreatedAt: 11027 return m.AddedCreatedAt() 11028 case currencyfeed.FieldUpdatedAt: 11029 return m.AddedUpdatedAt() 11030 case currencyfeed.FieldDeletedAt: 11031 return m.AddedDeletedAt() 11032 } 11033 return nil, false 11034 } 11035 11036 // AddField adds the value to the field with the given name. It returns an error if 11037 // the field is not defined in the schema, or if the type mismatched the field 11038 // type. 11039 func (m *CurrencyFeedMutation) AddField(name string, value ent.Value) error { 11040 switch name { 11041 case currencyfeed.FieldCreatedAt: 11042 v, ok := value.(int32) 11043 if !ok { 11044 return fmt.Errorf("unexpected type %T for field %s", value, name) 11045 } 11046 m.AddCreatedAt(v) 11047 return nil 11048 case currencyfeed.FieldUpdatedAt: 11049 v, ok := value.(int32) 11050 if !ok { 11051 return fmt.Errorf("unexpected type %T for field %s", value, name) 11052 } 11053 m.AddUpdatedAt(v) 11054 return nil 11055 case currencyfeed.FieldDeletedAt: 11056 v, ok := value.(int32) 11057 if !ok { 11058 return fmt.Errorf("unexpected type %T for field %s", value, name) 11059 } 11060 m.AddDeletedAt(v) 11061 return nil 11062 } 11063 return fmt.Errorf("unknown CurrencyFeed numeric field %s", name) 11064 } 11065 11066 // ClearedFields returns all nullable fields that were cleared during this 11067 // mutation. 11068 func (m *CurrencyFeedMutation) ClearedFields() []string { 11069 var fields []string 11070 if m.FieldCleared(currencyfeed.FieldCoinTypeID) { 11071 fields = append(fields, currencyfeed.FieldCoinTypeID) 11072 } 11073 if m.FieldCleared(currencyfeed.FieldFeedType) { 11074 fields = append(fields, currencyfeed.FieldFeedType) 11075 } 11076 if m.FieldCleared(currencyfeed.FieldFeedCoinName) { 11077 fields = append(fields, currencyfeed.FieldFeedCoinName) 11078 } 11079 if m.FieldCleared(currencyfeed.FieldDisabled) { 11080 fields = append(fields, currencyfeed.FieldDisabled) 11081 } 11082 return fields 11083 } 11084 11085 // FieldCleared returns a boolean indicating if a field with the given name was 11086 // cleared in this mutation. 11087 func (m *CurrencyFeedMutation) FieldCleared(name string) bool { 11088 _, ok := m.clearedFields[name] 11089 return ok 11090 } 11091 11092 // ClearField clears the value of the field with the given name. It returns an 11093 // error if the field is not defined in the schema. 11094 func (m *CurrencyFeedMutation) ClearField(name string) error { 11095 switch name { 11096 case currencyfeed.FieldCoinTypeID: 11097 m.ClearCoinTypeID() 11098 return nil 11099 case currencyfeed.FieldFeedType: 11100 m.ClearFeedType() 11101 return nil 11102 case currencyfeed.FieldFeedCoinName: 11103 m.ClearFeedCoinName() 11104 return nil 11105 case currencyfeed.FieldDisabled: 11106 m.ClearDisabled() 11107 return nil 11108 } 11109 return fmt.Errorf("unknown CurrencyFeed nullable field %s", name) 11110 } 11111 11112 // ResetField resets all changes in the mutation for the field with the given name. 11113 // It returns an error if the field is not defined in the schema. 11114 func (m *CurrencyFeedMutation) ResetField(name string) error { 11115 switch name { 11116 case currencyfeed.FieldCreatedAt: 11117 m.ResetCreatedAt() 11118 return nil 11119 case currencyfeed.FieldUpdatedAt: 11120 m.ResetUpdatedAt() 11121 return nil 11122 case currencyfeed.FieldDeletedAt: 11123 m.ResetDeletedAt() 11124 return nil 11125 case currencyfeed.FieldEntID: 11126 m.ResetEntID() 11127 return nil 11128 case currencyfeed.FieldCoinTypeID: 11129 m.ResetCoinTypeID() 11130 return nil 11131 case currencyfeed.FieldFeedType: 11132 m.ResetFeedType() 11133 return nil 11134 case currencyfeed.FieldFeedCoinName: 11135 m.ResetFeedCoinName() 11136 return nil 11137 case currencyfeed.FieldDisabled: 11138 m.ResetDisabled() 11139 return nil 11140 } 11141 return fmt.Errorf("unknown CurrencyFeed field %s", name) 11142 } 11143 11144 // AddedEdges returns all edge names that were set/added in this mutation. 11145 func (m *CurrencyFeedMutation) AddedEdges() []string { 11146 edges := make([]string, 0, 0) 11147 return edges 11148 } 11149 11150 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 11151 // name in this mutation. 11152 func (m *CurrencyFeedMutation) AddedIDs(name string) []ent.Value { 11153 return nil 11154 } 11155 11156 // RemovedEdges returns all edge names that were removed in this mutation. 11157 func (m *CurrencyFeedMutation) RemovedEdges() []string { 11158 edges := make([]string, 0, 0) 11159 return edges 11160 } 11161 11162 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 11163 // the given name in this mutation. 11164 func (m *CurrencyFeedMutation) RemovedIDs(name string) []ent.Value { 11165 return nil 11166 } 11167 11168 // ClearedEdges returns all edge names that were cleared in this mutation. 11169 func (m *CurrencyFeedMutation) ClearedEdges() []string { 11170 edges := make([]string, 0, 0) 11171 return edges 11172 } 11173 11174 // EdgeCleared returns a boolean which indicates if the edge with the given name 11175 // was cleared in this mutation. 11176 func (m *CurrencyFeedMutation) EdgeCleared(name string) bool { 11177 return false 11178 } 11179 11180 // ClearEdge clears the value of the edge with the given name. It returns an error 11181 // if that edge is not defined in the schema. 11182 func (m *CurrencyFeedMutation) ClearEdge(name string) error { 11183 return fmt.Errorf("unknown CurrencyFeed unique edge %s", name) 11184 } 11185 11186 // ResetEdge resets all changes to the edge with the given name in this mutation. 11187 // It returns an error if the edge is not defined in the schema. 11188 func (m *CurrencyFeedMutation) ResetEdge(name string) error { 11189 return fmt.Errorf("unknown CurrencyFeed edge %s", name) 11190 } 11191 11192 // CurrencyHistoryMutation represents an operation that mutates the CurrencyHistory nodes in the graph. 11193 type CurrencyHistoryMutation struct { 11194 config 11195 op Op 11196 typ string 11197 id *uint32 11198 created_at *uint32 11199 addcreated_at *int32 11200 updated_at *uint32 11201 addupdated_at *int32 11202 deleted_at *uint32 11203 adddeleted_at *int32 11204 ent_id *uuid.UUID 11205 coin_type_id *uuid.UUID 11206 feed_type *string 11207 market_value_high *decimal.Decimal 11208 market_value_low *decimal.Decimal 11209 clearedFields map[string]struct{} 11210 done bool 11211 oldValue func(context.Context) (*CurrencyHistory, error) 11212 predicates []predicate.CurrencyHistory 11213 } 11214 11215 var _ ent.Mutation = (*CurrencyHistoryMutation)(nil) 11216 11217 // currencyhistoryOption allows management of the mutation configuration using functional options. 11218 type currencyhistoryOption func(*CurrencyHistoryMutation) 11219 11220 // newCurrencyHistoryMutation creates new mutation for the CurrencyHistory entity. 11221 func newCurrencyHistoryMutation(c config, op Op, opts ...currencyhistoryOption) *CurrencyHistoryMutation { 11222 m := &CurrencyHistoryMutation{ 11223 config: c, 11224 op: op, 11225 typ: TypeCurrencyHistory, 11226 clearedFields: make(map[string]struct{}), 11227 } 11228 for _, opt := range opts { 11229 opt(m) 11230 } 11231 return m 11232 } 11233 11234 // withCurrencyHistoryID sets the ID field of the mutation. 11235 func withCurrencyHistoryID(id uint32) currencyhistoryOption { 11236 return func(m *CurrencyHistoryMutation) { 11237 var ( 11238 err error 11239 once sync.Once 11240 value *CurrencyHistory 11241 ) 11242 m.oldValue = func(ctx context.Context) (*CurrencyHistory, error) { 11243 once.Do(func() { 11244 if m.done { 11245 err = errors.New("querying old values post mutation is not allowed") 11246 } else { 11247 value, err = m.Client().CurrencyHistory.Get(ctx, id) 11248 } 11249 }) 11250 return value, err 11251 } 11252 m.id = &id 11253 } 11254 } 11255 11256 // withCurrencyHistory sets the old CurrencyHistory of the mutation. 11257 func withCurrencyHistory(node *CurrencyHistory) currencyhistoryOption { 11258 return func(m *CurrencyHistoryMutation) { 11259 m.oldValue = func(context.Context) (*CurrencyHistory, error) { 11260 return node, nil 11261 } 11262 m.id = &node.ID 11263 } 11264 } 11265 11266 // Client returns a new `ent.Client` from the mutation. If the mutation was 11267 // executed in a transaction (ent.Tx), a transactional client is returned. 11268 func (m CurrencyHistoryMutation) Client() *Client { 11269 client := &Client{config: m.config} 11270 client.init() 11271 return client 11272 } 11273 11274 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 11275 // it returns an error otherwise. 11276 func (m CurrencyHistoryMutation) Tx() (*Tx, error) { 11277 if _, ok := m.driver.(*txDriver); !ok { 11278 return nil, errors.New("ent: mutation is not running in a transaction") 11279 } 11280 tx := &Tx{config: m.config} 11281 tx.init() 11282 return tx, nil 11283 } 11284 11285 // SetID sets the value of the id field. Note that this 11286 // operation is only accepted on creation of CurrencyHistory entities. 11287 func (m *CurrencyHistoryMutation) SetID(id uint32) { 11288 m.id = &id 11289 } 11290 11291 // ID returns the ID value in the mutation. Note that the ID is only available 11292 // if it was provided to the builder or after it was returned from the database. 11293 func (m *CurrencyHistoryMutation) ID() (id uint32, exists bool) { 11294 if m.id == nil { 11295 return 11296 } 11297 return *m.id, true 11298 } 11299 11300 // IDs queries the database and returns the entity ids that match the mutation's predicate. 11301 // That means, if the mutation is applied within a transaction with an isolation level such 11302 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 11303 // or updated by the mutation. 11304 func (m *CurrencyHistoryMutation) IDs(ctx context.Context) ([]uint32, error) { 11305 switch { 11306 case m.op.Is(OpUpdateOne | OpDeleteOne): 11307 id, exists := m.ID() 11308 if exists { 11309 return []uint32{id}, nil 11310 } 11311 fallthrough 11312 case m.op.Is(OpUpdate | OpDelete): 11313 return m.Client().CurrencyHistory.Query().Where(m.predicates...).IDs(ctx) 11314 default: 11315 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 11316 } 11317 } 11318 11319 // SetCreatedAt sets the "created_at" field. 11320 func (m *CurrencyHistoryMutation) SetCreatedAt(u uint32) { 11321 m.created_at = &u 11322 m.addcreated_at = nil 11323 } 11324 11325 // CreatedAt returns the value of the "created_at" field in the mutation. 11326 func (m *CurrencyHistoryMutation) CreatedAt() (r uint32, exists bool) { 11327 v := m.created_at 11328 if v == nil { 11329 return 11330 } 11331 return *v, true 11332 } 11333 11334 // OldCreatedAt returns the old "created_at" field's value of the CurrencyHistory entity. 11335 // If the CurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 11336 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 11337 func (m *CurrencyHistoryMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 11338 if !m.op.Is(OpUpdateOne) { 11339 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 11340 } 11341 if m.id == nil || m.oldValue == nil { 11342 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 11343 } 11344 oldValue, err := m.oldValue(ctx) 11345 if err != nil { 11346 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 11347 } 11348 return oldValue.CreatedAt, nil 11349 } 11350 11351 // AddCreatedAt adds u to the "created_at" field. 11352 func (m *CurrencyHistoryMutation) AddCreatedAt(u int32) { 11353 if m.addcreated_at != nil { 11354 *m.addcreated_at += u 11355 } else { 11356 m.addcreated_at = &u 11357 } 11358 } 11359 11360 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 11361 func (m *CurrencyHistoryMutation) AddedCreatedAt() (r int32, exists bool) { 11362 v := m.addcreated_at 11363 if v == nil { 11364 return 11365 } 11366 return *v, true 11367 } 11368 11369 // ResetCreatedAt resets all changes to the "created_at" field. 11370 func (m *CurrencyHistoryMutation) ResetCreatedAt() { 11371 m.created_at = nil 11372 m.addcreated_at = nil 11373 } 11374 11375 // SetUpdatedAt sets the "updated_at" field. 11376 func (m *CurrencyHistoryMutation) SetUpdatedAt(u uint32) { 11377 m.updated_at = &u 11378 m.addupdated_at = nil 11379 } 11380 11381 // UpdatedAt returns the value of the "updated_at" field in the mutation. 11382 func (m *CurrencyHistoryMutation) UpdatedAt() (r uint32, exists bool) { 11383 v := m.updated_at 11384 if v == nil { 11385 return 11386 } 11387 return *v, true 11388 } 11389 11390 // OldUpdatedAt returns the old "updated_at" field's value of the CurrencyHistory entity. 11391 // If the CurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 11392 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 11393 func (m *CurrencyHistoryMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 11394 if !m.op.Is(OpUpdateOne) { 11395 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 11396 } 11397 if m.id == nil || m.oldValue == nil { 11398 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 11399 } 11400 oldValue, err := m.oldValue(ctx) 11401 if err != nil { 11402 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 11403 } 11404 return oldValue.UpdatedAt, nil 11405 } 11406 11407 // AddUpdatedAt adds u to the "updated_at" field. 11408 func (m *CurrencyHistoryMutation) AddUpdatedAt(u int32) { 11409 if m.addupdated_at != nil { 11410 *m.addupdated_at += u 11411 } else { 11412 m.addupdated_at = &u 11413 } 11414 } 11415 11416 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 11417 func (m *CurrencyHistoryMutation) AddedUpdatedAt() (r int32, exists bool) { 11418 v := m.addupdated_at 11419 if v == nil { 11420 return 11421 } 11422 return *v, true 11423 } 11424 11425 // ResetUpdatedAt resets all changes to the "updated_at" field. 11426 func (m *CurrencyHistoryMutation) ResetUpdatedAt() { 11427 m.updated_at = nil 11428 m.addupdated_at = nil 11429 } 11430 11431 // SetDeletedAt sets the "deleted_at" field. 11432 func (m *CurrencyHistoryMutation) SetDeletedAt(u uint32) { 11433 m.deleted_at = &u 11434 m.adddeleted_at = nil 11435 } 11436 11437 // DeletedAt returns the value of the "deleted_at" field in the mutation. 11438 func (m *CurrencyHistoryMutation) DeletedAt() (r uint32, exists bool) { 11439 v := m.deleted_at 11440 if v == nil { 11441 return 11442 } 11443 return *v, true 11444 } 11445 11446 // OldDeletedAt returns the old "deleted_at" field's value of the CurrencyHistory entity. 11447 // If the CurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 11448 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 11449 func (m *CurrencyHistoryMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 11450 if !m.op.Is(OpUpdateOne) { 11451 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 11452 } 11453 if m.id == nil || m.oldValue == nil { 11454 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 11455 } 11456 oldValue, err := m.oldValue(ctx) 11457 if err != nil { 11458 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 11459 } 11460 return oldValue.DeletedAt, nil 11461 } 11462 11463 // AddDeletedAt adds u to the "deleted_at" field. 11464 func (m *CurrencyHistoryMutation) AddDeletedAt(u int32) { 11465 if m.adddeleted_at != nil { 11466 *m.adddeleted_at += u 11467 } else { 11468 m.adddeleted_at = &u 11469 } 11470 } 11471 11472 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 11473 func (m *CurrencyHistoryMutation) AddedDeletedAt() (r int32, exists bool) { 11474 v := m.adddeleted_at 11475 if v == nil { 11476 return 11477 } 11478 return *v, true 11479 } 11480 11481 // ResetDeletedAt resets all changes to the "deleted_at" field. 11482 func (m *CurrencyHistoryMutation) ResetDeletedAt() { 11483 m.deleted_at = nil 11484 m.adddeleted_at = nil 11485 } 11486 11487 // SetEntID sets the "ent_id" field. 11488 func (m *CurrencyHistoryMutation) SetEntID(u uuid.UUID) { 11489 m.ent_id = &u 11490 } 11491 11492 // EntID returns the value of the "ent_id" field in the mutation. 11493 func (m *CurrencyHistoryMutation) EntID() (r uuid.UUID, exists bool) { 11494 v := m.ent_id 11495 if v == nil { 11496 return 11497 } 11498 return *v, true 11499 } 11500 11501 // OldEntID returns the old "ent_id" field's value of the CurrencyHistory entity. 11502 // If the CurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 11503 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 11504 func (m *CurrencyHistoryMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 11505 if !m.op.Is(OpUpdateOne) { 11506 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 11507 } 11508 if m.id == nil || m.oldValue == nil { 11509 return v, errors.New("OldEntID requires an ID field in the mutation") 11510 } 11511 oldValue, err := m.oldValue(ctx) 11512 if err != nil { 11513 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 11514 } 11515 return oldValue.EntID, nil 11516 } 11517 11518 // ResetEntID resets all changes to the "ent_id" field. 11519 func (m *CurrencyHistoryMutation) ResetEntID() { 11520 m.ent_id = nil 11521 } 11522 11523 // SetCoinTypeID sets the "coin_type_id" field. 11524 func (m *CurrencyHistoryMutation) SetCoinTypeID(u uuid.UUID) { 11525 m.coin_type_id = &u 11526 } 11527 11528 // CoinTypeID returns the value of the "coin_type_id" field in the mutation. 11529 func (m *CurrencyHistoryMutation) CoinTypeID() (r uuid.UUID, exists bool) { 11530 v := m.coin_type_id 11531 if v == nil { 11532 return 11533 } 11534 return *v, true 11535 } 11536 11537 // OldCoinTypeID returns the old "coin_type_id" field's value of the CurrencyHistory entity. 11538 // If the CurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 11539 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 11540 func (m *CurrencyHistoryMutation) OldCoinTypeID(ctx context.Context) (v uuid.UUID, err error) { 11541 if !m.op.Is(OpUpdateOne) { 11542 return v, errors.New("OldCoinTypeID is only allowed on UpdateOne operations") 11543 } 11544 if m.id == nil || m.oldValue == nil { 11545 return v, errors.New("OldCoinTypeID requires an ID field in the mutation") 11546 } 11547 oldValue, err := m.oldValue(ctx) 11548 if err != nil { 11549 return v, fmt.Errorf("querying old value for OldCoinTypeID: %w", err) 11550 } 11551 return oldValue.CoinTypeID, nil 11552 } 11553 11554 // ClearCoinTypeID clears the value of the "coin_type_id" field. 11555 func (m *CurrencyHistoryMutation) ClearCoinTypeID() { 11556 m.coin_type_id = nil 11557 m.clearedFields[currencyhistory.FieldCoinTypeID] = struct{}{} 11558 } 11559 11560 // CoinTypeIDCleared returns if the "coin_type_id" field was cleared in this mutation. 11561 func (m *CurrencyHistoryMutation) CoinTypeIDCleared() bool { 11562 _, ok := m.clearedFields[currencyhistory.FieldCoinTypeID] 11563 return ok 11564 } 11565 11566 // ResetCoinTypeID resets all changes to the "coin_type_id" field. 11567 func (m *CurrencyHistoryMutation) ResetCoinTypeID() { 11568 m.coin_type_id = nil 11569 delete(m.clearedFields, currencyhistory.FieldCoinTypeID) 11570 } 11571 11572 // SetFeedType sets the "feed_type" field. 11573 func (m *CurrencyHistoryMutation) SetFeedType(s string) { 11574 m.feed_type = &s 11575 } 11576 11577 // FeedType returns the value of the "feed_type" field in the mutation. 11578 func (m *CurrencyHistoryMutation) FeedType() (r string, exists bool) { 11579 v := m.feed_type 11580 if v == nil { 11581 return 11582 } 11583 return *v, true 11584 } 11585 11586 // OldFeedType returns the old "feed_type" field's value of the CurrencyHistory entity. 11587 // If the CurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 11588 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 11589 func (m *CurrencyHistoryMutation) OldFeedType(ctx context.Context) (v string, err error) { 11590 if !m.op.Is(OpUpdateOne) { 11591 return v, errors.New("OldFeedType is only allowed on UpdateOne operations") 11592 } 11593 if m.id == nil || m.oldValue == nil { 11594 return v, errors.New("OldFeedType requires an ID field in the mutation") 11595 } 11596 oldValue, err := m.oldValue(ctx) 11597 if err != nil { 11598 return v, fmt.Errorf("querying old value for OldFeedType: %w", err) 11599 } 11600 return oldValue.FeedType, nil 11601 } 11602 11603 // ClearFeedType clears the value of the "feed_type" field. 11604 func (m *CurrencyHistoryMutation) ClearFeedType() { 11605 m.feed_type = nil 11606 m.clearedFields[currencyhistory.FieldFeedType] = struct{}{} 11607 } 11608 11609 // FeedTypeCleared returns if the "feed_type" field was cleared in this mutation. 11610 func (m *CurrencyHistoryMutation) FeedTypeCleared() bool { 11611 _, ok := m.clearedFields[currencyhistory.FieldFeedType] 11612 return ok 11613 } 11614 11615 // ResetFeedType resets all changes to the "feed_type" field. 11616 func (m *CurrencyHistoryMutation) ResetFeedType() { 11617 m.feed_type = nil 11618 delete(m.clearedFields, currencyhistory.FieldFeedType) 11619 } 11620 11621 // SetMarketValueHigh sets the "market_value_high" field. 11622 func (m *CurrencyHistoryMutation) SetMarketValueHigh(d decimal.Decimal) { 11623 m.market_value_high = &d 11624 } 11625 11626 // MarketValueHigh returns the value of the "market_value_high" field in the mutation. 11627 func (m *CurrencyHistoryMutation) MarketValueHigh() (r decimal.Decimal, exists bool) { 11628 v := m.market_value_high 11629 if v == nil { 11630 return 11631 } 11632 return *v, true 11633 } 11634 11635 // OldMarketValueHigh returns the old "market_value_high" field's value of the CurrencyHistory entity. 11636 // If the CurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 11637 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 11638 func (m *CurrencyHistoryMutation) OldMarketValueHigh(ctx context.Context) (v decimal.Decimal, err error) { 11639 if !m.op.Is(OpUpdateOne) { 11640 return v, errors.New("OldMarketValueHigh is only allowed on UpdateOne operations") 11641 } 11642 if m.id == nil || m.oldValue == nil { 11643 return v, errors.New("OldMarketValueHigh requires an ID field in the mutation") 11644 } 11645 oldValue, err := m.oldValue(ctx) 11646 if err != nil { 11647 return v, fmt.Errorf("querying old value for OldMarketValueHigh: %w", err) 11648 } 11649 return oldValue.MarketValueHigh, nil 11650 } 11651 11652 // ClearMarketValueHigh clears the value of the "market_value_high" field. 11653 func (m *CurrencyHistoryMutation) ClearMarketValueHigh() { 11654 m.market_value_high = nil 11655 m.clearedFields[currencyhistory.FieldMarketValueHigh] = struct{}{} 11656 } 11657 11658 // MarketValueHighCleared returns if the "market_value_high" field was cleared in this mutation. 11659 func (m *CurrencyHistoryMutation) MarketValueHighCleared() bool { 11660 _, ok := m.clearedFields[currencyhistory.FieldMarketValueHigh] 11661 return ok 11662 } 11663 11664 // ResetMarketValueHigh resets all changes to the "market_value_high" field. 11665 func (m *CurrencyHistoryMutation) ResetMarketValueHigh() { 11666 m.market_value_high = nil 11667 delete(m.clearedFields, currencyhistory.FieldMarketValueHigh) 11668 } 11669 11670 // SetMarketValueLow sets the "market_value_low" field. 11671 func (m *CurrencyHistoryMutation) SetMarketValueLow(d decimal.Decimal) { 11672 m.market_value_low = &d 11673 } 11674 11675 // MarketValueLow returns the value of the "market_value_low" field in the mutation. 11676 func (m *CurrencyHistoryMutation) MarketValueLow() (r decimal.Decimal, exists bool) { 11677 v := m.market_value_low 11678 if v == nil { 11679 return 11680 } 11681 return *v, true 11682 } 11683 11684 // OldMarketValueLow returns the old "market_value_low" field's value of the CurrencyHistory entity. 11685 // If the CurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 11686 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 11687 func (m *CurrencyHistoryMutation) OldMarketValueLow(ctx context.Context) (v decimal.Decimal, err error) { 11688 if !m.op.Is(OpUpdateOne) { 11689 return v, errors.New("OldMarketValueLow is only allowed on UpdateOne operations") 11690 } 11691 if m.id == nil || m.oldValue == nil { 11692 return v, errors.New("OldMarketValueLow requires an ID field in the mutation") 11693 } 11694 oldValue, err := m.oldValue(ctx) 11695 if err != nil { 11696 return v, fmt.Errorf("querying old value for OldMarketValueLow: %w", err) 11697 } 11698 return oldValue.MarketValueLow, nil 11699 } 11700 11701 // ClearMarketValueLow clears the value of the "market_value_low" field. 11702 func (m *CurrencyHistoryMutation) ClearMarketValueLow() { 11703 m.market_value_low = nil 11704 m.clearedFields[currencyhistory.FieldMarketValueLow] = struct{}{} 11705 } 11706 11707 // MarketValueLowCleared returns if the "market_value_low" field was cleared in this mutation. 11708 func (m *CurrencyHistoryMutation) MarketValueLowCleared() bool { 11709 _, ok := m.clearedFields[currencyhistory.FieldMarketValueLow] 11710 return ok 11711 } 11712 11713 // ResetMarketValueLow resets all changes to the "market_value_low" field. 11714 func (m *CurrencyHistoryMutation) ResetMarketValueLow() { 11715 m.market_value_low = nil 11716 delete(m.clearedFields, currencyhistory.FieldMarketValueLow) 11717 } 11718 11719 // Where appends a list predicates to the CurrencyHistoryMutation builder. 11720 func (m *CurrencyHistoryMutation) Where(ps ...predicate.CurrencyHistory) { 11721 m.predicates = append(m.predicates, ps...) 11722 } 11723 11724 // Op returns the operation name. 11725 func (m *CurrencyHistoryMutation) Op() Op { 11726 return m.op 11727 } 11728 11729 // Type returns the node type of this mutation (CurrencyHistory). 11730 func (m *CurrencyHistoryMutation) Type() string { 11731 return m.typ 11732 } 11733 11734 // Fields returns all fields that were changed during this mutation. Note that in 11735 // order to get all numeric fields that were incremented/decremented, call 11736 // AddedFields(). 11737 func (m *CurrencyHistoryMutation) Fields() []string { 11738 fields := make([]string, 0, 8) 11739 if m.created_at != nil { 11740 fields = append(fields, currencyhistory.FieldCreatedAt) 11741 } 11742 if m.updated_at != nil { 11743 fields = append(fields, currencyhistory.FieldUpdatedAt) 11744 } 11745 if m.deleted_at != nil { 11746 fields = append(fields, currencyhistory.FieldDeletedAt) 11747 } 11748 if m.ent_id != nil { 11749 fields = append(fields, currencyhistory.FieldEntID) 11750 } 11751 if m.coin_type_id != nil { 11752 fields = append(fields, currencyhistory.FieldCoinTypeID) 11753 } 11754 if m.feed_type != nil { 11755 fields = append(fields, currencyhistory.FieldFeedType) 11756 } 11757 if m.market_value_high != nil { 11758 fields = append(fields, currencyhistory.FieldMarketValueHigh) 11759 } 11760 if m.market_value_low != nil { 11761 fields = append(fields, currencyhistory.FieldMarketValueLow) 11762 } 11763 return fields 11764 } 11765 11766 // Field returns the value of a field with the given name. The second boolean 11767 // return value indicates that this field was not set, or was not defined in the 11768 // schema. 11769 func (m *CurrencyHistoryMutation) Field(name string) (ent.Value, bool) { 11770 switch name { 11771 case currencyhistory.FieldCreatedAt: 11772 return m.CreatedAt() 11773 case currencyhistory.FieldUpdatedAt: 11774 return m.UpdatedAt() 11775 case currencyhistory.FieldDeletedAt: 11776 return m.DeletedAt() 11777 case currencyhistory.FieldEntID: 11778 return m.EntID() 11779 case currencyhistory.FieldCoinTypeID: 11780 return m.CoinTypeID() 11781 case currencyhistory.FieldFeedType: 11782 return m.FeedType() 11783 case currencyhistory.FieldMarketValueHigh: 11784 return m.MarketValueHigh() 11785 case currencyhistory.FieldMarketValueLow: 11786 return m.MarketValueLow() 11787 } 11788 return nil, false 11789 } 11790 11791 // OldField returns the old value of the field from the database. An error is 11792 // returned if the mutation operation is not UpdateOne, or the query to the 11793 // database failed. 11794 func (m *CurrencyHistoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 11795 switch name { 11796 case currencyhistory.FieldCreatedAt: 11797 return m.OldCreatedAt(ctx) 11798 case currencyhistory.FieldUpdatedAt: 11799 return m.OldUpdatedAt(ctx) 11800 case currencyhistory.FieldDeletedAt: 11801 return m.OldDeletedAt(ctx) 11802 case currencyhistory.FieldEntID: 11803 return m.OldEntID(ctx) 11804 case currencyhistory.FieldCoinTypeID: 11805 return m.OldCoinTypeID(ctx) 11806 case currencyhistory.FieldFeedType: 11807 return m.OldFeedType(ctx) 11808 case currencyhistory.FieldMarketValueHigh: 11809 return m.OldMarketValueHigh(ctx) 11810 case currencyhistory.FieldMarketValueLow: 11811 return m.OldMarketValueLow(ctx) 11812 } 11813 return nil, fmt.Errorf("unknown CurrencyHistory field %s", name) 11814 } 11815 11816 // SetField sets the value of a field with the given name. It returns an error if 11817 // the field is not defined in the schema, or if the type mismatched the field 11818 // type. 11819 func (m *CurrencyHistoryMutation) SetField(name string, value ent.Value) error { 11820 switch name { 11821 case currencyhistory.FieldCreatedAt: 11822 v, ok := value.(uint32) 11823 if !ok { 11824 return fmt.Errorf("unexpected type %T for field %s", value, name) 11825 } 11826 m.SetCreatedAt(v) 11827 return nil 11828 case currencyhistory.FieldUpdatedAt: 11829 v, ok := value.(uint32) 11830 if !ok { 11831 return fmt.Errorf("unexpected type %T for field %s", value, name) 11832 } 11833 m.SetUpdatedAt(v) 11834 return nil 11835 case currencyhistory.FieldDeletedAt: 11836 v, ok := value.(uint32) 11837 if !ok { 11838 return fmt.Errorf("unexpected type %T for field %s", value, name) 11839 } 11840 m.SetDeletedAt(v) 11841 return nil 11842 case currencyhistory.FieldEntID: 11843 v, ok := value.(uuid.UUID) 11844 if !ok { 11845 return fmt.Errorf("unexpected type %T for field %s", value, name) 11846 } 11847 m.SetEntID(v) 11848 return nil 11849 case currencyhistory.FieldCoinTypeID: 11850 v, ok := value.(uuid.UUID) 11851 if !ok { 11852 return fmt.Errorf("unexpected type %T for field %s", value, name) 11853 } 11854 m.SetCoinTypeID(v) 11855 return nil 11856 case currencyhistory.FieldFeedType: 11857 v, ok := value.(string) 11858 if !ok { 11859 return fmt.Errorf("unexpected type %T for field %s", value, name) 11860 } 11861 m.SetFeedType(v) 11862 return nil 11863 case currencyhistory.FieldMarketValueHigh: 11864 v, ok := value.(decimal.Decimal) 11865 if !ok { 11866 return fmt.Errorf("unexpected type %T for field %s", value, name) 11867 } 11868 m.SetMarketValueHigh(v) 11869 return nil 11870 case currencyhistory.FieldMarketValueLow: 11871 v, ok := value.(decimal.Decimal) 11872 if !ok { 11873 return fmt.Errorf("unexpected type %T for field %s", value, name) 11874 } 11875 m.SetMarketValueLow(v) 11876 return nil 11877 } 11878 return fmt.Errorf("unknown CurrencyHistory field %s", name) 11879 } 11880 11881 // AddedFields returns all numeric fields that were incremented/decremented during 11882 // this mutation. 11883 func (m *CurrencyHistoryMutation) AddedFields() []string { 11884 var fields []string 11885 if m.addcreated_at != nil { 11886 fields = append(fields, currencyhistory.FieldCreatedAt) 11887 } 11888 if m.addupdated_at != nil { 11889 fields = append(fields, currencyhistory.FieldUpdatedAt) 11890 } 11891 if m.adddeleted_at != nil { 11892 fields = append(fields, currencyhistory.FieldDeletedAt) 11893 } 11894 return fields 11895 } 11896 11897 // AddedField returns the numeric value that was incremented/decremented on a field 11898 // with the given name. The second boolean return value indicates that this field 11899 // was not set, or was not defined in the schema. 11900 func (m *CurrencyHistoryMutation) AddedField(name string) (ent.Value, bool) { 11901 switch name { 11902 case currencyhistory.FieldCreatedAt: 11903 return m.AddedCreatedAt() 11904 case currencyhistory.FieldUpdatedAt: 11905 return m.AddedUpdatedAt() 11906 case currencyhistory.FieldDeletedAt: 11907 return m.AddedDeletedAt() 11908 } 11909 return nil, false 11910 } 11911 11912 // AddField adds the value to the field with the given name. It returns an error if 11913 // the field is not defined in the schema, or if the type mismatched the field 11914 // type. 11915 func (m *CurrencyHistoryMutation) AddField(name string, value ent.Value) error { 11916 switch name { 11917 case currencyhistory.FieldCreatedAt: 11918 v, ok := value.(int32) 11919 if !ok { 11920 return fmt.Errorf("unexpected type %T for field %s", value, name) 11921 } 11922 m.AddCreatedAt(v) 11923 return nil 11924 case currencyhistory.FieldUpdatedAt: 11925 v, ok := value.(int32) 11926 if !ok { 11927 return fmt.Errorf("unexpected type %T for field %s", value, name) 11928 } 11929 m.AddUpdatedAt(v) 11930 return nil 11931 case currencyhistory.FieldDeletedAt: 11932 v, ok := value.(int32) 11933 if !ok { 11934 return fmt.Errorf("unexpected type %T for field %s", value, name) 11935 } 11936 m.AddDeletedAt(v) 11937 return nil 11938 } 11939 return fmt.Errorf("unknown CurrencyHistory numeric field %s", name) 11940 } 11941 11942 // ClearedFields returns all nullable fields that were cleared during this 11943 // mutation. 11944 func (m *CurrencyHistoryMutation) ClearedFields() []string { 11945 var fields []string 11946 if m.FieldCleared(currencyhistory.FieldCoinTypeID) { 11947 fields = append(fields, currencyhistory.FieldCoinTypeID) 11948 } 11949 if m.FieldCleared(currencyhistory.FieldFeedType) { 11950 fields = append(fields, currencyhistory.FieldFeedType) 11951 } 11952 if m.FieldCleared(currencyhistory.FieldMarketValueHigh) { 11953 fields = append(fields, currencyhistory.FieldMarketValueHigh) 11954 } 11955 if m.FieldCleared(currencyhistory.FieldMarketValueLow) { 11956 fields = append(fields, currencyhistory.FieldMarketValueLow) 11957 } 11958 return fields 11959 } 11960 11961 // FieldCleared returns a boolean indicating if a field with the given name was 11962 // cleared in this mutation. 11963 func (m *CurrencyHistoryMutation) FieldCleared(name string) bool { 11964 _, ok := m.clearedFields[name] 11965 return ok 11966 } 11967 11968 // ClearField clears the value of the field with the given name. It returns an 11969 // error if the field is not defined in the schema. 11970 func (m *CurrencyHistoryMutation) ClearField(name string) error { 11971 switch name { 11972 case currencyhistory.FieldCoinTypeID: 11973 m.ClearCoinTypeID() 11974 return nil 11975 case currencyhistory.FieldFeedType: 11976 m.ClearFeedType() 11977 return nil 11978 case currencyhistory.FieldMarketValueHigh: 11979 m.ClearMarketValueHigh() 11980 return nil 11981 case currencyhistory.FieldMarketValueLow: 11982 m.ClearMarketValueLow() 11983 return nil 11984 } 11985 return fmt.Errorf("unknown CurrencyHistory nullable field %s", name) 11986 } 11987 11988 // ResetField resets all changes in the mutation for the field with the given name. 11989 // It returns an error if the field is not defined in the schema. 11990 func (m *CurrencyHistoryMutation) ResetField(name string) error { 11991 switch name { 11992 case currencyhistory.FieldCreatedAt: 11993 m.ResetCreatedAt() 11994 return nil 11995 case currencyhistory.FieldUpdatedAt: 11996 m.ResetUpdatedAt() 11997 return nil 11998 case currencyhistory.FieldDeletedAt: 11999 m.ResetDeletedAt() 12000 return nil 12001 case currencyhistory.FieldEntID: 12002 m.ResetEntID() 12003 return nil 12004 case currencyhistory.FieldCoinTypeID: 12005 m.ResetCoinTypeID() 12006 return nil 12007 case currencyhistory.FieldFeedType: 12008 m.ResetFeedType() 12009 return nil 12010 case currencyhistory.FieldMarketValueHigh: 12011 m.ResetMarketValueHigh() 12012 return nil 12013 case currencyhistory.FieldMarketValueLow: 12014 m.ResetMarketValueLow() 12015 return nil 12016 } 12017 return fmt.Errorf("unknown CurrencyHistory field %s", name) 12018 } 12019 12020 // AddedEdges returns all edge names that were set/added in this mutation. 12021 func (m *CurrencyHistoryMutation) AddedEdges() []string { 12022 edges := make([]string, 0, 0) 12023 return edges 12024 } 12025 12026 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 12027 // name in this mutation. 12028 func (m *CurrencyHistoryMutation) AddedIDs(name string) []ent.Value { 12029 return nil 12030 } 12031 12032 // RemovedEdges returns all edge names that were removed in this mutation. 12033 func (m *CurrencyHistoryMutation) RemovedEdges() []string { 12034 edges := make([]string, 0, 0) 12035 return edges 12036 } 12037 12038 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 12039 // the given name in this mutation. 12040 func (m *CurrencyHistoryMutation) RemovedIDs(name string) []ent.Value { 12041 return nil 12042 } 12043 12044 // ClearedEdges returns all edge names that were cleared in this mutation. 12045 func (m *CurrencyHistoryMutation) ClearedEdges() []string { 12046 edges := make([]string, 0, 0) 12047 return edges 12048 } 12049 12050 // EdgeCleared returns a boolean which indicates if the edge with the given name 12051 // was cleared in this mutation. 12052 func (m *CurrencyHistoryMutation) EdgeCleared(name string) bool { 12053 return false 12054 } 12055 12056 // ClearEdge clears the value of the edge with the given name. It returns an error 12057 // if that edge is not defined in the schema. 12058 func (m *CurrencyHistoryMutation) ClearEdge(name string) error { 12059 return fmt.Errorf("unknown CurrencyHistory unique edge %s", name) 12060 } 12061 12062 // ResetEdge resets all changes to the edge with the given name in this mutation. 12063 // It returns an error if the edge is not defined in the schema. 12064 func (m *CurrencyHistoryMutation) ResetEdge(name string) error { 12065 return fmt.Errorf("unknown CurrencyHistory edge %s", name) 12066 } 12067 12068 // ExchangeRateMutation represents an operation that mutates the ExchangeRate nodes in the graph. 12069 type ExchangeRateMutation struct { 12070 config 12071 op Op 12072 typ string 12073 id *uint32 12074 created_at *uint32 12075 addcreated_at *int32 12076 updated_at *uint32 12077 addupdated_at *int32 12078 deleted_at *uint32 12079 adddeleted_at *int32 12080 ent_id *uuid.UUID 12081 app_id *uuid.UUID 12082 coin_type_id *uuid.UUID 12083 market_value *decimal.Decimal 12084 settle_value *decimal.Decimal 12085 settle_percent *uint32 12086 addsettle_percent *int32 12087 settle_tips *[]string 12088 setter *uuid.UUID 12089 clearedFields map[string]struct{} 12090 done bool 12091 oldValue func(context.Context) (*ExchangeRate, error) 12092 predicates []predicate.ExchangeRate 12093 } 12094 12095 var _ ent.Mutation = (*ExchangeRateMutation)(nil) 12096 12097 // exchangerateOption allows management of the mutation configuration using functional options. 12098 type exchangerateOption func(*ExchangeRateMutation) 12099 12100 // newExchangeRateMutation creates new mutation for the ExchangeRate entity. 12101 func newExchangeRateMutation(c config, op Op, opts ...exchangerateOption) *ExchangeRateMutation { 12102 m := &ExchangeRateMutation{ 12103 config: c, 12104 op: op, 12105 typ: TypeExchangeRate, 12106 clearedFields: make(map[string]struct{}), 12107 } 12108 for _, opt := range opts { 12109 opt(m) 12110 } 12111 return m 12112 } 12113 12114 // withExchangeRateID sets the ID field of the mutation. 12115 func withExchangeRateID(id uint32) exchangerateOption { 12116 return func(m *ExchangeRateMutation) { 12117 var ( 12118 err error 12119 once sync.Once 12120 value *ExchangeRate 12121 ) 12122 m.oldValue = func(ctx context.Context) (*ExchangeRate, error) { 12123 once.Do(func() { 12124 if m.done { 12125 err = errors.New("querying old values post mutation is not allowed") 12126 } else { 12127 value, err = m.Client().ExchangeRate.Get(ctx, id) 12128 } 12129 }) 12130 return value, err 12131 } 12132 m.id = &id 12133 } 12134 } 12135 12136 // withExchangeRate sets the old ExchangeRate of the mutation. 12137 func withExchangeRate(node *ExchangeRate) exchangerateOption { 12138 return func(m *ExchangeRateMutation) { 12139 m.oldValue = func(context.Context) (*ExchangeRate, error) { 12140 return node, nil 12141 } 12142 m.id = &node.ID 12143 } 12144 } 12145 12146 // Client returns a new `ent.Client` from the mutation. If the mutation was 12147 // executed in a transaction (ent.Tx), a transactional client is returned. 12148 func (m ExchangeRateMutation) Client() *Client { 12149 client := &Client{config: m.config} 12150 client.init() 12151 return client 12152 } 12153 12154 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 12155 // it returns an error otherwise. 12156 func (m ExchangeRateMutation) Tx() (*Tx, error) { 12157 if _, ok := m.driver.(*txDriver); !ok { 12158 return nil, errors.New("ent: mutation is not running in a transaction") 12159 } 12160 tx := &Tx{config: m.config} 12161 tx.init() 12162 return tx, nil 12163 } 12164 12165 // SetID sets the value of the id field. Note that this 12166 // operation is only accepted on creation of ExchangeRate entities. 12167 func (m *ExchangeRateMutation) SetID(id uint32) { 12168 m.id = &id 12169 } 12170 12171 // ID returns the ID value in the mutation. Note that the ID is only available 12172 // if it was provided to the builder or after it was returned from the database. 12173 func (m *ExchangeRateMutation) ID() (id uint32, exists bool) { 12174 if m.id == nil { 12175 return 12176 } 12177 return *m.id, true 12178 } 12179 12180 // IDs queries the database and returns the entity ids that match the mutation's predicate. 12181 // That means, if the mutation is applied within a transaction with an isolation level such 12182 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 12183 // or updated by the mutation. 12184 func (m *ExchangeRateMutation) IDs(ctx context.Context) ([]uint32, error) { 12185 switch { 12186 case m.op.Is(OpUpdateOne | OpDeleteOne): 12187 id, exists := m.ID() 12188 if exists { 12189 return []uint32{id}, nil 12190 } 12191 fallthrough 12192 case m.op.Is(OpUpdate | OpDelete): 12193 return m.Client().ExchangeRate.Query().Where(m.predicates...).IDs(ctx) 12194 default: 12195 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 12196 } 12197 } 12198 12199 // SetCreatedAt sets the "created_at" field. 12200 func (m *ExchangeRateMutation) SetCreatedAt(u uint32) { 12201 m.created_at = &u 12202 m.addcreated_at = nil 12203 } 12204 12205 // CreatedAt returns the value of the "created_at" field in the mutation. 12206 func (m *ExchangeRateMutation) CreatedAt() (r uint32, exists bool) { 12207 v := m.created_at 12208 if v == nil { 12209 return 12210 } 12211 return *v, true 12212 } 12213 12214 // OldCreatedAt returns the old "created_at" field's value of the ExchangeRate entity. 12215 // If the ExchangeRate object wasn't provided to the builder, the object is fetched from the database. 12216 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 12217 func (m *ExchangeRateMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 12218 if !m.op.Is(OpUpdateOne) { 12219 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 12220 } 12221 if m.id == nil || m.oldValue == nil { 12222 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 12223 } 12224 oldValue, err := m.oldValue(ctx) 12225 if err != nil { 12226 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 12227 } 12228 return oldValue.CreatedAt, nil 12229 } 12230 12231 // AddCreatedAt adds u to the "created_at" field. 12232 func (m *ExchangeRateMutation) AddCreatedAt(u int32) { 12233 if m.addcreated_at != nil { 12234 *m.addcreated_at += u 12235 } else { 12236 m.addcreated_at = &u 12237 } 12238 } 12239 12240 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 12241 func (m *ExchangeRateMutation) AddedCreatedAt() (r int32, exists bool) { 12242 v := m.addcreated_at 12243 if v == nil { 12244 return 12245 } 12246 return *v, true 12247 } 12248 12249 // ResetCreatedAt resets all changes to the "created_at" field. 12250 func (m *ExchangeRateMutation) ResetCreatedAt() { 12251 m.created_at = nil 12252 m.addcreated_at = nil 12253 } 12254 12255 // SetUpdatedAt sets the "updated_at" field. 12256 func (m *ExchangeRateMutation) SetUpdatedAt(u uint32) { 12257 m.updated_at = &u 12258 m.addupdated_at = nil 12259 } 12260 12261 // UpdatedAt returns the value of the "updated_at" field in the mutation. 12262 func (m *ExchangeRateMutation) UpdatedAt() (r uint32, exists bool) { 12263 v := m.updated_at 12264 if v == nil { 12265 return 12266 } 12267 return *v, true 12268 } 12269 12270 // OldUpdatedAt returns the old "updated_at" field's value of the ExchangeRate entity. 12271 // If the ExchangeRate object wasn't provided to the builder, the object is fetched from the database. 12272 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 12273 func (m *ExchangeRateMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 12274 if !m.op.Is(OpUpdateOne) { 12275 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 12276 } 12277 if m.id == nil || m.oldValue == nil { 12278 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 12279 } 12280 oldValue, err := m.oldValue(ctx) 12281 if err != nil { 12282 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 12283 } 12284 return oldValue.UpdatedAt, nil 12285 } 12286 12287 // AddUpdatedAt adds u to the "updated_at" field. 12288 func (m *ExchangeRateMutation) AddUpdatedAt(u int32) { 12289 if m.addupdated_at != nil { 12290 *m.addupdated_at += u 12291 } else { 12292 m.addupdated_at = &u 12293 } 12294 } 12295 12296 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 12297 func (m *ExchangeRateMutation) AddedUpdatedAt() (r int32, exists bool) { 12298 v := m.addupdated_at 12299 if v == nil { 12300 return 12301 } 12302 return *v, true 12303 } 12304 12305 // ResetUpdatedAt resets all changes to the "updated_at" field. 12306 func (m *ExchangeRateMutation) ResetUpdatedAt() { 12307 m.updated_at = nil 12308 m.addupdated_at = nil 12309 } 12310 12311 // SetDeletedAt sets the "deleted_at" field. 12312 func (m *ExchangeRateMutation) SetDeletedAt(u uint32) { 12313 m.deleted_at = &u 12314 m.adddeleted_at = nil 12315 } 12316 12317 // DeletedAt returns the value of the "deleted_at" field in the mutation. 12318 func (m *ExchangeRateMutation) DeletedAt() (r uint32, exists bool) { 12319 v := m.deleted_at 12320 if v == nil { 12321 return 12322 } 12323 return *v, true 12324 } 12325 12326 // OldDeletedAt returns the old "deleted_at" field's value of the ExchangeRate entity. 12327 // If the ExchangeRate object wasn't provided to the builder, the object is fetched from the database. 12328 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 12329 func (m *ExchangeRateMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 12330 if !m.op.Is(OpUpdateOne) { 12331 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 12332 } 12333 if m.id == nil || m.oldValue == nil { 12334 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 12335 } 12336 oldValue, err := m.oldValue(ctx) 12337 if err != nil { 12338 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 12339 } 12340 return oldValue.DeletedAt, nil 12341 } 12342 12343 // AddDeletedAt adds u to the "deleted_at" field. 12344 func (m *ExchangeRateMutation) AddDeletedAt(u int32) { 12345 if m.adddeleted_at != nil { 12346 *m.adddeleted_at += u 12347 } else { 12348 m.adddeleted_at = &u 12349 } 12350 } 12351 12352 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 12353 func (m *ExchangeRateMutation) AddedDeletedAt() (r int32, exists bool) { 12354 v := m.adddeleted_at 12355 if v == nil { 12356 return 12357 } 12358 return *v, true 12359 } 12360 12361 // ResetDeletedAt resets all changes to the "deleted_at" field. 12362 func (m *ExchangeRateMutation) ResetDeletedAt() { 12363 m.deleted_at = nil 12364 m.adddeleted_at = nil 12365 } 12366 12367 // SetEntID sets the "ent_id" field. 12368 func (m *ExchangeRateMutation) SetEntID(u uuid.UUID) { 12369 m.ent_id = &u 12370 } 12371 12372 // EntID returns the value of the "ent_id" field in the mutation. 12373 func (m *ExchangeRateMutation) EntID() (r uuid.UUID, exists bool) { 12374 v := m.ent_id 12375 if v == nil { 12376 return 12377 } 12378 return *v, true 12379 } 12380 12381 // OldEntID returns the old "ent_id" field's value of the ExchangeRate entity. 12382 // If the ExchangeRate object wasn't provided to the builder, the object is fetched from the database. 12383 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 12384 func (m *ExchangeRateMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 12385 if !m.op.Is(OpUpdateOne) { 12386 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 12387 } 12388 if m.id == nil || m.oldValue == nil { 12389 return v, errors.New("OldEntID requires an ID field in the mutation") 12390 } 12391 oldValue, err := m.oldValue(ctx) 12392 if err != nil { 12393 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 12394 } 12395 return oldValue.EntID, nil 12396 } 12397 12398 // ResetEntID resets all changes to the "ent_id" field. 12399 func (m *ExchangeRateMutation) ResetEntID() { 12400 m.ent_id = nil 12401 } 12402 12403 // SetAppID sets the "app_id" field. 12404 func (m *ExchangeRateMutation) SetAppID(u uuid.UUID) { 12405 m.app_id = &u 12406 } 12407 12408 // AppID returns the value of the "app_id" field in the mutation. 12409 func (m *ExchangeRateMutation) AppID() (r uuid.UUID, exists bool) { 12410 v := m.app_id 12411 if v == nil { 12412 return 12413 } 12414 return *v, true 12415 } 12416 12417 // OldAppID returns the old "app_id" field's value of the ExchangeRate entity. 12418 // If the ExchangeRate object wasn't provided to the builder, the object is fetched from the database. 12419 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 12420 func (m *ExchangeRateMutation) OldAppID(ctx context.Context) (v uuid.UUID, err error) { 12421 if !m.op.Is(OpUpdateOne) { 12422 return v, errors.New("OldAppID is only allowed on UpdateOne operations") 12423 } 12424 if m.id == nil || m.oldValue == nil { 12425 return v, errors.New("OldAppID requires an ID field in the mutation") 12426 } 12427 oldValue, err := m.oldValue(ctx) 12428 if err != nil { 12429 return v, fmt.Errorf("querying old value for OldAppID: %w", err) 12430 } 12431 return oldValue.AppID, nil 12432 } 12433 12434 // ClearAppID clears the value of the "app_id" field. 12435 func (m *ExchangeRateMutation) ClearAppID() { 12436 m.app_id = nil 12437 m.clearedFields[exchangerate.FieldAppID] = struct{}{} 12438 } 12439 12440 // AppIDCleared returns if the "app_id" field was cleared in this mutation. 12441 func (m *ExchangeRateMutation) AppIDCleared() bool { 12442 _, ok := m.clearedFields[exchangerate.FieldAppID] 12443 return ok 12444 } 12445 12446 // ResetAppID resets all changes to the "app_id" field. 12447 func (m *ExchangeRateMutation) ResetAppID() { 12448 m.app_id = nil 12449 delete(m.clearedFields, exchangerate.FieldAppID) 12450 } 12451 12452 // SetCoinTypeID sets the "coin_type_id" field. 12453 func (m *ExchangeRateMutation) SetCoinTypeID(u uuid.UUID) { 12454 m.coin_type_id = &u 12455 } 12456 12457 // CoinTypeID returns the value of the "coin_type_id" field in the mutation. 12458 func (m *ExchangeRateMutation) CoinTypeID() (r uuid.UUID, exists bool) { 12459 v := m.coin_type_id 12460 if v == nil { 12461 return 12462 } 12463 return *v, true 12464 } 12465 12466 // OldCoinTypeID returns the old "coin_type_id" field's value of the ExchangeRate entity. 12467 // If the ExchangeRate object wasn't provided to the builder, the object is fetched from the database. 12468 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 12469 func (m *ExchangeRateMutation) OldCoinTypeID(ctx context.Context) (v uuid.UUID, err error) { 12470 if !m.op.Is(OpUpdateOne) { 12471 return v, errors.New("OldCoinTypeID is only allowed on UpdateOne operations") 12472 } 12473 if m.id == nil || m.oldValue == nil { 12474 return v, errors.New("OldCoinTypeID requires an ID field in the mutation") 12475 } 12476 oldValue, err := m.oldValue(ctx) 12477 if err != nil { 12478 return v, fmt.Errorf("querying old value for OldCoinTypeID: %w", err) 12479 } 12480 return oldValue.CoinTypeID, nil 12481 } 12482 12483 // ClearCoinTypeID clears the value of the "coin_type_id" field. 12484 func (m *ExchangeRateMutation) ClearCoinTypeID() { 12485 m.coin_type_id = nil 12486 m.clearedFields[exchangerate.FieldCoinTypeID] = struct{}{} 12487 } 12488 12489 // CoinTypeIDCleared returns if the "coin_type_id" field was cleared in this mutation. 12490 func (m *ExchangeRateMutation) CoinTypeIDCleared() bool { 12491 _, ok := m.clearedFields[exchangerate.FieldCoinTypeID] 12492 return ok 12493 } 12494 12495 // ResetCoinTypeID resets all changes to the "coin_type_id" field. 12496 func (m *ExchangeRateMutation) ResetCoinTypeID() { 12497 m.coin_type_id = nil 12498 delete(m.clearedFields, exchangerate.FieldCoinTypeID) 12499 } 12500 12501 // SetMarketValue sets the "market_value" field. 12502 func (m *ExchangeRateMutation) SetMarketValue(d decimal.Decimal) { 12503 m.market_value = &d 12504 } 12505 12506 // MarketValue returns the value of the "market_value" field in the mutation. 12507 func (m *ExchangeRateMutation) MarketValue() (r decimal.Decimal, exists bool) { 12508 v := m.market_value 12509 if v == nil { 12510 return 12511 } 12512 return *v, true 12513 } 12514 12515 // OldMarketValue returns the old "market_value" field's value of the ExchangeRate entity. 12516 // If the ExchangeRate object wasn't provided to the builder, the object is fetched from the database. 12517 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 12518 func (m *ExchangeRateMutation) OldMarketValue(ctx context.Context) (v decimal.Decimal, err error) { 12519 if !m.op.Is(OpUpdateOne) { 12520 return v, errors.New("OldMarketValue is only allowed on UpdateOne operations") 12521 } 12522 if m.id == nil || m.oldValue == nil { 12523 return v, errors.New("OldMarketValue requires an ID field in the mutation") 12524 } 12525 oldValue, err := m.oldValue(ctx) 12526 if err != nil { 12527 return v, fmt.Errorf("querying old value for OldMarketValue: %w", err) 12528 } 12529 return oldValue.MarketValue, nil 12530 } 12531 12532 // ClearMarketValue clears the value of the "market_value" field. 12533 func (m *ExchangeRateMutation) ClearMarketValue() { 12534 m.market_value = nil 12535 m.clearedFields[exchangerate.FieldMarketValue] = struct{}{} 12536 } 12537 12538 // MarketValueCleared returns if the "market_value" field was cleared in this mutation. 12539 func (m *ExchangeRateMutation) MarketValueCleared() bool { 12540 _, ok := m.clearedFields[exchangerate.FieldMarketValue] 12541 return ok 12542 } 12543 12544 // ResetMarketValue resets all changes to the "market_value" field. 12545 func (m *ExchangeRateMutation) ResetMarketValue() { 12546 m.market_value = nil 12547 delete(m.clearedFields, exchangerate.FieldMarketValue) 12548 } 12549 12550 // SetSettleValue sets the "settle_value" field. 12551 func (m *ExchangeRateMutation) SetSettleValue(d decimal.Decimal) { 12552 m.settle_value = &d 12553 } 12554 12555 // SettleValue returns the value of the "settle_value" field in the mutation. 12556 func (m *ExchangeRateMutation) SettleValue() (r decimal.Decimal, exists bool) { 12557 v := m.settle_value 12558 if v == nil { 12559 return 12560 } 12561 return *v, true 12562 } 12563 12564 // OldSettleValue returns the old "settle_value" field's value of the ExchangeRate entity. 12565 // If the ExchangeRate object wasn't provided to the builder, the object is fetched from the database. 12566 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 12567 func (m *ExchangeRateMutation) OldSettleValue(ctx context.Context) (v decimal.Decimal, err error) { 12568 if !m.op.Is(OpUpdateOne) { 12569 return v, errors.New("OldSettleValue is only allowed on UpdateOne operations") 12570 } 12571 if m.id == nil || m.oldValue == nil { 12572 return v, errors.New("OldSettleValue requires an ID field in the mutation") 12573 } 12574 oldValue, err := m.oldValue(ctx) 12575 if err != nil { 12576 return v, fmt.Errorf("querying old value for OldSettleValue: %w", err) 12577 } 12578 return oldValue.SettleValue, nil 12579 } 12580 12581 // ClearSettleValue clears the value of the "settle_value" field. 12582 func (m *ExchangeRateMutation) ClearSettleValue() { 12583 m.settle_value = nil 12584 m.clearedFields[exchangerate.FieldSettleValue] = struct{}{} 12585 } 12586 12587 // SettleValueCleared returns if the "settle_value" field was cleared in this mutation. 12588 func (m *ExchangeRateMutation) SettleValueCleared() bool { 12589 _, ok := m.clearedFields[exchangerate.FieldSettleValue] 12590 return ok 12591 } 12592 12593 // ResetSettleValue resets all changes to the "settle_value" field. 12594 func (m *ExchangeRateMutation) ResetSettleValue() { 12595 m.settle_value = nil 12596 delete(m.clearedFields, exchangerate.FieldSettleValue) 12597 } 12598 12599 // SetSettlePercent sets the "settle_percent" field. 12600 func (m *ExchangeRateMutation) SetSettlePercent(u uint32) { 12601 m.settle_percent = &u 12602 m.addsettle_percent = nil 12603 } 12604 12605 // SettlePercent returns the value of the "settle_percent" field in the mutation. 12606 func (m *ExchangeRateMutation) SettlePercent() (r uint32, exists bool) { 12607 v := m.settle_percent 12608 if v == nil { 12609 return 12610 } 12611 return *v, true 12612 } 12613 12614 // OldSettlePercent returns the old "settle_percent" field's value of the ExchangeRate entity. 12615 // If the ExchangeRate object wasn't provided to the builder, the object is fetched from the database. 12616 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 12617 func (m *ExchangeRateMutation) OldSettlePercent(ctx context.Context) (v uint32, err error) { 12618 if !m.op.Is(OpUpdateOne) { 12619 return v, errors.New("OldSettlePercent is only allowed on UpdateOne operations") 12620 } 12621 if m.id == nil || m.oldValue == nil { 12622 return v, errors.New("OldSettlePercent requires an ID field in the mutation") 12623 } 12624 oldValue, err := m.oldValue(ctx) 12625 if err != nil { 12626 return v, fmt.Errorf("querying old value for OldSettlePercent: %w", err) 12627 } 12628 return oldValue.SettlePercent, nil 12629 } 12630 12631 // AddSettlePercent adds u to the "settle_percent" field. 12632 func (m *ExchangeRateMutation) AddSettlePercent(u int32) { 12633 if m.addsettle_percent != nil { 12634 *m.addsettle_percent += u 12635 } else { 12636 m.addsettle_percent = &u 12637 } 12638 } 12639 12640 // AddedSettlePercent returns the value that was added to the "settle_percent" field in this mutation. 12641 func (m *ExchangeRateMutation) AddedSettlePercent() (r int32, exists bool) { 12642 v := m.addsettle_percent 12643 if v == nil { 12644 return 12645 } 12646 return *v, true 12647 } 12648 12649 // ClearSettlePercent clears the value of the "settle_percent" field. 12650 func (m *ExchangeRateMutation) ClearSettlePercent() { 12651 m.settle_percent = nil 12652 m.addsettle_percent = nil 12653 m.clearedFields[exchangerate.FieldSettlePercent] = struct{}{} 12654 } 12655 12656 // SettlePercentCleared returns if the "settle_percent" field was cleared in this mutation. 12657 func (m *ExchangeRateMutation) SettlePercentCleared() bool { 12658 _, ok := m.clearedFields[exchangerate.FieldSettlePercent] 12659 return ok 12660 } 12661 12662 // ResetSettlePercent resets all changes to the "settle_percent" field. 12663 func (m *ExchangeRateMutation) ResetSettlePercent() { 12664 m.settle_percent = nil 12665 m.addsettle_percent = nil 12666 delete(m.clearedFields, exchangerate.FieldSettlePercent) 12667 } 12668 12669 // SetSettleTips sets the "settle_tips" field. 12670 func (m *ExchangeRateMutation) SetSettleTips(s []string) { 12671 m.settle_tips = &s 12672 } 12673 12674 // SettleTips returns the value of the "settle_tips" field in the mutation. 12675 func (m *ExchangeRateMutation) SettleTips() (r []string, exists bool) { 12676 v := m.settle_tips 12677 if v == nil { 12678 return 12679 } 12680 return *v, true 12681 } 12682 12683 // OldSettleTips returns the old "settle_tips" field's value of the ExchangeRate entity. 12684 // If the ExchangeRate object wasn't provided to the builder, the object is fetched from the database. 12685 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 12686 func (m *ExchangeRateMutation) OldSettleTips(ctx context.Context) (v []string, err error) { 12687 if !m.op.Is(OpUpdateOne) { 12688 return v, errors.New("OldSettleTips is only allowed on UpdateOne operations") 12689 } 12690 if m.id == nil || m.oldValue == nil { 12691 return v, errors.New("OldSettleTips requires an ID field in the mutation") 12692 } 12693 oldValue, err := m.oldValue(ctx) 12694 if err != nil { 12695 return v, fmt.Errorf("querying old value for OldSettleTips: %w", err) 12696 } 12697 return oldValue.SettleTips, nil 12698 } 12699 12700 // ClearSettleTips clears the value of the "settle_tips" field. 12701 func (m *ExchangeRateMutation) ClearSettleTips() { 12702 m.settle_tips = nil 12703 m.clearedFields[exchangerate.FieldSettleTips] = struct{}{} 12704 } 12705 12706 // SettleTipsCleared returns if the "settle_tips" field was cleared in this mutation. 12707 func (m *ExchangeRateMutation) SettleTipsCleared() bool { 12708 _, ok := m.clearedFields[exchangerate.FieldSettleTips] 12709 return ok 12710 } 12711 12712 // ResetSettleTips resets all changes to the "settle_tips" field. 12713 func (m *ExchangeRateMutation) ResetSettleTips() { 12714 m.settle_tips = nil 12715 delete(m.clearedFields, exchangerate.FieldSettleTips) 12716 } 12717 12718 // SetSetter sets the "setter" field. 12719 func (m *ExchangeRateMutation) SetSetter(u uuid.UUID) { 12720 m.setter = &u 12721 } 12722 12723 // Setter returns the value of the "setter" field in the mutation. 12724 func (m *ExchangeRateMutation) Setter() (r uuid.UUID, exists bool) { 12725 v := m.setter 12726 if v == nil { 12727 return 12728 } 12729 return *v, true 12730 } 12731 12732 // OldSetter returns the old "setter" field's value of the ExchangeRate entity. 12733 // If the ExchangeRate object wasn't provided to the builder, the object is fetched from the database. 12734 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 12735 func (m *ExchangeRateMutation) OldSetter(ctx context.Context) (v uuid.UUID, err error) { 12736 if !m.op.Is(OpUpdateOne) { 12737 return v, errors.New("OldSetter is only allowed on UpdateOne operations") 12738 } 12739 if m.id == nil || m.oldValue == nil { 12740 return v, errors.New("OldSetter requires an ID field in the mutation") 12741 } 12742 oldValue, err := m.oldValue(ctx) 12743 if err != nil { 12744 return v, fmt.Errorf("querying old value for OldSetter: %w", err) 12745 } 12746 return oldValue.Setter, nil 12747 } 12748 12749 // ClearSetter clears the value of the "setter" field. 12750 func (m *ExchangeRateMutation) ClearSetter() { 12751 m.setter = nil 12752 m.clearedFields[exchangerate.FieldSetter] = struct{}{} 12753 } 12754 12755 // SetterCleared returns if the "setter" field was cleared in this mutation. 12756 func (m *ExchangeRateMutation) SetterCleared() bool { 12757 _, ok := m.clearedFields[exchangerate.FieldSetter] 12758 return ok 12759 } 12760 12761 // ResetSetter resets all changes to the "setter" field. 12762 func (m *ExchangeRateMutation) ResetSetter() { 12763 m.setter = nil 12764 delete(m.clearedFields, exchangerate.FieldSetter) 12765 } 12766 12767 // Where appends a list predicates to the ExchangeRateMutation builder. 12768 func (m *ExchangeRateMutation) Where(ps ...predicate.ExchangeRate) { 12769 m.predicates = append(m.predicates, ps...) 12770 } 12771 12772 // Op returns the operation name. 12773 func (m *ExchangeRateMutation) Op() Op { 12774 return m.op 12775 } 12776 12777 // Type returns the node type of this mutation (ExchangeRate). 12778 func (m *ExchangeRateMutation) Type() string { 12779 return m.typ 12780 } 12781 12782 // Fields returns all fields that were changed during this mutation. Note that in 12783 // order to get all numeric fields that were incremented/decremented, call 12784 // AddedFields(). 12785 func (m *ExchangeRateMutation) Fields() []string { 12786 fields := make([]string, 0, 11) 12787 if m.created_at != nil { 12788 fields = append(fields, exchangerate.FieldCreatedAt) 12789 } 12790 if m.updated_at != nil { 12791 fields = append(fields, exchangerate.FieldUpdatedAt) 12792 } 12793 if m.deleted_at != nil { 12794 fields = append(fields, exchangerate.FieldDeletedAt) 12795 } 12796 if m.ent_id != nil { 12797 fields = append(fields, exchangerate.FieldEntID) 12798 } 12799 if m.app_id != nil { 12800 fields = append(fields, exchangerate.FieldAppID) 12801 } 12802 if m.coin_type_id != nil { 12803 fields = append(fields, exchangerate.FieldCoinTypeID) 12804 } 12805 if m.market_value != nil { 12806 fields = append(fields, exchangerate.FieldMarketValue) 12807 } 12808 if m.settle_value != nil { 12809 fields = append(fields, exchangerate.FieldSettleValue) 12810 } 12811 if m.settle_percent != nil { 12812 fields = append(fields, exchangerate.FieldSettlePercent) 12813 } 12814 if m.settle_tips != nil { 12815 fields = append(fields, exchangerate.FieldSettleTips) 12816 } 12817 if m.setter != nil { 12818 fields = append(fields, exchangerate.FieldSetter) 12819 } 12820 return fields 12821 } 12822 12823 // Field returns the value of a field with the given name. The second boolean 12824 // return value indicates that this field was not set, or was not defined in the 12825 // schema. 12826 func (m *ExchangeRateMutation) Field(name string) (ent.Value, bool) { 12827 switch name { 12828 case exchangerate.FieldCreatedAt: 12829 return m.CreatedAt() 12830 case exchangerate.FieldUpdatedAt: 12831 return m.UpdatedAt() 12832 case exchangerate.FieldDeletedAt: 12833 return m.DeletedAt() 12834 case exchangerate.FieldEntID: 12835 return m.EntID() 12836 case exchangerate.FieldAppID: 12837 return m.AppID() 12838 case exchangerate.FieldCoinTypeID: 12839 return m.CoinTypeID() 12840 case exchangerate.FieldMarketValue: 12841 return m.MarketValue() 12842 case exchangerate.FieldSettleValue: 12843 return m.SettleValue() 12844 case exchangerate.FieldSettlePercent: 12845 return m.SettlePercent() 12846 case exchangerate.FieldSettleTips: 12847 return m.SettleTips() 12848 case exchangerate.FieldSetter: 12849 return m.Setter() 12850 } 12851 return nil, false 12852 } 12853 12854 // OldField returns the old value of the field from the database. An error is 12855 // returned if the mutation operation is not UpdateOne, or the query to the 12856 // database failed. 12857 func (m *ExchangeRateMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 12858 switch name { 12859 case exchangerate.FieldCreatedAt: 12860 return m.OldCreatedAt(ctx) 12861 case exchangerate.FieldUpdatedAt: 12862 return m.OldUpdatedAt(ctx) 12863 case exchangerate.FieldDeletedAt: 12864 return m.OldDeletedAt(ctx) 12865 case exchangerate.FieldEntID: 12866 return m.OldEntID(ctx) 12867 case exchangerate.FieldAppID: 12868 return m.OldAppID(ctx) 12869 case exchangerate.FieldCoinTypeID: 12870 return m.OldCoinTypeID(ctx) 12871 case exchangerate.FieldMarketValue: 12872 return m.OldMarketValue(ctx) 12873 case exchangerate.FieldSettleValue: 12874 return m.OldSettleValue(ctx) 12875 case exchangerate.FieldSettlePercent: 12876 return m.OldSettlePercent(ctx) 12877 case exchangerate.FieldSettleTips: 12878 return m.OldSettleTips(ctx) 12879 case exchangerate.FieldSetter: 12880 return m.OldSetter(ctx) 12881 } 12882 return nil, fmt.Errorf("unknown ExchangeRate field %s", name) 12883 } 12884 12885 // SetField sets the value of a field with the given name. It returns an error if 12886 // the field is not defined in the schema, or if the type mismatched the field 12887 // type. 12888 func (m *ExchangeRateMutation) SetField(name string, value ent.Value) error { 12889 switch name { 12890 case exchangerate.FieldCreatedAt: 12891 v, ok := value.(uint32) 12892 if !ok { 12893 return fmt.Errorf("unexpected type %T for field %s", value, name) 12894 } 12895 m.SetCreatedAt(v) 12896 return nil 12897 case exchangerate.FieldUpdatedAt: 12898 v, ok := value.(uint32) 12899 if !ok { 12900 return fmt.Errorf("unexpected type %T for field %s", value, name) 12901 } 12902 m.SetUpdatedAt(v) 12903 return nil 12904 case exchangerate.FieldDeletedAt: 12905 v, ok := value.(uint32) 12906 if !ok { 12907 return fmt.Errorf("unexpected type %T for field %s", value, name) 12908 } 12909 m.SetDeletedAt(v) 12910 return nil 12911 case exchangerate.FieldEntID: 12912 v, ok := value.(uuid.UUID) 12913 if !ok { 12914 return fmt.Errorf("unexpected type %T for field %s", value, name) 12915 } 12916 m.SetEntID(v) 12917 return nil 12918 case exchangerate.FieldAppID: 12919 v, ok := value.(uuid.UUID) 12920 if !ok { 12921 return fmt.Errorf("unexpected type %T for field %s", value, name) 12922 } 12923 m.SetAppID(v) 12924 return nil 12925 case exchangerate.FieldCoinTypeID: 12926 v, ok := value.(uuid.UUID) 12927 if !ok { 12928 return fmt.Errorf("unexpected type %T for field %s", value, name) 12929 } 12930 m.SetCoinTypeID(v) 12931 return nil 12932 case exchangerate.FieldMarketValue: 12933 v, ok := value.(decimal.Decimal) 12934 if !ok { 12935 return fmt.Errorf("unexpected type %T for field %s", value, name) 12936 } 12937 m.SetMarketValue(v) 12938 return nil 12939 case exchangerate.FieldSettleValue: 12940 v, ok := value.(decimal.Decimal) 12941 if !ok { 12942 return fmt.Errorf("unexpected type %T for field %s", value, name) 12943 } 12944 m.SetSettleValue(v) 12945 return nil 12946 case exchangerate.FieldSettlePercent: 12947 v, ok := value.(uint32) 12948 if !ok { 12949 return fmt.Errorf("unexpected type %T for field %s", value, name) 12950 } 12951 m.SetSettlePercent(v) 12952 return nil 12953 case exchangerate.FieldSettleTips: 12954 v, ok := value.([]string) 12955 if !ok { 12956 return fmt.Errorf("unexpected type %T for field %s", value, name) 12957 } 12958 m.SetSettleTips(v) 12959 return nil 12960 case exchangerate.FieldSetter: 12961 v, ok := value.(uuid.UUID) 12962 if !ok { 12963 return fmt.Errorf("unexpected type %T for field %s", value, name) 12964 } 12965 m.SetSetter(v) 12966 return nil 12967 } 12968 return fmt.Errorf("unknown ExchangeRate field %s", name) 12969 } 12970 12971 // AddedFields returns all numeric fields that were incremented/decremented during 12972 // this mutation. 12973 func (m *ExchangeRateMutation) AddedFields() []string { 12974 var fields []string 12975 if m.addcreated_at != nil { 12976 fields = append(fields, exchangerate.FieldCreatedAt) 12977 } 12978 if m.addupdated_at != nil { 12979 fields = append(fields, exchangerate.FieldUpdatedAt) 12980 } 12981 if m.adddeleted_at != nil { 12982 fields = append(fields, exchangerate.FieldDeletedAt) 12983 } 12984 if m.addsettle_percent != nil { 12985 fields = append(fields, exchangerate.FieldSettlePercent) 12986 } 12987 return fields 12988 } 12989 12990 // AddedField returns the numeric value that was incremented/decremented on a field 12991 // with the given name. The second boolean return value indicates that this field 12992 // was not set, or was not defined in the schema. 12993 func (m *ExchangeRateMutation) AddedField(name string) (ent.Value, bool) { 12994 switch name { 12995 case exchangerate.FieldCreatedAt: 12996 return m.AddedCreatedAt() 12997 case exchangerate.FieldUpdatedAt: 12998 return m.AddedUpdatedAt() 12999 case exchangerate.FieldDeletedAt: 13000 return m.AddedDeletedAt() 13001 case exchangerate.FieldSettlePercent: 13002 return m.AddedSettlePercent() 13003 } 13004 return nil, false 13005 } 13006 13007 // AddField adds the value to the field with the given name. It returns an error if 13008 // the field is not defined in the schema, or if the type mismatched the field 13009 // type. 13010 func (m *ExchangeRateMutation) AddField(name string, value ent.Value) error { 13011 switch name { 13012 case exchangerate.FieldCreatedAt: 13013 v, ok := value.(int32) 13014 if !ok { 13015 return fmt.Errorf("unexpected type %T for field %s", value, name) 13016 } 13017 m.AddCreatedAt(v) 13018 return nil 13019 case exchangerate.FieldUpdatedAt: 13020 v, ok := value.(int32) 13021 if !ok { 13022 return fmt.Errorf("unexpected type %T for field %s", value, name) 13023 } 13024 m.AddUpdatedAt(v) 13025 return nil 13026 case exchangerate.FieldDeletedAt: 13027 v, ok := value.(int32) 13028 if !ok { 13029 return fmt.Errorf("unexpected type %T for field %s", value, name) 13030 } 13031 m.AddDeletedAt(v) 13032 return nil 13033 case exchangerate.FieldSettlePercent: 13034 v, ok := value.(int32) 13035 if !ok { 13036 return fmt.Errorf("unexpected type %T for field %s", value, name) 13037 } 13038 m.AddSettlePercent(v) 13039 return nil 13040 } 13041 return fmt.Errorf("unknown ExchangeRate numeric field %s", name) 13042 } 13043 13044 // ClearedFields returns all nullable fields that were cleared during this 13045 // mutation. 13046 func (m *ExchangeRateMutation) ClearedFields() []string { 13047 var fields []string 13048 if m.FieldCleared(exchangerate.FieldAppID) { 13049 fields = append(fields, exchangerate.FieldAppID) 13050 } 13051 if m.FieldCleared(exchangerate.FieldCoinTypeID) { 13052 fields = append(fields, exchangerate.FieldCoinTypeID) 13053 } 13054 if m.FieldCleared(exchangerate.FieldMarketValue) { 13055 fields = append(fields, exchangerate.FieldMarketValue) 13056 } 13057 if m.FieldCleared(exchangerate.FieldSettleValue) { 13058 fields = append(fields, exchangerate.FieldSettleValue) 13059 } 13060 if m.FieldCleared(exchangerate.FieldSettlePercent) { 13061 fields = append(fields, exchangerate.FieldSettlePercent) 13062 } 13063 if m.FieldCleared(exchangerate.FieldSettleTips) { 13064 fields = append(fields, exchangerate.FieldSettleTips) 13065 } 13066 if m.FieldCleared(exchangerate.FieldSetter) { 13067 fields = append(fields, exchangerate.FieldSetter) 13068 } 13069 return fields 13070 } 13071 13072 // FieldCleared returns a boolean indicating if a field with the given name was 13073 // cleared in this mutation. 13074 func (m *ExchangeRateMutation) FieldCleared(name string) bool { 13075 _, ok := m.clearedFields[name] 13076 return ok 13077 } 13078 13079 // ClearField clears the value of the field with the given name. It returns an 13080 // error if the field is not defined in the schema. 13081 func (m *ExchangeRateMutation) ClearField(name string) error { 13082 switch name { 13083 case exchangerate.FieldAppID: 13084 m.ClearAppID() 13085 return nil 13086 case exchangerate.FieldCoinTypeID: 13087 m.ClearCoinTypeID() 13088 return nil 13089 case exchangerate.FieldMarketValue: 13090 m.ClearMarketValue() 13091 return nil 13092 case exchangerate.FieldSettleValue: 13093 m.ClearSettleValue() 13094 return nil 13095 case exchangerate.FieldSettlePercent: 13096 m.ClearSettlePercent() 13097 return nil 13098 case exchangerate.FieldSettleTips: 13099 m.ClearSettleTips() 13100 return nil 13101 case exchangerate.FieldSetter: 13102 m.ClearSetter() 13103 return nil 13104 } 13105 return fmt.Errorf("unknown ExchangeRate nullable field %s", name) 13106 } 13107 13108 // ResetField resets all changes in the mutation for the field with the given name. 13109 // It returns an error if the field is not defined in the schema. 13110 func (m *ExchangeRateMutation) ResetField(name string) error { 13111 switch name { 13112 case exchangerate.FieldCreatedAt: 13113 m.ResetCreatedAt() 13114 return nil 13115 case exchangerate.FieldUpdatedAt: 13116 m.ResetUpdatedAt() 13117 return nil 13118 case exchangerate.FieldDeletedAt: 13119 m.ResetDeletedAt() 13120 return nil 13121 case exchangerate.FieldEntID: 13122 m.ResetEntID() 13123 return nil 13124 case exchangerate.FieldAppID: 13125 m.ResetAppID() 13126 return nil 13127 case exchangerate.FieldCoinTypeID: 13128 m.ResetCoinTypeID() 13129 return nil 13130 case exchangerate.FieldMarketValue: 13131 m.ResetMarketValue() 13132 return nil 13133 case exchangerate.FieldSettleValue: 13134 m.ResetSettleValue() 13135 return nil 13136 case exchangerate.FieldSettlePercent: 13137 m.ResetSettlePercent() 13138 return nil 13139 case exchangerate.FieldSettleTips: 13140 m.ResetSettleTips() 13141 return nil 13142 case exchangerate.FieldSetter: 13143 m.ResetSetter() 13144 return nil 13145 } 13146 return fmt.Errorf("unknown ExchangeRate field %s", name) 13147 } 13148 13149 // AddedEdges returns all edge names that were set/added in this mutation. 13150 func (m *ExchangeRateMutation) AddedEdges() []string { 13151 edges := make([]string, 0, 0) 13152 return edges 13153 } 13154 13155 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 13156 // name in this mutation. 13157 func (m *ExchangeRateMutation) AddedIDs(name string) []ent.Value { 13158 return nil 13159 } 13160 13161 // RemovedEdges returns all edge names that were removed in this mutation. 13162 func (m *ExchangeRateMutation) RemovedEdges() []string { 13163 edges := make([]string, 0, 0) 13164 return edges 13165 } 13166 13167 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 13168 // the given name in this mutation. 13169 func (m *ExchangeRateMutation) RemovedIDs(name string) []ent.Value { 13170 return nil 13171 } 13172 13173 // ClearedEdges returns all edge names that were cleared in this mutation. 13174 func (m *ExchangeRateMutation) ClearedEdges() []string { 13175 edges := make([]string, 0, 0) 13176 return edges 13177 } 13178 13179 // EdgeCleared returns a boolean which indicates if the edge with the given name 13180 // was cleared in this mutation. 13181 func (m *ExchangeRateMutation) EdgeCleared(name string) bool { 13182 return false 13183 } 13184 13185 // ClearEdge clears the value of the edge with the given name. It returns an error 13186 // if that edge is not defined in the schema. 13187 func (m *ExchangeRateMutation) ClearEdge(name string) error { 13188 return fmt.Errorf("unknown ExchangeRate unique edge %s", name) 13189 } 13190 13191 // ResetEdge resets all changes to the edge with the given name in this mutation. 13192 // It returns an error if the edge is not defined in the schema. 13193 func (m *ExchangeRateMutation) ResetEdge(name string) error { 13194 return fmt.Errorf("unknown ExchangeRate edge %s", name) 13195 } 13196 13197 // FiatMutation represents an operation that mutates the Fiat nodes in the graph. 13198 type FiatMutation struct { 13199 config 13200 op Op 13201 typ string 13202 id *uint32 13203 created_at *uint32 13204 addcreated_at *int32 13205 updated_at *uint32 13206 addupdated_at *int32 13207 deleted_at *uint32 13208 adddeleted_at *int32 13209 ent_id *uuid.UUID 13210 name *string 13211 logo *string 13212 unit *string 13213 clearedFields map[string]struct{} 13214 done bool 13215 oldValue func(context.Context) (*Fiat, error) 13216 predicates []predicate.Fiat 13217 } 13218 13219 var _ ent.Mutation = (*FiatMutation)(nil) 13220 13221 // fiatOption allows management of the mutation configuration using functional options. 13222 type fiatOption func(*FiatMutation) 13223 13224 // newFiatMutation creates new mutation for the Fiat entity. 13225 func newFiatMutation(c config, op Op, opts ...fiatOption) *FiatMutation { 13226 m := &FiatMutation{ 13227 config: c, 13228 op: op, 13229 typ: TypeFiat, 13230 clearedFields: make(map[string]struct{}), 13231 } 13232 for _, opt := range opts { 13233 opt(m) 13234 } 13235 return m 13236 } 13237 13238 // withFiatID sets the ID field of the mutation. 13239 func withFiatID(id uint32) fiatOption { 13240 return func(m *FiatMutation) { 13241 var ( 13242 err error 13243 once sync.Once 13244 value *Fiat 13245 ) 13246 m.oldValue = func(ctx context.Context) (*Fiat, error) { 13247 once.Do(func() { 13248 if m.done { 13249 err = errors.New("querying old values post mutation is not allowed") 13250 } else { 13251 value, err = m.Client().Fiat.Get(ctx, id) 13252 } 13253 }) 13254 return value, err 13255 } 13256 m.id = &id 13257 } 13258 } 13259 13260 // withFiat sets the old Fiat of the mutation. 13261 func withFiat(node *Fiat) fiatOption { 13262 return func(m *FiatMutation) { 13263 m.oldValue = func(context.Context) (*Fiat, error) { 13264 return node, nil 13265 } 13266 m.id = &node.ID 13267 } 13268 } 13269 13270 // Client returns a new `ent.Client` from the mutation. If the mutation was 13271 // executed in a transaction (ent.Tx), a transactional client is returned. 13272 func (m FiatMutation) Client() *Client { 13273 client := &Client{config: m.config} 13274 client.init() 13275 return client 13276 } 13277 13278 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 13279 // it returns an error otherwise. 13280 func (m FiatMutation) Tx() (*Tx, error) { 13281 if _, ok := m.driver.(*txDriver); !ok { 13282 return nil, errors.New("ent: mutation is not running in a transaction") 13283 } 13284 tx := &Tx{config: m.config} 13285 tx.init() 13286 return tx, nil 13287 } 13288 13289 // SetID sets the value of the id field. Note that this 13290 // operation is only accepted on creation of Fiat entities. 13291 func (m *FiatMutation) SetID(id uint32) { 13292 m.id = &id 13293 } 13294 13295 // ID returns the ID value in the mutation. Note that the ID is only available 13296 // if it was provided to the builder or after it was returned from the database. 13297 func (m *FiatMutation) ID() (id uint32, exists bool) { 13298 if m.id == nil { 13299 return 13300 } 13301 return *m.id, true 13302 } 13303 13304 // IDs queries the database and returns the entity ids that match the mutation's predicate. 13305 // That means, if the mutation is applied within a transaction with an isolation level such 13306 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 13307 // or updated by the mutation. 13308 func (m *FiatMutation) IDs(ctx context.Context) ([]uint32, error) { 13309 switch { 13310 case m.op.Is(OpUpdateOne | OpDeleteOne): 13311 id, exists := m.ID() 13312 if exists { 13313 return []uint32{id}, nil 13314 } 13315 fallthrough 13316 case m.op.Is(OpUpdate | OpDelete): 13317 return m.Client().Fiat.Query().Where(m.predicates...).IDs(ctx) 13318 default: 13319 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 13320 } 13321 } 13322 13323 // SetCreatedAt sets the "created_at" field. 13324 func (m *FiatMutation) SetCreatedAt(u uint32) { 13325 m.created_at = &u 13326 m.addcreated_at = nil 13327 } 13328 13329 // CreatedAt returns the value of the "created_at" field in the mutation. 13330 func (m *FiatMutation) CreatedAt() (r uint32, exists bool) { 13331 v := m.created_at 13332 if v == nil { 13333 return 13334 } 13335 return *v, true 13336 } 13337 13338 // OldCreatedAt returns the old "created_at" field's value of the Fiat entity. 13339 // If the Fiat object wasn't provided to the builder, the object is fetched from the database. 13340 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 13341 func (m *FiatMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 13342 if !m.op.Is(OpUpdateOne) { 13343 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 13344 } 13345 if m.id == nil || m.oldValue == nil { 13346 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 13347 } 13348 oldValue, err := m.oldValue(ctx) 13349 if err != nil { 13350 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 13351 } 13352 return oldValue.CreatedAt, nil 13353 } 13354 13355 // AddCreatedAt adds u to the "created_at" field. 13356 func (m *FiatMutation) AddCreatedAt(u int32) { 13357 if m.addcreated_at != nil { 13358 *m.addcreated_at += u 13359 } else { 13360 m.addcreated_at = &u 13361 } 13362 } 13363 13364 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 13365 func (m *FiatMutation) AddedCreatedAt() (r int32, exists bool) { 13366 v := m.addcreated_at 13367 if v == nil { 13368 return 13369 } 13370 return *v, true 13371 } 13372 13373 // ResetCreatedAt resets all changes to the "created_at" field. 13374 func (m *FiatMutation) ResetCreatedAt() { 13375 m.created_at = nil 13376 m.addcreated_at = nil 13377 } 13378 13379 // SetUpdatedAt sets the "updated_at" field. 13380 func (m *FiatMutation) SetUpdatedAt(u uint32) { 13381 m.updated_at = &u 13382 m.addupdated_at = nil 13383 } 13384 13385 // UpdatedAt returns the value of the "updated_at" field in the mutation. 13386 func (m *FiatMutation) UpdatedAt() (r uint32, exists bool) { 13387 v := m.updated_at 13388 if v == nil { 13389 return 13390 } 13391 return *v, true 13392 } 13393 13394 // OldUpdatedAt returns the old "updated_at" field's value of the Fiat entity. 13395 // If the Fiat object wasn't provided to the builder, the object is fetched from the database. 13396 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 13397 func (m *FiatMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 13398 if !m.op.Is(OpUpdateOne) { 13399 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 13400 } 13401 if m.id == nil || m.oldValue == nil { 13402 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 13403 } 13404 oldValue, err := m.oldValue(ctx) 13405 if err != nil { 13406 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 13407 } 13408 return oldValue.UpdatedAt, nil 13409 } 13410 13411 // AddUpdatedAt adds u to the "updated_at" field. 13412 func (m *FiatMutation) AddUpdatedAt(u int32) { 13413 if m.addupdated_at != nil { 13414 *m.addupdated_at += u 13415 } else { 13416 m.addupdated_at = &u 13417 } 13418 } 13419 13420 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 13421 func (m *FiatMutation) AddedUpdatedAt() (r int32, exists bool) { 13422 v := m.addupdated_at 13423 if v == nil { 13424 return 13425 } 13426 return *v, true 13427 } 13428 13429 // ResetUpdatedAt resets all changes to the "updated_at" field. 13430 func (m *FiatMutation) ResetUpdatedAt() { 13431 m.updated_at = nil 13432 m.addupdated_at = nil 13433 } 13434 13435 // SetDeletedAt sets the "deleted_at" field. 13436 func (m *FiatMutation) SetDeletedAt(u uint32) { 13437 m.deleted_at = &u 13438 m.adddeleted_at = nil 13439 } 13440 13441 // DeletedAt returns the value of the "deleted_at" field in the mutation. 13442 func (m *FiatMutation) DeletedAt() (r uint32, exists bool) { 13443 v := m.deleted_at 13444 if v == nil { 13445 return 13446 } 13447 return *v, true 13448 } 13449 13450 // OldDeletedAt returns the old "deleted_at" field's value of the Fiat entity. 13451 // If the Fiat object wasn't provided to the builder, the object is fetched from the database. 13452 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 13453 func (m *FiatMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 13454 if !m.op.Is(OpUpdateOne) { 13455 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 13456 } 13457 if m.id == nil || m.oldValue == nil { 13458 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 13459 } 13460 oldValue, err := m.oldValue(ctx) 13461 if err != nil { 13462 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 13463 } 13464 return oldValue.DeletedAt, nil 13465 } 13466 13467 // AddDeletedAt adds u to the "deleted_at" field. 13468 func (m *FiatMutation) AddDeletedAt(u int32) { 13469 if m.adddeleted_at != nil { 13470 *m.adddeleted_at += u 13471 } else { 13472 m.adddeleted_at = &u 13473 } 13474 } 13475 13476 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 13477 func (m *FiatMutation) AddedDeletedAt() (r int32, exists bool) { 13478 v := m.adddeleted_at 13479 if v == nil { 13480 return 13481 } 13482 return *v, true 13483 } 13484 13485 // ResetDeletedAt resets all changes to the "deleted_at" field. 13486 func (m *FiatMutation) ResetDeletedAt() { 13487 m.deleted_at = nil 13488 m.adddeleted_at = nil 13489 } 13490 13491 // SetEntID sets the "ent_id" field. 13492 func (m *FiatMutation) SetEntID(u uuid.UUID) { 13493 m.ent_id = &u 13494 } 13495 13496 // EntID returns the value of the "ent_id" field in the mutation. 13497 func (m *FiatMutation) EntID() (r uuid.UUID, exists bool) { 13498 v := m.ent_id 13499 if v == nil { 13500 return 13501 } 13502 return *v, true 13503 } 13504 13505 // OldEntID returns the old "ent_id" field's value of the Fiat entity. 13506 // If the Fiat object wasn't provided to the builder, the object is fetched from the database. 13507 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 13508 func (m *FiatMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 13509 if !m.op.Is(OpUpdateOne) { 13510 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 13511 } 13512 if m.id == nil || m.oldValue == nil { 13513 return v, errors.New("OldEntID requires an ID field in the mutation") 13514 } 13515 oldValue, err := m.oldValue(ctx) 13516 if err != nil { 13517 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 13518 } 13519 return oldValue.EntID, nil 13520 } 13521 13522 // ResetEntID resets all changes to the "ent_id" field. 13523 func (m *FiatMutation) ResetEntID() { 13524 m.ent_id = nil 13525 } 13526 13527 // SetName sets the "name" field. 13528 func (m *FiatMutation) SetName(s string) { 13529 m.name = &s 13530 } 13531 13532 // Name returns the value of the "name" field in the mutation. 13533 func (m *FiatMutation) Name() (r string, exists bool) { 13534 v := m.name 13535 if v == nil { 13536 return 13537 } 13538 return *v, true 13539 } 13540 13541 // OldName returns the old "name" field's value of the Fiat entity. 13542 // If the Fiat object wasn't provided to the builder, the object is fetched from the database. 13543 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 13544 func (m *FiatMutation) OldName(ctx context.Context) (v string, err error) { 13545 if !m.op.Is(OpUpdateOne) { 13546 return v, errors.New("OldName is only allowed on UpdateOne operations") 13547 } 13548 if m.id == nil || m.oldValue == nil { 13549 return v, errors.New("OldName requires an ID field in the mutation") 13550 } 13551 oldValue, err := m.oldValue(ctx) 13552 if err != nil { 13553 return v, fmt.Errorf("querying old value for OldName: %w", err) 13554 } 13555 return oldValue.Name, nil 13556 } 13557 13558 // ClearName clears the value of the "name" field. 13559 func (m *FiatMutation) ClearName() { 13560 m.name = nil 13561 m.clearedFields[fiat.FieldName] = struct{}{} 13562 } 13563 13564 // NameCleared returns if the "name" field was cleared in this mutation. 13565 func (m *FiatMutation) NameCleared() bool { 13566 _, ok := m.clearedFields[fiat.FieldName] 13567 return ok 13568 } 13569 13570 // ResetName resets all changes to the "name" field. 13571 func (m *FiatMutation) ResetName() { 13572 m.name = nil 13573 delete(m.clearedFields, fiat.FieldName) 13574 } 13575 13576 // SetLogo sets the "logo" field. 13577 func (m *FiatMutation) SetLogo(s string) { 13578 m.logo = &s 13579 } 13580 13581 // Logo returns the value of the "logo" field in the mutation. 13582 func (m *FiatMutation) Logo() (r string, exists bool) { 13583 v := m.logo 13584 if v == nil { 13585 return 13586 } 13587 return *v, true 13588 } 13589 13590 // OldLogo returns the old "logo" field's value of the Fiat entity. 13591 // If the Fiat object wasn't provided to the builder, the object is fetched from the database. 13592 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 13593 func (m *FiatMutation) OldLogo(ctx context.Context) (v string, err error) { 13594 if !m.op.Is(OpUpdateOne) { 13595 return v, errors.New("OldLogo is only allowed on UpdateOne operations") 13596 } 13597 if m.id == nil || m.oldValue == nil { 13598 return v, errors.New("OldLogo requires an ID field in the mutation") 13599 } 13600 oldValue, err := m.oldValue(ctx) 13601 if err != nil { 13602 return v, fmt.Errorf("querying old value for OldLogo: %w", err) 13603 } 13604 return oldValue.Logo, nil 13605 } 13606 13607 // ClearLogo clears the value of the "logo" field. 13608 func (m *FiatMutation) ClearLogo() { 13609 m.logo = nil 13610 m.clearedFields[fiat.FieldLogo] = struct{}{} 13611 } 13612 13613 // LogoCleared returns if the "logo" field was cleared in this mutation. 13614 func (m *FiatMutation) LogoCleared() bool { 13615 _, ok := m.clearedFields[fiat.FieldLogo] 13616 return ok 13617 } 13618 13619 // ResetLogo resets all changes to the "logo" field. 13620 func (m *FiatMutation) ResetLogo() { 13621 m.logo = nil 13622 delete(m.clearedFields, fiat.FieldLogo) 13623 } 13624 13625 // SetUnit sets the "unit" field. 13626 func (m *FiatMutation) SetUnit(s string) { 13627 m.unit = &s 13628 } 13629 13630 // Unit returns the value of the "unit" field in the mutation. 13631 func (m *FiatMutation) Unit() (r string, exists bool) { 13632 v := m.unit 13633 if v == nil { 13634 return 13635 } 13636 return *v, true 13637 } 13638 13639 // OldUnit returns the old "unit" field's value of the Fiat entity. 13640 // If the Fiat object wasn't provided to the builder, the object is fetched from the database. 13641 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 13642 func (m *FiatMutation) OldUnit(ctx context.Context) (v string, err error) { 13643 if !m.op.Is(OpUpdateOne) { 13644 return v, errors.New("OldUnit is only allowed on UpdateOne operations") 13645 } 13646 if m.id == nil || m.oldValue == nil { 13647 return v, errors.New("OldUnit requires an ID field in the mutation") 13648 } 13649 oldValue, err := m.oldValue(ctx) 13650 if err != nil { 13651 return v, fmt.Errorf("querying old value for OldUnit: %w", err) 13652 } 13653 return oldValue.Unit, nil 13654 } 13655 13656 // ClearUnit clears the value of the "unit" field. 13657 func (m *FiatMutation) ClearUnit() { 13658 m.unit = nil 13659 m.clearedFields[fiat.FieldUnit] = struct{}{} 13660 } 13661 13662 // UnitCleared returns if the "unit" field was cleared in this mutation. 13663 func (m *FiatMutation) UnitCleared() bool { 13664 _, ok := m.clearedFields[fiat.FieldUnit] 13665 return ok 13666 } 13667 13668 // ResetUnit resets all changes to the "unit" field. 13669 func (m *FiatMutation) ResetUnit() { 13670 m.unit = nil 13671 delete(m.clearedFields, fiat.FieldUnit) 13672 } 13673 13674 // Where appends a list predicates to the FiatMutation builder. 13675 func (m *FiatMutation) Where(ps ...predicate.Fiat) { 13676 m.predicates = append(m.predicates, ps...) 13677 } 13678 13679 // Op returns the operation name. 13680 func (m *FiatMutation) Op() Op { 13681 return m.op 13682 } 13683 13684 // Type returns the node type of this mutation (Fiat). 13685 func (m *FiatMutation) Type() string { 13686 return m.typ 13687 } 13688 13689 // Fields returns all fields that were changed during this mutation. Note that in 13690 // order to get all numeric fields that were incremented/decremented, call 13691 // AddedFields(). 13692 func (m *FiatMutation) Fields() []string { 13693 fields := make([]string, 0, 7) 13694 if m.created_at != nil { 13695 fields = append(fields, fiat.FieldCreatedAt) 13696 } 13697 if m.updated_at != nil { 13698 fields = append(fields, fiat.FieldUpdatedAt) 13699 } 13700 if m.deleted_at != nil { 13701 fields = append(fields, fiat.FieldDeletedAt) 13702 } 13703 if m.ent_id != nil { 13704 fields = append(fields, fiat.FieldEntID) 13705 } 13706 if m.name != nil { 13707 fields = append(fields, fiat.FieldName) 13708 } 13709 if m.logo != nil { 13710 fields = append(fields, fiat.FieldLogo) 13711 } 13712 if m.unit != nil { 13713 fields = append(fields, fiat.FieldUnit) 13714 } 13715 return fields 13716 } 13717 13718 // Field returns the value of a field with the given name. The second boolean 13719 // return value indicates that this field was not set, or was not defined in the 13720 // schema. 13721 func (m *FiatMutation) Field(name string) (ent.Value, bool) { 13722 switch name { 13723 case fiat.FieldCreatedAt: 13724 return m.CreatedAt() 13725 case fiat.FieldUpdatedAt: 13726 return m.UpdatedAt() 13727 case fiat.FieldDeletedAt: 13728 return m.DeletedAt() 13729 case fiat.FieldEntID: 13730 return m.EntID() 13731 case fiat.FieldName: 13732 return m.Name() 13733 case fiat.FieldLogo: 13734 return m.Logo() 13735 case fiat.FieldUnit: 13736 return m.Unit() 13737 } 13738 return nil, false 13739 } 13740 13741 // OldField returns the old value of the field from the database. An error is 13742 // returned if the mutation operation is not UpdateOne, or the query to the 13743 // database failed. 13744 func (m *FiatMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 13745 switch name { 13746 case fiat.FieldCreatedAt: 13747 return m.OldCreatedAt(ctx) 13748 case fiat.FieldUpdatedAt: 13749 return m.OldUpdatedAt(ctx) 13750 case fiat.FieldDeletedAt: 13751 return m.OldDeletedAt(ctx) 13752 case fiat.FieldEntID: 13753 return m.OldEntID(ctx) 13754 case fiat.FieldName: 13755 return m.OldName(ctx) 13756 case fiat.FieldLogo: 13757 return m.OldLogo(ctx) 13758 case fiat.FieldUnit: 13759 return m.OldUnit(ctx) 13760 } 13761 return nil, fmt.Errorf("unknown Fiat field %s", name) 13762 } 13763 13764 // SetField sets the value of a field with the given name. It returns an error if 13765 // the field is not defined in the schema, or if the type mismatched the field 13766 // type. 13767 func (m *FiatMutation) SetField(name string, value ent.Value) error { 13768 switch name { 13769 case fiat.FieldCreatedAt: 13770 v, ok := value.(uint32) 13771 if !ok { 13772 return fmt.Errorf("unexpected type %T for field %s", value, name) 13773 } 13774 m.SetCreatedAt(v) 13775 return nil 13776 case fiat.FieldUpdatedAt: 13777 v, ok := value.(uint32) 13778 if !ok { 13779 return fmt.Errorf("unexpected type %T for field %s", value, name) 13780 } 13781 m.SetUpdatedAt(v) 13782 return nil 13783 case fiat.FieldDeletedAt: 13784 v, ok := value.(uint32) 13785 if !ok { 13786 return fmt.Errorf("unexpected type %T for field %s", value, name) 13787 } 13788 m.SetDeletedAt(v) 13789 return nil 13790 case fiat.FieldEntID: 13791 v, ok := value.(uuid.UUID) 13792 if !ok { 13793 return fmt.Errorf("unexpected type %T for field %s", value, name) 13794 } 13795 m.SetEntID(v) 13796 return nil 13797 case fiat.FieldName: 13798 v, ok := value.(string) 13799 if !ok { 13800 return fmt.Errorf("unexpected type %T for field %s", value, name) 13801 } 13802 m.SetName(v) 13803 return nil 13804 case fiat.FieldLogo: 13805 v, ok := value.(string) 13806 if !ok { 13807 return fmt.Errorf("unexpected type %T for field %s", value, name) 13808 } 13809 m.SetLogo(v) 13810 return nil 13811 case fiat.FieldUnit: 13812 v, ok := value.(string) 13813 if !ok { 13814 return fmt.Errorf("unexpected type %T for field %s", value, name) 13815 } 13816 m.SetUnit(v) 13817 return nil 13818 } 13819 return fmt.Errorf("unknown Fiat field %s", name) 13820 } 13821 13822 // AddedFields returns all numeric fields that were incremented/decremented during 13823 // this mutation. 13824 func (m *FiatMutation) AddedFields() []string { 13825 var fields []string 13826 if m.addcreated_at != nil { 13827 fields = append(fields, fiat.FieldCreatedAt) 13828 } 13829 if m.addupdated_at != nil { 13830 fields = append(fields, fiat.FieldUpdatedAt) 13831 } 13832 if m.adddeleted_at != nil { 13833 fields = append(fields, fiat.FieldDeletedAt) 13834 } 13835 return fields 13836 } 13837 13838 // AddedField returns the numeric value that was incremented/decremented on a field 13839 // with the given name. The second boolean return value indicates that this field 13840 // was not set, or was not defined in the schema. 13841 func (m *FiatMutation) AddedField(name string) (ent.Value, bool) { 13842 switch name { 13843 case fiat.FieldCreatedAt: 13844 return m.AddedCreatedAt() 13845 case fiat.FieldUpdatedAt: 13846 return m.AddedUpdatedAt() 13847 case fiat.FieldDeletedAt: 13848 return m.AddedDeletedAt() 13849 } 13850 return nil, false 13851 } 13852 13853 // AddField adds the value to the field with the given name. It returns an error if 13854 // the field is not defined in the schema, or if the type mismatched the field 13855 // type. 13856 func (m *FiatMutation) AddField(name string, value ent.Value) error { 13857 switch name { 13858 case fiat.FieldCreatedAt: 13859 v, ok := value.(int32) 13860 if !ok { 13861 return fmt.Errorf("unexpected type %T for field %s", value, name) 13862 } 13863 m.AddCreatedAt(v) 13864 return nil 13865 case fiat.FieldUpdatedAt: 13866 v, ok := value.(int32) 13867 if !ok { 13868 return fmt.Errorf("unexpected type %T for field %s", value, name) 13869 } 13870 m.AddUpdatedAt(v) 13871 return nil 13872 case fiat.FieldDeletedAt: 13873 v, ok := value.(int32) 13874 if !ok { 13875 return fmt.Errorf("unexpected type %T for field %s", value, name) 13876 } 13877 m.AddDeletedAt(v) 13878 return nil 13879 } 13880 return fmt.Errorf("unknown Fiat numeric field %s", name) 13881 } 13882 13883 // ClearedFields returns all nullable fields that were cleared during this 13884 // mutation. 13885 func (m *FiatMutation) ClearedFields() []string { 13886 var fields []string 13887 if m.FieldCleared(fiat.FieldName) { 13888 fields = append(fields, fiat.FieldName) 13889 } 13890 if m.FieldCleared(fiat.FieldLogo) { 13891 fields = append(fields, fiat.FieldLogo) 13892 } 13893 if m.FieldCleared(fiat.FieldUnit) { 13894 fields = append(fields, fiat.FieldUnit) 13895 } 13896 return fields 13897 } 13898 13899 // FieldCleared returns a boolean indicating if a field with the given name was 13900 // cleared in this mutation. 13901 func (m *FiatMutation) FieldCleared(name string) bool { 13902 _, ok := m.clearedFields[name] 13903 return ok 13904 } 13905 13906 // ClearField clears the value of the field with the given name. It returns an 13907 // error if the field is not defined in the schema. 13908 func (m *FiatMutation) ClearField(name string) error { 13909 switch name { 13910 case fiat.FieldName: 13911 m.ClearName() 13912 return nil 13913 case fiat.FieldLogo: 13914 m.ClearLogo() 13915 return nil 13916 case fiat.FieldUnit: 13917 m.ClearUnit() 13918 return nil 13919 } 13920 return fmt.Errorf("unknown Fiat nullable field %s", name) 13921 } 13922 13923 // ResetField resets all changes in the mutation for the field with the given name. 13924 // It returns an error if the field is not defined in the schema. 13925 func (m *FiatMutation) ResetField(name string) error { 13926 switch name { 13927 case fiat.FieldCreatedAt: 13928 m.ResetCreatedAt() 13929 return nil 13930 case fiat.FieldUpdatedAt: 13931 m.ResetUpdatedAt() 13932 return nil 13933 case fiat.FieldDeletedAt: 13934 m.ResetDeletedAt() 13935 return nil 13936 case fiat.FieldEntID: 13937 m.ResetEntID() 13938 return nil 13939 case fiat.FieldName: 13940 m.ResetName() 13941 return nil 13942 case fiat.FieldLogo: 13943 m.ResetLogo() 13944 return nil 13945 case fiat.FieldUnit: 13946 m.ResetUnit() 13947 return nil 13948 } 13949 return fmt.Errorf("unknown Fiat field %s", name) 13950 } 13951 13952 // AddedEdges returns all edge names that were set/added in this mutation. 13953 func (m *FiatMutation) AddedEdges() []string { 13954 edges := make([]string, 0, 0) 13955 return edges 13956 } 13957 13958 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 13959 // name in this mutation. 13960 func (m *FiatMutation) AddedIDs(name string) []ent.Value { 13961 return nil 13962 } 13963 13964 // RemovedEdges returns all edge names that were removed in this mutation. 13965 func (m *FiatMutation) RemovedEdges() []string { 13966 edges := make([]string, 0, 0) 13967 return edges 13968 } 13969 13970 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 13971 // the given name in this mutation. 13972 func (m *FiatMutation) RemovedIDs(name string) []ent.Value { 13973 return nil 13974 } 13975 13976 // ClearedEdges returns all edge names that were cleared in this mutation. 13977 func (m *FiatMutation) ClearedEdges() []string { 13978 edges := make([]string, 0, 0) 13979 return edges 13980 } 13981 13982 // EdgeCleared returns a boolean which indicates if the edge with the given name 13983 // was cleared in this mutation. 13984 func (m *FiatMutation) EdgeCleared(name string) bool { 13985 return false 13986 } 13987 13988 // ClearEdge clears the value of the edge with the given name. It returns an error 13989 // if that edge is not defined in the schema. 13990 func (m *FiatMutation) ClearEdge(name string) error { 13991 return fmt.Errorf("unknown Fiat unique edge %s", name) 13992 } 13993 13994 // ResetEdge resets all changes to the edge with the given name in this mutation. 13995 // It returns an error if the edge is not defined in the schema. 13996 func (m *FiatMutation) ResetEdge(name string) error { 13997 return fmt.Errorf("unknown Fiat edge %s", name) 13998 } 13999 14000 // FiatCurrencyMutation represents an operation that mutates the FiatCurrency nodes in the graph. 14001 type FiatCurrencyMutation struct { 14002 config 14003 op Op 14004 typ string 14005 id *uint32 14006 created_at *uint32 14007 addcreated_at *int32 14008 updated_at *uint32 14009 addupdated_at *int32 14010 deleted_at *uint32 14011 adddeleted_at *int32 14012 ent_id *uuid.UUID 14013 fiat_id *uuid.UUID 14014 feed_type *string 14015 market_value_low *decimal.Decimal 14016 market_value_high *decimal.Decimal 14017 clearedFields map[string]struct{} 14018 done bool 14019 oldValue func(context.Context) (*FiatCurrency, error) 14020 predicates []predicate.FiatCurrency 14021 } 14022 14023 var _ ent.Mutation = (*FiatCurrencyMutation)(nil) 14024 14025 // fiatcurrencyOption allows management of the mutation configuration using functional options. 14026 type fiatcurrencyOption func(*FiatCurrencyMutation) 14027 14028 // newFiatCurrencyMutation creates new mutation for the FiatCurrency entity. 14029 func newFiatCurrencyMutation(c config, op Op, opts ...fiatcurrencyOption) *FiatCurrencyMutation { 14030 m := &FiatCurrencyMutation{ 14031 config: c, 14032 op: op, 14033 typ: TypeFiatCurrency, 14034 clearedFields: make(map[string]struct{}), 14035 } 14036 for _, opt := range opts { 14037 opt(m) 14038 } 14039 return m 14040 } 14041 14042 // withFiatCurrencyID sets the ID field of the mutation. 14043 func withFiatCurrencyID(id uint32) fiatcurrencyOption { 14044 return func(m *FiatCurrencyMutation) { 14045 var ( 14046 err error 14047 once sync.Once 14048 value *FiatCurrency 14049 ) 14050 m.oldValue = func(ctx context.Context) (*FiatCurrency, error) { 14051 once.Do(func() { 14052 if m.done { 14053 err = errors.New("querying old values post mutation is not allowed") 14054 } else { 14055 value, err = m.Client().FiatCurrency.Get(ctx, id) 14056 } 14057 }) 14058 return value, err 14059 } 14060 m.id = &id 14061 } 14062 } 14063 14064 // withFiatCurrency sets the old FiatCurrency of the mutation. 14065 func withFiatCurrency(node *FiatCurrency) fiatcurrencyOption { 14066 return func(m *FiatCurrencyMutation) { 14067 m.oldValue = func(context.Context) (*FiatCurrency, error) { 14068 return node, nil 14069 } 14070 m.id = &node.ID 14071 } 14072 } 14073 14074 // Client returns a new `ent.Client` from the mutation. If the mutation was 14075 // executed in a transaction (ent.Tx), a transactional client is returned. 14076 func (m FiatCurrencyMutation) Client() *Client { 14077 client := &Client{config: m.config} 14078 client.init() 14079 return client 14080 } 14081 14082 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 14083 // it returns an error otherwise. 14084 func (m FiatCurrencyMutation) Tx() (*Tx, error) { 14085 if _, ok := m.driver.(*txDriver); !ok { 14086 return nil, errors.New("ent: mutation is not running in a transaction") 14087 } 14088 tx := &Tx{config: m.config} 14089 tx.init() 14090 return tx, nil 14091 } 14092 14093 // SetID sets the value of the id field. Note that this 14094 // operation is only accepted on creation of FiatCurrency entities. 14095 func (m *FiatCurrencyMutation) SetID(id uint32) { 14096 m.id = &id 14097 } 14098 14099 // ID returns the ID value in the mutation. Note that the ID is only available 14100 // if it was provided to the builder or after it was returned from the database. 14101 func (m *FiatCurrencyMutation) ID() (id uint32, exists bool) { 14102 if m.id == nil { 14103 return 14104 } 14105 return *m.id, true 14106 } 14107 14108 // IDs queries the database and returns the entity ids that match the mutation's predicate. 14109 // That means, if the mutation is applied within a transaction with an isolation level such 14110 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 14111 // or updated by the mutation. 14112 func (m *FiatCurrencyMutation) IDs(ctx context.Context) ([]uint32, error) { 14113 switch { 14114 case m.op.Is(OpUpdateOne | OpDeleteOne): 14115 id, exists := m.ID() 14116 if exists { 14117 return []uint32{id}, nil 14118 } 14119 fallthrough 14120 case m.op.Is(OpUpdate | OpDelete): 14121 return m.Client().FiatCurrency.Query().Where(m.predicates...).IDs(ctx) 14122 default: 14123 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 14124 } 14125 } 14126 14127 // SetCreatedAt sets the "created_at" field. 14128 func (m *FiatCurrencyMutation) SetCreatedAt(u uint32) { 14129 m.created_at = &u 14130 m.addcreated_at = nil 14131 } 14132 14133 // CreatedAt returns the value of the "created_at" field in the mutation. 14134 func (m *FiatCurrencyMutation) CreatedAt() (r uint32, exists bool) { 14135 v := m.created_at 14136 if v == nil { 14137 return 14138 } 14139 return *v, true 14140 } 14141 14142 // OldCreatedAt returns the old "created_at" field's value of the FiatCurrency entity. 14143 // If the FiatCurrency object wasn't provided to the builder, the object is fetched from the database. 14144 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 14145 func (m *FiatCurrencyMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 14146 if !m.op.Is(OpUpdateOne) { 14147 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 14148 } 14149 if m.id == nil || m.oldValue == nil { 14150 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 14151 } 14152 oldValue, err := m.oldValue(ctx) 14153 if err != nil { 14154 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 14155 } 14156 return oldValue.CreatedAt, nil 14157 } 14158 14159 // AddCreatedAt adds u to the "created_at" field. 14160 func (m *FiatCurrencyMutation) AddCreatedAt(u int32) { 14161 if m.addcreated_at != nil { 14162 *m.addcreated_at += u 14163 } else { 14164 m.addcreated_at = &u 14165 } 14166 } 14167 14168 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 14169 func (m *FiatCurrencyMutation) AddedCreatedAt() (r int32, exists bool) { 14170 v := m.addcreated_at 14171 if v == nil { 14172 return 14173 } 14174 return *v, true 14175 } 14176 14177 // ResetCreatedAt resets all changes to the "created_at" field. 14178 func (m *FiatCurrencyMutation) ResetCreatedAt() { 14179 m.created_at = nil 14180 m.addcreated_at = nil 14181 } 14182 14183 // SetUpdatedAt sets the "updated_at" field. 14184 func (m *FiatCurrencyMutation) SetUpdatedAt(u uint32) { 14185 m.updated_at = &u 14186 m.addupdated_at = nil 14187 } 14188 14189 // UpdatedAt returns the value of the "updated_at" field in the mutation. 14190 func (m *FiatCurrencyMutation) UpdatedAt() (r uint32, exists bool) { 14191 v := m.updated_at 14192 if v == nil { 14193 return 14194 } 14195 return *v, true 14196 } 14197 14198 // OldUpdatedAt returns the old "updated_at" field's value of the FiatCurrency entity. 14199 // If the FiatCurrency object wasn't provided to the builder, the object is fetched from the database. 14200 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 14201 func (m *FiatCurrencyMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 14202 if !m.op.Is(OpUpdateOne) { 14203 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 14204 } 14205 if m.id == nil || m.oldValue == nil { 14206 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 14207 } 14208 oldValue, err := m.oldValue(ctx) 14209 if err != nil { 14210 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 14211 } 14212 return oldValue.UpdatedAt, nil 14213 } 14214 14215 // AddUpdatedAt adds u to the "updated_at" field. 14216 func (m *FiatCurrencyMutation) AddUpdatedAt(u int32) { 14217 if m.addupdated_at != nil { 14218 *m.addupdated_at += u 14219 } else { 14220 m.addupdated_at = &u 14221 } 14222 } 14223 14224 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 14225 func (m *FiatCurrencyMutation) AddedUpdatedAt() (r int32, exists bool) { 14226 v := m.addupdated_at 14227 if v == nil { 14228 return 14229 } 14230 return *v, true 14231 } 14232 14233 // ResetUpdatedAt resets all changes to the "updated_at" field. 14234 func (m *FiatCurrencyMutation) ResetUpdatedAt() { 14235 m.updated_at = nil 14236 m.addupdated_at = nil 14237 } 14238 14239 // SetDeletedAt sets the "deleted_at" field. 14240 func (m *FiatCurrencyMutation) SetDeletedAt(u uint32) { 14241 m.deleted_at = &u 14242 m.adddeleted_at = nil 14243 } 14244 14245 // DeletedAt returns the value of the "deleted_at" field in the mutation. 14246 func (m *FiatCurrencyMutation) DeletedAt() (r uint32, exists bool) { 14247 v := m.deleted_at 14248 if v == nil { 14249 return 14250 } 14251 return *v, true 14252 } 14253 14254 // OldDeletedAt returns the old "deleted_at" field's value of the FiatCurrency entity. 14255 // If the FiatCurrency object wasn't provided to the builder, the object is fetched from the database. 14256 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 14257 func (m *FiatCurrencyMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 14258 if !m.op.Is(OpUpdateOne) { 14259 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 14260 } 14261 if m.id == nil || m.oldValue == nil { 14262 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 14263 } 14264 oldValue, err := m.oldValue(ctx) 14265 if err != nil { 14266 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 14267 } 14268 return oldValue.DeletedAt, nil 14269 } 14270 14271 // AddDeletedAt adds u to the "deleted_at" field. 14272 func (m *FiatCurrencyMutation) AddDeletedAt(u int32) { 14273 if m.adddeleted_at != nil { 14274 *m.adddeleted_at += u 14275 } else { 14276 m.adddeleted_at = &u 14277 } 14278 } 14279 14280 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 14281 func (m *FiatCurrencyMutation) AddedDeletedAt() (r int32, exists bool) { 14282 v := m.adddeleted_at 14283 if v == nil { 14284 return 14285 } 14286 return *v, true 14287 } 14288 14289 // ResetDeletedAt resets all changes to the "deleted_at" field. 14290 func (m *FiatCurrencyMutation) ResetDeletedAt() { 14291 m.deleted_at = nil 14292 m.adddeleted_at = nil 14293 } 14294 14295 // SetEntID sets the "ent_id" field. 14296 func (m *FiatCurrencyMutation) SetEntID(u uuid.UUID) { 14297 m.ent_id = &u 14298 } 14299 14300 // EntID returns the value of the "ent_id" field in the mutation. 14301 func (m *FiatCurrencyMutation) EntID() (r uuid.UUID, exists bool) { 14302 v := m.ent_id 14303 if v == nil { 14304 return 14305 } 14306 return *v, true 14307 } 14308 14309 // OldEntID returns the old "ent_id" field's value of the FiatCurrency entity. 14310 // If the FiatCurrency object wasn't provided to the builder, the object is fetched from the database. 14311 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 14312 func (m *FiatCurrencyMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 14313 if !m.op.Is(OpUpdateOne) { 14314 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 14315 } 14316 if m.id == nil || m.oldValue == nil { 14317 return v, errors.New("OldEntID requires an ID field in the mutation") 14318 } 14319 oldValue, err := m.oldValue(ctx) 14320 if err != nil { 14321 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 14322 } 14323 return oldValue.EntID, nil 14324 } 14325 14326 // ResetEntID resets all changes to the "ent_id" field. 14327 func (m *FiatCurrencyMutation) ResetEntID() { 14328 m.ent_id = nil 14329 } 14330 14331 // SetFiatID sets the "fiat_id" field. 14332 func (m *FiatCurrencyMutation) SetFiatID(u uuid.UUID) { 14333 m.fiat_id = &u 14334 } 14335 14336 // FiatID returns the value of the "fiat_id" field in the mutation. 14337 func (m *FiatCurrencyMutation) FiatID() (r uuid.UUID, exists bool) { 14338 v := m.fiat_id 14339 if v == nil { 14340 return 14341 } 14342 return *v, true 14343 } 14344 14345 // OldFiatID returns the old "fiat_id" field's value of the FiatCurrency entity. 14346 // If the FiatCurrency object wasn't provided to the builder, the object is fetched from the database. 14347 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 14348 func (m *FiatCurrencyMutation) OldFiatID(ctx context.Context) (v uuid.UUID, err error) { 14349 if !m.op.Is(OpUpdateOne) { 14350 return v, errors.New("OldFiatID is only allowed on UpdateOne operations") 14351 } 14352 if m.id == nil || m.oldValue == nil { 14353 return v, errors.New("OldFiatID requires an ID field in the mutation") 14354 } 14355 oldValue, err := m.oldValue(ctx) 14356 if err != nil { 14357 return v, fmt.Errorf("querying old value for OldFiatID: %w", err) 14358 } 14359 return oldValue.FiatID, nil 14360 } 14361 14362 // ClearFiatID clears the value of the "fiat_id" field. 14363 func (m *FiatCurrencyMutation) ClearFiatID() { 14364 m.fiat_id = nil 14365 m.clearedFields[fiatcurrency.FieldFiatID] = struct{}{} 14366 } 14367 14368 // FiatIDCleared returns if the "fiat_id" field was cleared in this mutation. 14369 func (m *FiatCurrencyMutation) FiatIDCleared() bool { 14370 _, ok := m.clearedFields[fiatcurrency.FieldFiatID] 14371 return ok 14372 } 14373 14374 // ResetFiatID resets all changes to the "fiat_id" field. 14375 func (m *FiatCurrencyMutation) ResetFiatID() { 14376 m.fiat_id = nil 14377 delete(m.clearedFields, fiatcurrency.FieldFiatID) 14378 } 14379 14380 // SetFeedType sets the "feed_type" field. 14381 func (m *FiatCurrencyMutation) SetFeedType(s string) { 14382 m.feed_type = &s 14383 } 14384 14385 // FeedType returns the value of the "feed_type" field in the mutation. 14386 func (m *FiatCurrencyMutation) FeedType() (r string, exists bool) { 14387 v := m.feed_type 14388 if v == nil { 14389 return 14390 } 14391 return *v, true 14392 } 14393 14394 // OldFeedType returns the old "feed_type" field's value of the FiatCurrency entity. 14395 // If the FiatCurrency object wasn't provided to the builder, the object is fetched from the database. 14396 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 14397 func (m *FiatCurrencyMutation) OldFeedType(ctx context.Context) (v string, err error) { 14398 if !m.op.Is(OpUpdateOne) { 14399 return v, errors.New("OldFeedType is only allowed on UpdateOne operations") 14400 } 14401 if m.id == nil || m.oldValue == nil { 14402 return v, errors.New("OldFeedType requires an ID field in the mutation") 14403 } 14404 oldValue, err := m.oldValue(ctx) 14405 if err != nil { 14406 return v, fmt.Errorf("querying old value for OldFeedType: %w", err) 14407 } 14408 return oldValue.FeedType, nil 14409 } 14410 14411 // ClearFeedType clears the value of the "feed_type" field. 14412 func (m *FiatCurrencyMutation) ClearFeedType() { 14413 m.feed_type = nil 14414 m.clearedFields[fiatcurrency.FieldFeedType] = struct{}{} 14415 } 14416 14417 // FeedTypeCleared returns if the "feed_type" field was cleared in this mutation. 14418 func (m *FiatCurrencyMutation) FeedTypeCleared() bool { 14419 _, ok := m.clearedFields[fiatcurrency.FieldFeedType] 14420 return ok 14421 } 14422 14423 // ResetFeedType resets all changes to the "feed_type" field. 14424 func (m *FiatCurrencyMutation) ResetFeedType() { 14425 m.feed_type = nil 14426 delete(m.clearedFields, fiatcurrency.FieldFeedType) 14427 } 14428 14429 // SetMarketValueLow sets the "market_value_low" field. 14430 func (m *FiatCurrencyMutation) SetMarketValueLow(d decimal.Decimal) { 14431 m.market_value_low = &d 14432 } 14433 14434 // MarketValueLow returns the value of the "market_value_low" field in the mutation. 14435 func (m *FiatCurrencyMutation) MarketValueLow() (r decimal.Decimal, exists bool) { 14436 v := m.market_value_low 14437 if v == nil { 14438 return 14439 } 14440 return *v, true 14441 } 14442 14443 // OldMarketValueLow returns the old "market_value_low" field's value of the FiatCurrency entity. 14444 // If the FiatCurrency object wasn't provided to the builder, the object is fetched from the database. 14445 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 14446 func (m *FiatCurrencyMutation) OldMarketValueLow(ctx context.Context) (v decimal.Decimal, err error) { 14447 if !m.op.Is(OpUpdateOne) { 14448 return v, errors.New("OldMarketValueLow is only allowed on UpdateOne operations") 14449 } 14450 if m.id == nil || m.oldValue == nil { 14451 return v, errors.New("OldMarketValueLow requires an ID field in the mutation") 14452 } 14453 oldValue, err := m.oldValue(ctx) 14454 if err != nil { 14455 return v, fmt.Errorf("querying old value for OldMarketValueLow: %w", err) 14456 } 14457 return oldValue.MarketValueLow, nil 14458 } 14459 14460 // ClearMarketValueLow clears the value of the "market_value_low" field. 14461 func (m *FiatCurrencyMutation) ClearMarketValueLow() { 14462 m.market_value_low = nil 14463 m.clearedFields[fiatcurrency.FieldMarketValueLow] = struct{}{} 14464 } 14465 14466 // MarketValueLowCleared returns if the "market_value_low" field was cleared in this mutation. 14467 func (m *FiatCurrencyMutation) MarketValueLowCleared() bool { 14468 _, ok := m.clearedFields[fiatcurrency.FieldMarketValueLow] 14469 return ok 14470 } 14471 14472 // ResetMarketValueLow resets all changes to the "market_value_low" field. 14473 func (m *FiatCurrencyMutation) ResetMarketValueLow() { 14474 m.market_value_low = nil 14475 delete(m.clearedFields, fiatcurrency.FieldMarketValueLow) 14476 } 14477 14478 // SetMarketValueHigh sets the "market_value_high" field. 14479 func (m *FiatCurrencyMutation) SetMarketValueHigh(d decimal.Decimal) { 14480 m.market_value_high = &d 14481 } 14482 14483 // MarketValueHigh returns the value of the "market_value_high" field in the mutation. 14484 func (m *FiatCurrencyMutation) MarketValueHigh() (r decimal.Decimal, exists bool) { 14485 v := m.market_value_high 14486 if v == nil { 14487 return 14488 } 14489 return *v, true 14490 } 14491 14492 // OldMarketValueHigh returns the old "market_value_high" field's value of the FiatCurrency entity. 14493 // If the FiatCurrency object wasn't provided to the builder, the object is fetched from the database. 14494 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 14495 func (m *FiatCurrencyMutation) OldMarketValueHigh(ctx context.Context) (v decimal.Decimal, err error) { 14496 if !m.op.Is(OpUpdateOne) { 14497 return v, errors.New("OldMarketValueHigh is only allowed on UpdateOne operations") 14498 } 14499 if m.id == nil || m.oldValue == nil { 14500 return v, errors.New("OldMarketValueHigh requires an ID field in the mutation") 14501 } 14502 oldValue, err := m.oldValue(ctx) 14503 if err != nil { 14504 return v, fmt.Errorf("querying old value for OldMarketValueHigh: %w", err) 14505 } 14506 return oldValue.MarketValueHigh, nil 14507 } 14508 14509 // ClearMarketValueHigh clears the value of the "market_value_high" field. 14510 func (m *FiatCurrencyMutation) ClearMarketValueHigh() { 14511 m.market_value_high = nil 14512 m.clearedFields[fiatcurrency.FieldMarketValueHigh] = struct{}{} 14513 } 14514 14515 // MarketValueHighCleared returns if the "market_value_high" field was cleared in this mutation. 14516 func (m *FiatCurrencyMutation) MarketValueHighCleared() bool { 14517 _, ok := m.clearedFields[fiatcurrency.FieldMarketValueHigh] 14518 return ok 14519 } 14520 14521 // ResetMarketValueHigh resets all changes to the "market_value_high" field. 14522 func (m *FiatCurrencyMutation) ResetMarketValueHigh() { 14523 m.market_value_high = nil 14524 delete(m.clearedFields, fiatcurrency.FieldMarketValueHigh) 14525 } 14526 14527 // Where appends a list predicates to the FiatCurrencyMutation builder. 14528 func (m *FiatCurrencyMutation) Where(ps ...predicate.FiatCurrency) { 14529 m.predicates = append(m.predicates, ps...) 14530 } 14531 14532 // Op returns the operation name. 14533 func (m *FiatCurrencyMutation) Op() Op { 14534 return m.op 14535 } 14536 14537 // Type returns the node type of this mutation (FiatCurrency). 14538 func (m *FiatCurrencyMutation) Type() string { 14539 return m.typ 14540 } 14541 14542 // Fields returns all fields that were changed during this mutation. Note that in 14543 // order to get all numeric fields that were incremented/decremented, call 14544 // AddedFields(). 14545 func (m *FiatCurrencyMutation) Fields() []string { 14546 fields := make([]string, 0, 8) 14547 if m.created_at != nil { 14548 fields = append(fields, fiatcurrency.FieldCreatedAt) 14549 } 14550 if m.updated_at != nil { 14551 fields = append(fields, fiatcurrency.FieldUpdatedAt) 14552 } 14553 if m.deleted_at != nil { 14554 fields = append(fields, fiatcurrency.FieldDeletedAt) 14555 } 14556 if m.ent_id != nil { 14557 fields = append(fields, fiatcurrency.FieldEntID) 14558 } 14559 if m.fiat_id != nil { 14560 fields = append(fields, fiatcurrency.FieldFiatID) 14561 } 14562 if m.feed_type != nil { 14563 fields = append(fields, fiatcurrency.FieldFeedType) 14564 } 14565 if m.market_value_low != nil { 14566 fields = append(fields, fiatcurrency.FieldMarketValueLow) 14567 } 14568 if m.market_value_high != nil { 14569 fields = append(fields, fiatcurrency.FieldMarketValueHigh) 14570 } 14571 return fields 14572 } 14573 14574 // Field returns the value of a field with the given name. The second boolean 14575 // return value indicates that this field was not set, or was not defined in the 14576 // schema. 14577 func (m *FiatCurrencyMutation) Field(name string) (ent.Value, bool) { 14578 switch name { 14579 case fiatcurrency.FieldCreatedAt: 14580 return m.CreatedAt() 14581 case fiatcurrency.FieldUpdatedAt: 14582 return m.UpdatedAt() 14583 case fiatcurrency.FieldDeletedAt: 14584 return m.DeletedAt() 14585 case fiatcurrency.FieldEntID: 14586 return m.EntID() 14587 case fiatcurrency.FieldFiatID: 14588 return m.FiatID() 14589 case fiatcurrency.FieldFeedType: 14590 return m.FeedType() 14591 case fiatcurrency.FieldMarketValueLow: 14592 return m.MarketValueLow() 14593 case fiatcurrency.FieldMarketValueHigh: 14594 return m.MarketValueHigh() 14595 } 14596 return nil, false 14597 } 14598 14599 // OldField returns the old value of the field from the database. An error is 14600 // returned if the mutation operation is not UpdateOne, or the query to the 14601 // database failed. 14602 func (m *FiatCurrencyMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 14603 switch name { 14604 case fiatcurrency.FieldCreatedAt: 14605 return m.OldCreatedAt(ctx) 14606 case fiatcurrency.FieldUpdatedAt: 14607 return m.OldUpdatedAt(ctx) 14608 case fiatcurrency.FieldDeletedAt: 14609 return m.OldDeletedAt(ctx) 14610 case fiatcurrency.FieldEntID: 14611 return m.OldEntID(ctx) 14612 case fiatcurrency.FieldFiatID: 14613 return m.OldFiatID(ctx) 14614 case fiatcurrency.FieldFeedType: 14615 return m.OldFeedType(ctx) 14616 case fiatcurrency.FieldMarketValueLow: 14617 return m.OldMarketValueLow(ctx) 14618 case fiatcurrency.FieldMarketValueHigh: 14619 return m.OldMarketValueHigh(ctx) 14620 } 14621 return nil, fmt.Errorf("unknown FiatCurrency field %s", name) 14622 } 14623 14624 // SetField sets the value of a field with the given name. It returns an error if 14625 // the field is not defined in the schema, or if the type mismatched the field 14626 // type. 14627 func (m *FiatCurrencyMutation) SetField(name string, value ent.Value) error { 14628 switch name { 14629 case fiatcurrency.FieldCreatedAt: 14630 v, ok := value.(uint32) 14631 if !ok { 14632 return fmt.Errorf("unexpected type %T for field %s", value, name) 14633 } 14634 m.SetCreatedAt(v) 14635 return nil 14636 case fiatcurrency.FieldUpdatedAt: 14637 v, ok := value.(uint32) 14638 if !ok { 14639 return fmt.Errorf("unexpected type %T for field %s", value, name) 14640 } 14641 m.SetUpdatedAt(v) 14642 return nil 14643 case fiatcurrency.FieldDeletedAt: 14644 v, ok := value.(uint32) 14645 if !ok { 14646 return fmt.Errorf("unexpected type %T for field %s", value, name) 14647 } 14648 m.SetDeletedAt(v) 14649 return nil 14650 case fiatcurrency.FieldEntID: 14651 v, ok := value.(uuid.UUID) 14652 if !ok { 14653 return fmt.Errorf("unexpected type %T for field %s", value, name) 14654 } 14655 m.SetEntID(v) 14656 return nil 14657 case fiatcurrency.FieldFiatID: 14658 v, ok := value.(uuid.UUID) 14659 if !ok { 14660 return fmt.Errorf("unexpected type %T for field %s", value, name) 14661 } 14662 m.SetFiatID(v) 14663 return nil 14664 case fiatcurrency.FieldFeedType: 14665 v, ok := value.(string) 14666 if !ok { 14667 return fmt.Errorf("unexpected type %T for field %s", value, name) 14668 } 14669 m.SetFeedType(v) 14670 return nil 14671 case fiatcurrency.FieldMarketValueLow: 14672 v, ok := value.(decimal.Decimal) 14673 if !ok { 14674 return fmt.Errorf("unexpected type %T for field %s", value, name) 14675 } 14676 m.SetMarketValueLow(v) 14677 return nil 14678 case fiatcurrency.FieldMarketValueHigh: 14679 v, ok := value.(decimal.Decimal) 14680 if !ok { 14681 return fmt.Errorf("unexpected type %T for field %s", value, name) 14682 } 14683 m.SetMarketValueHigh(v) 14684 return nil 14685 } 14686 return fmt.Errorf("unknown FiatCurrency field %s", name) 14687 } 14688 14689 // AddedFields returns all numeric fields that were incremented/decremented during 14690 // this mutation. 14691 func (m *FiatCurrencyMutation) AddedFields() []string { 14692 var fields []string 14693 if m.addcreated_at != nil { 14694 fields = append(fields, fiatcurrency.FieldCreatedAt) 14695 } 14696 if m.addupdated_at != nil { 14697 fields = append(fields, fiatcurrency.FieldUpdatedAt) 14698 } 14699 if m.adddeleted_at != nil { 14700 fields = append(fields, fiatcurrency.FieldDeletedAt) 14701 } 14702 return fields 14703 } 14704 14705 // AddedField returns the numeric value that was incremented/decremented on a field 14706 // with the given name. The second boolean return value indicates that this field 14707 // was not set, or was not defined in the schema. 14708 func (m *FiatCurrencyMutation) AddedField(name string) (ent.Value, bool) { 14709 switch name { 14710 case fiatcurrency.FieldCreatedAt: 14711 return m.AddedCreatedAt() 14712 case fiatcurrency.FieldUpdatedAt: 14713 return m.AddedUpdatedAt() 14714 case fiatcurrency.FieldDeletedAt: 14715 return m.AddedDeletedAt() 14716 } 14717 return nil, false 14718 } 14719 14720 // AddField adds the value to the field with the given name. It returns an error if 14721 // the field is not defined in the schema, or if the type mismatched the field 14722 // type. 14723 func (m *FiatCurrencyMutation) AddField(name string, value ent.Value) error { 14724 switch name { 14725 case fiatcurrency.FieldCreatedAt: 14726 v, ok := value.(int32) 14727 if !ok { 14728 return fmt.Errorf("unexpected type %T for field %s", value, name) 14729 } 14730 m.AddCreatedAt(v) 14731 return nil 14732 case fiatcurrency.FieldUpdatedAt: 14733 v, ok := value.(int32) 14734 if !ok { 14735 return fmt.Errorf("unexpected type %T for field %s", value, name) 14736 } 14737 m.AddUpdatedAt(v) 14738 return nil 14739 case fiatcurrency.FieldDeletedAt: 14740 v, ok := value.(int32) 14741 if !ok { 14742 return fmt.Errorf("unexpected type %T for field %s", value, name) 14743 } 14744 m.AddDeletedAt(v) 14745 return nil 14746 } 14747 return fmt.Errorf("unknown FiatCurrency numeric field %s", name) 14748 } 14749 14750 // ClearedFields returns all nullable fields that were cleared during this 14751 // mutation. 14752 func (m *FiatCurrencyMutation) ClearedFields() []string { 14753 var fields []string 14754 if m.FieldCleared(fiatcurrency.FieldFiatID) { 14755 fields = append(fields, fiatcurrency.FieldFiatID) 14756 } 14757 if m.FieldCleared(fiatcurrency.FieldFeedType) { 14758 fields = append(fields, fiatcurrency.FieldFeedType) 14759 } 14760 if m.FieldCleared(fiatcurrency.FieldMarketValueLow) { 14761 fields = append(fields, fiatcurrency.FieldMarketValueLow) 14762 } 14763 if m.FieldCleared(fiatcurrency.FieldMarketValueHigh) { 14764 fields = append(fields, fiatcurrency.FieldMarketValueHigh) 14765 } 14766 return fields 14767 } 14768 14769 // FieldCleared returns a boolean indicating if a field with the given name was 14770 // cleared in this mutation. 14771 func (m *FiatCurrencyMutation) FieldCleared(name string) bool { 14772 _, ok := m.clearedFields[name] 14773 return ok 14774 } 14775 14776 // ClearField clears the value of the field with the given name. It returns an 14777 // error if the field is not defined in the schema. 14778 func (m *FiatCurrencyMutation) ClearField(name string) error { 14779 switch name { 14780 case fiatcurrency.FieldFiatID: 14781 m.ClearFiatID() 14782 return nil 14783 case fiatcurrency.FieldFeedType: 14784 m.ClearFeedType() 14785 return nil 14786 case fiatcurrency.FieldMarketValueLow: 14787 m.ClearMarketValueLow() 14788 return nil 14789 case fiatcurrency.FieldMarketValueHigh: 14790 m.ClearMarketValueHigh() 14791 return nil 14792 } 14793 return fmt.Errorf("unknown FiatCurrency nullable field %s", name) 14794 } 14795 14796 // ResetField resets all changes in the mutation for the field with the given name. 14797 // It returns an error if the field is not defined in the schema. 14798 func (m *FiatCurrencyMutation) ResetField(name string) error { 14799 switch name { 14800 case fiatcurrency.FieldCreatedAt: 14801 m.ResetCreatedAt() 14802 return nil 14803 case fiatcurrency.FieldUpdatedAt: 14804 m.ResetUpdatedAt() 14805 return nil 14806 case fiatcurrency.FieldDeletedAt: 14807 m.ResetDeletedAt() 14808 return nil 14809 case fiatcurrency.FieldEntID: 14810 m.ResetEntID() 14811 return nil 14812 case fiatcurrency.FieldFiatID: 14813 m.ResetFiatID() 14814 return nil 14815 case fiatcurrency.FieldFeedType: 14816 m.ResetFeedType() 14817 return nil 14818 case fiatcurrency.FieldMarketValueLow: 14819 m.ResetMarketValueLow() 14820 return nil 14821 case fiatcurrency.FieldMarketValueHigh: 14822 m.ResetMarketValueHigh() 14823 return nil 14824 } 14825 return fmt.Errorf("unknown FiatCurrency field %s", name) 14826 } 14827 14828 // AddedEdges returns all edge names that were set/added in this mutation. 14829 func (m *FiatCurrencyMutation) AddedEdges() []string { 14830 edges := make([]string, 0, 0) 14831 return edges 14832 } 14833 14834 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 14835 // name in this mutation. 14836 func (m *FiatCurrencyMutation) AddedIDs(name string) []ent.Value { 14837 return nil 14838 } 14839 14840 // RemovedEdges returns all edge names that were removed in this mutation. 14841 func (m *FiatCurrencyMutation) RemovedEdges() []string { 14842 edges := make([]string, 0, 0) 14843 return edges 14844 } 14845 14846 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 14847 // the given name in this mutation. 14848 func (m *FiatCurrencyMutation) RemovedIDs(name string) []ent.Value { 14849 return nil 14850 } 14851 14852 // ClearedEdges returns all edge names that were cleared in this mutation. 14853 func (m *FiatCurrencyMutation) ClearedEdges() []string { 14854 edges := make([]string, 0, 0) 14855 return edges 14856 } 14857 14858 // EdgeCleared returns a boolean which indicates if the edge with the given name 14859 // was cleared in this mutation. 14860 func (m *FiatCurrencyMutation) EdgeCleared(name string) bool { 14861 return false 14862 } 14863 14864 // ClearEdge clears the value of the edge with the given name. It returns an error 14865 // if that edge is not defined in the schema. 14866 func (m *FiatCurrencyMutation) ClearEdge(name string) error { 14867 return fmt.Errorf("unknown FiatCurrency unique edge %s", name) 14868 } 14869 14870 // ResetEdge resets all changes to the edge with the given name in this mutation. 14871 // It returns an error if the edge is not defined in the schema. 14872 func (m *FiatCurrencyMutation) ResetEdge(name string) error { 14873 return fmt.Errorf("unknown FiatCurrency edge %s", name) 14874 } 14875 14876 // FiatCurrencyFeedMutation represents an operation that mutates the FiatCurrencyFeed nodes in the graph. 14877 type FiatCurrencyFeedMutation struct { 14878 config 14879 op Op 14880 typ string 14881 id *uint32 14882 created_at *uint32 14883 addcreated_at *int32 14884 updated_at *uint32 14885 addupdated_at *int32 14886 deleted_at *uint32 14887 adddeleted_at *int32 14888 ent_id *uuid.UUID 14889 fiat_id *uuid.UUID 14890 feed_type *string 14891 feed_fiat_name *string 14892 disabled *bool 14893 clearedFields map[string]struct{} 14894 done bool 14895 oldValue func(context.Context) (*FiatCurrencyFeed, error) 14896 predicates []predicate.FiatCurrencyFeed 14897 } 14898 14899 var _ ent.Mutation = (*FiatCurrencyFeedMutation)(nil) 14900 14901 // fiatcurrencyfeedOption allows management of the mutation configuration using functional options. 14902 type fiatcurrencyfeedOption func(*FiatCurrencyFeedMutation) 14903 14904 // newFiatCurrencyFeedMutation creates new mutation for the FiatCurrencyFeed entity. 14905 func newFiatCurrencyFeedMutation(c config, op Op, opts ...fiatcurrencyfeedOption) *FiatCurrencyFeedMutation { 14906 m := &FiatCurrencyFeedMutation{ 14907 config: c, 14908 op: op, 14909 typ: TypeFiatCurrencyFeed, 14910 clearedFields: make(map[string]struct{}), 14911 } 14912 for _, opt := range opts { 14913 opt(m) 14914 } 14915 return m 14916 } 14917 14918 // withFiatCurrencyFeedID sets the ID field of the mutation. 14919 func withFiatCurrencyFeedID(id uint32) fiatcurrencyfeedOption { 14920 return func(m *FiatCurrencyFeedMutation) { 14921 var ( 14922 err error 14923 once sync.Once 14924 value *FiatCurrencyFeed 14925 ) 14926 m.oldValue = func(ctx context.Context) (*FiatCurrencyFeed, error) { 14927 once.Do(func() { 14928 if m.done { 14929 err = errors.New("querying old values post mutation is not allowed") 14930 } else { 14931 value, err = m.Client().FiatCurrencyFeed.Get(ctx, id) 14932 } 14933 }) 14934 return value, err 14935 } 14936 m.id = &id 14937 } 14938 } 14939 14940 // withFiatCurrencyFeed sets the old FiatCurrencyFeed of the mutation. 14941 func withFiatCurrencyFeed(node *FiatCurrencyFeed) fiatcurrencyfeedOption { 14942 return func(m *FiatCurrencyFeedMutation) { 14943 m.oldValue = func(context.Context) (*FiatCurrencyFeed, error) { 14944 return node, nil 14945 } 14946 m.id = &node.ID 14947 } 14948 } 14949 14950 // Client returns a new `ent.Client` from the mutation. If the mutation was 14951 // executed in a transaction (ent.Tx), a transactional client is returned. 14952 func (m FiatCurrencyFeedMutation) Client() *Client { 14953 client := &Client{config: m.config} 14954 client.init() 14955 return client 14956 } 14957 14958 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 14959 // it returns an error otherwise. 14960 func (m FiatCurrencyFeedMutation) Tx() (*Tx, error) { 14961 if _, ok := m.driver.(*txDriver); !ok { 14962 return nil, errors.New("ent: mutation is not running in a transaction") 14963 } 14964 tx := &Tx{config: m.config} 14965 tx.init() 14966 return tx, nil 14967 } 14968 14969 // SetID sets the value of the id field. Note that this 14970 // operation is only accepted on creation of FiatCurrencyFeed entities. 14971 func (m *FiatCurrencyFeedMutation) SetID(id uint32) { 14972 m.id = &id 14973 } 14974 14975 // ID returns the ID value in the mutation. Note that the ID is only available 14976 // if it was provided to the builder or after it was returned from the database. 14977 func (m *FiatCurrencyFeedMutation) ID() (id uint32, exists bool) { 14978 if m.id == nil { 14979 return 14980 } 14981 return *m.id, true 14982 } 14983 14984 // IDs queries the database and returns the entity ids that match the mutation's predicate. 14985 // That means, if the mutation is applied within a transaction with an isolation level such 14986 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 14987 // or updated by the mutation. 14988 func (m *FiatCurrencyFeedMutation) IDs(ctx context.Context) ([]uint32, error) { 14989 switch { 14990 case m.op.Is(OpUpdateOne | OpDeleteOne): 14991 id, exists := m.ID() 14992 if exists { 14993 return []uint32{id}, nil 14994 } 14995 fallthrough 14996 case m.op.Is(OpUpdate | OpDelete): 14997 return m.Client().FiatCurrencyFeed.Query().Where(m.predicates...).IDs(ctx) 14998 default: 14999 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 15000 } 15001 } 15002 15003 // SetCreatedAt sets the "created_at" field. 15004 func (m *FiatCurrencyFeedMutation) SetCreatedAt(u uint32) { 15005 m.created_at = &u 15006 m.addcreated_at = nil 15007 } 15008 15009 // CreatedAt returns the value of the "created_at" field in the mutation. 15010 func (m *FiatCurrencyFeedMutation) CreatedAt() (r uint32, exists bool) { 15011 v := m.created_at 15012 if v == nil { 15013 return 15014 } 15015 return *v, true 15016 } 15017 15018 // OldCreatedAt returns the old "created_at" field's value of the FiatCurrencyFeed entity. 15019 // If the FiatCurrencyFeed object wasn't provided to the builder, the object is fetched from the database. 15020 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 15021 func (m *FiatCurrencyFeedMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 15022 if !m.op.Is(OpUpdateOne) { 15023 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 15024 } 15025 if m.id == nil || m.oldValue == nil { 15026 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 15027 } 15028 oldValue, err := m.oldValue(ctx) 15029 if err != nil { 15030 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 15031 } 15032 return oldValue.CreatedAt, nil 15033 } 15034 15035 // AddCreatedAt adds u to the "created_at" field. 15036 func (m *FiatCurrencyFeedMutation) AddCreatedAt(u int32) { 15037 if m.addcreated_at != nil { 15038 *m.addcreated_at += u 15039 } else { 15040 m.addcreated_at = &u 15041 } 15042 } 15043 15044 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 15045 func (m *FiatCurrencyFeedMutation) AddedCreatedAt() (r int32, exists bool) { 15046 v := m.addcreated_at 15047 if v == nil { 15048 return 15049 } 15050 return *v, true 15051 } 15052 15053 // ResetCreatedAt resets all changes to the "created_at" field. 15054 func (m *FiatCurrencyFeedMutation) ResetCreatedAt() { 15055 m.created_at = nil 15056 m.addcreated_at = nil 15057 } 15058 15059 // SetUpdatedAt sets the "updated_at" field. 15060 func (m *FiatCurrencyFeedMutation) SetUpdatedAt(u uint32) { 15061 m.updated_at = &u 15062 m.addupdated_at = nil 15063 } 15064 15065 // UpdatedAt returns the value of the "updated_at" field in the mutation. 15066 func (m *FiatCurrencyFeedMutation) UpdatedAt() (r uint32, exists bool) { 15067 v := m.updated_at 15068 if v == nil { 15069 return 15070 } 15071 return *v, true 15072 } 15073 15074 // OldUpdatedAt returns the old "updated_at" field's value of the FiatCurrencyFeed entity. 15075 // If the FiatCurrencyFeed object wasn't provided to the builder, the object is fetched from the database. 15076 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 15077 func (m *FiatCurrencyFeedMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 15078 if !m.op.Is(OpUpdateOne) { 15079 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 15080 } 15081 if m.id == nil || m.oldValue == nil { 15082 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 15083 } 15084 oldValue, err := m.oldValue(ctx) 15085 if err != nil { 15086 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 15087 } 15088 return oldValue.UpdatedAt, nil 15089 } 15090 15091 // AddUpdatedAt adds u to the "updated_at" field. 15092 func (m *FiatCurrencyFeedMutation) AddUpdatedAt(u int32) { 15093 if m.addupdated_at != nil { 15094 *m.addupdated_at += u 15095 } else { 15096 m.addupdated_at = &u 15097 } 15098 } 15099 15100 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 15101 func (m *FiatCurrencyFeedMutation) AddedUpdatedAt() (r int32, exists bool) { 15102 v := m.addupdated_at 15103 if v == nil { 15104 return 15105 } 15106 return *v, true 15107 } 15108 15109 // ResetUpdatedAt resets all changes to the "updated_at" field. 15110 func (m *FiatCurrencyFeedMutation) ResetUpdatedAt() { 15111 m.updated_at = nil 15112 m.addupdated_at = nil 15113 } 15114 15115 // SetDeletedAt sets the "deleted_at" field. 15116 func (m *FiatCurrencyFeedMutation) SetDeletedAt(u uint32) { 15117 m.deleted_at = &u 15118 m.adddeleted_at = nil 15119 } 15120 15121 // DeletedAt returns the value of the "deleted_at" field in the mutation. 15122 func (m *FiatCurrencyFeedMutation) DeletedAt() (r uint32, exists bool) { 15123 v := m.deleted_at 15124 if v == nil { 15125 return 15126 } 15127 return *v, true 15128 } 15129 15130 // OldDeletedAt returns the old "deleted_at" field's value of the FiatCurrencyFeed entity. 15131 // If the FiatCurrencyFeed object wasn't provided to the builder, the object is fetched from the database. 15132 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 15133 func (m *FiatCurrencyFeedMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 15134 if !m.op.Is(OpUpdateOne) { 15135 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 15136 } 15137 if m.id == nil || m.oldValue == nil { 15138 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 15139 } 15140 oldValue, err := m.oldValue(ctx) 15141 if err != nil { 15142 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 15143 } 15144 return oldValue.DeletedAt, nil 15145 } 15146 15147 // AddDeletedAt adds u to the "deleted_at" field. 15148 func (m *FiatCurrencyFeedMutation) AddDeletedAt(u int32) { 15149 if m.adddeleted_at != nil { 15150 *m.adddeleted_at += u 15151 } else { 15152 m.adddeleted_at = &u 15153 } 15154 } 15155 15156 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 15157 func (m *FiatCurrencyFeedMutation) AddedDeletedAt() (r int32, exists bool) { 15158 v := m.adddeleted_at 15159 if v == nil { 15160 return 15161 } 15162 return *v, true 15163 } 15164 15165 // ResetDeletedAt resets all changes to the "deleted_at" field. 15166 func (m *FiatCurrencyFeedMutation) ResetDeletedAt() { 15167 m.deleted_at = nil 15168 m.adddeleted_at = nil 15169 } 15170 15171 // SetEntID sets the "ent_id" field. 15172 func (m *FiatCurrencyFeedMutation) SetEntID(u uuid.UUID) { 15173 m.ent_id = &u 15174 } 15175 15176 // EntID returns the value of the "ent_id" field in the mutation. 15177 func (m *FiatCurrencyFeedMutation) EntID() (r uuid.UUID, exists bool) { 15178 v := m.ent_id 15179 if v == nil { 15180 return 15181 } 15182 return *v, true 15183 } 15184 15185 // OldEntID returns the old "ent_id" field's value of the FiatCurrencyFeed entity. 15186 // If the FiatCurrencyFeed object wasn't provided to the builder, the object is fetched from the database. 15187 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 15188 func (m *FiatCurrencyFeedMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 15189 if !m.op.Is(OpUpdateOne) { 15190 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 15191 } 15192 if m.id == nil || m.oldValue == nil { 15193 return v, errors.New("OldEntID requires an ID field in the mutation") 15194 } 15195 oldValue, err := m.oldValue(ctx) 15196 if err != nil { 15197 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 15198 } 15199 return oldValue.EntID, nil 15200 } 15201 15202 // ResetEntID resets all changes to the "ent_id" field. 15203 func (m *FiatCurrencyFeedMutation) ResetEntID() { 15204 m.ent_id = nil 15205 } 15206 15207 // SetFiatID sets the "fiat_id" field. 15208 func (m *FiatCurrencyFeedMutation) SetFiatID(u uuid.UUID) { 15209 m.fiat_id = &u 15210 } 15211 15212 // FiatID returns the value of the "fiat_id" field in the mutation. 15213 func (m *FiatCurrencyFeedMutation) FiatID() (r uuid.UUID, exists bool) { 15214 v := m.fiat_id 15215 if v == nil { 15216 return 15217 } 15218 return *v, true 15219 } 15220 15221 // OldFiatID returns the old "fiat_id" field's value of the FiatCurrencyFeed entity. 15222 // If the FiatCurrencyFeed object wasn't provided to the builder, the object is fetched from the database. 15223 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 15224 func (m *FiatCurrencyFeedMutation) OldFiatID(ctx context.Context) (v uuid.UUID, err error) { 15225 if !m.op.Is(OpUpdateOne) { 15226 return v, errors.New("OldFiatID is only allowed on UpdateOne operations") 15227 } 15228 if m.id == nil || m.oldValue == nil { 15229 return v, errors.New("OldFiatID requires an ID field in the mutation") 15230 } 15231 oldValue, err := m.oldValue(ctx) 15232 if err != nil { 15233 return v, fmt.Errorf("querying old value for OldFiatID: %w", err) 15234 } 15235 return oldValue.FiatID, nil 15236 } 15237 15238 // ClearFiatID clears the value of the "fiat_id" field. 15239 func (m *FiatCurrencyFeedMutation) ClearFiatID() { 15240 m.fiat_id = nil 15241 m.clearedFields[fiatcurrencyfeed.FieldFiatID] = struct{}{} 15242 } 15243 15244 // FiatIDCleared returns if the "fiat_id" field was cleared in this mutation. 15245 func (m *FiatCurrencyFeedMutation) FiatIDCleared() bool { 15246 _, ok := m.clearedFields[fiatcurrencyfeed.FieldFiatID] 15247 return ok 15248 } 15249 15250 // ResetFiatID resets all changes to the "fiat_id" field. 15251 func (m *FiatCurrencyFeedMutation) ResetFiatID() { 15252 m.fiat_id = nil 15253 delete(m.clearedFields, fiatcurrencyfeed.FieldFiatID) 15254 } 15255 15256 // SetFeedType sets the "feed_type" field. 15257 func (m *FiatCurrencyFeedMutation) SetFeedType(s string) { 15258 m.feed_type = &s 15259 } 15260 15261 // FeedType returns the value of the "feed_type" field in the mutation. 15262 func (m *FiatCurrencyFeedMutation) FeedType() (r string, exists bool) { 15263 v := m.feed_type 15264 if v == nil { 15265 return 15266 } 15267 return *v, true 15268 } 15269 15270 // OldFeedType returns the old "feed_type" field's value of the FiatCurrencyFeed entity. 15271 // If the FiatCurrencyFeed object wasn't provided to the builder, the object is fetched from the database. 15272 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 15273 func (m *FiatCurrencyFeedMutation) OldFeedType(ctx context.Context) (v string, err error) { 15274 if !m.op.Is(OpUpdateOne) { 15275 return v, errors.New("OldFeedType is only allowed on UpdateOne operations") 15276 } 15277 if m.id == nil || m.oldValue == nil { 15278 return v, errors.New("OldFeedType requires an ID field in the mutation") 15279 } 15280 oldValue, err := m.oldValue(ctx) 15281 if err != nil { 15282 return v, fmt.Errorf("querying old value for OldFeedType: %w", err) 15283 } 15284 return oldValue.FeedType, nil 15285 } 15286 15287 // ClearFeedType clears the value of the "feed_type" field. 15288 func (m *FiatCurrencyFeedMutation) ClearFeedType() { 15289 m.feed_type = nil 15290 m.clearedFields[fiatcurrencyfeed.FieldFeedType] = struct{}{} 15291 } 15292 15293 // FeedTypeCleared returns if the "feed_type" field was cleared in this mutation. 15294 func (m *FiatCurrencyFeedMutation) FeedTypeCleared() bool { 15295 _, ok := m.clearedFields[fiatcurrencyfeed.FieldFeedType] 15296 return ok 15297 } 15298 15299 // ResetFeedType resets all changes to the "feed_type" field. 15300 func (m *FiatCurrencyFeedMutation) ResetFeedType() { 15301 m.feed_type = nil 15302 delete(m.clearedFields, fiatcurrencyfeed.FieldFeedType) 15303 } 15304 15305 // SetFeedFiatName sets the "feed_fiat_name" field. 15306 func (m *FiatCurrencyFeedMutation) SetFeedFiatName(s string) { 15307 m.feed_fiat_name = &s 15308 } 15309 15310 // FeedFiatName returns the value of the "feed_fiat_name" field in the mutation. 15311 func (m *FiatCurrencyFeedMutation) FeedFiatName() (r string, exists bool) { 15312 v := m.feed_fiat_name 15313 if v == nil { 15314 return 15315 } 15316 return *v, true 15317 } 15318 15319 // OldFeedFiatName returns the old "feed_fiat_name" field's value of the FiatCurrencyFeed entity. 15320 // If the FiatCurrencyFeed object wasn't provided to the builder, the object is fetched from the database. 15321 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 15322 func (m *FiatCurrencyFeedMutation) OldFeedFiatName(ctx context.Context) (v string, err error) { 15323 if !m.op.Is(OpUpdateOne) { 15324 return v, errors.New("OldFeedFiatName is only allowed on UpdateOne operations") 15325 } 15326 if m.id == nil || m.oldValue == nil { 15327 return v, errors.New("OldFeedFiatName requires an ID field in the mutation") 15328 } 15329 oldValue, err := m.oldValue(ctx) 15330 if err != nil { 15331 return v, fmt.Errorf("querying old value for OldFeedFiatName: %w", err) 15332 } 15333 return oldValue.FeedFiatName, nil 15334 } 15335 15336 // ClearFeedFiatName clears the value of the "feed_fiat_name" field. 15337 func (m *FiatCurrencyFeedMutation) ClearFeedFiatName() { 15338 m.feed_fiat_name = nil 15339 m.clearedFields[fiatcurrencyfeed.FieldFeedFiatName] = struct{}{} 15340 } 15341 15342 // FeedFiatNameCleared returns if the "feed_fiat_name" field was cleared in this mutation. 15343 func (m *FiatCurrencyFeedMutation) FeedFiatNameCleared() bool { 15344 _, ok := m.clearedFields[fiatcurrencyfeed.FieldFeedFiatName] 15345 return ok 15346 } 15347 15348 // ResetFeedFiatName resets all changes to the "feed_fiat_name" field. 15349 func (m *FiatCurrencyFeedMutation) ResetFeedFiatName() { 15350 m.feed_fiat_name = nil 15351 delete(m.clearedFields, fiatcurrencyfeed.FieldFeedFiatName) 15352 } 15353 15354 // SetDisabled sets the "disabled" field. 15355 func (m *FiatCurrencyFeedMutation) SetDisabled(b bool) { 15356 m.disabled = &b 15357 } 15358 15359 // Disabled returns the value of the "disabled" field in the mutation. 15360 func (m *FiatCurrencyFeedMutation) Disabled() (r bool, exists bool) { 15361 v := m.disabled 15362 if v == nil { 15363 return 15364 } 15365 return *v, true 15366 } 15367 15368 // OldDisabled returns the old "disabled" field's value of the FiatCurrencyFeed entity. 15369 // If the FiatCurrencyFeed object wasn't provided to the builder, the object is fetched from the database. 15370 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 15371 func (m *FiatCurrencyFeedMutation) OldDisabled(ctx context.Context) (v bool, err error) { 15372 if !m.op.Is(OpUpdateOne) { 15373 return v, errors.New("OldDisabled is only allowed on UpdateOne operations") 15374 } 15375 if m.id == nil || m.oldValue == nil { 15376 return v, errors.New("OldDisabled requires an ID field in the mutation") 15377 } 15378 oldValue, err := m.oldValue(ctx) 15379 if err != nil { 15380 return v, fmt.Errorf("querying old value for OldDisabled: %w", err) 15381 } 15382 return oldValue.Disabled, nil 15383 } 15384 15385 // ClearDisabled clears the value of the "disabled" field. 15386 func (m *FiatCurrencyFeedMutation) ClearDisabled() { 15387 m.disabled = nil 15388 m.clearedFields[fiatcurrencyfeed.FieldDisabled] = struct{}{} 15389 } 15390 15391 // DisabledCleared returns if the "disabled" field was cleared in this mutation. 15392 func (m *FiatCurrencyFeedMutation) DisabledCleared() bool { 15393 _, ok := m.clearedFields[fiatcurrencyfeed.FieldDisabled] 15394 return ok 15395 } 15396 15397 // ResetDisabled resets all changes to the "disabled" field. 15398 func (m *FiatCurrencyFeedMutation) ResetDisabled() { 15399 m.disabled = nil 15400 delete(m.clearedFields, fiatcurrencyfeed.FieldDisabled) 15401 } 15402 15403 // Where appends a list predicates to the FiatCurrencyFeedMutation builder. 15404 func (m *FiatCurrencyFeedMutation) Where(ps ...predicate.FiatCurrencyFeed) { 15405 m.predicates = append(m.predicates, ps...) 15406 } 15407 15408 // Op returns the operation name. 15409 func (m *FiatCurrencyFeedMutation) Op() Op { 15410 return m.op 15411 } 15412 15413 // Type returns the node type of this mutation (FiatCurrencyFeed). 15414 func (m *FiatCurrencyFeedMutation) Type() string { 15415 return m.typ 15416 } 15417 15418 // Fields returns all fields that were changed during this mutation. Note that in 15419 // order to get all numeric fields that were incremented/decremented, call 15420 // AddedFields(). 15421 func (m *FiatCurrencyFeedMutation) Fields() []string { 15422 fields := make([]string, 0, 8) 15423 if m.created_at != nil { 15424 fields = append(fields, fiatcurrencyfeed.FieldCreatedAt) 15425 } 15426 if m.updated_at != nil { 15427 fields = append(fields, fiatcurrencyfeed.FieldUpdatedAt) 15428 } 15429 if m.deleted_at != nil { 15430 fields = append(fields, fiatcurrencyfeed.FieldDeletedAt) 15431 } 15432 if m.ent_id != nil { 15433 fields = append(fields, fiatcurrencyfeed.FieldEntID) 15434 } 15435 if m.fiat_id != nil { 15436 fields = append(fields, fiatcurrencyfeed.FieldFiatID) 15437 } 15438 if m.feed_type != nil { 15439 fields = append(fields, fiatcurrencyfeed.FieldFeedType) 15440 } 15441 if m.feed_fiat_name != nil { 15442 fields = append(fields, fiatcurrencyfeed.FieldFeedFiatName) 15443 } 15444 if m.disabled != nil { 15445 fields = append(fields, fiatcurrencyfeed.FieldDisabled) 15446 } 15447 return fields 15448 } 15449 15450 // Field returns the value of a field with the given name. The second boolean 15451 // return value indicates that this field was not set, or was not defined in the 15452 // schema. 15453 func (m *FiatCurrencyFeedMutation) Field(name string) (ent.Value, bool) { 15454 switch name { 15455 case fiatcurrencyfeed.FieldCreatedAt: 15456 return m.CreatedAt() 15457 case fiatcurrencyfeed.FieldUpdatedAt: 15458 return m.UpdatedAt() 15459 case fiatcurrencyfeed.FieldDeletedAt: 15460 return m.DeletedAt() 15461 case fiatcurrencyfeed.FieldEntID: 15462 return m.EntID() 15463 case fiatcurrencyfeed.FieldFiatID: 15464 return m.FiatID() 15465 case fiatcurrencyfeed.FieldFeedType: 15466 return m.FeedType() 15467 case fiatcurrencyfeed.FieldFeedFiatName: 15468 return m.FeedFiatName() 15469 case fiatcurrencyfeed.FieldDisabled: 15470 return m.Disabled() 15471 } 15472 return nil, false 15473 } 15474 15475 // OldField returns the old value of the field from the database. An error is 15476 // returned if the mutation operation is not UpdateOne, or the query to the 15477 // database failed. 15478 func (m *FiatCurrencyFeedMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 15479 switch name { 15480 case fiatcurrencyfeed.FieldCreatedAt: 15481 return m.OldCreatedAt(ctx) 15482 case fiatcurrencyfeed.FieldUpdatedAt: 15483 return m.OldUpdatedAt(ctx) 15484 case fiatcurrencyfeed.FieldDeletedAt: 15485 return m.OldDeletedAt(ctx) 15486 case fiatcurrencyfeed.FieldEntID: 15487 return m.OldEntID(ctx) 15488 case fiatcurrencyfeed.FieldFiatID: 15489 return m.OldFiatID(ctx) 15490 case fiatcurrencyfeed.FieldFeedType: 15491 return m.OldFeedType(ctx) 15492 case fiatcurrencyfeed.FieldFeedFiatName: 15493 return m.OldFeedFiatName(ctx) 15494 case fiatcurrencyfeed.FieldDisabled: 15495 return m.OldDisabled(ctx) 15496 } 15497 return nil, fmt.Errorf("unknown FiatCurrencyFeed field %s", name) 15498 } 15499 15500 // SetField sets the value of a field with the given name. It returns an error if 15501 // the field is not defined in the schema, or if the type mismatched the field 15502 // type. 15503 func (m *FiatCurrencyFeedMutation) SetField(name string, value ent.Value) error { 15504 switch name { 15505 case fiatcurrencyfeed.FieldCreatedAt: 15506 v, ok := value.(uint32) 15507 if !ok { 15508 return fmt.Errorf("unexpected type %T for field %s", value, name) 15509 } 15510 m.SetCreatedAt(v) 15511 return nil 15512 case fiatcurrencyfeed.FieldUpdatedAt: 15513 v, ok := value.(uint32) 15514 if !ok { 15515 return fmt.Errorf("unexpected type %T for field %s", value, name) 15516 } 15517 m.SetUpdatedAt(v) 15518 return nil 15519 case fiatcurrencyfeed.FieldDeletedAt: 15520 v, ok := value.(uint32) 15521 if !ok { 15522 return fmt.Errorf("unexpected type %T for field %s", value, name) 15523 } 15524 m.SetDeletedAt(v) 15525 return nil 15526 case fiatcurrencyfeed.FieldEntID: 15527 v, ok := value.(uuid.UUID) 15528 if !ok { 15529 return fmt.Errorf("unexpected type %T for field %s", value, name) 15530 } 15531 m.SetEntID(v) 15532 return nil 15533 case fiatcurrencyfeed.FieldFiatID: 15534 v, ok := value.(uuid.UUID) 15535 if !ok { 15536 return fmt.Errorf("unexpected type %T for field %s", value, name) 15537 } 15538 m.SetFiatID(v) 15539 return nil 15540 case fiatcurrencyfeed.FieldFeedType: 15541 v, ok := value.(string) 15542 if !ok { 15543 return fmt.Errorf("unexpected type %T for field %s", value, name) 15544 } 15545 m.SetFeedType(v) 15546 return nil 15547 case fiatcurrencyfeed.FieldFeedFiatName: 15548 v, ok := value.(string) 15549 if !ok { 15550 return fmt.Errorf("unexpected type %T for field %s", value, name) 15551 } 15552 m.SetFeedFiatName(v) 15553 return nil 15554 case fiatcurrencyfeed.FieldDisabled: 15555 v, ok := value.(bool) 15556 if !ok { 15557 return fmt.Errorf("unexpected type %T for field %s", value, name) 15558 } 15559 m.SetDisabled(v) 15560 return nil 15561 } 15562 return fmt.Errorf("unknown FiatCurrencyFeed field %s", name) 15563 } 15564 15565 // AddedFields returns all numeric fields that were incremented/decremented during 15566 // this mutation. 15567 func (m *FiatCurrencyFeedMutation) AddedFields() []string { 15568 var fields []string 15569 if m.addcreated_at != nil { 15570 fields = append(fields, fiatcurrencyfeed.FieldCreatedAt) 15571 } 15572 if m.addupdated_at != nil { 15573 fields = append(fields, fiatcurrencyfeed.FieldUpdatedAt) 15574 } 15575 if m.adddeleted_at != nil { 15576 fields = append(fields, fiatcurrencyfeed.FieldDeletedAt) 15577 } 15578 return fields 15579 } 15580 15581 // AddedField returns the numeric value that was incremented/decremented on a field 15582 // with the given name. The second boolean return value indicates that this field 15583 // was not set, or was not defined in the schema. 15584 func (m *FiatCurrencyFeedMutation) AddedField(name string) (ent.Value, bool) { 15585 switch name { 15586 case fiatcurrencyfeed.FieldCreatedAt: 15587 return m.AddedCreatedAt() 15588 case fiatcurrencyfeed.FieldUpdatedAt: 15589 return m.AddedUpdatedAt() 15590 case fiatcurrencyfeed.FieldDeletedAt: 15591 return m.AddedDeletedAt() 15592 } 15593 return nil, false 15594 } 15595 15596 // AddField adds the value to the field with the given name. It returns an error if 15597 // the field is not defined in the schema, or if the type mismatched the field 15598 // type. 15599 func (m *FiatCurrencyFeedMutation) AddField(name string, value ent.Value) error { 15600 switch name { 15601 case fiatcurrencyfeed.FieldCreatedAt: 15602 v, ok := value.(int32) 15603 if !ok { 15604 return fmt.Errorf("unexpected type %T for field %s", value, name) 15605 } 15606 m.AddCreatedAt(v) 15607 return nil 15608 case fiatcurrencyfeed.FieldUpdatedAt: 15609 v, ok := value.(int32) 15610 if !ok { 15611 return fmt.Errorf("unexpected type %T for field %s", value, name) 15612 } 15613 m.AddUpdatedAt(v) 15614 return nil 15615 case fiatcurrencyfeed.FieldDeletedAt: 15616 v, ok := value.(int32) 15617 if !ok { 15618 return fmt.Errorf("unexpected type %T for field %s", value, name) 15619 } 15620 m.AddDeletedAt(v) 15621 return nil 15622 } 15623 return fmt.Errorf("unknown FiatCurrencyFeed numeric field %s", name) 15624 } 15625 15626 // ClearedFields returns all nullable fields that were cleared during this 15627 // mutation. 15628 func (m *FiatCurrencyFeedMutation) ClearedFields() []string { 15629 var fields []string 15630 if m.FieldCleared(fiatcurrencyfeed.FieldFiatID) { 15631 fields = append(fields, fiatcurrencyfeed.FieldFiatID) 15632 } 15633 if m.FieldCleared(fiatcurrencyfeed.FieldFeedType) { 15634 fields = append(fields, fiatcurrencyfeed.FieldFeedType) 15635 } 15636 if m.FieldCleared(fiatcurrencyfeed.FieldFeedFiatName) { 15637 fields = append(fields, fiatcurrencyfeed.FieldFeedFiatName) 15638 } 15639 if m.FieldCleared(fiatcurrencyfeed.FieldDisabled) { 15640 fields = append(fields, fiatcurrencyfeed.FieldDisabled) 15641 } 15642 return fields 15643 } 15644 15645 // FieldCleared returns a boolean indicating if a field with the given name was 15646 // cleared in this mutation. 15647 func (m *FiatCurrencyFeedMutation) FieldCleared(name string) bool { 15648 _, ok := m.clearedFields[name] 15649 return ok 15650 } 15651 15652 // ClearField clears the value of the field with the given name. It returns an 15653 // error if the field is not defined in the schema. 15654 func (m *FiatCurrencyFeedMutation) ClearField(name string) error { 15655 switch name { 15656 case fiatcurrencyfeed.FieldFiatID: 15657 m.ClearFiatID() 15658 return nil 15659 case fiatcurrencyfeed.FieldFeedType: 15660 m.ClearFeedType() 15661 return nil 15662 case fiatcurrencyfeed.FieldFeedFiatName: 15663 m.ClearFeedFiatName() 15664 return nil 15665 case fiatcurrencyfeed.FieldDisabled: 15666 m.ClearDisabled() 15667 return nil 15668 } 15669 return fmt.Errorf("unknown FiatCurrencyFeed nullable field %s", name) 15670 } 15671 15672 // ResetField resets all changes in the mutation for the field with the given name. 15673 // It returns an error if the field is not defined in the schema. 15674 func (m *FiatCurrencyFeedMutation) ResetField(name string) error { 15675 switch name { 15676 case fiatcurrencyfeed.FieldCreatedAt: 15677 m.ResetCreatedAt() 15678 return nil 15679 case fiatcurrencyfeed.FieldUpdatedAt: 15680 m.ResetUpdatedAt() 15681 return nil 15682 case fiatcurrencyfeed.FieldDeletedAt: 15683 m.ResetDeletedAt() 15684 return nil 15685 case fiatcurrencyfeed.FieldEntID: 15686 m.ResetEntID() 15687 return nil 15688 case fiatcurrencyfeed.FieldFiatID: 15689 m.ResetFiatID() 15690 return nil 15691 case fiatcurrencyfeed.FieldFeedType: 15692 m.ResetFeedType() 15693 return nil 15694 case fiatcurrencyfeed.FieldFeedFiatName: 15695 m.ResetFeedFiatName() 15696 return nil 15697 case fiatcurrencyfeed.FieldDisabled: 15698 m.ResetDisabled() 15699 return nil 15700 } 15701 return fmt.Errorf("unknown FiatCurrencyFeed field %s", name) 15702 } 15703 15704 // AddedEdges returns all edge names that were set/added in this mutation. 15705 func (m *FiatCurrencyFeedMutation) AddedEdges() []string { 15706 edges := make([]string, 0, 0) 15707 return edges 15708 } 15709 15710 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 15711 // name in this mutation. 15712 func (m *FiatCurrencyFeedMutation) AddedIDs(name string) []ent.Value { 15713 return nil 15714 } 15715 15716 // RemovedEdges returns all edge names that were removed in this mutation. 15717 func (m *FiatCurrencyFeedMutation) RemovedEdges() []string { 15718 edges := make([]string, 0, 0) 15719 return edges 15720 } 15721 15722 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 15723 // the given name in this mutation. 15724 func (m *FiatCurrencyFeedMutation) RemovedIDs(name string) []ent.Value { 15725 return nil 15726 } 15727 15728 // ClearedEdges returns all edge names that were cleared in this mutation. 15729 func (m *FiatCurrencyFeedMutation) ClearedEdges() []string { 15730 edges := make([]string, 0, 0) 15731 return edges 15732 } 15733 15734 // EdgeCleared returns a boolean which indicates if the edge with the given name 15735 // was cleared in this mutation. 15736 func (m *FiatCurrencyFeedMutation) EdgeCleared(name string) bool { 15737 return false 15738 } 15739 15740 // ClearEdge clears the value of the edge with the given name. It returns an error 15741 // if that edge is not defined in the schema. 15742 func (m *FiatCurrencyFeedMutation) ClearEdge(name string) error { 15743 return fmt.Errorf("unknown FiatCurrencyFeed unique edge %s", name) 15744 } 15745 15746 // ResetEdge resets all changes to the edge with the given name in this mutation. 15747 // It returns an error if the edge is not defined in the schema. 15748 func (m *FiatCurrencyFeedMutation) ResetEdge(name string) error { 15749 return fmt.Errorf("unknown FiatCurrencyFeed edge %s", name) 15750 } 15751 15752 // FiatCurrencyHistoryMutation represents an operation that mutates the FiatCurrencyHistory nodes in the graph. 15753 type FiatCurrencyHistoryMutation struct { 15754 config 15755 op Op 15756 typ string 15757 id *uint32 15758 created_at *uint32 15759 addcreated_at *int32 15760 updated_at *uint32 15761 addupdated_at *int32 15762 deleted_at *uint32 15763 adddeleted_at *int32 15764 ent_id *uuid.UUID 15765 fiat_id *uuid.UUID 15766 feed_type *string 15767 market_value_low *decimal.Decimal 15768 market_value_high *decimal.Decimal 15769 clearedFields map[string]struct{} 15770 done bool 15771 oldValue func(context.Context) (*FiatCurrencyHistory, error) 15772 predicates []predicate.FiatCurrencyHistory 15773 } 15774 15775 var _ ent.Mutation = (*FiatCurrencyHistoryMutation)(nil) 15776 15777 // fiatcurrencyhistoryOption allows management of the mutation configuration using functional options. 15778 type fiatcurrencyhistoryOption func(*FiatCurrencyHistoryMutation) 15779 15780 // newFiatCurrencyHistoryMutation creates new mutation for the FiatCurrencyHistory entity. 15781 func newFiatCurrencyHistoryMutation(c config, op Op, opts ...fiatcurrencyhistoryOption) *FiatCurrencyHistoryMutation { 15782 m := &FiatCurrencyHistoryMutation{ 15783 config: c, 15784 op: op, 15785 typ: TypeFiatCurrencyHistory, 15786 clearedFields: make(map[string]struct{}), 15787 } 15788 for _, opt := range opts { 15789 opt(m) 15790 } 15791 return m 15792 } 15793 15794 // withFiatCurrencyHistoryID sets the ID field of the mutation. 15795 func withFiatCurrencyHistoryID(id uint32) fiatcurrencyhistoryOption { 15796 return func(m *FiatCurrencyHistoryMutation) { 15797 var ( 15798 err error 15799 once sync.Once 15800 value *FiatCurrencyHistory 15801 ) 15802 m.oldValue = func(ctx context.Context) (*FiatCurrencyHistory, error) { 15803 once.Do(func() { 15804 if m.done { 15805 err = errors.New("querying old values post mutation is not allowed") 15806 } else { 15807 value, err = m.Client().FiatCurrencyHistory.Get(ctx, id) 15808 } 15809 }) 15810 return value, err 15811 } 15812 m.id = &id 15813 } 15814 } 15815 15816 // withFiatCurrencyHistory sets the old FiatCurrencyHistory of the mutation. 15817 func withFiatCurrencyHistory(node *FiatCurrencyHistory) fiatcurrencyhistoryOption { 15818 return func(m *FiatCurrencyHistoryMutation) { 15819 m.oldValue = func(context.Context) (*FiatCurrencyHistory, error) { 15820 return node, nil 15821 } 15822 m.id = &node.ID 15823 } 15824 } 15825 15826 // Client returns a new `ent.Client` from the mutation. If the mutation was 15827 // executed in a transaction (ent.Tx), a transactional client is returned. 15828 func (m FiatCurrencyHistoryMutation) Client() *Client { 15829 client := &Client{config: m.config} 15830 client.init() 15831 return client 15832 } 15833 15834 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 15835 // it returns an error otherwise. 15836 func (m FiatCurrencyHistoryMutation) Tx() (*Tx, error) { 15837 if _, ok := m.driver.(*txDriver); !ok { 15838 return nil, errors.New("ent: mutation is not running in a transaction") 15839 } 15840 tx := &Tx{config: m.config} 15841 tx.init() 15842 return tx, nil 15843 } 15844 15845 // SetID sets the value of the id field. Note that this 15846 // operation is only accepted on creation of FiatCurrencyHistory entities. 15847 func (m *FiatCurrencyHistoryMutation) SetID(id uint32) { 15848 m.id = &id 15849 } 15850 15851 // ID returns the ID value in the mutation. Note that the ID is only available 15852 // if it was provided to the builder or after it was returned from the database. 15853 func (m *FiatCurrencyHistoryMutation) ID() (id uint32, exists bool) { 15854 if m.id == nil { 15855 return 15856 } 15857 return *m.id, true 15858 } 15859 15860 // IDs queries the database and returns the entity ids that match the mutation's predicate. 15861 // That means, if the mutation is applied within a transaction with an isolation level such 15862 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 15863 // or updated by the mutation. 15864 func (m *FiatCurrencyHistoryMutation) IDs(ctx context.Context) ([]uint32, error) { 15865 switch { 15866 case m.op.Is(OpUpdateOne | OpDeleteOne): 15867 id, exists := m.ID() 15868 if exists { 15869 return []uint32{id}, nil 15870 } 15871 fallthrough 15872 case m.op.Is(OpUpdate | OpDelete): 15873 return m.Client().FiatCurrencyHistory.Query().Where(m.predicates...).IDs(ctx) 15874 default: 15875 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 15876 } 15877 } 15878 15879 // SetCreatedAt sets the "created_at" field. 15880 func (m *FiatCurrencyHistoryMutation) SetCreatedAt(u uint32) { 15881 m.created_at = &u 15882 m.addcreated_at = nil 15883 } 15884 15885 // CreatedAt returns the value of the "created_at" field in the mutation. 15886 func (m *FiatCurrencyHistoryMutation) CreatedAt() (r uint32, exists bool) { 15887 v := m.created_at 15888 if v == nil { 15889 return 15890 } 15891 return *v, true 15892 } 15893 15894 // OldCreatedAt returns the old "created_at" field's value of the FiatCurrencyHistory entity. 15895 // If the FiatCurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 15896 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 15897 func (m *FiatCurrencyHistoryMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 15898 if !m.op.Is(OpUpdateOne) { 15899 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 15900 } 15901 if m.id == nil || m.oldValue == nil { 15902 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 15903 } 15904 oldValue, err := m.oldValue(ctx) 15905 if err != nil { 15906 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 15907 } 15908 return oldValue.CreatedAt, nil 15909 } 15910 15911 // AddCreatedAt adds u to the "created_at" field. 15912 func (m *FiatCurrencyHistoryMutation) AddCreatedAt(u int32) { 15913 if m.addcreated_at != nil { 15914 *m.addcreated_at += u 15915 } else { 15916 m.addcreated_at = &u 15917 } 15918 } 15919 15920 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 15921 func (m *FiatCurrencyHistoryMutation) AddedCreatedAt() (r int32, exists bool) { 15922 v := m.addcreated_at 15923 if v == nil { 15924 return 15925 } 15926 return *v, true 15927 } 15928 15929 // ResetCreatedAt resets all changes to the "created_at" field. 15930 func (m *FiatCurrencyHistoryMutation) ResetCreatedAt() { 15931 m.created_at = nil 15932 m.addcreated_at = nil 15933 } 15934 15935 // SetUpdatedAt sets the "updated_at" field. 15936 func (m *FiatCurrencyHistoryMutation) SetUpdatedAt(u uint32) { 15937 m.updated_at = &u 15938 m.addupdated_at = nil 15939 } 15940 15941 // UpdatedAt returns the value of the "updated_at" field in the mutation. 15942 func (m *FiatCurrencyHistoryMutation) UpdatedAt() (r uint32, exists bool) { 15943 v := m.updated_at 15944 if v == nil { 15945 return 15946 } 15947 return *v, true 15948 } 15949 15950 // OldUpdatedAt returns the old "updated_at" field's value of the FiatCurrencyHistory entity. 15951 // If the FiatCurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 15952 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 15953 func (m *FiatCurrencyHistoryMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 15954 if !m.op.Is(OpUpdateOne) { 15955 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 15956 } 15957 if m.id == nil || m.oldValue == nil { 15958 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 15959 } 15960 oldValue, err := m.oldValue(ctx) 15961 if err != nil { 15962 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 15963 } 15964 return oldValue.UpdatedAt, nil 15965 } 15966 15967 // AddUpdatedAt adds u to the "updated_at" field. 15968 func (m *FiatCurrencyHistoryMutation) AddUpdatedAt(u int32) { 15969 if m.addupdated_at != nil { 15970 *m.addupdated_at += u 15971 } else { 15972 m.addupdated_at = &u 15973 } 15974 } 15975 15976 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 15977 func (m *FiatCurrencyHistoryMutation) AddedUpdatedAt() (r int32, exists bool) { 15978 v := m.addupdated_at 15979 if v == nil { 15980 return 15981 } 15982 return *v, true 15983 } 15984 15985 // ResetUpdatedAt resets all changes to the "updated_at" field. 15986 func (m *FiatCurrencyHistoryMutation) ResetUpdatedAt() { 15987 m.updated_at = nil 15988 m.addupdated_at = nil 15989 } 15990 15991 // SetDeletedAt sets the "deleted_at" field. 15992 func (m *FiatCurrencyHistoryMutation) SetDeletedAt(u uint32) { 15993 m.deleted_at = &u 15994 m.adddeleted_at = nil 15995 } 15996 15997 // DeletedAt returns the value of the "deleted_at" field in the mutation. 15998 func (m *FiatCurrencyHistoryMutation) DeletedAt() (r uint32, exists bool) { 15999 v := m.deleted_at 16000 if v == nil { 16001 return 16002 } 16003 return *v, true 16004 } 16005 16006 // OldDeletedAt returns the old "deleted_at" field's value of the FiatCurrencyHistory entity. 16007 // If the FiatCurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 16008 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 16009 func (m *FiatCurrencyHistoryMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 16010 if !m.op.Is(OpUpdateOne) { 16011 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 16012 } 16013 if m.id == nil || m.oldValue == nil { 16014 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 16015 } 16016 oldValue, err := m.oldValue(ctx) 16017 if err != nil { 16018 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 16019 } 16020 return oldValue.DeletedAt, nil 16021 } 16022 16023 // AddDeletedAt adds u to the "deleted_at" field. 16024 func (m *FiatCurrencyHistoryMutation) AddDeletedAt(u int32) { 16025 if m.adddeleted_at != nil { 16026 *m.adddeleted_at += u 16027 } else { 16028 m.adddeleted_at = &u 16029 } 16030 } 16031 16032 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 16033 func (m *FiatCurrencyHistoryMutation) AddedDeletedAt() (r int32, exists bool) { 16034 v := m.adddeleted_at 16035 if v == nil { 16036 return 16037 } 16038 return *v, true 16039 } 16040 16041 // ResetDeletedAt resets all changes to the "deleted_at" field. 16042 func (m *FiatCurrencyHistoryMutation) ResetDeletedAt() { 16043 m.deleted_at = nil 16044 m.adddeleted_at = nil 16045 } 16046 16047 // SetEntID sets the "ent_id" field. 16048 func (m *FiatCurrencyHistoryMutation) SetEntID(u uuid.UUID) { 16049 m.ent_id = &u 16050 } 16051 16052 // EntID returns the value of the "ent_id" field in the mutation. 16053 func (m *FiatCurrencyHistoryMutation) EntID() (r uuid.UUID, exists bool) { 16054 v := m.ent_id 16055 if v == nil { 16056 return 16057 } 16058 return *v, true 16059 } 16060 16061 // OldEntID returns the old "ent_id" field's value of the FiatCurrencyHistory entity. 16062 // If the FiatCurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 16063 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 16064 func (m *FiatCurrencyHistoryMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 16065 if !m.op.Is(OpUpdateOne) { 16066 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 16067 } 16068 if m.id == nil || m.oldValue == nil { 16069 return v, errors.New("OldEntID requires an ID field in the mutation") 16070 } 16071 oldValue, err := m.oldValue(ctx) 16072 if err != nil { 16073 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 16074 } 16075 return oldValue.EntID, nil 16076 } 16077 16078 // ResetEntID resets all changes to the "ent_id" field. 16079 func (m *FiatCurrencyHistoryMutation) ResetEntID() { 16080 m.ent_id = nil 16081 } 16082 16083 // SetFiatID sets the "fiat_id" field. 16084 func (m *FiatCurrencyHistoryMutation) SetFiatID(u uuid.UUID) { 16085 m.fiat_id = &u 16086 } 16087 16088 // FiatID returns the value of the "fiat_id" field in the mutation. 16089 func (m *FiatCurrencyHistoryMutation) FiatID() (r uuid.UUID, exists bool) { 16090 v := m.fiat_id 16091 if v == nil { 16092 return 16093 } 16094 return *v, true 16095 } 16096 16097 // OldFiatID returns the old "fiat_id" field's value of the FiatCurrencyHistory entity. 16098 // If the FiatCurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 16099 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 16100 func (m *FiatCurrencyHistoryMutation) OldFiatID(ctx context.Context) (v uuid.UUID, err error) { 16101 if !m.op.Is(OpUpdateOne) { 16102 return v, errors.New("OldFiatID is only allowed on UpdateOne operations") 16103 } 16104 if m.id == nil || m.oldValue == nil { 16105 return v, errors.New("OldFiatID requires an ID field in the mutation") 16106 } 16107 oldValue, err := m.oldValue(ctx) 16108 if err != nil { 16109 return v, fmt.Errorf("querying old value for OldFiatID: %w", err) 16110 } 16111 return oldValue.FiatID, nil 16112 } 16113 16114 // ClearFiatID clears the value of the "fiat_id" field. 16115 func (m *FiatCurrencyHistoryMutation) ClearFiatID() { 16116 m.fiat_id = nil 16117 m.clearedFields[fiatcurrencyhistory.FieldFiatID] = struct{}{} 16118 } 16119 16120 // FiatIDCleared returns if the "fiat_id" field was cleared in this mutation. 16121 func (m *FiatCurrencyHistoryMutation) FiatIDCleared() bool { 16122 _, ok := m.clearedFields[fiatcurrencyhistory.FieldFiatID] 16123 return ok 16124 } 16125 16126 // ResetFiatID resets all changes to the "fiat_id" field. 16127 func (m *FiatCurrencyHistoryMutation) ResetFiatID() { 16128 m.fiat_id = nil 16129 delete(m.clearedFields, fiatcurrencyhistory.FieldFiatID) 16130 } 16131 16132 // SetFeedType sets the "feed_type" field. 16133 func (m *FiatCurrencyHistoryMutation) SetFeedType(s string) { 16134 m.feed_type = &s 16135 } 16136 16137 // FeedType returns the value of the "feed_type" field in the mutation. 16138 func (m *FiatCurrencyHistoryMutation) FeedType() (r string, exists bool) { 16139 v := m.feed_type 16140 if v == nil { 16141 return 16142 } 16143 return *v, true 16144 } 16145 16146 // OldFeedType returns the old "feed_type" field's value of the FiatCurrencyHistory entity. 16147 // If the FiatCurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 16148 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 16149 func (m *FiatCurrencyHistoryMutation) OldFeedType(ctx context.Context) (v string, err error) { 16150 if !m.op.Is(OpUpdateOne) { 16151 return v, errors.New("OldFeedType is only allowed on UpdateOne operations") 16152 } 16153 if m.id == nil || m.oldValue == nil { 16154 return v, errors.New("OldFeedType requires an ID field in the mutation") 16155 } 16156 oldValue, err := m.oldValue(ctx) 16157 if err != nil { 16158 return v, fmt.Errorf("querying old value for OldFeedType: %w", err) 16159 } 16160 return oldValue.FeedType, nil 16161 } 16162 16163 // ClearFeedType clears the value of the "feed_type" field. 16164 func (m *FiatCurrencyHistoryMutation) ClearFeedType() { 16165 m.feed_type = nil 16166 m.clearedFields[fiatcurrencyhistory.FieldFeedType] = struct{}{} 16167 } 16168 16169 // FeedTypeCleared returns if the "feed_type" field was cleared in this mutation. 16170 func (m *FiatCurrencyHistoryMutation) FeedTypeCleared() bool { 16171 _, ok := m.clearedFields[fiatcurrencyhistory.FieldFeedType] 16172 return ok 16173 } 16174 16175 // ResetFeedType resets all changes to the "feed_type" field. 16176 func (m *FiatCurrencyHistoryMutation) ResetFeedType() { 16177 m.feed_type = nil 16178 delete(m.clearedFields, fiatcurrencyhistory.FieldFeedType) 16179 } 16180 16181 // SetMarketValueLow sets the "market_value_low" field. 16182 func (m *FiatCurrencyHistoryMutation) SetMarketValueLow(d decimal.Decimal) { 16183 m.market_value_low = &d 16184 } 16185 16186 // MarketValueLow returns the value of the "market_value_low" field in the mutation. 16187 func (m *FiatCurrencyHistoryMutation) MarketValueLow() (r decimal.Decimal, exists bool) { 16188 v := m.market_value_low 16189 if v == nil { 16190 return 16191 } 16192 return *v, true 16193 } 16194 16195 // OldMarketValueLow returns the old "market_value_low" field's value of the FiatCurrencyHistory entity. 16196 // If the FiatCurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 16197 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 16198 func (m *FiatCurrencyHistoryMutation) OldMarketValueLow(ctx context.Context) (v decimal.Decimal, err error) { 16199 if !m.op.Is(OpUpdateOne) { 16200 return v, errors.New("OldMarketValueLow is only allowed on UpdateOne operations") 16201 } 16202 if m.id == nil || m.oldValue == nil { 16203 return v, errors.New("OldMarketValueLow requires an ID field in the mutation") 16204 } 16205 oldValue, err := m.oldValue(ctx) 16206 if err != nil { 16207 return v, fmt.Errorf("querying old value for OldMarketValueLow: %w", err) 16208 } 16209 return oldValue.MarketValueLow, nil 16210 } 16211 16212 // ClearMarketValueLow clears the value of the "market_value_low" field. 16213 func (m *FiatCurrencyHistoryMutation) ClearMarketValueLow() { 16214 m.market_value_low = nil 16215 m.clearedFields[fiatcurrencyhistory.FieldMarketValueLow] = struct{}{} 16216 } 16217 16218 // MarketValueLowCleared returns if the "market_value_low" field was cleared in this mutation. 16219 func (m *FiatCurrencyHistoryMutation) MarketValueLowCleared() bool { 16220 _, ok := m.clearedFields[fiatcurrencyhistory.FieldMarketValueLow] 16221 return ok 16222 } 16223 16224 // ResetMarketValueLow resets all changes to the "market_value_low" field. 16225 func (m *FiatCurrencyHistoryMutation) ResetMarketValueLow() { 16226 m.market_value_low = nil 16227 delete(m.clearedFields, fiatcurrencyhistory.FieldMarketValueLow) 16228 } 16229 16230 // SetMarketValueHigh sets the "market_value_high" field. 16231 func (m *FiatCurrencyHistoryMutation) SetMarketValueHigh(d decimal.Decimal) { 16232 m.market_value_high = &d 16233 } 16234 16235 // MarketValueHigh returns the value of the "market_value_high" field in the mutation. 16236 func (m *FiatCurrencyHistoryMutation) MarketValueHigh() (r decimal.Decimal, exists bool) { 16237 v := m.market_value_high 16238 if v == nil { 16239 return 16240 } 16241 return *v, true 16242 } 16243 16244 // OldMarketValueHigh returns the old "market_value_high" field's value of the FiatCurrencyHistory entity. 16245 // If the FiatCurrencyHistory object wasn't provided to the builder, the object is fetched from the database. 16246 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 16247 func (m *FiatCurrencyHistoryMutation) OldMarketValueHigh(ctx context.Context) (v decimal.Decimal, err error) { 16248 if !m.op.Is(OpUpdateOne) { 16249 return v, errors.New("OldMarketValueHigh is only allowed on UpdateOne operations") 16250 } 16251 if m.id == nil || m.oldValue == nil { 16252 return v, errors.New("OldMarketValueHigh requires an ID field in the mutation") 16253 } 16254 oldValue, err := m.oldValue(ctx) 16255 if err != nil { 16256 return v, fmt.Errorf("querying old value for OldMarketValueHigh: %w", err) 16257 } 16258 return oldValue.MarketValueHigh, nil 16259 } 16260 16261 // ClearMarketValueHigh clears the value of the "market_value_high" field. 16262 func (m *FiatCurrencyHistoryMutation) ClearMarketValueHigh() { 16263 m.market_value_high = nil 16264 m.clearedFields[fiatcurrencyhistory.FieldMarketValueHigh] = struct{}{} 16265 } 16266 16267 // MarketValueHighCleared returns if the "market_value_high" field was cleared in this mutation. 16268 func (m *FiatCurrencyHistoryMutation) MarketValueHighCleared() bool { 16269 _, ok := m.clearedFields[fiatcurrencyhistory.FieldMarketValueHigh] 16270 return ok 16271 } 16272 16273 // ResetMarketValueHigh resets all changes to the "market_value_high" field. 16274 func (m *FiatCurrencyHistoryMutation) ResetMarketValueHigh() { 16275 m.market_value_high = nil 16276 delete(m.clearedFields, fiatcurrencyhistory.FieldMarketValueHigh) 16277 } 16278 16279 // Where appends a list predicates to the FiatCurrencyHistoryMutation builder. 16280 func (m *FiatCurrencyHistoryMutation) Where(ps ...predicate.FiatCurrencyHistory) { 16281 m.predicates = append(m.predicates, ps...) 16282 } 16283 16284 // Op returns the operation name. 16285 func (m *FiatCurrencyHistoryMutation) Op() Op { 16286 return m.op 16287 } 16288 16289 // Type returns the node type of this mutation (FiatCurrencyHistory). 16290 func (m *FiatCurrencyHistoryMutation) Type() string { 16291 return m.typ 16292 } 16293 16294 // Fields returns all fields that were changed during this mutation. Note that in 16295 // order to get all numeric fields that were incremented/decremented, call 16296 // AddedFields(). 16297 func (m *FiatCurrencyHistoryMutation) Fields() []string { 16298 fields := make([]string, 0, 8) 16299 if m.created_at != nil { 16300 fields = append(fields, fiatcurrencyhistory.FieldCreatedAt) 16301 } 16302 if m.updated_at != nil { 16303 fields = append(fields, fiatcurrencyhistory.FieldUpdatedAt) 16304 } 16305 if m.deleted_at != nil { 16306 fields = append(fields, fiatcurrencyhistory.FieldDeletedAt) 16307 } 16308 if m.ent_id != nil { 16309 fields = append(fields, fiatcurrencyhistory.FieldEntID) 16310 } 16311 if m.fiat_id != nil { 16312 fields = append(fields, fiatcurrencyhistory.FieldFiatID) 16313 } 16314 if m.feed_type != nil { 16315 fields = append(fields, fiatcurrencyhistory.FieldFeedType) 16316 } 16317 if m.market_value_low != nil { 16318 fields = append(fields, fiatcurrencyhistory.FieldMarketValueLow) 16319 } 16320 if m.market_value_high != nil { 16321 fields = append(fields, fiatcurrencyhistory.FieldMarketValueHigh) 16322 } 16323 return fields 16324 } 16325 16326 // Field returns the value of a field with the given name. The second boolean 16327 // return value indicates that this field was not set, or was not defined in the 16328 // schema. 16329 func (m *FiatCurrencyHistoryMutation) Field(name string) (ent.Value, bool) { 16330 switch name { 16331 case fiatcurrencyhistory.FieldCreatedAt: 16332 return m.CreatedAt() 16333 case fiatcurrencyhistory.FieldUpdatedAt: 16334 return m.UpdatedAt() 16335 case fiatcurrencyhistory.FieldDeletedAt: 16336 return m.DeletedAt() 16337 case fiatcurrencyhistory.FieldEntID: 16338 return m.EntID() 16339 case fiatcurrencyhistory.FieldFiatID: 16340 return m.FiatID() 16341 case fiatcurrencyhistory.FieldFeedType: 16342 return m.FeedType() 16343 case fiatcurrencyhistory.FieldMarketValueLow: 16344 return m.MarketValueLow() 16345 case fiatcurrencyhistory.FieldMarketValueHigh: 16346 return m.MarketValueHigh() 16347 } 16348 return nil, false 16349 } 16350 16351 // OldField returns the old value of the field from the database. An error is 16352 // returned if the mutation operation is not UpdateOne, or the query to the 16353 // database failed. 16354 func (m *FiatCurrencyHistoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 16355 switch name { 16356 case fiatcurrencyhistory.FieldCreatedAt: 16357 return m.OldCreatedAt(ctx) 16358 case fiatcurrencyhistory.FieldUpdatedAt: 16359 return m.OldUpdatedAt(ctx) 16360 case fiatcurrencyhistory.FieldDeletedAt: 16361 return m.OldDeletedAt(ctx) 16362 case fiatcurrencyhistory.FieldEntID: 16363 return m.OldEntID(ctx) 16364 case fiatcurrencyhistory.FieldFiatID: 16365 return m.OldFiatID(ctx) 16366 case fiatcurrencyhistory.FieldFeedType: 16367 return m.OldFeedType(ctx) 16368 case fiatcurrencyhistory.FieldMarketValueLow: 16369 return m.OldMarketValueLow(ctx) 16370 case fiatcurrencyhistory.FieldMarketValueHigh: 16371 return m.OldMarketValueHigh(ctx) 16372 } 16373 return nil, fmt.Errorf("unknown FiatCurrencyHistory field %s", name) 16374 } 16375 16376 // SetField sets the value of a field with the given name. It returns an error if 16377 // the field is not defined in the schema, or if the type mismatched the field 16378 // type. 16379 func (m *FiatCurrencyHistoryMutation) SetField(name string, value ent.Value) error { 16380 switch name { 16381 case fiatcurrencyhistory.FieldCreatedAt: 16382 v, ok := value.(uint32) 16383 if !ok { 16384 return fmt.Errorf("unexpected type %T for field %s", value, name) 16385 } 16386 m.SetCreatedAt(v) 16387 return nil 16388 case fiatcurrencyhistory.FieldUpdatedAt: 16389 v, ok := value.(uint32) 16390 if !ok { 16391 return fmt.Errorf("unexpected type %T for field %s", value, name) 16392 } 16393 m.SetUpdatedAt(v) 16394 return nil 16395 case fiatcurrencyhistory.FieldDeletedAt: 16396 v, ok := value.(uint32) 16397 if !ok { 16398 return fmt.Errorf("unexpected type %T for field %s", value, name) 16399 } 16400 m.SetDeletedAt(v) 16401 return nil 16402 case fiatcurrencyhistory.FieldEntID: 16403 v, ok := value.(uuid.UUID) 16404 if !ok { 16405 return fmt.Errorf("unexpected type %T for field %s", value, name) 16406 } 16407 m.SetEntID(v) 16408 return nil 16409 case fiatcurrencyhistory.FieldFiatID: 16410 v, ok := value.(uuid.UUID) 16411 if !ok { 16412 return fmt.Errorf("unexpected type %T for field %s", value, name) 16413 } 16414 m.SetFiatID(v) 16415 return nil 16416 case fiatcurrencyhistory.FieldFeedType: 16417 v, ok := value.(string) 16418 if !ok { 16419 return fmt.Errorf("unexpected type %T for field %s", value, name) 16420 } 16421 m.SetFeedType(v) 16422 return nil 16423 case fiatcurrencyhistory.FieldMarketValueLow: 16424 v, ok := value.(decimal.Decimal) 16425 if !ok { 16426 return fmt.Errorf("unexpected type %T for field %s", value, name) 16427 } 16428 m.SetMarketValueLow(v) 16429 return nil 16430 case fiatcurrencyhistory.FieldMarketValueHigh: 16431 v, ok := value.(decimal.Decimal) 16432 if !ok { 16433 return fmt.Errorf("unexpected type %T for field %s", value, name) 16434 } 16435 m.SetMarketValueHigh(v) 16436 return nil 16437 } 16438 return fmt.Errorf("unknown FiatCurrencyHistory field %s", name) 16439 } 16440 16441 // AddedFields returns all numeric fields that were incremented/decremented during 16442 // this mutation. 16443 func (m *FiatCurrencyHistoryMutation) AddedFields() []string { 16444 var fields []string 16445 if m.addcreated_at != nil { 16446 fields = append(fields, fiatcurrencyhistory.FieldCreatedAt) 16447 } 16448 if m.addupdated_at != nil { 16449 fields = append(fields, fiatcurrencyhistory.FieldUpdatedAt) 16450 } 16451 if m.adddeleted_at != nil { 16452 fields = append(fields, fiatcurrencyhistory.FieldDeletedAt) 16453 } 16454 return fields 16455 } 16456 16457 // AddedField returns the numeric value that was incremented/decremented on a field 16458 // with the given name. The second boolean return value indicates that this field 16459 // was not set, or was not defined in the schema. 16460 func (m *FiatCurrencyHistoryMutation) AddedField(name string) (ent.Value, bool) { 16461 switch name { 16462 case fiatcurrencyhistory.FieldCreatedAt: 16463 return m.AddedCreatedAt() 16464 case fiatcurrencyhistory.FieldUpdatedAt: 16465 return m.AddedUpdatedAt() 16466 case fiatcurrencyhistory.FieldDeletedAt: 16467 return m.AddedDeletedAt() 16468 } 16469 return nil, false 16470 } 16471 16472 // AddField adds the value to the field with the given name. It returns an error if 16473 // the field is not defined in the schema, or if the type mismatched the field 16474 // type. 16475 func (m *FiatCurrencyHistoryMutation) AddField(name string, value ent.Value) error { 16476 switch name { 16477 case fiatcurrencyhistory.FieldCreatedAt: 16478 v, ok := value.(int32) 16479 if !ok { 16480 return fmt.Errorf("unexpected type %T for field %s", value, name) 16481 } 16482 m.AddCreatedAt(v) 16483 return nil 16484 case fiatcurrencyhistory.FieldUpdatedAt: 16485 v, ok := value.(int32) 16486 if !ok { 16487 return fmt.Errorf("unexpected type %T for field %s", value, name) 16488 } 16489 m.AddUpdatedAt(v) 16490 return nil 16491 case fiatcurrencyhistory.FieldDeletedAt: 16492 v, ok := value.(int32) 16493 if !ok { 16494 return fmt.Errorf("unexpected type %T for field %s", value, name) 16495 } 16496 m.AddDeletedAt(v) 16497 return nil 16498 } 16499 return fmt.Errorf("unknown FiatCurrencyHistory numeric field %s", name) 16500 } 16501 16502 // ClearedFields returns all nullable fields that were cleared during this 16503 // mutation. 16504 func (m *FiatCurrencyHistoryMutation) ClearedFields() []string { 16505 var fields []string 16506 if m.FieldCleared(fiatcurrencyhistory.FieldFiatID) { 16507 fields = append(fields, fiatcurrencyhistory.FieldFiatID) 16508 } 16509 if m.FieldCleared(fiatcurrencyhistory.FieldFeedType) { 16510 fields = append(fields, fiatcurrencyhistory.FieldFeedType) 16511 } 16512 if m.FieldCleared(fiatcurrencyhistory.FieldMarketValueLow) { 16513 fields = append(fields, fiatcurrencyhistory.FieldMarketValueLow) 16514 } 16515 if m.FieldCleared(fiatcurrencyhistory.FieldMarketValueHigh) { 16516 fields = append(fields, fiatcurrencyhistory.FieldMarketValueHigh) 16517 } 16518 return fields 16519 } 16520 16521 // FieldCleared returns a boolean indicating if a field with the given name was 16522 // cleared in this mutation. 16523 func (m *FiatCurrencyHistoryMutation) FieldCleared(name string) bool { 16524 _, ok := m.clearedFields[name] 16525 return ok 16526 } 16527 16528 // ClearField clears the value of the field with the given name. It returns an 16529 // error if the field is not defined in the schema. 16530 func (m *FiatCurrencyHistoryMutation) ClearField(name string) error { 16531 switch name { 16532 case fiatcurrencyhistory.FieldFiatID: 16533 m.ClearFiatID() 16534 return nil 16535 case fiatcurrencyhistory.FieldFeedType: 16536 m.ClearFeedType() 16537 return nil 16538 case fiatcurrencyhistory.FieldMarketValueLow: 16539 m.ClearMarketValueLow() 16540 return nil 16541 case fiatcurrencyhistory.FieldMarketValueHigh: 16542 m.ClearMarketValueHigh() 16543 return nil 16544 } 16545 return fmt.Errorf("unknown FiatCurrencyHistory nullable field %s", name) 16546 } 16547 16548 // ResetField resets all changes in the mutation for the field with the given name. 16549 // It returns an error if the field is not defined in the schema. 16550 func (m *FiatCurrencyHistoryMutation) ResetField(name string) error { 16551 switch name { 16552 case fiatcurrencyhistory.FieldCreatedAt: 16553 m.ResetCreatedAt() 16554 return nil 16555 case fiatcurrencyhistory.FieldUpdatedAt: 16556 m.ResetUpdatedAt() 16557 return nil 16558 case fiatcurrencyhistory.FieldDeletedAt: 16559 m.ResetDeletedAt() 16560 return nil 16561 case fiatcurrencyhistory.FieldEntID: 16562 m.ResetEntID() 16563 return nil 16564 case fiatcurrencyhistory.FieldFiatID: 16565 m.ResetFiatID() 16566 return nil 16567 case fiatcurrencyhistory.FieldFeedType: 16568 m.ResetFeedType() 16569 return nil 16570 case fiatcurrencyhistory.FieldMarketValueLow: 16571 m.ResetMarketValueLow() 16572 return nil 16573 case fiatcurrencyhistory.FieldMarketValueHigh: 16574 m.ResetMarketValueHigh() 16575 return nil 16576 } 16577 return fmt.Errorf("unknown FiatCurrencyHistory field %s", name) 16578 } 16579 16580 // AddedEdges returns all edge names that were set/added in this mutation. 16581 func (m *FiatCurrencyHistoryMutation) AddedEdges() []string { 16582 edges := make([]string, 0, 0) 16583 return edges 16584 } 16585 16586 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 16587 // name in this mutation. 16588 func (m *FiatCurrencyHistoryMutation) AddedIDs(name string) []ent.Value { 16589 return nil 16590 } 16591 16592 // RemovedEdges returns all edge names that were removed in this mutation. 16593 func (m *FiatCurrencyHistoryMutation) RemovedEdges() []string { 16594 edges := make([]string, 0, 0) 16595 return edges 16596 } 16597 16598 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 16599 // the given name in this mutation. 16600 func (m *FiatCurrencyHistoryMutation) RemovedIDs(name string) []ent.Value { 16601 return nil 16602 } 16603 16604 // ClearedEdges returns all edge names that were cleared in this mutation. 16605 func (m *FiatCurrencyHistoryMutation) ClearedEdges() []string { 16606 edges := make([]string, 0, 0) 16607 return edges 16608 } 16609 16610 // EdgeCleared returns a boolean which indicates if the edge with the given name 16611 // was cleared in this mutation. 16612 func (m *FiatCurrencyHistoryMutation) EdgeCleared(name string) bool { 16613 return false 16614 } 16615 16616 // ClearEdge clears the value of the edge with the given name. It returns an error 16617 // if that edge is not defined in the schema. 16618 func (m *FiatCurrencyHistoryMutation) ClearEdge(name string) error { 16619 return fmt.Errorf("unknown FiatCurrencyHistory unique edge %s", name) 16620 } 16621 16622 // ResetEdge resets all changes to the edge with the given name in this mutation. 16623 // It returns an error if the edge is not defined in the schema. 16624 func (m *FiatCurrencyHistoryMutation) ResetEdge(name string) error { 16625 return fmt.Errorf("unknown FiatCurrencyHistory edge %s", name) 16626 } 16627 16628 // SettingMutation represents an operation that mutates the Setting nodes in the graph. 16629 type SettingMutation struct { 16630 config 16631 op Op 16632 typ string 16633 id *uint32 16634 created_at *uint32 16635 addcreated_at *int32 16636 updated_at *uint32 16637 addupdated_at *int32 16638 deleted_at *uint32 16639 adddeleted_at *int32 16640 ent_id *uuid.UUID 16641 coin_type_id *uuid.UUID 16642 fee_coin_type_id *uuid.UUID 16643 withdraw_fee_by_stable_usd *bool 16644 withdraw_fee_amount *decimal.Decimal 16645 collect_fee_amount *decimal.Decimal 16646 hot_wallet_fee_amount *decimal.Decimal 16647 low_fee_amount *decimal.Decimal 16648 hot_low_fee_amount *decimal.Decimal 16649 hot_wallet_account_amount *decimal.Decimal 16650 payment_account_collect_amount *decimal.Decimal 16651 least_transfer_amount *decimal.Decimal 16652 need_memo *bool 16653 refresh_currency *bool 16654 check_new_address_balance *bool 16655 clearedFields map[string]struct{} 16656 done bool 16657 oldValue func(context.Context) (*Setting, error) 16658 predicates []predicate.Setting 16659 } 16660 16661 var _ ent.Mutation = (*SettingMutation)(nil) 16662 16663 // settingOption allows management of the mutation configuration using functional options. 16664 type settingOption func(*SettingMutation) 16665 16666 // newSettingMutation creates new mutation for the Setting entity. 16667 func newSettingMutation(c config, op Op, opts ...settingOption) *SettingMutation { 16668 m := &SettingMutation{ 16669 config: c, 16670 op: op, 16671 typ: TypeSetting, 16672 clearedFields: make(map[string]struct{}), 16673 } 16674 for _, opt := range opts { 16675 opt(m) 16676 } 16677 return m 16678 } 16679 16680 // withSettingID sets the ID field of the mutation. 16681 func withSettingID(id uint32) settingOption { 16682 return func(m *SettingMutation) { 16683 var ( 16684 err error 16685 once sync.Once 16686 value *Setting 16687 ) 16688 m.oldValue = func(ctx context.Context) (*Setting, error) { 16689 once.Do(func() { 16690 if m.done { 16691 err = errors.New("querying old values post mutation is not allowed") 16692 } else { 16693 value, err = m.Client().Setting.Get(ctx, id) 16694 } 16695 }) 16696 return value, err 16697 } 16698 m.id = &id 16699 } 16700 } 16701 16702 // withSetting sets the old Setting of the mutation. 16703 func withSetting(node *Setting) settingOption { 16704 return func(m *SettingMutation) { 16705 m.oldValue = func(context.Context) (*Setting, error) { 16706 return node, nil 16707 } 16708 m.id = &node.ID 16709 } 16710 } 16711 16712 // Client returns a new `ent.Client` from the mutation. If the mutation was 16713 // executed in a transaction (ent.Tx), a transactional client is returned. 16714 func (m SettingMutation) Client() *Client { 16715 client := &Client{config: m.config} 16716 client.init() 16717 return client 16718 } 16719 16720 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 16721 // it returns an error otherwise. 16722 func (m SettingMutation) Tx() (*Tx, error) { 16723 if _, ok := m.driver.(*txDriver); !ok { 16724 return nil, errors.New("ent: mutation is not running in a transaction") 16725 } 16726 tx := &Tx{config: m.config} 16727 tx.init() 16728 return tx, nil 16729 } 16730 16731 // SetID sets the value of the id field. Note that this 16732 // operation is only accepted on creation of Setting entities. 16733 func (m *SettingMutation) SetID(id uint32) { 16734 m.id = &id 16735 } 16736 16737 // ID returns the ID value in the mutation. Note that the ID is only available 16738 // if it was provided to the builder or after it was returned from the database. 16739 func (m *SettingMutation) ID() (id uint32, exists bool) { 16740 if m.id == nil { 16741 return 16742 } 16743 return *m.id, true 16744 } 16745 16746 // IDs queries the database and returns the entity ids that match the mutation's predicate. 16747 // That means, if the mutation is applied within a transaction with an isolation level such 16748 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 16749 // or updated by the mutation. 16750 func (m *SettingMutation) IDs(ctx context.Context) ([]uint32, error) { 16751 switch { 16752 case m.op.Is(OpUpdateOne | OpDeleteOne): 16753 id, exists := m.ID() 16754 if exists { 16755 return []uint32{id}, nil 16756 } 16757 fallthrough 16758 case m.op.Is(OpUpdate | OpDelete): 16759 return m.Client().Setting.Query().Where(m.predicates...).IDs(ctx) 16760 default: 16761 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 16762 } 16763 } 16764 16765 // SetCreatedAt sets the "created_at" field. 16766 func (m *SettingMutation) SetCreatedAt(u uint32) { 16767 m.created_at = &u 16768 m.addcreated_at = nil 16769 } 16770 16771 // CreatedAt returns the value of the "created_at" field in the mutation. 16772 func (m *SettingMutation) CreatedAt() (r uint32, exists bool) { 16773 v := m.created_at 16774 if v == nil { 16775 return 16776 } 16777 return *v, true 16778 } 16779 16780 // OldCreatedAt returns the old "created_at" field's value of the Setting entity. 16781 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 16782 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 16783 func (m *SettingMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 16784 if !m.op.Is(OpUpdateOne) { 16785 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 16786 } 16787 if m.id == nil || m.oldValue == nil { 16788 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 16789 } 16790 oldValue, err := m.oldValue(ctx) 16791 if err != nil { 16792 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 16793 } 16794 return oldValue.CreatedAt, nil 16795 } 16796 16797 // AddCreatedAt adds u to the "created_at" field. 16798 func (m *SettingMutation) AddCreatedAt(u int32) { 16799 if m.addcreated_at != nil { 16800 *m.addcreated_at += u 16801 } else { 16802 m.addcreated_at = &u 16803 } 16804 } 16805 16806 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 16807 func (m *SettingMutation) AddedCreatedAt() (r int32, exists bool) { 16808 v := m.addcreated_at 16809 if v == nil { 16810 return 16811 } 16812 return *v, true 16813 } 16814 16815 // ResetCreatedAt resets all changes to the "created_at" field. 16816 func (m *SettingMutation) ResetCreatedAt() { 16817 m.created_at = nil 16818 m.addcreated_at = nil 16819 } 16820 16821 // SetUpdatedAt sets the "updated_at" field. 16822 func (m *SettingMutation) SetUpdatedAt(u uint32) { 16823 m.updated_at = &u 16824 m.addupdated_at = nil 16825 } 16826 16827 // UpdatedAt returns the value of the "updated_at" field in the mutation. 16828 func (m *SettingMutation) UpdatedAt() (r uint32, exists bool) { 16829 v := m.updated_at 16830 if v == nil { 16831 return 16832 } 16833 return *v, true 16834 } 16835 16836 // OldUpdatedAt returns the old "updated_at" field's value of the Setting entity. 16837 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 16838 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 16839 func (m *SettingMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 16840 if !m.op.Is(OpUpdateOne) { 16841 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 16842 } 16843 if m.id == nil || m.oldValue == nil { 16844 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 16845 } 16846 oldValue, err := m.oldValue(ctx) 16847 if err != nil { 16848 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 16849 } 16850 return oldValue.UpdatedAt, nil 16851 } 16852 16853 // AddUpdatedAt adds u to the "updated_at" field. 16854 func (m *SettingMutation) AddUpdatedAt(u int32) { 16855 if m.addupdated_at != nil { 16856 *m.addupdated_at += u 16857 } else { 16858 m.addupdated_at = &u 16859 } 16860 } 16861 16862 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 16863 func (m *SettingMutation) AddedUpdatedAt() (r int32, exists bool) { 16864 v := m.addupdated_at 16865 if v == nil { 16866 return 16867 } 16868 return *v, true 16869 } 16870 16871 // ResetUpdatedAt resets all changes to the "updated_at" field. 16872 func (m *SettingMutation) ResetUpdatedAt() { 16873 m.updated_at = nil 16874 m.addupdated_at = nil 16875 } 16876 16877 // SetDeletedAt sets the "deleted_at" field. 16878 func (m *SettingMutation) SetDeletedAt(u uint32) { 16879 m.deleted_at = &u 16880 m.adddeleted_at = nil 16881 } 16882 16883 // DeletedAt returns the value of the "deleted_at" field in the mutation. 16884 func (m *SettingMutation) DeletedAt() (r uint32, exists bool) { 16885 v := m.deleted_at 16886 if v == nil { 16887 return 16888 } 16889 return *v, true 16890 } 16891 16892 // OldDeletedAt returns the old "deleted_at" field's value of the Setting entity. 16893 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 16894 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 16895 func (m *SettingMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 16896 if !m.op.Is(OpUpdateOne) { 16897 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 16898 } 16899 if m.id == nil || m.oldValue == nil { 16900 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 16901 } 16902 oldValue, err := m.oldValue(ctx) 16903 if err != nil { 16904 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 16905 } 16906 return oldValue.DeletedAt, nil 16907 } 16908 16909 // AddDeletedAt adds u to the "deleted_at" field. 16910 func (m *SettingMutation) AddDeletedAt(u int32) { 16911 if m.adddeleted_at != nil { 16912 *m.adddeleted_at += u 16913 } else { 16914 m.adddeleted_at = &u 16915 } 16916 } 16917 16918 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 16919 func (m *SettingMutation) AddedDeletedAt() (r int32, exists bool) { 16920 v := m.adddeleted_at 16921 if v == nil { 16922 return 16923 } 16924 return *v, true 16925 } 16926 16927 // ResetDeletedAt resets all changes to the "deleted_at" field. 16928 func (m *SettingMutation) ResetDeletedAt() { 16929 m.deleted_at = nil 16930 m.adddeleted_at = nil 16931 } 16932 16933 // SetEntID sets the "ent_id" field. 16934 func (m *SettingMutation) SetEntID(u uuid.UUID) { 16935 m.ent_id = &u 16936 } 16937 16938 // EntID returns the value of the "ent_id" field in the mutation. 16939 func (m *SettingMutation) EntID() (r uuid.UUID, exists bool) { 16940 v := m.ent_id 16941 if v == nil { 16942 return 16943 } 16944 return *v, true 16945 } 16946 16947 // OldEntID returns the old "ent_id" field's value of the Setting entity. 16948 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 16949 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 16950 func (m *SettingMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 16951 if !m.op.Is(OpUpdateOne) { 16952 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 16953 } 16954 if m.id == nil || m.oldValue == nil { 16955 return v, errors.New("OldEntID requires an ID field in the mutation") 16956 } 16957 oldValue, err := m.oldValue(ctx) 16958 if err != nil { 16959 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 16960 } 16961 return oldValue.EntID, nil 16962 } 16963 16964 // ResetEntID resets all changes to the "ent_id" field. 16965 func (m *SettingMutation) ResetEntID() { 16966 m.ent_id = nil 16967 } 16968 16969 // SetCoinTypeID sets the "coin_type_id" field. 16970 func (m *SettingMutation) SetCoinTypeID(u uuid.UUID) { 16971 m.coin_type_id = &u 16972 } 16973 16974 // CoinTypeID returns the value of the "coin_type_id" field in the mutation. 16975 func (m *SettingMutation) CoinTypeID() (r uuid.UUID, exists bool) { 16976 v := m.coin_type_id 16977 if v == nil { 16978 return 16979 } 16980 return *v, true 16981 } 16982 16983 // OldCoinTypeID returns the old "coin_type_id" field's value of the Setting entity. 16984 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 16985 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 16986 func (m *SettingMutation) OldCoinTypeID(ctx context.Context) (v uuid.UUID, err error) { 16987 if !m.op.Is(OpUpdateOne) { 16988 return v, errors.New("OldCoinTypeID is only allowed on UpdateOne operations") 16989 } 16990 if m.id == nil || m.oldValue == nil { 16991 return v, errors.New("OldCoinTypeID requires an ID field in the mutation") 16992 } 16993 oldValue, err := m.oldValue(ctx) 16994 if err != nil { 16995 return v, fmt.Errorf("querying old value for OldCoinTypeID: %w", err) 16996 } 16997 return oldValue.CoinTypeID, nil 16998 } 16999 17000 // ClearCoinTypeID clears the value of the "coin_type_id" field. 17001 func (m *SettingMutation) ClearCoinTypeID() { 17002 m.coin_type_id = nil 17003 m.clearedFields[setting.FieldCoinTypeID] = struct{}{} 17004 } 17005 17006 // CoinTypeIDCleared returns if the "coin_type_id" field was cleared in this mutation. 17007 func (m *SettingMutation) CoinTypeIDCleared() bool { 17008 _, ok := m.clearedFields[setting.FieldCoinTypeID] 17009 return ok 17010 } 17011 17012 // ResetCoinTypeID resets all changes to the "coin_type_id" field. 17013 func (m *SettingMutation) ResetCoinTypeID() { 17014 m.coin_type_id = nil 17015 delete(m.clearedFields, setting.FieldCoinTypeID) 17016 } 17017 17018 // SetFeeCoinTypeID sets the "fee_coin_type_id" field. 17019 func (m *SettingMutation) SetFeeCoinTypeID(u uuid.UUID) { 17020 m.fee_coin_type_id = &u 17021 } 17022 17023 // FeeCoinTypeID returns the value of the "fee_coin_type_id" field in the mutation. 17024 func (m *SettingMutation) FeeCoinTypeID() (r uuid.UUID, exists bool) { 17025 v := m.fee_coin_type_id 17026 if v == nil { 17027 return 17028 } 17029 return *v, true 17030 } 17031 17032 // OldFeeCoinTypeID returns the old "fee_coin_type_id" field's value of the Setting entity. 17033 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 17034 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 17035 func (m *SettingMutation) OldFeeCoinTypeID(ctx context.Context) (v uuid.UUID, err error) { 17036 if !m.op.Is(OpUpdateOne) { 17037 return v, errors.New("OldFeeCoinTypeID is only allowed on UpdateOne operations") 17038 } 17039 if m.id == nil || m.oldValue == nil { 17040 return v, errors.New("OldFeeCoinTypeID requires an ID field in the mutation") 17041 } 17042 oldValue, err := m.oldValue(ctx) 17043 if err != nil { 17044 return v, fmt.Errorf("querying old value for OldFeeCoinTypeID: %w", err) 17045 } 17046 return oldValue.FeeCoinTypeID, nil 17047 } 17048 17049 // ClearFeeCoinTypeID clears the value of the "fee_coin_type_id" field. 17050 func (m *SettingMutation) ClearFeeCoinTypeID() { 17051 m.fee_coin_type_id = nil 17052 m.clearedFields[setting.FieldFeeCoinTypeID] = struct{}{} 17053 } 17054 17055 // FeeCoinTypeIDCleared returns if the "fee_coin_type_id" field was cleared in this mutation. 17056 func (m *SettingMutation) FeeCoinTypeIDCleared() bool { 17057 _, ok := m.clearedFields[setting.FieldFeeCoinTypeID] 17058 return ok 17059 } 17060 17061 // ResetFeeCoinTypeID resets all changes to the "fee_coin_type_id" field. 17062 func (m *SettingMutation) ResetFeeCoinTypeID() { 17063 m.fee_coin_type_id = nil 17064 delete(m.clearedFields, setting.FieldFeeCoinTypeID) 17065 } 17066 17067 // SetWithdrawFeeByStableUsd sets the "withdraw_fee_by_stable_usd" field. 17068 func (m *SettingMutation) SetWithdrawFeeByStableUsd(b bool) { 17069 m.withdraw_fee_by_stable_usd = &b 17070 } 17071 17072 // WithdrawFeeByStableUsd returns the value of the "withdraw_fee_by_stable_usd" field in the mutation. 17073 func (m *SettingMutation) WithdrawFeeByStableUsd() (r bool, exists bool) { 17074 v := m.withdraw_fee_by_stable_usd 17075 if v == nil { 17076 return 17077 } 17078 return *v, true 17079 } 17080 17081 // OldWithdrawFeeByStableUsd returns the old "withdraw_fee_by_stable_usd" field's value of the Setting entity. 17082 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 17083 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 17084 func (m *SettingMutation) OldWithdrawFeeByStableUsd(ctx context.Context) (v bool, err error) { 17085 if !m.op.Is(OpUpdateOne) { 17086 return v, errors.New("OldWithdrawFeeByStableUsd is only allowed on UpdateOne operations") 17087 } 17088 if m.id == nil || m.oldValue == nil { 17089 return v, errors.New("OldWithdrawFeeByStableUsd requires an ID field in the mutation") 17090 } 17091 oldValue, err := m.oldValue(ctx) 17092 if err != nil { 17093 return v, fmt.Errorf("querying old value for OldWithdrawFeeByStableUsd: %w", err) 17094 } 17095 return oldValue.WithdrawFeeByStableUsd, nil 17096 } 17097 17098 // ClearWithdrawFeeByStableUsd clears the value of the "withdraw_fee_by_stable_usd" field. 17099 func (m *SettingMutation) ClearWithdrawFeeByStableUsd() { 17100 m.withdraw_fee_by_stable_usd = nil 17101 m.clearedFields[setting.FieldWithdrawFeeByStableUsd] = struct{}{} 17102 } 17103 17104 // WithdrawFeeByStableUsdCleared returns if the "withdraw_fee_by_stable_usd" field was cleared in this mutation. 17105 func (m *SettingMutation) WithdrawFeeByStableUsdCleared() bool { 17106 _, ok := m.clearedFields[setting.FieldWithdrawFeeByStableUsd] 17107 return ok 17108 } 17109 17110 // ResetWithdrawFeeByStableUsd resets all changes to the "withdraw_fee_by_stable_usd" field. 17111 func (m *SettingMutation) ResetWithdrawFeeByStableUsd() { 17112 m.withdraw_fee_by_stable_usd = nil 17113 delete(m.clearedFields, setting.FieldWithdrawFeeByStableUsd) 17114 } 17115 17116 // SetWithdrawFeeAmount sets the "withdraw_fee_amount" field. 17117 func (m *SettingMutation) SetWithdrawFeeAmount(d decimal.Decimal) { 17118 m.withdraw_fee_amount = &d 17119 } 17120 17121 // WithdrawFeeAmount returns the value of the "withdraw_fee_amount" field in the mutation. 17122 func (m *SettingMutation) WithdrawFeeAmount() (r decimal.Decimal, exists bool) { 17123 v := m.withdraw_fee_amount 17124 if v == nil { 17125 return 17126 } 17127 return *v, true 17128 } 17129 17130 // OldWithdrawFeeAmount returns the old "withdraw_fee_amount" field's value of the Setting entity. 17131 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 17132 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 17133 func (m *SettingMutation) OldWithdrawFeeAmount(ctx context.Context) (v decimal.Decimal, err error) { 17134 if !m.op.Is(OpUpdateOne) { 17135 return v, errors.New("OldWithdrawFeeAmount is only allowed on UpdateOne operations") 17136 } 17137 if m.id == nil || m.oldValue == nil { 17138 return v, errors.New("OldWithdrawFeeAmount requires an ID field in the mutation") 17139 } 17140 oldValue, err := m.oldValue(ctx) 17141 if err != nil { 17142 return v, fmt.Errorf("querying old value for OldWithdrawFeeAmount: %w", err) 17143 } 17144 return oldValue.WithdrawFeeAmount, nil 17145 } 17146 17147 // ClearWithdrawFeeAmount clears the value of the "withdraw_fee_amount" field. 17148 func (m *SettingMutation) ClearWithdrawFeeAmount() { 17149 m.withdraw_fee_amount = nil 17150 m.clearedFields[setting.FieldWithdrawFeeAmount] = struct{}{} 17151 } 17152 17153 // WithdrawFeeAmountCleared returns if the "withdraw_fee_amount" field was cleared in this mutation. 17154 func (m *SettingMutation) WithdrawFeeAmountCleared() bool { 17155 _, ok := m.clearedFields[setting.FieldWithdrawFeeAmount] 17156 return ok 17157 } 17158 17159 // ResetWithdrawFeeAmount resets all changes to the "withdraw_fee_amount" field. 17160 func (m *SettingMutation) ResetWithdrawFeeAmount() { 17161 m.withdraw_fee_amount = nil 17162 delete(m.clearedFields, setting.FieldWithdrawFeeAmount) 17163 } 17164 17165 // SetCollectFeeAmount sets the "collect_fee_amount" field. 17166 func (m *SettingMutation) SetCollectFeeAmount(d decimal.Decimal) { 17167 m.collect_fee_amount = &d 17168 } 17169 17170 // CollectFeeAmount returns the value of the "collect_fee_amount" field in the mutation. 17171 func (m *SettingMutation) CollectFeeAmount() (r decimal.Decimal, exists bool) { 17172 v := m.collect_fee_amount 17173 if v == nil { 17174 return 17175 } 17176 return *v, true 17177 } 17178 17179 // OldCollectFeeAmount returns the old "collect_fee_amount" field's value of the Setting entity. 17180 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 17181 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 17182 func (m *SettingMutation) OldCollectFeeAmount(ctx context.Context) (v decimal.Decimal, err error) { 17183 if !m.op.Is(OpUpdateOne) { 17184 return v, errors.New("OldCollectFeeAmount is only allowed on UpdateOne operations") 17185 } 17186 if m.id == nil || m.oldValue == nil { 17187 return v, errors.New("OldCollectFeeAmount requires an ID field in the mutation") 17188 } 17189 oldValue, err := m.oldValue(ctx) 17190 if err != nil { 17191 return v, fmt.Errorf("querying old value for OldCollectFeeAmount: %w", err) 17192 } 17193 return oldValue.CollectFeeAmount, nil 17194 } 17195 17196 // ClearCollectFeeAmount clears the value of the "collect_fee_amount" field. 17197 func (m *SettingMutation) ClearCollectFeeAmount() { 17198 m.collect_fee_amount = nil 17199 m.clearedFields[setting.FieldCollectFeeAmount] = struct{}{} 17200 } 17201 17202 // CollectFeeAmountCleared returns if the "collect_fee_amount" field was cleared in this mutation. 17203 func (m *SettingMutation) CollectFeeAmountCleared() bool { 17204 _, ok := m.clearedFields[setting.FieldCollectFeeAmount] 17205 return ok 17206 } 17207 17208 // ResetCollectFeeAmount resets all changes to the "collect_fee_amount" field. 17209 func (m *SettingMutation) ResetCollectFeeAmount() { 17210 m.collect_fee_amount = nil 17211 delete(m.clearedFields, setting.FieldCollectFeeAmount) 17212 } 17213 17214 // SetHotWalletFeeAmount sets the "hot_wallet_fee_amount" field. 17215 func (m *SettingMutation) SetHotWalletFeeAmount(d decimal.Decimal) { 17216 m.hot_wallet_fee_amount = &d 17217 } 17218 17219 // HotWalletFeeAmount returns the value of the "hot_wallet_fee_amount" field in the mutation. 17220 func (m *SettingMutation) HotWalletFeeAmount() (r decimal.Decimal, exists bool) { 17221 v := m.hot_wallet_fee_amount 17222 if v == nil { 17223 return 17224 } 17225 return *v, true 17226 } 17227 17228 // OldHotWalletFeeAmount returns the old "hot_wallet_fee_amount" field's value of the Setting entity. 17229 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 17230 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 17231 func (m *SettingMutation) OldHotWalletFeeAmount(ctx context.Context) (v decimal.Decimal, err error) { 17232 if !m.op.Is(OpUpdateOne) { 17233 return v, errors.New("OldHotWalletFeeAmount is only allowed on UpdateOne operations") 17234 } 17235 if m.id == nil || m.oldValue == nil { 17236 return v, errors.New("OldHotWalletFeeAmount requires an ID field in the mutation") 17237 } 17238 oldValue, err := m.oldValue(ctx) 17239 if err != nil { 17240 return v, fmt.Errorf("querying old value for OldHotWalletFeeAmount: %w", err) 17241 } 17242 return oldValue.HotWalletFeeAmount, nil 17243 } 17244 17245 // ClearHotWalletFeeAmount clears the value of the "hot_wallet_fee_amount" field. 17246 func (m *SettingMutation) ClearHotWalletFeeAmount() { 17247 m.hot_wallet_fee_amount = nil 17248 m.clearedFields[setting.FieldHotWalletFeeAmount] = struct{}{} 17249 } 17250 17251 // HotWalletFeeAmountCleared returns if the "hot_wallet_fee_amount" field was cleared in this mutation. 17252 func (m *SettingMutation) HotWalletFeeAmountCleared() bool { 17253 _, ok := m.clearedFields[setting.FieldHotWalletFeeAmount] 17254 return ok 17255 } 17256 17257 // ResetHotWalletFeeAmount resets all changes to the "hot_wallet_fee_amount" field. 17258 func (m *SettingMutation) ResetHotWalletFeeAmount() { 17259 m.hot_wallet_fee_amount = nil 17260 delete(m.clearedFields, setting.FieldHotWalletFeeAmount) 17261 } 17262 17263 // SetLowFeeAmount sets the "low_fee_amount" field. 17264 func (m *SettingMutation) SetLowFeeAmount(d decimal.Decimal) { 17265 m.low_fee_amount = &d 17266 } 17267 17268 // LowFeeAmount returns the value of the "low_fee_amount" field in the mutation. 17269 func (m *SettingMutation) LowFeeAmount() (r decimal.Decimal, exists bool) { 17270 v := m.low_fee_amount 17271 if v == nil { 17272 return 17273 } 17274 return *v, true 17275 } 17276 17277 // OldLowFeeAmount returns the old "low_fee_amount" field's value of the Setting entity. 17278 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 17279 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 17280 func (m *SettingMutation) OldLowFeeAmount(ctx context.Context) (v decimal.Decimal, err error) { 17281 if !m.op.Is(OpUpdateOne) { 17282 return v, errors.New("OldLowFeeAmount is only allowed on UpdateOne operations") 17283 } 17284 if m.id == nil || m.oldValue == nil { 17285 return v, errors.New("OldLowFeeAmount requires an ID field in the mutation") 17286 } 17287 oldValue, err := m.oldValue(ctx) 17288 if err != nil { 17289 return v, fmt.Errorf("querying old value for OldLowFeeAmount: %w", err) 17290 } 17291 return oldValue.LowFeeAmount, nil 17292 } 17293 17294 // ClearLowFeeAmount clears the value of the "low_fee_amount" field. 17295 func (m *SettingMutation) ClearLowFeeAmount() { 17296 m.low_fee_amount = nil 17297 m.clearedFields[setting.FieldLowFeeAmount] = struct{}{} 17298 } 17299 17300 // LowFeeAmountCleared returns if the "low_fee_amount" field was cleared in this mutation. 17301 func (m *SettingMutation) LowFeeAmountCleared() bool { 17302 _, ok := m.clearedFields[setting.FieldLowFeeAmount] 17303 return ok 17304 } 17305 17306 // ResetLowFeeAmount resets all changes to the "low_fee_amount" field. 17307 func (m *SettingMutation) ResetLowFeeAmount() { 17308 m.low_fee_amount = nil 17309 delete(m.clearedFields, setting.FieldLowFeeAmount) 17310 } 17311 17312 // SetHotLowFeeAmount sets the "hot_low_fee_amount" field. 17313 func (m *SettingMutation) SetHotLowFeeAmount(d decimal.Decimal) { 17314 m.hot_low_fee_amount = &d 17315 } 17316 17317 // HotLowFeeAmount returns the value of the "hot_low_fee_amount" field in the mutation. 17318 func (m *SettingMutation) HotLowFeeAmount() (r decimal.Decimal, exists bool) { 17319 v := m.hot_low_fee_amount 17320 if v == nil { 17321 return 17322 } 17323 return *v, true 17324 } 17325 17326 // OldHotLowFeeAmount returns the old "hot_low_fee_amount" field's value of the Setting entity. 17327 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 17328 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 17329 func (m *SettingMutation) OldHotLowFeeAmount(ctx context.Context) (v decimal.Decimal, err error) { 17330 if !m.op.Is(OpUpdateOne) { 17331 return v, errors.New("OldHotLowFeeAmount is only allowed on UpdateOne operations") 17332 } 17333 if m.id == nil || m.oldValue == nil { 17334 return v, errors.New("OldHotLowFeeAmount requires an ID field in the mutation") 17335 } 17336 oldValue, err := m.oldValue(ctx) 17337 if err != nil { 17338 return v, fmt.Errorf("querying old value for OldHotLowFeeAmount: %w", err) 17339 } 17340 return oldValue.HotLowFeeAmount, nil 17341 } 17342 17343 // ClearHotLowFeeAmount clears the value of the "hot_low_fee_amount" field. 17344 func (m *SettingMutation) ClearHotLowFeeAmount() { 17345 m.hot_low_fee_amount = nil 17346 m.clearedFields[setting.FieldHotLowFeeAmount] = struct{}{} 17347 } 17348 17349 // HotLowFeeAmountCleared returns if the "hot_low_fee_amount" field was cleared in this mutation. 17350 func (m *SettingMutation) HotLowFeeAmountCleared() bool { 17351 _, ok := m.clearedFields[setting.FieldHotLowFeeAmount] 17352 return ok 17353 } 17354 17355 // ResetHotLowFeeAmount resets all changes to the "hot_low_fee_amount" field. 17356 func (m *SettingMutation) ResetHotLowFeeAmount() { 17357 m.hot_low_fee_amount = nil 17358 delete(m.clearedFields, setting.FieldHotLowFeeAmount) 17359 } 17360 17361 // SetHotWalletAccountAmount sets the "hot_wallet_account_amount" field. 17362 func (m *SettingMutation) SetHotWalletAccountAmount(d decimal.Decimal) { 17363 m.hot_wallet_account_amount = &d 17364 } 17365 17366 // HotWalletAccountAmount returns the value of the "hot_wallet_account_amount" field in the mutation. 17367 func (m *SettingMutation) HotWalletAccountAmount() (r decimal.Decimal, exists bool) { 17368 v := m.hot_wallet_account_amount 17369 if v == nil { 17370 return 17371 } 17372 return *v, true 17373 } 17374 17375 // OldHotWalletAccountAmount returns the old "hot_wallet_account_amount" field's value of the Setting entity. 17376 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 17377 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 17378 func (m *SettingMutation) OldHotWalletAccountAmount(ctx context.Context) (v decimal.Decimal, err error) { 17379 if !m.op.Is(OpUpdateOne) { 17380 return v, errors.New("OldHotWalletAccountAmount is only allowed on UpdateOne operations") 17381 } 17382 if m.id == nil || m.oldValue == nil { 17383 return v, errors.New("OldHotWalletAccountAmount requires an ID field in the mutation") 17384 } 17385 oldValue, err := m.oldValue(ctx) 17386 if err != nil { 17387 return v, fmt.Errorf("querying old value for OldHotWalletAccountAmount: %w", err) 17388 } 17389 return oldValue.HotWalletAccountAmount, nil 17390 } 17391 17392 // ClearHotWalletAccountAmount clears the value of the "hot_wallet_account_amount" field. 17393 func (m *SettingMutation) ClearHotWalletAccountAmount() { 17394 m.hot_wallet_account_amount = nil 17395 m.clearedFields[setting.FieldHotWalletAccountAmount] = struct{}{} 17396 } 17397 17398 // HotWalletAccountAmountCleared returns if the "hot_wallet_account_amount" field was cleared in this mutation. 17399 func (m *SettingMutation) HotWalletAccountAmountCleared() bool { 17400 _, ok := m.clearedFields[setting.FieldHotWalletAccountAmount] 17401 return ok 17402 } 17403 17404 // ResetHotWalletAccountAmount resets all changes to the "hot_wallet_account_amount" field. 17405 func (m *SettingMutation) ResetHotWalletAccountAmount() { 17406 m.hot_wallet_account_amount = nil 17407 delete(m.clearedFields, setting.FieldHotWalletAccountAmount) 17408 } 17409 17410 // SetPaymentAccountCollectAmount sets the "payment_account_collect_amount" field. 17411 func (m *SettingMutation) SetPaymentAccountCollectAmount(d decimal.Decimal) { 17412 m.payment_account_collect_amount = &d 17413 } 17414 17415 // PaymentAccountCollectAmount returns the value of the "payment_account_collect_amount" field in the mutation. 17416 func (m *SettingMutation) PaymentAccountCollectAmount() (r decimal.Decimal, exists bool) { 17417 v := m.payment_account_collect_amount 17418 if v == nil { 17419 return 17420 } 17421 return *v, true 17422 } 17423 17424 // OldPaymentAccountCollectAmount returns the old "payment_account_collect_amount" field's value of the Setting entity. 17425 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 17426 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 17427 func (m *SettingMutation) OldPaymentAccountCollectAmount(ctx context.Context) (v decimal.Decimal, err error) { 17428 if !m.op.Is(OpUpdateOne) { 17429 return v, errors.New("OldPaymentAccountCollectAmount is only allowed on UpdateOne operations") 17430 } 17431 if m.id == nil || m.oldValue == nil { 17432 return v, errors.New("OldPaymentAccountCollectAmount requires an ID field in the mutation") 17433 } 17434 oldValue, err := m.oldValue(ctx) 17435 if err != nil { 17436 return v, fmt.Errorf("querying old value for OldPaymentAccountCollectAmount: %w", err) 17437 } 17438 return oldValue.PaymentAccountCollectAmount, nil 17439 } 17440 17441 // ClearPaymentAccountCollectAmount clears the value of the "payment_account_collect_amount" field. 17442 func (m *SettingMutation) ClearPaymentAccountCollectAmount() { 17443 m.payment_account_collect_amount = nil 17444 m.clearedFields[setting.FieldPaymentAccountCollectAmount] = struct{}{} 17445 } 17446 17447 // PaymentAccountCollectAmountCleared returns if the "payment_account_collect_amount" field was cleared in this mutation. 17448 func (m *SettingMutation) PaymentAccountCollectAmountCleared() bool { 17449 _, ok := m.clearedFields[setting.FieldPaymentAccountCollectAmount] 17450 return ok 17451 } 17452 17453 // ResetPaymentAccountCollectAmount resets all changes to the "payment_account_collect_amount" field. 17454 func (m *SettingMutation) ResetPaymentAccountCollectAmount() { 17455 m.payment_account_collect_amount = nil 17456 delete(m.clearedFields, setting.FieldPaymentAccountCollectAmount) 17457 } 17458 17459 // SetLeastTransferAmount sets the "least_transfer_amount" field. 17460 func (m *SettingMutation) SetLeastTransferAmount(d decimal.Decimal) { 17461 m.least_transfer_amount = &d 17462 } 17463 17464 // LeastTransferAmount returns the value of the "least_transfer_amount" field in the mutation. 17465 func (m *SettingMutation) LeastTransferAmount() (r decimal.Decimal, exists bool) { 17466 v := m.least_transfer_amount 17467 if v == nil { 17468 return 17469 } 17470 return *v, true 17471 } 17472 17473 // OldLeastTransferAmount returns the old "least_transfer_amount" field's value of the Setting entity. 17474 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 17475 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 17476 func (m *SettingMutation) OldLeastTransferAmount(ctx context.Context) (v decimal.Decimal, err error) { 17477 if !m.op.Is(OpUpdateOne) { 17478 return v, errors.New("OldLeastTransferAmount is only allowed on UpdateOne operations") 17479 } 17480 if m.id == nil || m.oldValue == nil { 17481 return v, errors.New("OldLeastTransferAmount requires an ID field in the mutation") 17482 } 17483 oldValue, err := m.oldValue(ctx) 17484 if err != nil { 17485 return v, fmt.Errorf("querying old value for OldLeastTransferAmount: %w", err) 17486 } 17487 return oldValue.LeastTransferAmount, nil 17488 } 17489 17490 // ClearLeastTransferAmount clears the value of the "least_transfer_amount" field. 17491 func (m *SettingMutation) ClearLeastTransferAmount() { 17492 m.least_transfer_amount = nil 17493 m.clearedFields[setting.FieldLeastTransferAmount] = struct{}{} 17494 } 17495 17496 // LeastTransferAmountCleared returns if the "least_transfer_amount" field was cleared in this mutation. 17497 func (m *SettingMutation) LeastTransferAmountCleared() bool { 17498 _, ok := m.clearedFields[setting.FieldLeastTransferAmount] 17499 return ok 17500 } 17501 17502 // ResetLeastTransferAmount resets all changes to the "least_transfer_amount" field. 17503 func (m *SettingMutation) ResetLeastTransferAmount() { 17504 m.least_transfer_amount = nil 17505 delete(m.clearedFields, setting.FieldLeastTransferAmount) 17506 } 17507 17508 // SetNeedMemo sets the "need_memo" field. 17509 func (m *SettingMutation) SetNeedMemo(b bool) { 17510 m.need_memo = &b 17511 } 17512 17513 // NeedMemo returns the value of the "need_memo" field in the mutation. 17514 func (m *SettingMutation) NeedMemo() (r bool, exists bool) { 17515 v := m.need_memo 17516 if v == nil { 17517 return 17518 } 17519 return *v, true 17520 } 17521 17522 // OldNeedMemo returns the old "need_memo" field's value of the Setting entity. 17523 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 17524 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 17525 func (m *SettingMutation) OldNeedMemo(ctx context.Context) (v bool, err error) { 17526 if !m.op.Is(OpUpdateOne) { 17527 return v, errors.New("OldNeedMemo is only allowed on UpdateOne operations") 17528 } 17529 if m.id == nil || m.oldValue == nil { 17530 return v, errors.New("OldNeedMemo requires an ID field in the mutation") 17531 } 17532 oldValue, err := m.oldValue(ctx) 17533 if err != nil { 17534 return v, fmt.Errorf("querying old value for OldNeedMemo: %w", err) 17535 } 17536 return oldValue.NeedMemo, nil 17537 } 17538 17539 // ClearNeedMemo clears the value of the "need_memo" field. 17540 func (m *SettingMutation) ClearNeedMemo() { 17541 m.need_memo = nil 17542 m.clearedFields[setting.FieldNeedMemo] = struct{}{} 17543 } 17544 17545 // NeedMemoCleared returns if the "need_memo" field was cleared in this mutation. 17546 func (m *SettingMutation) NeedMemoCleared() bool { 17547 _, ok := m.clearedFields[setting.FieldNeedMemo] 17548 return ok 17549 } 17550 17551 // ResetNeedMemo resets all changes to the "need_memo" field. 17552 func (m *SettingMutation) ResetNeedMemo() { 17553 m.need_memo = nil 17554 delete(m.clearedFields, setting.FieldNeedMemo) 17555 } 17556 17557 // SetRefreshCurrency sets the "refresh_currency" field. 17558 func (m *SettingMutation) SetRefreshCurrency(b bool) { 17559 m.refresh_currency = &b 17560 } 17561 17562 // RefreshCurrency returns the value of the "refresh_currency" field in the mutation. 17563 func (m *SettingMutation) RefreshCurrency() (r bool, exists bool) { 17564 v := m.refresh_currency 17565 if v == nil { 17566 return 17567 } 17568 return *v, true 17569 } 17570 17571 // OldRefreshCurrency returns the old "refresh_currency" field's value of the Setting entity. 17572 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 17573 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 17574 func (m *SettingMutation) OldRefreshCurrency(ctx context.Context) (v bool, err error) { 17575 if !m.op.Is(OpUpdateOne) { 17576 return v, errors.New("OldRefreshCurrency is only allowed on UpdateOne operations") 17577 } 17578 if m.id == nil || m.oldValue == nil { 17579 return v, errors.New("OldRefreshCurrency requires an ID field in the mutation") 17580 } 17581 oldValue, err := m.oldValue(ctx) 17582 if err != nil { 17583 return v, fmt.Errorf("querying old value for OldRefreshCurrency: %w", err) 17584 } 17585 return oldValue.RefreshCurrency, nil 17586 } 17587 17588 // ClearRefreshCurrency clears the value of the "refresh_currency" field. 17589 func (m *SettingMutation) ClearRefreshCurrency() { 17590 m.refresh_currency = nil 17591 m.clearedFields[setting.FieldRefreshCurrency] = struct{}{} 17592 } 17593 17594 // RefreshCurrencyCleared returns if the "refresh_currency" field was cleared in this mutation. 17595 func (m *SettingMutation) RefreshCurrencyCleared() bool { 17596 _, ok := m.clearedFields[setting.FieldRefreshCurrency] 17597 return ok 17598 } 17599 17600 // ResetRefreshCurrency resets all changes to the "refresh_currency" field. 17601 func (m *SettingMutation) ResetRefreshCurrency() { 17602 m.refresh_currency = nil 17603 delete(m.clearedFields, setting.FieldRefreshCurrency) 17604 } 17605 17606 // SetCheckNewAddressBalance sets the "check_new_address_balance" field. 17607 func (m *SettingMutation) SetCheckNewAddressBalance(b bool) { 17608 m.check_new_address_balance = &b 17609 } 17610 17611 // CheckNewAddressBalance returns the value of the "check_new_address_balance" field in the mutation. 17612 func (m *SettingMutation) CheckNewAddressBalance() (r bool, exists bool) { 17613 v := m.check_new_address_balance 17614 if v == nil { 17615 return 17616 } 17617 return *v, true 17618 } 17619 17620 // OldCheckNewAddressBalance returns the old "check_new_address_balance" field's value of the Setting entity. 17621 // If the Setting object wasn't provided to the builder, the object is fetched from the database. 17622 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 17623 func (m *SettingMutation) OldCheckNewAddressBalance(ctx context.Context) (v bool, err error) { 17624 if !m.op.Is(OpUpdateOne) { 17625 return v, errors.New("OldCheckNewAddressBalance is only allowed on UpdateOne operations") 17626 } 17627 if m.id == nil || m.oldValue == nil { 17628 return v, errors.New("OldCheckNewAddressBalance requires an ID field in the mutation") 17629 } 17630 oldValue, err := m.oldValue(ctx) 17631 if err != nil { 17632 return v, fmt.Errorf("querying old value for OldCheckNewAddressBalance: %w", err) 17633 } 17634 return oldValue.CheckNewAddressBalance, nil 17635 } 17636 17637 // ClearCheckNewAddressBalance clears the value of the "check_new_address_balance" field. 17638 func (m *SettingMutation) ClearCheckNewAddressBalance() { 17639 m.check_new_address_balance = nil 17640 m.clearedFields[setting.FieldCheckNewAddressBalance] = struct{}{} 17641 } 17642 17643 // CheckNewAddressBalanceCleared returns if the "check_new_address_balance" field was cleared in this mutation. 17644 func (m *SettingMutation) CheckNewAddressBalanceCleared() bool { 17645 _, ok := m.clearedFields[setting.FieldCheckNewAddressBalance] 17646 return ok 17647 } 17648 17649 // ResetCheckNewAddressBalance resets all changes to the "check_new_address_balance" field. 17650 func (m *SettingMutation) ResetCheckNewAddressBalance() { 17651 m.check_new_address_balance = nil 17652 delete(m.clearedFields, setting.FieldCheckNewAddressBalance) 17653 } 17654 17655 // Where appends a list predicates to the SettingMutation builder. 17656 func (m *SettingMutation) Where(ps ...predicate.Setting) { 17657 m.predicates = append(m.predicates, ps...) 17658 } 17659 17660 // Op returns the operation name. 17661 func (m *SettingMutation) Op() Op { 17662 return m.op 17663 } 17664 17665 // Type returns the node type of this mutation (Setting). 17666 func (m *SettingMutation) Type() string { 17667 return m.typ 17668 } 17669 17670 // Fields returns all fields that were changed during this mutation. Note that in 17671 // order to get all numeric fields that were incremented/decremented, call 17672 // AddedFields(). 17673 func (m *SettingMutation) Fields() []string { 17674 fields := make([]string, 0, 18) 17675 if m.created_at != nil { 17676 fields = append(fields, setting.FieldCreatedAt) 17677 } 17678 if m.updated_at != nil { 17679 fields = append(fields, setting.FieldUpdatedAt) 17680 } 17681 if m.deleted_at != nil { 17682 fields = append(fields, setting.FieldDeletedAt) 17683 } 17684 if m.ent_id != nil { 17685 fields = append(fields, setting.FieldEntID) 17686 } 17687 if m.coin_type_id != nil { 17688 fields = append(fields, setting.FieldCoinTypeID) 17689 } 17690 if m.fee_coin_type_id != nil { 17691 fields = append(fields, setting.FieldFeeCoinTypeID) 17692 } 17693 if m.withdraw_fee_by_stable_usd != nil { 17694 fields = append(fields, setting.FieldWithdrawFeeByStableUsd) 17695 } 17696 if m.withdraw_fee_amount != nil { 17697 fields = append(fields, setting.FieldWithdrawFeeAmount) 17698 } 17699 if m.collect_fee_amount != nil { 17700 fields = append(fields, setting.FieldCollectFeeAmount) 17701 } 17702 if m.hot_wallet_fee_amount != nil { 17703 fields = append(fields, setting.FieldHotWalletFeeAmount) 17704 } 17705 if m.low_fee_amount != nil { 17706 fields = append(fields, setting.FieldLowFeeAmount) 17707 } 17708 if m.hot_low_fee_amount != nil { 17709 fields = append(fields, setting.FieldHotLowFeeAmount) 17710 } 17711 if m.hot_wallet_account_amount != nil { 17712 fields = append(fields, setting.FieldHotWalletAccountAmount) 17713 } 17714 if m.payment_account_collect_amount != nil { 17715 fields = append(fields, setting.FieldPaymentAccountCollectAmount) 17716 } 17717 if m.least_transfer_amount != nil { 17718 fields = append(fields, setting.FieldLeastTransferAmount) 17719 } 17720 if m.need_memo != nil { 17721 fields = append(fields, setting.FieldNeedMemo) 17722 } 17723 if m.refresh_currency != nil { 17724 fields = append(fields, setting.FieldRefreshCurrency) 17725 } 17726 if m.check_new_address_balance != nil { 17727 fields = append(fields, setting.FieldCheckNewAddressBalance) 17728 } 17729 return fields 17730 } 17731 17732 // Field returns the value of a field with the given name. The second boolean 17733 // return value indicates that this field was not set, or was not defined in the 17734 // schema. 17735 func (m *SettingMutation) Field(name string) (ent.Value, bool) { 17736 switch name { 17737 case setting.FieldCreatedAt: 17738 return m.CreatedAt() 17739 case setting.FieldUpdatedAt: 17740 return m.UpdatedAt() 17741 case setting.FieldDeletedAt: 17742 return m.DeletedAt() 17743 case setting.FieldEntID: 17744 return m.EntID() 17745 case setting.FieldCoinTypeID: 17746 return m.CoinTypeID() 17747 case setting.FieldFeeCoinTypeID: 17748 return m.FeeCoinTypeID() 17749 case setting.FieldWithdrawFeeByStableUsd: 17750 return m.WithdrawFeeByStableUsd() 17751 case setting.FieldWithdrawFeeAmount: 17752 return m.WithdrawFeeAmount() 17753 case setting.FieldCollectFeeAmount: 17754 return m.CollectFeeAmount() 17755 case setting.FieldHotWalletFeeAmount: 17756 return m.HotWalletFeeAmount() 17757 case setting.FieldLowFeeAmount: 17758 return m.LowFeeAmount() 17759 case setting.FieldHotLowFeeAmount: 17760 return m.HotLowFeeAmount() 17761 case setting.FieldHotWalletAccountAmount: 17762 return m.HotWalletAccountAmount() 17763 case setting.FieldPaymentAccountCollectAmount: 17764 return m.PaymentAccountCollectAmount() 17765 case setting.FieldLeastTransferAmount: 17766 return m.LeastTransferAmount() 17767 case setting.FieldNeedMemo: 17768 return m.NeedMemo() 17769 case setting.FieldRefreshCurrency: 17770 return m.RefreshCurrency() 17771 case setting.FieldCheckNewAddressBalance: 17772 return m.CheckNewAddressBalance() 17773 } 17774 return nil, false 17775 } 17776 17777 // OldField returns the old value of the field from the database. An error is 17778 // returned if the mutation operation is not UpdateOne, or the query to the 17779 // database failed. 17780 func (m *SettingMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 17781 switch name { 17782 case setting.FieldCreatedAt: 17783 return m.OldCreatedAt(ctx) 17784 case setting.FieldUpdatedAt: 17785 return m.OldUpdatedAt(ctx) 17786 case setting.FieldDeletedAt: 17787 return m.OldDeletedAt(ctx) 17788 case setting.FieldEntID: 17789 return m.OldEntID(ctx) 17790 case setting.FieldCoinTypeID: 17791 return m.OldCoinTypeID(ctx) 17792 case setting.FieldFeeCoinTypeID: 17793 return m.OldFeeCoinTypeID(ctx) 17794 case setting.FieldWithdrawFeeByStableUsd: 17795 return m.OldWithdrawFeeByStableUsd(ctx) 17796 case setting.FieldWithdrawFeeAmount: 17797 return m.OldWithdrawFeeAmount(ctx) 17798 case setting.FieldCollectFeeAmount: 17799 return m.OldCollectFeeAmount(ctx) 17800 case setting.FieldHotWalletFeeAmount: 17801 return m.OldHotWalletFeeAmount(ctx) 17802 case setting.FieldLowFeeAmount: 17803 return m.OldLowFeeAmount(ctx) 17804 case setting.FieldHotLowFeeAmount: 17805 return m.OldHotLowFeeAmount(ctx) 17806 case setting.FieldHotWalletAccountAmount: 17807 return m.OldHotWalletAccountAmount(ctx) 17808 case setting.FieldPaymentAccountCollectAmount: 17809 return m.OldPaymentAccountCollectAmount(ctx) 17810 case setting.FieldLeastTransferAmount: 17811 return m.OldLeastTransferAmount(ctx) 17812 case setting.FieldNeedMemo: 17813 return m.OldNeedMemo(ctx) 17814 case setting.FieldRefreshCurrency: 17815 return m.OldRefreshCurrency(ctx) 17816 case setting.FieldCheckNewAddressBalance: 17817 return m.OldCheckNewAddressBalance(ctx) 17818 } 17819 return nil, fmt.Errorf("unknown Setting field %s", name) 17820 } 17821 17822 // SetField sets the value of a field with the given name. It returns an error if 17823 // the field is not defined in the schema, or if the type mismatched the field 17824 // type. 17825 func (m *SettingMutation) SetField(name string, value ent.Value) error { 17826 switch name { 17827 case setting.FieldCreatedAt: 17828 v, ok := value.(uint32) 17829 if !ok { 17830 return fmt.Errorf("unexpected type %T for field %s", value, name) 17831 } 17832 m.SetCreatedAt(v) 17833 return nil 17834 case setting.FieldUpdatedAt: 17835 v, ok := value.(uint32) 17836 if !ok { 17837 return fmt.Errorf("unexpected type %T for field %s", value, name) 17838 } 17839 m.SetUpdatedAt(v) 17840 return nil 17841 case setting.FieldDeletedAt: 17842 v, ok := value.(uint32) 17843 if !ok { 17844 return fmt.Errorf("unexpected type %T for field %s", value, name) 17845 } 17846 m.SetDeletedAt(v) 17847 return nil 17848 case setting.FieldEntID: 17849 v, ok := value.(uuid.UUID) 17850 if !ok { 17851 return fmt.Errorf("unexpected type %T for field %s", value, name) 17852 } 17853 m.SetEntID(v) 17854 return nil 17855 case setting.FieldCoinTypeID: 17856 v, ok := value.(uuid.UUID) 17857 if !ok { 17858 return fmt.Errorf("unexpected type %T for field %s", value, name) 17859 } 17860 m.SetCoinTypeID(v) 17861 return nil 17862 case setting.FieldFeeCoinTypeID: 17863 v, ok := value.(uuid.UUID) 17864 if !ok { 17865 return fmt.Errorf("unexpected type %T for field %s", value, name) 17866 } 17867 m.SetFeeCoinTypeID(v) 17868 return nil 17869 case setting.FieldWithdrawFeeByStableUsd: 17870 v, ok := value.(bool) 17871 if !ok { 17872 return fmt.Errorf("unexpected type %T for field %s", value, name) 17873 } 17874 m.SetWithdrawFeeByStableUsd(v) 17875 return nil 17876 case setting.FieldWithdrawFeeAmount: 17877 v, ok := value.(decimal.Decimal) 17878 if !ok { 17879 return fmt.Errorf("unexpected type %T for field %s", value, name) 17880 } 17881 m.SetWithdrawFeeAmount(v) 17882 return nil 17883 case setting.FieldCollectFeeAmount: 17884 v, ok := value.(decimal.Decimal) 17885 if !ok { 17886 return fmt.Errorf("unexpected type %T for field %s", value, name) 17887 } 17888 m.SetCollectFeeAmount(v) 17889 return nil 17890 case setting.FieldHotWalletFeeAmount: 17891 v, ok := value.(decimal.Decimal) 17892 if !ok { 17893 return fmt.Errorf("unexpected type %T for field %s", value, name) 17894 } 17895 m.SetHotWalletFeeAmount(v) 17896 return nil 17897 case setting.FieldLowFeeAmount: 17898 v, ok := value.(decimal.Decimal) 17899 if !ok { 17900 return fmt.Errorf("unexpected type %T for field %s", value, name) 17901 } 17902 m.SetLowFeeAmount(v) 17903 return nil 17904 case setting.FieldHotLowFeeAmount: 17905 v, ok := value.(decimal.Decimal) 17906 if !ok { 17907 return fmt.Errorf("unexpected type %T for field %s", value, name) 17908 } 17909 m.SetHotLowFeeAmount(v) 17910 return nil 17911 case setting.FieldHotWalletAccountAmount: 17912 v, ok := value.(decimal.Decimal) 17913 if !ok { 17914 return fmt.Errorf("unexpected type %T for field %s", value, name) 17915 } 17916 m.SetHotWalletAccountAmount(v) 17917 return nil 17918 case setting.FieldPaymentAccountCollectAmount: 17919 v, ok := value.(decimal.Decimal) 17920 if !ok { 17921 return fmt.Errorf("unexpected type %T for field %s", value, name) 17922 } 17923 m.SetPaymentAccountCollectAmount(v) 17924 return nil 17925 case setting.FieldLeastTransferAmount: 17926 v, ok := value.(decimal.Decimal) 17927 if !ok { 17928 return fmt.Errorf("unexpected type %T for field %s", value, name) 17929 } 17930 m.SetLeastTransferAmount(v) 17931 return nil 17932 case setting.FieldNeedMemo: 17933 v, ok := value.(bool) 17934 if !ok { 17935 return fmt.Errorf("unexpected type %T for field %s", value, name) 17936 } 17937 m.SetNeedMemo(v) 17938 return nil 17939 case setting.FieldRefreshCurrency: 17940 v, ok := value.(bool) 17941 if !ok { 17942 return fmt.Errorf("unexpected type %T for field %s", value, name) 17943 } 17944 m.SetRefreshCurrency(v) 17945 return nil 17946 case setting.FieldCheckNewAddressBalance: 17947 v, ok := value.(bool) 17948 if !ok { 17949 return fmt.Errorf("unexpected type %T for field %s", value, name) 17950 } 17951 m.SetCheckNewAddressBalance(v) 17952 return nil 17953 } 17954 return fmt.Errorf("unknown Setting field %s", name) 17955 } 17956 17957 // AddedFields returns all numeric fields that were incremented/decremented during 17958 // this mutation. 17959 func (m *SettingMutation) AddedFields() []string { 17960 var fields []string 17961 if m.addcreated_at != nil { 17962 fields = append(fields, setting.FieldCreatedAt) 17963 } 17964 if m.addupdated_at != nil { 17965 fields = append(fields, setting.FieldUpdatedAt) 17966 } 17967 if m.adddeleted_at != nil { 17968 fields = append(fields, setting.FieldDeletedAt) 17969 } 17970 return fields 17971 } 17972 17973 // AddedField returns the numeric value that was incremented/decremented on a field 17974 // with the given name. The second boolean return value indicates that this field 17975 // was not set, or was not defined in the schema. 17976 func (m *SettingMutation) AddedField(name string) (ent.Value, bool) { 17977 switch name { 17978 case setting.FieldCreatedAt: 17979 return m.AddedCreatedAt() 17980 case setting.FieldUpdatedAt: 17981 return m.AddedUpdatedAt() 17982 case setting.FieldDeletedAt: 17983 return m.AddedDeletedAt() 17984 } 17985 return nil, false 17986 } 17987 17988 // AddField adds the value to the field with the given name. It returns an error if 17989 // the field is not defined in the schema, or if the type mismatched the field 17990 // type. 17991 func (m *SettingMutation) AddField(name string, value ent.Value) error { 17992 switch name { 17993 case setting.FieldCreatedAt: 17994 v, ok := value.(int32) 17995 if !ok { 17996 return fmt.Errorf("unexpected type %T for field %s", value, name) 17997 } 17998 m.AddCreatedAt(v) 17999 return nil 18000 case setting.FieldUpdatedAt: 18001 v, ok := value.(int32) 18002 if !ok { 18003 return fmt.Errorf("unexpected type %T for field %s", value, name) 18004 } 18005 m.AddUpdatedAt(v) 18006 return nil 18007 case setting.FieldDeletedAt: 18008 v, ok := value.(int32) 18009 if !ok { 18010 return fmt.Errorf("unexpected type %T for field %s", value, name) 18011 } 18012 m.AddDeletedAt(v) 18013 return nil 18014 } 18015 return fmt.Errorf("unknown Setting numeric field %s", name) 18016 } 18017 18018 // ClearedFields returns all nullable fields that were cleared during this 18019 // mutation. 18020 func (m *SettingMutation) ClearedFields() []string { 18021 var fields []string 18022 if m.FieldCleared(setting.FieldCoinTypeID) { 18023 fields = append(fields, setting.FieldCoinTypeID) 18024 } 18025 if m.FieldCleared(setting.FieldFeeCoinTypeID) { 18026 fields = append(fields, setting.FieldFeeCoinTypeID) 18027 } 18028 if m.FieldCleared(setting.FieldWithdrawFeeByStableUsd) { 18029 fields = append(fields, setting.FieldWithdrawFeeByStableUsd) 18030 } 18031 if m.FieldCleared(setting.FieldWithdrawFeeAmount) { 18032 fields = append(fields, setting.FieldWithdrawFeeAmount) 18033 } 18034 if m.FieldCleared(setting.FieldCollectFeeAmount) { 18035 fields = append(fields, setting.FieldCollectFeeAmount) 18036 } 18037 if m.FieldCleared(setting.FieldHotWalletFeeAmount) { 18038 fields = append(fields, setting.FieldHotWalletFeeAmount) 18039 } 18040 if m.FieldCleared(setting.FieldLowFeeAmount) { 18041 fields = append(fields, setting.FieldLowFeeAmount) 18042 } 18043 if m.FieldCleared(setting.FieldHotLowFeeAmount) { 18044 fields = append(fields, setting.FieldHotLowFeeAmount) 18045 } 18046 if m.FieldCleared(setting.FieldHotWalletAccountAmount) { 18047 fields = append(fields, setting.FieldHotWalletAccountAmount) 18048 } 18049 if m.FieldCleared(setting.FieldPaymentAccountCollectAmount) { 18050 fields = append(fields, setting.FieldPaymentAccountCollectAmount) 18051 } 18052 if m.FieldCleared(setting.FieldLeastTransferAmount) { 18053 fields = append(fields, setting.FieldLeastTransferAmount) 18054 } 18055 if m.FieldCleared(setting.FieldNeedMemo) { 18056 fields = append(fields, setting.FieldNeedMemo) 18057 } 18058 if m.FieldCleared(setting.FieldRefreshCurrency) { 18059 fields = append(fields, setting.FieldRefreshCurrency) 18060 } 18061 if m.FieldCleared(setting.FieldCheckNewAddressBalance) { 18062 fields = append(fields, setting.FieldCheckNewAddressBalance) 18063 } 18064 return fields 18065 } 18066 18067 // FieldCleared returns a boolean indicating if a field with the given name was 18068 // cleared in this mutation. 18069 func (m *SettingMutation) FieldCleared(name string) bool { 18070 _, ok := m.clearedFields[name] 18071 return ok 18072 } 18073 18074 // ClearField clears the value of the field with the given name. It returns an 18075 // error if the field is not defined in the schema. 18076 func (m *SettingMutation) ClearField(name string) error { 18077 switch name { 18078 case setting.FieldCoinTypeID: 18079 m.ClearCoinTypeID() 18080 return nil 18081 case setting.FieldFeeCoinTypeID: 18082 m.ClearFeeCoinTypeID() 18083 return nil 18084 case setting.FieldWithdrawFeeByStableUsd: 18085 m.ClearWithdrawFeeByStableUsd() 18086 return nil 18087 case setting.FieldWithdrawFeeAmount: 18088 m.ClearWithdrawFeeAmount() 18089 return nil 18090 case setting.FieldCollectFeeAmount: 18091 m.ClearCollectFeeAmount() 18092 return nil 18093 case setting.FieldHotWalletFeeAmount: 18094 m.ClearHotWalletFeeAmount() 18095 return nil 18096 case setting.FieldLowFeeAmount: 18097 m.ClearLowFeeAmount() 18098 return nil 18099 case setting.FieldHotLowFeeAmount: 18100 m.ClearHotLowFeeAmount() 18101 return nil 18102 case setting.FieldHotWalletAccountAmount: 18103 m.ClearHotWalletAccountAmount() 18104 return nil 18105 case setting.FieldPaymentAccountCollectAmount: 18106 m.ClearPaymentAccountCollectAmount() 18107 return nil 18108 case setting.FieldLeastTransferAmount: 18109 m.ClearLeastTransferAmount() 18110 return nil 18111 case setting.FieldNeedMemo: 18112 m.ClearNeedMemo() 18113 return nil 18114 case setting.FieldRefreshCurrency: 18115 m.ClearRefreshCurrency() 18116 return nil 18117 case setting.FieldCheckNewAddressBalance: 18118 m.ClearCheckNewAddressBalance() 18119 return nil 18120 } 18121 return fmt.Errorf("unknown Setting nullable field %s", name) 18122 } 18123 18124 // ResetField resets all changes in the mutation for the field with the given name. 18125 // It returns an error if the field is not defined in the schema. 18126 func (m *SettingMutation) ResetField(name string) error { 18127 switch name { 18128 case setting.FieldCreatedAt: 18129 m.ResetCreatedAt() 18130 return nil 18131 case setting.FieldUpdatedAt: 18132 m.ResetUpdatedAt() 18133 return nil 18134 case setting.FieldDeletedAt: 18135 m.ResetDeletedAt() 18136 return nil 18137 case setting.FieldEntID: 18138 m.ResetEntID() 18139 return nil 18140 case setting.FieldCoinTypeID: 18141 m.ResetCoinTypeID() 18142 return nil 18143 case setting.FieldFeeCoinTypeID: 18144 m.ResetFeeCoinTypeID() 18145 return nil 18146 case setting.FieldWithdrawFeeByStableUsd: 18147 m.ResetWithdrawFeeByStableUsd() 18148 return nil 18149 case setting.FieldWithdrawFeeAmount: 18150 m.ResetWithdrawFeeAmount() 18151 return nil 18152 case setting.FieldCollectFeeAmount: 18153 m.ResetCollectFeeAmount() 18154 return nil 18155 case setting.FieldHotWalletFeeAmount: 18156 m.ResetHotWalletFeeAmount() 18157 return nil 18158 case setting.FieldLowFeeAmount: 18159 m.ResetLowFeeAmount() 18160 return nil 18161 case setting.FieldHotLowFeeAmount: 18162 m.ResetHotLowFeeAmount() 18163 return nil 18164 case setting.FieldHotWalletAccountAmount: 18165 m.ResetHotWalletAccountAmount() 18166 return nil 18167 case setting.FieldPaymentAccountCollectAmount: 18168 m.ResetPaymentAccountCollectAmount() 18169 return nil 18170 case setting.FieldLeastTransferAmount: 18171 m.ResetLeastTransferAmount() 18172 return nil 18173 case setting.FieldNeedMemo: 18174 m.ResetNeedMemo() 18175 return nil 18176 case setting.FieldRefreshCurrency: 18177 m.ResetRefreshCurrency() 18178 return nil 18179 case setting.FieldCheckNewAddressBalance: 18180 m.ResetCheckNewAddressBalance() 18181 return nil 18182 } 18183 return fmt.Errorf("unknown Setting field %s", name) 18184 } 18185 18186 // AddedEdges returns all edge names that were set/added in this mutation. 18187 func (m *SettingMutation) AddedEdges() []string { 18188 edges := make([]string, 0, 0) 18189 return edges 18190 } 18191 18192 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 18193 // name in this mutation. 18194 func (m *SettingMutation) AddedIDs(name string) []ent.Value { 18195 return nil 18196 } 18197 18198 // RemovedEdges returns all edge names that were removed in this mutation. 18199 func (m *SettingMutation) RemovedEdges() []string { 18200 edges := make([]string, 0, 0) 18201 return edges 18202 } 18203 18204 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 18205 // the given name in this mutation. 18206 func (m *SettingMutation) RemovedIDs(name string) []ent.Value { 18207 return nil 18208 } 18209 18210 // ClearedEdges returns all edge names that were cleared in this mutation. 18211 func (m *SettingMutation) ClearedEdges() []string { 18212 edges := make([]string, 0, 0) 18213 return edges 18214 } 18215 18216 // EdgeCleared returns a boolean which indicates if the edge with the given name 18217 // was cleared in this mutation. 18218 func (m *SettingMutation) EdgeCleared(name string) bool { 18219 return false 18220 } 18221 18222 // ClearEdge clears the value of the edge with the given name. It returns an error 18223 // if that edge is not defined in the schema. 18224 func (m *SettingMutation) ClearEdge(name string) error { 18225 return fmt.Errorf("unknown Setting unique edge %s", name) 18226 } 18227 18228 // ResetEdge resets all changes to the edge with the given name in this mutation. 18229 // It returns an error if the edge is not defined in the schema. 18230 func (m *SettingMutation) ResetEdge(name string) error { 18231 return fmt.Errorf("unknown Setting edge %s", name) 18232 } 18233 18234 // TranMutation represents an operation that mutates the Tran nodes in the graph. 18235 type TranMutation struct { 18236 config 18237 op Op 18238 typ string 18239 id *uint32 18240 created_at *uint32 18241 addcreated_at *int32 18242 updated_at *uint32 18243 addupdated_at *int32 18244 deleted_at *uint32 18245 adddeleted_at *int32 18246 ent_id *uuid.UUID 18247 coin_type_id *uuid.UUID 18248 from_account_id *uuid.UUID 18249 to_account_id *uuid.UUID 18250 amount *decimal.Decimal 18251 fee_amount *decimal.Decimal 18252 chain_tx_id *string 18253 state *string 18254 extra *string 18255 _type *string 18256 clearedFields map[string]struct{} 18257 done bool 18258 oldValue func(context.Context) (*Tran, error) 18259 predicates []predicate.Tran 18260 } 18261 18262 var _ ent.Mutation = (*TranMutation)(nil) 18263 18264 // tranOption allows management of the mutation configuration using functional options. 18265 type tranOption func(*TranMutation) 18266 18267 // newTranMutation creates new mutation for the Tran entity. 18268 func newTranMutation(c config, op Op, opts ...tranOption) *TranMutation { 18269 m := &TranMutation{ 18270 config: c, 18271 op: op, 18272 typ: TypeTran, 18273 clearedFields: make(map[string]struct{}), 18274 } 18275 for _, opt := range opts { 18276 opt(m) 18277 } 18278 return m 18279 } 18280 18281 // withTranID sets the ID field of the mutation. 18282 func withTranID(id uint32) tranOption { 18283 return func(m *TranMutation) { 18284 var ( 18285 err error 18286 once sync.Once 18287 value *Tran 18288 ) 18289 m.oldValue = func(ctx context.Context) (*Tran, error) { 18290 once.Do(func() { 18291 if m.done { 18292 err = errors.New("querying old values post mutation is not allowed") 18293 } else { 18294 value, err = m.Client().Tran.Get(ctx, id) 18295 } 18296 }) 18297 return value, err 18298 } 18299 m.id = &id 18300 } 18301 } 18302 18303 // withTran sets the old Tran of the mutation. 18304 func withTran(node *Tran) tranOption { 18305 return func(m *TranMutation) { 18306 m.oldValue = func(context.Context) (*Tran, error) { 18307 return node, nil 18308 } 18309 m.id = &node.ID 18310 } 18311 } 18312 18313 // Client returns a new `ent.Client` from the mutation. If the mutation was 18314 // executed in a transaction (ent.Tx), a transactional client is returned. 18315 func (m TranMutation) Client() *Client { 18316 client := &Client{config: m.config} 18317 client.init() 18318 return client 18319 } 18320 18321 // Tx returns an `ent.Tx` for mutations that were executed in transactions; 18322 // it returns an error otherwise. 18323 func (m TranMutation) Tx() (*Tx, error) { 18324 if _, ok := m.driver.(*txDriver); !ok { 18325 return nil, errors.New("ent: mutation is not running in a transaction") 18326 } 18327 tx := &Tx{config: m.config} 18328 tx.init() 18329 return tx, nil 18330 } 18331 18332 // SetID sets the value of the id field. Note that this 18333 // operation is only accepted on creation of Tran entities. 18334 func (m *TranMutation) SetID(id uint32) { 18335 m.id = &id 18336 } 18337 18338 // ID returns the ID value in the mutation. Note that the ID is only available 18339 // if it was provided to the builder or after it was returned from the database. 18340 func (m *TranMutation) ID() (id uint32, exists bool) { 18341 if m.id == nil { 18342 return 18343 } 18344 return *m.id, true 18345 } 18346 18347 // IDs queries the database and returns the entity ids that match the mutation's predicate. 18348 // That means, if the mutation is applied within a transaction with an isolation level such 18349 // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated 18350 // or updated by the mutation. 18351 func (m *TranMutation) IDs(ctx context.Context) ([]uint32, error) { 18352 switch { 18353 case m.op.Is(OpUpdateOne | OpDeleteOne): 18354 id, exists := m.ID() 18355 if exists { 18356 return []uint32{id}, nil 18357 } 18358 fallthrough 18359 case m.op.Is(OpUpdate | OpDelete): 18360 return m.Client().Tran.Query().Where(m.predicates...).IDs(ctx) 18361 default: 18362 return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) 18363 } 18364 } 18365 18366 // SetCreatedAt sets the "created_at" field. 18367 func (m *TranMutation) SetCreatedAt(u uint32) { 18368 m.created_at = &u 18369 m.addcreated_at = nil 18370 } 18371 18372 // CreatedAt returns the value of the "created_at" field in the mutation. 18373 func (m *TranMutation) CreatedAt() (r uint32, exists bool) { 18374 v := m.created_at 18375 if v == nil { 18376 return 18377 } 18378 return *v, true 18379 } 18380 18381 // OldCreatedAt returns the old "created_at" field's value of the Tran entity. 18382 // If the Tran object wasn't provided to the builder, the object is fetched from the database. 18383 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 18384 func (m *TranMutation) OldCreatedAt(ctx context.Context) (v uint32, err error) { 18385 if !m.op.Is(OpUpdateOne) { 18386 return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") 18387 } 18388 if m.id == nil || m.oldValue == nil { 18389 return v, errors.New("OldCreatedAt requires an ID field in the mutation") 18390 } 18391 oldValue, err := m.oldValue(ctx) 18392 if err != nil { 18393 return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) 18394 } 18395 return oldValue.CreatedAt, nil 18396 } 18397 18398 // AddCreatedAt adds u to the "created_at" field. 18399 func (m *TranMutation) AddCreatedAt(u int32) { 18400 if m.addcreated_at != nil { 18401 *m.addcreated_at += u 18402 } else { 18403 m.addcreated_at = &u 18404 } 18405 } 18406 18407 // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation. 18408 func (m *TranMutation) AddedCreatedAt() (r int32, exists bool) { 18409 v := m.addcreated_at 18410 if v == nil { 18411 return 18412 } 18413 return *v, true 18414 } 18415 18416 // ResetCreatedAt resets all changes to the "created_at" field. 18417 func (m *TranMutation) ResetCreatedAt() { 18418 m.created_at = nil 18419 m.addcreated_at = nil 18420 } 18421 18422 // SetUpdatedAt sets the "updated_at" field. 18423 func (m *TranMutation) SetUpdatedAt(u uint32) { 18424 m.updated_at = &u 18425 m.addupdated_at = nil 18426 } 18427 18428 // UpdatedAt returns the value of the "updated_at" field in the mutation. 18429 func (m *TranMutation) UpdatedAt() (r uint32, exists bool) { 18430 v := m.updated_at 18431 if v == nil { 18432 return 18433 } 18434 return *v, true 18435 } 18436 18437 // OldUpdatedAt returns the old "updated_at" field's value of the Tran entity. 18438 // If the Tran object wasn't provided to the builder, the object is fetched from the database. 18439 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 18440 func (m *TranMutation) OldUpdatedAt(ctx context.Context) (v uint32, err error) { 18441 if !m.op.Is(OpUpdateOne) { 18442 return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") 18443 } 18444 if m.id == nil || m.oldValue == nil { 18445 return v, errors.New("OldUpdatedAt requires an ID field in the mutation") 18446 } 18447 oldValue, err := m.oldValue(ctx) 18448 if err != nil { 18449 return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) 18450 } 18451 return oldValue.UpdatedAt, nil 18452 } 18453 18454 // AddUpdatedAt adds u to the "updated_at" field. 18455 func (m *TranMutation) AddUpdatedAt(u int32) { 18456 if m.addupdated_at != nil { 18457 *m.addupdated_at += u 18458 } else { 18459 m.addupdated_at = &u 18460 } 18461 } 18462 18463 // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation. 18464 func (m *TranMutation) AddedUpdatedAt() (r int32, exists bool) { 18465 v := m.addupdated_at 18466 if v == nil { 18467 return 18468 } 18469 return *v, true 18470 } 18471 18472 // ResetUpdatedAt resets all changes to the "updated_at" field. 18473 func (m *TranMutation) ResetUpdatedAt() { 18474 m.updated_at = nil 18475 m.addupdated_at = nil 18476 } 18477 18478 // SetDeletedAt sets the "deleted_at" field. 18479 func (m *TranMutation) SetDeletedAt(u uint32) { 18480 m.deleted_at = &u 18481 m.adddeleted_at = nil 18482 } 18483 18484 // DeletedAt returns the value of the "deleted_at" field in the mutation. 18485 func (m *TranMutation) DeletedAt() (r uint32, exists bool) { 18486 v := m.deleted_at 18487 if v == nil { 18488 return 18489 } 18490 return *v, true 18491 } 18492 18493 // OldDeletedAt returns the old "deleted_at" field's value of the Tran entity. 18494 // If the Tran object wasn't provided to the builder, the object is fetched from the database. 18495 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 18496 func (m *TranMutation) OldDeletedAt(ctx context.Context) (v uint32, err error) { 18497 if !m.op.Is(OpUpdateOne) { 18498 return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") 18499 } 18500 if m.id == nil || m.oldValue == nil { 18501 return v, errors.New("OldDeletedAt requires an ID field in the mutation") 18502 } 18503 oldValue, err := m.oldValue(ctx) 18504 if err != nil { 18505 return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) 18506 } 18507 return oldValue.DeletedAt, nil 18508 } 18509 18510 // AddDeletedAt adds u to the "deleted_at" field. 18511 func (m *TranMutation) AddDeletedAt(u int32) { 18512 if m.adddeleted_at != nil { 18513 *m.adddeleted_at += u 18514 } else { 18515 m.adddeleted_at = &u 18516 } 18517 } 18518 18519 // AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. 18520 func (m *TranMutation) AddedDeletedAt() (r int32, exists bool) { 18521 v := m.adddeleted_at 18522 if v == nil { 18523 return 18524 } 18525 return *v, true 18526 } 18527 18528 // ResetDeletedAt resets all changes to the "deleted_at" field. 18529 func (m *TranMutation) ResetDeletedAt() { 18530 m.deleted_at = nil 18531 m.adddeleted_at = nil 18532 } 18533 18534 // SetEntID sets the "ent_id" field. 18535 func (m *TranMutation) SetEntID(u uuid.UUID) { 18536 m.ent_id = &u 18537 } 18538 18539 // EntID returns the value of the "ent_id" field in the mutation. 18540 func (m *TranMutation) EntID() (r uuid.UUID, exists bool) { 18541 v := m.ent_id 18542 if v == nil { 18543 return 18544 } 18545 return *v, true 18546 } 18547 18548 // OldEntID returns the old "ent_id" field's value of the Tran entity. 18549 // If the Tran object wasn't provided to the builder, the object is fetched from the database. 18550 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 18551 func (m *TranMutation) OldEntID(ctx context.Context) (v uuid.UUID, err error) { 18552 if !m.op.Is(OpUpdateOne) { 18553 return v, errors.New("OldEntID is only allowed on UpdateOne operations") 18554 } 18555 if m.id == nil || m.oldValue == nil { 18556 return v, errors.New("OldEntID requires an ID field in the mutation") 18557 } 18558 oldValue, err := m.oldValue(ctx) 18559 if err != nil { 18560 return v, fmt.Errorf("querying old value for OldEntID: %w", err) 18561 } 18562 return oldValue.EntID, nil 18563 } 18564 18565 // ResetEntID resets all changes to the "ent_id" field. 18566 func (m *TranMutation) ResetEntID() { 18567 m.ent_id = nil 18568 } 18569 18570 // SetCoinTypeID sets the "coin_type_id" field. 18571 func (m *TranMutation) SetCoinTypeID(u uuid.UUID) { 18572 m.coin_type_id = &u 18573 } 18574 18575 // CoinTypeID returns the value of the "coin_type_id" field in the mutation. 18576 func (m *TranMutation) CoinTypeID() (r uuid.UUID, exists bool) { 18577 v := m.coin_type_id 18578 if v == nil { 18579 return 18580 } 18581 return *v, true 18582 } 18583 18584 // OldCoinTypeID returns the old "coin_type_id" field's value of the Tran entity. 18585 // If the Tran object wasn't provided to the builder, the object is fetched from the database. 18586 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 18587 func (m *TranMutation) OldCoinTypeID(ctx context.Context) (v uuid.UUID, err error) { 18588 if !m.op.Is(OpUpdateOne) { 18589 return v, errors.New("OldCoinTypeID is only allowed on UpdateOne operations") 18590 } 18591 if m.id == nil || m.oldValue == nil { 18592 return v, errors.New("OldCoinTypeID requires an ID field in the mutation") 18593 } 18594 oldValue, err := m.oldValue(ctx) 18595 if err != nil { 18596 return v, fmt.Errorf("querying old value for OldCoinTypeID: %w", err) 18597 } 18598 return oldValue.CoinTypeID, nil 18599 } 18600 18601 // ClearCoinTypeID clears the value of the "coin_type_id" field. 18602 func (m *TranMutation) ClearCoinTypeID() { 18603 m.coin_type_id = nil 18604 m.clearedFields[tran.FieldCoinTypeID] = struct{}{} 18605 } 18606 18607 // CoinTypeIDCleared returns if the "coin_type_id" field was cleared in this mutation. 18608 func (m *TranMutation) CoinTypeIDCleared() bool { 18609 _, ok := m.clearedFields[tran.FieldCoinTypeID] 18610 return ok 18611 } 18612 18613 // ResetCoinTypeID resets all changes to the "coin_type_id" field. 18614 func (m *TranMutation) ResetCoinTypeID() { 18615 m.coin_type_id = nil 18616 delete(m.clearedFields, tran.FieldCoinTypeID) 18617 } 18618 18619 // SetFromAccountID sets the "from_account_id" field. 18620 func (m *TranMutation) SetFromAccountID(u uuid.UUID) { 18621 m.from_account_id = &u 18622 } 18623 18624 // FromAccountID returns the value of the "from_account_id" field in the mutation. 18625 func (m *TranMutation) FromAccountID() (r uuid.UUID, exists bool) { 18626 v := m.from_account_id 18627 if v == nil { 18628 return 18629 } 18630 return *v, true 18631 } 18632 18633 // OldFromAccountID returns the old "from_account_id" field's value of the Tran entity. 18634 // If the Tran object wasn't provided to the builder, the object is fetched from the database. 18635 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 18636 func (m *TranMutation) OldFromAccountID(ctx context.Context) (v uuid.UUID, err error) { 18637 if !m.op.Is(OpUpdateOne) { 18638 return v, errors.New("OldFromAccountID is only allowed on UpdateOne operations") 18639 } 18640 if m.id == nil || m.oldValue == nil { 18641 return v, errors.New("OldFromAccountID requires an ID field in the mutation") 18642 } 18643 oldValue, err := m.oldValue(ctx) 18644 if err != nil { 18645 return v, fmt.Errorf("querying old value for OldFromAccountID: %w", err) 18646 } 18647 return oldValue.FromAccountID, nil 18648 } 18649 18650 // ClearFromAccountID clears the value of the "from_account_id" field. 18651 func (m *TranMutation) ClearFromAccountID() { 18652 m.from_account_id = nil 18653 m.clearedFields[tran.FieldFromAccountID] = struct{}{} 18654 } 18655 18656 // FromAccountIDCleared returns if the "from_account_id" field was cleared in this mutation. 18657 func (m *TranMutation) FromAccountIDCleared() bool { 18658 _, ok := m.clearedFields[tran.FieldFromAccountID] 18659 return ok 18660 } 18661 18662 // ResetFromAccountID resets all changes to the "from_account_id" field. 18663 func (m *TranMutation) ResetFromAccountID() { 18664 m.from_account_id = nil 18665 delete(m.clearedFields, tran.FieldFromAccountID) 18666 } 18667 18668 // SetToAccountID sets the "to_account_id" field. 18669 func (m *TranMutation) SetToAccountID(u uuid.UUID) { 18670 m.to_account_id = &u 18671 } 18672 18673 // ToAccountID returns the value of the "to_account_id" field in the mutation. 18674 func (m *TranMutation) ToAccountID() (r uuid.UUID, exists bool) { 18675 v := m.to_account_id 18676 if v == nil { 18677 return 18678 } 18679 return *v, true 18680 } 18681 18682 // OldToAccountID returns the old "to_account_id" field's value of the Tran entity. 18683 // If the Tran object wasn't provided to the builder, the object is fetched from the database. 18684 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 18685 func (m *TranMutation) OldToAccountID(ctx context.Context) (v uuid.UUID, err error) { 18686 if !m.op.Is(OpUpdateOne) { 18687 return v, errors.New("OldToAccountID is only allowed on UpdateOne operations") 18688 } 18689 if m.id == nil || m.oldValue == nil { 18690 return v, errors.New("OldToAccountID requires an ID field in the mutation") 18691 } 18692 oldValue, err := m.oldValue(ctx) 18693 if err != nil { 18694 return v, fmt.Errorf("querying old value for OldToAccountID: %w", err) 18695 } 18696 return oldValue.ToAccountID, nil 18697 } 18698 18699 // ClearToAccountID clears the value of the "to_account_id" field. 18700 func (m *TranMutation) ClearToAccountID() { 18701 m.to_account_id = nil 18702 m.clearedFields[tran.FieldToAccountID] = struct{}{} 18703 } 18704 18705 // ToAccountIDCleared returns if the "to_account_id" field was cleared in this mutation. 18706 func (m *TranMutation) ToAccountIDCleared() bool { 18707 _, ok := m.clearedFields[tran.FieldToAccountID] 18708 return ok 18709 } 18710 18711 // ResetToAccountID resets all changes to the "to_account_id" field. 18712 func (m *TranMutation) ResetToAccountID() { 18713 m.to_account_id = nil 18714 delete(m.clearedFields, tran.FieldToAccountID) 18715 } 18716 18717 // SetAmount sets the "amount" field. 18718 func (m *TranMutation) SetAmount(d decimal.Decimal) { 18719 m.amount = &d 18720 } 18721 18722 // Amount returns the value of the "amount" field in the mutation. 18723 func (m *TranMutation) Amount() (r decimal.Decimal, exists bool) { 18724 v := m.amount 18725 if v == nil { 18726 return 18727 } 18728 return *v, true 18729 } 18730 18731 // OldAmount returns the old "amount" field's value of the Tran entity. 18732 // If the Tran object wasn't provided to the builder, the object is fetched from the database. 18733 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 18734 func (m *TranMutation) OldAmount(ctx context.Context) (v decimal.Decimal, err error) { 18735 if !m.op.Is(OpUpdateOne) { 18736 return v, errors.New("OldAmount is only allowed on UpdateOne operations") 18737 } 18738 if m.id == nil || m.oldValue == nil { 18739 return v, errors.New("OldAmount requires an ID field in the mutation") 18740 } 18741 oldValue, err := m.oldValue(ctx) 18742 if err != nil { 18743 return v, fmt.Errorf("querying old value for OldAmount: %w", err) 18744 } 18745 return oldValue.Amount, nil 18746 } 18747 18748 // ClearAmount clears the value of the "amount" field. 18749 func (m *TranMutation) ClearAmount() { 18750 m.amount = nil 18751 m.clearedFields[tran.FieldAmount] = struct{}{} 18752 } 18753 18754 // AmountCleared returns if the "amount" field was cleared in this mutation. 18755 func (m *TranMutation) AmountCleared() bool { 18756 _, ok := m.clearedFields[tran.FieldAmount] 18757 return ok 18758 } 18759 18760 // ResetAmount resets all changes to the "amount" field. 18761 func (m *TranMutation) ResetAmount() { 18762 m.amount = nil 18763 delete(m.clearedFields, tran.FieldAmount) 18764 } 18765 18766 // SetFeeAmount sets the "fee_amount" field. 18767 func (m *TranMutation) SetFeeAmount(d decimal.Decimal) { 18768 m.fee_amount = &d 18769 } 18770 18771 // FeeAmount returns the value of the "fee_amount" field in the mutation. 18772 func (m *TranMutation) FeeAmount() (r decimal.Decimal, exists bool) { 18773 v := m.fee_amount 18774 if v == nil { 18775 return 18776 } 18777 return *v, true 18778 } 18779 18780 // OldFeeAmount returns the old "fee_amount" field's value of the Tran entity. 18781 // If the Tran object wasn't provided to the builder, the object is fetched from the database. 18782 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 18783 func (m *TranMutation) OldFeeAmount(ctx context.Context) (v decimal.Decimal, err error) { 18784 if !m.op.Is(OpUpdateOne) { 18785 return v, errors.New("OldFeeAmount is only allowed on UpdateOne operations") 18786 } 18787 if m.id == nil || m.oldValue == nil { 18788 return v, errors.New("OldFeeAmount requires an ID field in the mutation") 18789 } 18790 oldValue, err := m.oldValue(ctx) 18791 if err != nil { 18792 return v, fmt.Errorf("querying old value for OldFeeAmount: %w", err) 18793 } 18794 return oldValue.FeeAmount, nil 18795 } 18796 18797 // ClearFeeAmount clears the value of the "fee_amount" field. 18798 func (m *TranMutation) ClearFeeAmount() { 18799 m.fee_amount = nil 18800 m.clearedFields[tran.FieldFeeAmount] = struct{}{} 18801 } 18802 18803 // FeeAmountCleared returns if the "fee_amount" field was cleared in this mutation. 18804 func (m *TranMutation) FeeAmountCleared() bool { 18805 _, ok := m.clearedFields[tran.FieldFeeAmount] 18806 return ok 18807 } 18808 18809 // ResetFeeAmount resets all changes to the "fee_amount" field. 18810 func (m *TranMutation) ResetFeeAmount() { 18811 m.fee_amount = nil 18812 delete(m.clearedFields, tran.FieldFeeAmount) 18813 } 18814 18815 // SetChainTxID sets the "chain_tx_id" field. 18816 func (m *TranMutation) SetChainTxID(s string) { 18817 m.chain_tx_id = &s 18818 } 18819 18820 // ChainTxID returns the value of the "chain_tx_id" field in the mutation. 18821 func (m *TranMutation) ChainTxID() (r string, exists bool) { 18822 v := m.chain_tx_id 18823 if v == nil { 18824 return 18825 } 18826 return *v, true 18827 } 18828 18829 // OldChainTxID returns the old "chain_tx_id" field's value of the Tran entity. 18830 // If the Tran object wasn't provided to the builder, the object is fetched from the database. 18831 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 18832 func (m *TranMutation) OldChainTxID(ctx context.Context) (v string, err error) { 18833 if !m.op.Is(OpUpdateOne) { 18834 return v, errors.New("OldChainTxID is only allowed on UpdateOne operations") 18835 } 18836 if m.id == nil || m.oldValue == nil { 18837 return v, errors.New("OldChainTxID requires an ID field in the mutation") 18838 } 18839 oldValue, err := m.oldValue(ctx) 18840 if err != nil { 18841 return v, fmt.Errorf("querying old value for OldChainTxID: %w", err) 18842 } 18843 return oldValue.ChainTxID, nil 18844 } 18845 18846 // ClearChainTxID clears the value of the "chain_tx_id" field. 18847 func (m *TranMutation) ClearChainTxID() { 18848 m.chain_tx_id = nil 18849 m.clearedFields[tran.FieldChainTxID] = struct{}{} 18850 } 18851 18852 // ChainTxIDCleared returns if the "chain_tx_id" field was cleared in this mutation. 18853 func (m *TranMutation) ChainTxIDCleared() bool { 18854 _, ok := m.clearedFields[tran.FieldChainTxID] 18855 return ok 18856 } 18857 18858 // ResetChainTxID resets all changes to the "chain_tx_id" field. 18859 func (m *TranMutation) ResetChainTxID() { 18860 m.chain_tx_id = nil 18861 delete(m.clearedFields, tran.FieldChainTxID) 18862 } 18863 18864 // SetState sets the "state" field. 18865 func (m *TranMutation) SetState(s string) { 18866 m.state = &s 18867 } 18868 18869 // State returns the value of the "state" field in the mutation. 18870 func (m *TranMutation) State() (r string, exists bool) { 18871 v := m.state 18872 if v == nil { 18873 return 18874 } 18875 return *v, true 18876 } 18877 18878 // OldState returns the old "state" field's value of the Tran entity. 18879 // If the Tran object wasn't provided to the builder, the object is fetched from the database. 18880 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 18881 func (m *TranMutation) OldState(ctx context.Context) (v string, err error) { 18882 if !m.op.Is(OpUpdateOne) { 18883 return v, errors.New("OldState is only allowed on UpdateOne operations") 18884 } 18885 if m.id == nil || m.oldValue == nil { 18886 return v, errors.New("OldState requires an ID field in the mutation") 18887 } 18888 oldValue, err := m.oldValue(ctx) 18889 if err != nil { 18890 return v, fmt.Errorf("querying old value for OldState: %w", err) 18891 } 18892 return oldValue.State, nil 18893 } 18894 18895 // ClearState clears the value of the "state" field. 18896 func (m *TranMutation) ClearState() { 18897 m.state = nil 18898 m.clearedFields[tran.FieldState] = struct{}{} 18899 } 18900 18901 // StateCleared returns if the "state" field was cleared in this mutation. 18902 func (m *TranMutation) StateCleared() bool { 18903 _, ok := m.clearedFields[tran.FieldState] 18904 return ok 18905 } 18906 18907 // ResetState resets all changes to the "state" field. 18908 func (m *TranMutation) ResetState() { 18909 m.state = nil 18910 delete(m.clearedFields, tran.FieldState) 18911 } 18912 18913 // SetExtra sets the "extra" field. 18914 func (m *TranMutation) SetExtra(s string) { 18915 m.extra = &s 18916 } 18917 18918 // Extra returns the value of the "extra" field in the mutation. 18919 func (m *TranMutation) Extra() (r string, exists bool) { 18920 v := m.extra 18921 if v == nil { 18922 return 18923 } 18924 return *v, true 18925 } 18926 18927 // OldExtra returns the old "extra" field's value of the Tran entity. 18928 // If the Tran object wasn't provided to the builder, the object is fetched from the database. 18929 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 18930 func (m *TranMutation) OldExtra(ctx context.Context) (v string, err error) { 18931 if !m.op.Is(OpUpdateOne) { 18932 return v, errors.New("OldExtra is only allowed on UpdateOne operations") 18933 } 18934 if m.id == nil || m.oldValue == nil { 18935 return v, errors.New("OldExtra requires an ID field in the mutation") 18936 } 18937 oldValue, err := m.oldValue(ctx) 18938 if err != nil { 18939 return v, fmt.Errorf("querying old value for OldExtra: %w", err) 18940 } 18941 return oldValue.Extra, nil 18942 } 18943 18944 // ClearExtra clears the value of the "extra" field. 18945 func (m *TranMutation) ClearExtra() { 18946 m.extra = nil 18947 m.clearedFields[tran.FieldExtra] = struct{}{} 18948 } 18949 18950 // ExtraCleared returns if the "extra" field was cleared in this mutation. 18951 func (m *TranMutation) ExtraCleared() bool { 18952 _, ok := m.clearedFields[tran.FieldExtra] 18953 return ok 18954 } 18955 18956 // ResetExtra resets all changes to the "extra" field. 18957 func (m *TranMutation) ResetExtra() { 18958 m.extra = nil 18959 delete(m.clearedFields, tran.FieldExtra) 18960 } 18961 18962 // SetType sets the "type" field. 18963 func (m *TranMutation) SetType(s string) { 18964 m._type = &s 18965 } 18966 18967 // GetType returns the value of the "type" field in the mutation. 18968 func (m *TranMutation) GetType() (r string, exists bool) { 18969 v := m._type 18970 if v == nil { 18971 return 18972 } 18973 return *v, true 18974 } 18975 18976 // OldType returns the old "type" field's value of the Tran entity. 18977 // If the Tran object wasn't provided to the builder, the object is fetched from the database. 18978 // An error is returned if the mutation operation is not UpdateOne, or the database query fails. 18979 func (m *TranMutation) OldType(ctx context.Context) (v string, err error) { 18980 if !m.op.Is(OpUpdateOne) { 18981 return v, errors.New("OldType is only allowed on UpdateOne operations") 18982 } 18983 if m.id == nil || m.oldValue == nil { 18984 return v, errors.New("OldType requires an ID field in the mutation") 18985 } 18986 oldValue, err := m.oldValue(ctx) 18987 if err != nil { 18988 return v, fmt.Errorf("querying old value for OldType: %w", err) 18989 } 18990 return oldValue.Type, nil 18991 } 18992 18993 // ClearType clears the value of the "type" field. 18994 func (m *TranMutation) ClearType() { 18995 m._type = nil 18996 m.clearedFields[tran.FieldType] = struct{}{} 18997 } 18998 18999 // TypeCleared returns if the "type" field was cleared in this mutation. 19000 func (m *TranMutation) TypeCleared() bool { 19001 _, ok := m.clearedFields[tran.FieldType] 19002 return ok 19003 } 19004 19005 // ResetType resets all changes to the "type" field. 19006 func (m *TranMutation) ResetType() { 19007 m._type = nil 19008 delete(m.clearedFields, tran.FieldType) 19009 } 19010 19011 // Where appends a list predicates to the TranMutation builder. 19012 func (m *TranMutation) Where(ps ...predicate.Tran) { 19013 m.predicates = append(m.predicates, ps...) 19014 } 19015 19016 // Op returns the operation name. 19017 func (m *TranMutation) Op() Op { 19018 return m.op 19019 } 19020 19021 // Type returns the node type of this mutation (Tran). 19022 func (m *TranMutation) Type() string { 19023 return m.typ 19024 } 19025 19026 // Fields returns all fields that were changed during this mutation. Note that in 19027 // order to get all numeric fields that were incremented/decremented, call 19028 // AddedFields(). 19029 func (m *TranMutation) Fields() []string { 19030 fields := make([]string, 0, 13) 19031 if m.created_at != nil { 19032 fields = append(fields, tran.FieldCreatedAt) 19033 } 19034 if m.updated_at != nil { 19035 fields = append(fields, tran.FieldUpdatedAt) 19036 } 19037 if m.deleted_at != nil { 19038 fields = append(fields, tran.FieldDeletedAt) 19039 } 19040 if m.ent_id != nil { 19041 fields = append(fields, tran.FieldEntID) 19042 } 19043 if m.coin_type_id != nil { 19044 fields = append(fields, tran.FieldCoinTypeID) 19045 } 19046 if m.from_account_id != nil { 19047 fields = append(fields, tran.FieldFromAccountID) 19048 } 19049 if m.to_account_id != nil { 19050 fields = append(fields, tran.FieldToAccountID) 19051 } 19052 if m.amount != nil { 19053 fields = append(fields, tran.FieldAmount) 19054 } 19055 if m.fee_amount != nil { 19056 fields = append(fields, tran.FieldFeeAmount) 19057 } 19058 if m.chain_tx_id != nil { 19059 fields = append(fields, tran.FieldChainTxID) 19060 } 19061 if m.state != nil { 19062 fields = append(fields, tran.FieldState) 19063 } 19064 if m.extra != nil { 19065 fields = append(fields, tran.FieldExtra) 19066 } 19067 if m._type != nil { 19068 fields = append(fields, tran.FieldType) 19069 } 19070 return fields 19071 } 19072 19073 // Field returns the value of a field with the given name. The second boolean 19074 // return value indicates that this field was not set, or was not defined in the 19075 // schema. 19076 func (m *TranMutation) Field(name string) (ent.Value, bool) { 19077 switch name { 19078 case tran.FieldCreatedAt: 19079 return m.CreatedAt() 19080 case tran.FieldUpdatedAt: 19081 return m.UpdatedAt() 19082 case tran.FieldDeletedAt: 19083 return m.DeletedAt() 19084 case tran.FieldEntID: 19085 return m.EntID() 19086 case tran.FieldCoinTypeID: 19087 return m.CoinTypeID() 19088 case tran.FieldFromAccountID: 19089 return m.FromAccountID() 19090 case tran.FieldToAccountID: 19091 return m.ToAccountID() 19092 case tran.FieldAmount: 19093 return m.Amount() 19094 case tran.FieldFeeAmount: 19095 return m.FeeAmount() 19096 case tran.FieldChainTxID: 19097 return m.ChainTxID() 19098 case tran.FieldState: 19099 return m.State() 19100 case tran.FieldExtra: 19101 return m.Extra() 19102 case tran.FieldType: 19103 return m.GetType() 19104 } 19105 return nil, false 19106 } 19107 19108 // OldField returns the old value of the field from the database. An error is 19109 // returned if the mutation operation is not UpdateOne, or the query to the 19110 // database failed. 19111 func (m *TranMutation) OldField(ctx context.Context, name string) (ent.Value, error) { 19112 switch name { 19113 case tran.FieldCreatedAt: 19114 return m.OldCreatedAt(ctx) 19115 case tran.FieldUpdatedAt: 19116 return m.OldUpdatedAt(ctx) 19117 case tran.FieldDeletedAt: 19118 return m.OldDeletedAt(ctx) 19119 case tran.FieldEntID: 19120 return m.OldEntID(ctx) 19121 case tran.FieldCoinTypeID: 19122 return m.OldCoinTypeID(ctx) 19123 case tran.FieldFromAccountID: 19124 return m.OldFromAccountID(ctx) 19125 case tran.FieldToAccountID: 19126 return m.OldToAccountID(ctx) 19127 case tran.FieldAmount: 19128 return m.OldAmount(ctx) 19129 case tran.FieldFeeAmount: 19130 return m.OldFeeAmount(ctx) 19131 case tran.FieldChainTxID: 19132 return m.OldChainTxID(ctx) 19133 case tran.FieldState: 19134 return m.OldState(ctx) 19135 case tran.FieldExtra: 19136 return m.OldExtra(ctx) 19137 case tran.FieldType: 19138 return m.OldType(ctx) 19139 } 19140 return nil, fmt.Errorf("unknown Tran field %s", name) 19141 } 19142 19143 // SetField sets the value of a field with the given name. It returns an error if 19144 // the field is not defined in the schema, or if the type mismatched the field 19145 // type. 19146 func (m *TranMutation) SetField(name string, value ent.Value) error { 19147 switch name { 19148 case tran.FieldCreatedAt: 19149 v, ok := value.(uint32) 19150 if !ok { 19151 return fmt.Errorf("unexpected type %T for field %s", value, name) 19152 } 19153 m.SetCreatedAt(v) 19154 return nil 19155 case tran.FieldUpdatedAt: 19156 v, ok := value.(uint32) 19157 if !ok { 19158 return fmt.Errorf("unexpected type %T for field %s", value, name) 19159 } 19160 m.SetUpdatedAt(v) 19161 return nil 19162 case tran.FieldDeletedAt: 19163 v, ok := value.(uint32) 19164 if !ok { 19165 return fmt.Errorf("unexpected type %T for field %s", value, name) 19166 } 19167 m.SetDeletedAt(v) 19168 return nil 19169 case tran.FieldEntID: 19170 v, ok := value.(uuid.UUID) 19171 if !ok { 19172 return fmt.Errorf("unexpected type %T for field %s", value, name) 19173 } 19174 m.SetEntID(v) 19175 return nil 19176 case tran.FieldCoinTypeID: 19177 v, ok := value.(uuid.UUID) 19178 if !ok { 19179 return fmt.Errorf("unexpected type %T for field %s", value, name) 19180 } 19181 m.SetCoinTypeID(v) 19182 return nil 19183 case tran.FieldFromAccountID: 19184 v, ok := value.(uuid.UUID) 19185 if !ok { 19186 return fmt.Errorf("unexpected type %T for field %s", value, name) 19187 } 19188 m.SetFromAccountID(v) 19189 return nil 19190 case tran.FieldToAccountID: 19191 v, ok := value.(uuid.UUID) 19192 if !ok { 19193 return fmt.Errorf("unexpected type %T for field %s", value, name) 19194 } 19195 m.SetToAccountID(v) 19196 return nil 19197 case tran.FieldAmount: 19198 v, ok := value.(decimal.Decimal) 19199 if !ok { 19200 return fmt.Errorf("unexpected type %T for field %s", value, name) 19201 } 19202 m.SetAmount(v) 19203 return nil 19204 case tran.FieldFeeAmount: 19205 v, ok := value.(decimal.Decimal) 19206 if !ok { 19207 return fmt.Errorf("unexpected type %T for field %s", value, name) 19208 } 19209 m.SetFeeAmount(v) 19210 return nil 19211 case tran.FieldChainTxID: 19212 v, ok := value.(string) 19213 if !ok { 19214 return fmt.Errorf("unexpected type %T for field %s", value, name) 19215 } 19216 m.SetChainTxID(v) 19217 return nil 19218 case tran.FieldState: 19219 v, ok := value.(string) 19220 if !ok { 19221 return fmt.Errorf("unexpected type %T for field %s", value, name) 19222 } 19223 m.SetState(v) 19224 return nil 19225 case tran.FieldExtra: 19226 v, ok := value.(string) 19227 if !ok { 19228 return fmt.Errorf("unexpected type %T for field %s", value, name) 19229 } 19230 m.SetExtra(v) 19231 return nil 19232 case tran.FieldType: 19233 v, ok := value.(string) 19234 if !ok { 19235 return fmt.Errorf("unexpected type %T for field %s", value, name) 19236 } 19237 m.SetType(v) 19238 return nil 19239 } 19240 return fmt.Errorf("unknown Tran field %s", name) 19241 } 19242 19243 // AddedFields returns all numeric fields that were incremented/decremented during 19244 // this mutation. 19245 func (m *TranMutation) AddedFields() []string { 19246 var fields []string 19247 if m.addcreated_at != nil { 19248 fields = append(fields, tran.FieldCreatedAt) 19249 } 19250 if m.addupdated_at != nil { 19251 fields = append(fields, tran.FieldUpdatedAt) 19252 } 19253 if m.adddeleted_at != nil { 19254 fields = append(fields, tran.FieldDeletedAt) 19255 } 19256 return fields 19257 } 19258 19259 // AddedField returns the numeric value that was incremented/decremented on a field 19260 // with the given name. The second boolean return value indicates that this field 19261 // was not set, or was not defined in the schema. 19262 func (m *TranMutation) AddedField(name string) (ent.Value, bool) { 19263 switch name { 19264 case tran.FieldCreatedAt: 19265 return m.AddedCreatedAt() 19266 case tran.FieldUpdatedAt: 19267 return m.AddedUpdatedAt() 19268 case tran.FieldDeletedAt: 19269 return m.AddedDeletedAt() 19270 } 19271 return nil, false 19272 } 19273 19274 // AddField adds the value to the field with the given name. It returns an error if 19275 // the field is not defined in the schema, or if the type mismatched the field 19276 // type. 19277 func (m *TranMutation) AddField(name string, value ent.Value) error { 19278 switch name { 19279 case tran.FieldCreatedAt: 19280 v, ok := value.(int32) 19281 if !ok { 19282 return fmt.Errorf("unexpected type %T for field %s", value, name) 19283 } 19284 m.AddCreatedAt(v) 19285 return nil 19286 case tran.FieldUpdatedAt: 19287 v, ok := value.(int32) 19288 if !ok { 19289 return fmt.Errorf("unexpected type %T for field %s", value, name) 19290 } 19291 m.AddUpdatedAt(v) 19292 return nil 19293 case tran.FieldDeletedAt: 19294 v, ok := value.(int32) 19295 if !ok { 19296 return fmt.Errorf("unexpected type %T for field %s", value, name) 19297 } 19298 m.AddDeletedAt(v) 19299 return nil 19300 } 19301 return fmt.Errorf("unknown Tran numeric field %s", name) 19302 } 19303 19304 // ClearedFields returns all nullable fields that were cleared during this 19305 // mutation. 19306 func (m *TranMutation) ClearedFields() []string { 19307 var fields []string 19308 if m.FieldCleared(tran.FieldCoinTypeID) { 19309 fields = append(fields, tran.FieldCoinTypeID) 19310 } 19311 if m.FieldCleared(tran.FieldFromAccountID) { 19312 fields = append(fields, tran.FieldFromAccountID) 19313 } 19314 if m.FieldCleared(tran.FieldToAccountID) { 19315 fields = append(fields, tran.FieldToAccountID) 19316 } 19317 if m.FieldCleared(tran.FieldAmount) { 19318 fields = append(fields, tran.FieldAmount) 19319 } 19320 if m.FieldCleared(tran.FieldFeeAmount) { 19321 fields = append(fields, tran.FieldFeeAmount) 19322 } 19323 if m.FieldCleared(tran.FieldChainTxID) { 19324 fields = append(fields, tran.FieldChainTxID) 19325 } 19326 if m.FieldCleared(tran.FieldState) { 19327 fields = append(fields, tran.FieldState) 19328 } 19329 if m.FieldCleared(tran.FieldExtra) { 19330 fields = append(fields, tran.FieldExtra) 19331 } 19332 if m.FieldCleared(tran.FieldType) { 19333 fields = append(fields, tran.FieldType) 19334 } 19335 return fields 19336 } 19337 19338 // FieldCleared returns a boolean indicating if a field with the given name was 19339 // cleared in this mutation. 19340 func (m *TranMutation) FieldCleared(name string) bool { 19341 _, ok := m.clearedFields[name] 19342 return ok 19343 } 19344 19345 // ClearField clears the value of the field with the given name. It returns an 19346 // error if the field is not defined in the schema. 19347 func (m *TranMutation) ClearField(name string) error { 19348 switch name { 19349 case tran.FieldCoinTypeID: 19350 m.ClearCoinTypeID() 19351 return nil 19352 case tran.FieldFromAccountID: 19353 m.ClearFromAccountID() 19354 return nil 19355 case tran.FieldToAccountID: 19356 m.ClearToAccountID() 19357 return nil 19358 case tran.FieldAmount: 19359 m.ClearAmount() 19360 return nil 19361 case tran.FieldFeeAmount: 19362 m.ClearFeeAmount() 19363 return nil 19364 case tran.FieldChainTxID: 19365 m.ClearChainTxID() 19366 return nil 19367 case tran.FieldState: 19368 m.ClearState() 19369 return nil 19370 case tran.FieldExtra: 19371 m.ClearExtra() 19372 return nil 19373 case tran.FieldType: 19374 m.ClearType() 19375 return nil 19376 } 19377 return fmt.Errorf("unknown Tran nullable field %s", name) 19378 } 19379 19380 // ResetField resets all changes in the mutation for the field with the given name. 19381 // It returns an error if the field is not defined in the schema. 19382 func (m *TranMutation) ResetField(name string) error { 19383 switch name { 19384 case tran.FieldCreatedAt: 19385 m.ResetCreatedAt() 19386 return nil 19387 case tran.FieldUpdatedAt: 19388 m.ResetUpdatedAt() 19389 return nil 19390 case tran.FieldDeletedAt: 19391 m.ResetDeletedAt() 19392 return nil 19393 case tran.FieldEntID: 19394 m.ResetEntID() 19395 return nil 19396 case tran.FieldCoinTypeID: 19397 m.ResetCoinTypeID() 19398 return nil 19399 case tran.FieldFromAccountID: 19400 m.ResetFromAccountID() 19401 return nil 19402 case tran.FieldToAccountID: 19403 m.ResetToAccountID() 19404 return nil 19405 case tran.FieldAmount: 19406 m.ResetAmount() 19407 return nil 19408 case tran.FieldFeeAmount: 19409 m.ResetFeeAmount() 19410 return nil 19411 case tran.FieldChainTxID: 19412 m.ResetChainTxID() 19413 return nil 19414 case tran.FieldState: 19415 m.ResetState() 19416 return nil 19417 case tran.FieldExtra: 19418 m.ResetExtra() 19419 return nil 19420 case tran.FieldType: 19421 m.ResetType() 19422 return nil 19423 } 19424 return fmt.Errorf("unknown Tran field %s", name) 19425 } 19426 19427 // AddedEdges returns all edge names that were set/added in this mutation. 19428 func (m *TranMutation) AddedEdges() []string { 19429 edges := make([]string, 0, 0) 19430 return edges 19431 } 19432 19433 // AddedIDs returns all IDs (to other nodes) that were added for the given edge 19434 // name in this mutation. 19435 func (m *TranMutation) AddedIDs(name string) []ent.Value { 19436 return nil 19437 } 19438 19439 // RemovedEdges returns all edge names that were removed in this mutation. 19440 func (m *TranMutation) RemovedEdges() []string { 19441 edges := make([]string, 0, 0) 19442 return edges 19443 } 19444 19445 // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with 19446 // the given name in this mutation. 19447 func (m *TranMutation) RemovedIDs(name string) []ent.Value { 19448 return nil 19449 } 19450 19451 // ClearedEdges returns all edge names that were cleared in this mutation. 19452 func (m *TranMutation) ClearedEdges() []string { 19453 edges := make([]string, 0, 0) 19454 return edges 19455 } 19456 19457 // EdgeCleared returns a boolean which indicates if the edge with the given name 19458 // was cleared in this mutation. 19459 func (m *TranMutation) EdgeCleared(name string) bool { 19460 return false 19461 } 19462 19463 // ClearEdge clears the value of the edge with the given name. It returns an error 19464 // if that edge is not defined in the schema. 19465 func (m *TranMutation) ClearEdge(name string) error { 19466 return fmt.Errorf("unknown Tran unique edge %s", name) 19467 } 19468 19469 // ResetEdge resets all changes to the edge with the given name in this mutation. 19470 // It returns an error if the edge is not defined in the schema. 19471 func (m *TranMutation) ResetEdge(name string) error { 19472 return fmt.Errorf("unknown Tran edge %s", name) 19473 }