github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/fiatcurrencyhistory.go (about)

     1  // Code generated by ent, DO NOT EDIT.
     2  
     3  package ent
     4  
     5  import (
     6  	"fmt"
     7  	"strings"
     8  
     9  	"entgo.io/ent/dialect/sql"
    10  	"github.com/NpoolPlatform/chain-middleware/pkg/db/ent/fiatcurrencyhistory"
    11  	"github.com/google/uuid"
    12  	"github.com/shopspring/decimal"
    13  )
    14  
    15  // FiatCurrencyHistory is the model entity for the FiatCurrencyHistory schema.
    16  type FiatCurrencyHistory struct {
    17  	config `json:"-"`
    18  	// ID of the ent.
    19  	ID uint32 `json:"id,omitempty"`
    20  	// CreatedAt holds the value of the "created_at" field.
    21  	CreatedAt uint32 `json:"created_at,omitempty"`
    22  	// UpdatedAt holds the value of the "updated_at" field.
    23  	UpdatedAt uint32 `json:"updated_at,omitempty"`
    24  	// DeletedAt holds the value of the "deleted_at" field.
    25  	DeletedAt uint32 `json:"deleted_at,omitempty"`
    26  	// EntID holds the value of the "ent_id" field.
    27  	EntID uuid.UUID `json:"ent_id,omitempty"`
    28  	// FiatID holds the value of the "fiat_id" field.
    29  	FiatID uuid.UUID `json:"fiat_id,omitempty"`
    30  	// FeedType holds the value of the "feed_type" field.
    31  	FeedType string `json:"feed_type,omitempty"`
    32  	// MarketValueLow holds the value of the "market_value_low" field.
    33  	MarketValueLow decimal.Decimal `json:"market_value_low,omitempty"`
    34  	// MarketValueHigh holds the value of the "market_value_high" field.
    35  	MarketValueHigh decimal.Decimal `json:"market_value_high,omitempty"`
    36  }
    37  
    38  // scanValues returns the types for scanning values from sql.Rows.
    39  func (*FiatCurrencyHistory) scanValues(columns []string) ([]interface{}, error) {
    40  	values := make([]interface{}, len(columns))
    41  	for i := range columns {
    42  		switch columns[i] {
    43  		case fiatcurrencyhistory.FieldMarketValueLow, fiatcurrencyhistory.FieldMarketValueHigh:
    44  			values[i] = new(decimal.Decimal)
    45  		case fiatcurrencyhistory.FieldID, fiatcurrencyhistory.FieldCreatedAt, fiatcurrencyhistory.FieldUpdatedAt, fiatcurrencyhistory.FieldDeletedAt:
    46  			values[i] = new(sql.NullInt64)
    47  		case fiatcurrencyhistory.FieldFeedType:
    48  			values[i] = new(sql.NullString)
    49  		case fiatcurrencyhistory.FieldEntID, fiatcurrencyhistory.FieldFiatID:
    50  			values[i] = new(uuid.UUID)
    51  		default:
    52  			return nil, fmt.Errorf("unexpected column %q for type FiatCurrencyHistory", columns[i])
    53  		}
    54  	}
    55  	return values, nil
    56  }
    57  
    58  // assignValues assigns the values that were returned from sql.Rows (after scanning)
    59  // to the FiatCurrencyHistory fields.
    60  func (fch *FiatCurrencyHistory) assignValues(columns []string, values []interface{}) error {
    61  	if m, n := len(values), len(columns); m < n {
    62  		return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
    63  	}
    64  	for i := range columns {
    65  		switch columns[i] {
    66  		case fiatcurrencyhistory.FieldID:
    67  			value, ok := values[i].(*sql.NullInt64)
    68  			if !ok {
    69  				return fmt.Errorf("unexpected type %T for field id", value)
    70  			}
    71  			fch.ID = uint32(value.Int64)
    72  		case fiatcurrencyhistory.FieldCreatedAt:
    73  			if value, ok := values[i].(*sql.NullInt64); !ok {
    74  				return fmt.Errorf("unexpected type %T for field created_at", values[i])
    75  			} else if value.Valid {
    76  				fch.CreatedAt = uint32(value.Int64)
    77  			}
    78  		case fiatcurrencyhistory.FieldUpdatedAt:
    79  			if value, ok := values[i].(*sql.NullInt64); !ok {
    80  				return fmt.Errorf("unexpected type %T for field updated_at", values[i])
    81  			} else if value.Valid {
    82  				fch.UpdatedAt = uint32(value.Int64)
    83  			}
    84  		case fiatcurrencyhistory.FieldDeletedAt:
    85  			if value, ok := values[i].(*sql.NullInt64); !ok {
    86  				return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
    87  			} else if value.Valid {
    88  				fch.DeletedAt = uint32(value.Int64)
    89  			}
    90  		case fiatcurrencyhistory.FieldEntID:
    91  			if value, ok := values[i].(*uuid.UUID); !ok {
    92  				return fmt.Errorf("unexpected type %T for field ent_id", values[i])
    93  			} else if value != nil {
    94  				fch.EntID = *value
    95  			}
    96  		case fiatcurrencyhistory.FieldFiatID:
    97  			if value, ok := values[i].(*uuid.UUID); !ok {
    98  				return fmt.Errorf("unexpected type %T for field fiat_id", values[i])
    99  			} else if value != nil {
   100  				fch.FiatID = *value
   101  			}
   102  		case fiatcurrencyhistory.FieldFeedType:
   103  			if value, ok := values[i].(*sql.NullString); !ok {
   104  				return fmt.Errorf("unexpected type %T for field feed_type", values[i])
   105  			} else if value.Valid {
   106  				fch.FeedType = value.String
   107  			}
   108  		case fiatcurrencyhistory.FieldMarketValueLow:
   109  			if value, ok := values[i].(*decimal.Decimal); !ok {
   110  				return fmt.Errorf("unexpected type %T for field market_value_low", values[i])
   111  			} else if value != nil {
   112  				fch.MarketValueLow = *value
   113  			}
   114  		case fiatcurrencyhistory.FieldMarketValueHigh:
   115  			if value, ok := values[i].(*decimal.Decimal); !ok {
   116  				return fmt.Errorf("unexpected type %T for field market_value_high", values[i])
   117  			} else if value != nil {
   118  				fch.MarketValueHigh = *value
   119  			}
   120  		}
   121  	}
   122  	return nil
   123  }
   124  
   125  // Update returns a builder for updating this FiatCurrencyHistory.
   126  // Note that you need to call FiatCurrencyHistory.Unwrap() before calling this method if this FiatCurrencyHistory
   127  // was returned from a transaction, and the transaction was committed or rolled back.
   128  func (fch *FiatCurrencyHistory) Update() *FiatCurrencyHistoryUpdateOne {
   129  	return (&FiatCurrencyHistoryClient{config: fch.config}).UpdateOne(fch)
   130  }
   131  
   132  // Unwrap unwraps the FiatCurrencyHistory entity that was returned from a transaction after it was closed,
   133  // so that all future queries will be executed through the driver which created the transaction.
   134  func (fch *FiatCurrencyHistory) Unwrap() *FiatCurrencyHistory {
   135  	_tx, ok := fch.config.driver.(*txDriver)
   136  	if !ok {
   137  		panic("ent: FiatCurrencyHistory is not a transactional entity")
   138  	}
   139  	fch.config.driver = _tx.drv
   140  	return fch
   141  }
   142  
   143  // String implements the fmt.Stringer.
   144  func (fch *FiatCurrencyHistory) String() string {
   145  	var builder strings.Builder
   146  	builder.WriteString("FiatCurrencyHistory(")
   147  	builder.WriteString(fmt.Sprintf("id=%v, ", fch.ID))
   148  	builder.WriteString("created_at=")
   149  	builder.WriteString(fmt.Sprintf("%v", fch.CreatedAt))
   150  	builder.WriteString(", ")
   151  	builder.WriteString("updated_at=")
   152  	builder.WriteString(fmt.Sprintf("%v", fch.UpdatedAt))
   153  	builder.WriteString(", ")
   154  	builder.WriteString("deleted_at=")
   155  	builder.WriteString(fmt.Sprintf("%v", fch.DeletedAt))
   156  	builder.WriteString(", ")
   157  	builder.WriteString("ent_id=")
   158  	builder.WriteString(fmt.Sprintf("%v", fch.EntID))
   159  	builder.WriteString(", ")
   160  	builder.WriteString("fiat_id=")
   161  	builder.WriteString(fmt.Sprintf("%v", fch.FiatID))
   162  	builder.WriteString(", ")
   163  	builder.WriteString("feed_type=")
   164  	builder.WriteString(fch.FeedType)
   165  	builder.WriteString(", ")
   166  	builder.WriteString("market_value_low=")
   167  	builder.WriteString(fmt.Sprintf("%v", fch.MarketValueLow))
   168  	builder.WriteString(", ")
   169  	builder.WriteString("market_value_high=")
   170  	builder.WriteString(fmt.Sprintf("%v", fch.MarketValueHigh))
   171  	builder.WriteByte(')')
   172  	return builder.String()
   173  }
   174  
   175  // FiatCurrencyHistories is a parsable slice of FiatCurrencyHistory.
   176  type FiatCurrencyHistories []*FiatCurrencyHistory
   177  
   178  func (fch FiatCurrencyHistories) config(cfg config) {
   179  	for _i := range fch {
   180  		fch[_i].config = cfg
   181  	}
   182  }