github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/currency.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/currency" 11 "github.com/google/uuid" 12 "github.com/shopspring/decimal" 13 ) 14 15 // Currency is the model entity for the Currency schema. 16 type Currency 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 // FeedType holds the value of the "feed_type" field. 31 FeedType string `json:"feed_type,omitempty"` 32 // MarketValueHigh holds the value of the "market_value_high" field. 33 MarketValueHigh decimal.Decimal `json:"market_value_high,omitempty"` 34 // MarketValueLow holds the value of the "market_value_low" field. 35 MarketValueLow decimal.Decimal `json:"market_value_low,omitempty"` 36 } 37 38 // scanValues returns the types for scanning values from sql.Rows. 39 func (*Currency) scanValues(columns []string) ([]interface{}, error) { 40 values := make([]interface{}, len(columns)) 41 for i := range columns { 42 switch columns[i] { 43 case currency.FieldMarketValueHigh, currency.FieldMarketValueLow: 44 values[i] = new(decimal.Decimal) 45 case currency.FieldID, currency.FieldCreatedAt, currency.FieldUpdatedAt, currency.FieldDeletedAt: 46 values[i] = new(sql.NullInt64) 47 case currency.FieldFeedType: 48 values[i] = new(sql.NullString) 49 case currency.FieldEntID, currency.FieldCoinTypeID: 50 values[i] = new(uuid.UUID) 51 default: 52 return nil, fmt.Errorf("unexpected column %q for type Currency", 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 Currency fields. 60 func (c *Currency) 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 currency.FieldID: 67 value, ok := values[i].(*sql.NullInt64) 68 if !ok { 69 return fmt.Errorf("unexpected type %T for field id", value) 70 } 71 c.ID = uint32(value.Int64) 72 case currency.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 c.CreatedAt = uint32(value.Int64) 77 } 78 case currency.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 c.UpdatedAt = uint32(value.Int64) 83 } 84 case currency.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 c.DeletedAt = uint32(value.Int64) 89 } 90 case currency.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 c.EntID = *value 95 } 96 case currency.FieldCoinTypeID: 97 if value, ok := values[i].(*uuid.UUID); !ok { 98 return fmt.Errorf("unexpected type %T for field coin_type_id", values[i]) 99 } else if value != nil { 100 c.CoinTypeID = *value 101 } 102 case currency.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 c.FeedType = value.String 107 } 108 case currency.FieldMarketValueHigh: 109 if value, ok := values[i].(*decimal.Decimal); !ok { 110 return fmt.Errorf("unexpected type %T for field market_value_high", values[i]) 111 } else if value != nil { 112 c.MarketValueHigh = *value 113 } 114 case currency.FieldMarketValueLow: 115 if value, ok := values[i].(*decimal.Decimal); !ok { 116 return fmt.Errorf("unexpected type %T for field market_value_low", values[i]) 117 } else if value != nil { 118 c.MarketValueLow = *value 119 } 120 } 121 } 122 return nil 123 } 124 125 // Update returns a builder for updating this Currency. 126 // Note that you need to call Currency.Unwrap() before calling this method if this Currency 127 // was returned from a transaction, and the transaction was committed or rolled back. 128 func (c *Currency) Update() *CurrencyUpdateOne { 129 return (&CurrencyClient{config: c.config}).UpdateOne(c) 130 } 131 132 // Unwrap unwraps the Currency 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 (c *Currency) Unwrap() *Currency { 135 _tx, ok := c.config.driver.(*txDriver) 136 if !ok { 137 panic("ent: Currency is not a transactional entity") 138 } 139 c.config.driver = _tx.drv 140 return c 141 } 142 143 // String implements the fmt.Stringer. 144 func (c *Currency) String() string { 145 var builder strings.Builder 146 builder.WriteString("Currency(") 147 builder.WriteString(fmt.Sprintf("id=%v, ", c.ID)) 148 builder.WriteString("created_at=") 149 builder.WriteString(fmt.Sprintf("%v", c.CreatedAt)) 150 builder.WriteString(", ") 151 builder.WriteString("updated_at=") 152 builder.WriteString(fmt.Sprintf("%v", c.UpdatedAt)) 153 builder.WriteString(", ") 154 builder.WriteString("deleted_at=") 155 builder.WriteString(fmt.Sprintf("%v", c.DeletedAt)) 156 builder.WriteString(", ") 157 builder.WriteString("ent_id=") 158 builder.WriteString(fmt.Sprintf("%v", c.EntID)) 159 builder.WriteString(", ") 160 builder.WriteString("coin_type_id=") 161 builder.WriteString(fmt.Sprintf("%v", c.CoinTypeID)) 162 builder.WriteString(", ") 163 builder.WriteString("feed_type=") 164 builder.WriteString(c.FeedType) 165 builder.WriteString(", ") 166 builder.WriteString("market_value_high=") 167 builder.WriteString(fmt.Sprintf("%v", c.MarketValueHigh)) 168 builder.WriteString(", ") 169 builder.WriteString("market_value_low=") 170 builder.WriteString(fmt.Sprintf("%v", c.MarketValueLow)) 171 builder.WriteByte(')') 172 return builder.String() 173 } 174 175 // Currencies is a parsable slice of Currency. 176 type Currencies []*Currency 177 178 func (c Currencies) config(cfg config) { 179 for _i := range c { 180 c[_i].config = cfg 181 } 182 }