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