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