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