github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/fiatcurrencyfeed.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/fiatcurrencyfeed"
    11  	"github.com/google/uuid"
    12  )
    13  
    14  // FiatCurrencyFeed is the model entity for the FiatCurrencyFeed schema.
    15  type FiatCurrencyFeed 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  	// FiatID holds the value of the "fiat_id" field.
    28  	FiatID uuid.UUID `json:"fiat_id,omitempty"`
    29  	// FeedType holds the value of the "feed_type" field.
    30  	FeedType string `json:"feed_type,omitempty"`
    31  	// FeedFiatName holds the value of the "feed_fiat_name" field.
    32  	FeedFiatName string `json:"feed_fiat_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 (*FiatCurrencyFeed) scanValues(columns []string) ([]interface{}, error) {
    39  	values := make([]interface{}, len(columns))
    40  	for i := range columns {
    41  		switch columns[i] {
    42  		case fiatcurrencyfeed.FieldDisabled:
    43  			values[i] = new(sql.NullBool)
    44  		case fiatcurrencyfeed.FieldID, fiatcurrencyfeed.FieldCreatedAt, fiatcurrencyfeed.FieldUpdatedAt, fiatcurrencyfeed.FieldDeletedAt:
    45  			values[i] = new(sql.NullInt64)
    46  		case fiatcurrencyfeed.FieldFeedType, fiatcurrencyfeed.FieldFeedFiatName:
    47  			values[i] = new(sql.NullString)
    48  		case fiatcurrencyfeed.FieldEntID, fiatcurrencyfeed.FieldFiatID:
    49  			values[i] = new(uuid.UUID)
    50  		default:
    51  			return nil, fmt.Errorf("unexpected column %q for type FiatCurrencyFeed", 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 FiatCurrencyFeed fields.
    59  func (fcf *FiatCurrencyFeed) 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 fiatcurrencyfeed.FieldID:
    66  			value, ok := values[i].(*sql.NullInt64)
    67  			if !ok {
    68  				return fmt.Errorf("unexpected type %T for field id", value)
    69  			}
    70  			fcf.ID = uint32(value.Int64)
    71  		case fiatcurrencyfeed.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  				fcf.CreatedAt = uint32(value.Int64)
    76  			}
    77  		case fiatcurrencyfeed.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  				fcf.UpdatedAt = uint32(value.Int64)
    82  			}
    83  		case fiatcurrencyfeed.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  				fcf.DeletedAt = uint32(value.Int64)
    88  			}
    89  		case fiatcurrencyfeed.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  				fcf.EntID = *value
    94  			}
    95  		case fiatcurrencyfeed.FieldFiatID:
    96  			if value, ok := values[i].(*uuid.UUID); !ok {
    97  				return fmt.Errorf("unexpected type %T for field fiat_id", values[i])
    98  			} else if value != nil {
    99  				fcf.FiatID = *value
   100  			}
   101  		case fiatcurrencyfeed.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  				fcf.FeedType = value.String
   106  			}
   107  		case fiatcurrencyfeed.FieldFeedFiatName:
   108  			if value, ok := values[i].(*sql.NullString); !ok {
   109  				return fmt.Errorf("unexpected type %T for field feed_fiat_name", values[i])
   110  			} else if value.Valid {
   111  				fcf.FeedFiatName = value.String
   112  			}
   113  		case fiatcurrencyfeed.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  				fcf.Disabled = value.Bool
   118  			}
   119  		}
   120  	}
   121  	return nil
   122  }
   123  
   124  // Update returns a builder for updating this FiatCurrencyFeed.
   125  // Note that you need to call FiatCurrencyFeed.Unwrap() before calling this method if this FiatCurrencyFeed
   126  // was returned from a transaction, and the transaction was committed or rolled back.
   127  func (fcf *FiatCurrencyFeed) Update() *FiatCurrencyFeedUpdateOne {
   128  	return (&FiatCurrencyFeedClient{config: fcf.config}).UpdateOne(fcf)
   129  }
   130  
   131  // Unwrap unwraps the FiatCurrencyFeed 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 (fcf *FiatCurrencyFeed) Unwrap() *FiatCurrencyFeed {
   134  	_tx, ok := fcf.config.driver.(*txDriver)
   135  	if !ok {
   136  		panic("ent: FiatCurrencyFeed is not a transactional entity")
   137  	}
   138  	fcf.config.driver = _tx.drv
   139  	return fcf
   140  }
   141  
   142  // String implements the fmt.Stringer.
   143  func (fcf *FiatCurrencyFeed) String() string {
   144  	var builder strings.Builder
   145  	builder.WriteString("FiatCurrencyFeed(")
   146  	builder.WriteString(fmt.Sprintf("id=%v, ", fcf.ID))
   147  	builder.WriteString("created_at=")
   148  	builder.WriteString(fmt.Sprintf("%v", fcf.CreatedAt))
   149  	builder.WriteString(", ")
   150  	builder.WriteString("updated_at=")
   151  	builder.WriteString(fmt.Sprintf("%v", fcf.UpdatedAt))
   152  	builder.WriteString(", ")
   153  	builder.WriteString("deleted_at=")
   154  	builder.WriteString(fmt.Sprintf("%v", fcf.DeletedAt))
   155  	builder.WriteString(", ")
   156  	builder.WriteString("ent_id=")
   157  	builder.WriteString(fmt.Sprintf("%v", fcf.EntID))
   158  	builder.WriteString(", ")
   159  	builder.WriteString("fiat_id=")
   160  	builder.WriteString(fmt.Sprintf("%v", fcf.FiatID))
   161  	builder.WriteString(", ")
   162  	builder.WriteString("feed_type=")
   163  	builder.WriteString(fcf.FeedType)
   164  	builder.WriteString(", ")
   165  	builder.WriteString("feed_fiat_name=")
   166  	builder.WriteString(fcf.FeedFiatName)
   167  	builder.WriteString(", ")
   168  	builder.WriteString("disabled=")
   169  	builder.WriteString(fmt.Sprintf("%v", fcf.Disabled))
   170  	builder.WriteByte(')')
   171  	return builder.String()
   172  }
   173  
   174  // FiatCurrencyFeeds is a parsable slice of FiatCurrencyFeed.
   175  type FiatCurrencyFeeds []*FiatCurrencyFeed
   176  
   177  func (fcf FiatCurrencyFeeds) config(cfg config) {
   178  	for _i := range fcf {
   179  		fcf[_i].config = cfg
   180  	}
   181  }