github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/coindescription.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/coindescription"
    11  	"github.com/google/uuid"
    12  )
    13  
    14  // CoinDescription is the model entity for the CoinDescription schema.
    15  type CoinDescription 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  	// AppID holds the value of the "app_id" field.
    28  	AppID uuid.UUID `json:"app_id,omitempty"`
    29  	// CoinTypeID holds the value of the "coin_type_id" field.
    30  	CoinTypeID uuid.UUID `json:"coin_type_id,omitempty"`
    31  	// UsedFor holds the value of the "used_for" field.
    32  	UsedFor string `json:"used_for,omitempty"`
    33  	// Title holds the value of the "title" field.
    34  	Title string `json:"title,omitempty"`
    35  	// Message holds the value of the "message" field.
    36  	Message string `json:"message,omitempty"`
    37  }
    38  
    39  // scanValues returns the types for scanning values from sql.Rows.
    40  func (*CoinDescription) scanValues(columns []string) ([]interface{}, error) {
    41  	values := make([]interface{}, len(columns))
    42  	for i := range columns {
    43  		switch columns[i] {
    44  		case coindescription.FieldID, coindescription.FieldCreatedAt, coindescription.FieldUpdatedAt, coindescription.FieldDeletedAt:
    45  			values[i] = new(sql.NullInt64)
    46  		case coindescription.FieldUsedFor, coindescription.FieldTitle, coindescription.FieldMessage:
    47  			values[i] = new(sql.NullString)
    48  		case coindescription.FieldEntID, coindescription.FieldAppID, coindescription.FieldCoinTypeID:
    49  			values[i] = new(uuid.UUID)
    50  		default:
    51  			return nil, fmt.Errorf("unexpected column %q for type CoinDescription", 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 CoinDescription fields.
    59  func (cd *CoinDescription) 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 coindescription.FieldID:
    66  			value, ok := values[i].(*sql.NullInt64)
    67  			if !ok {
    68  				return fmt.Errorf("unexpected type %T for field id", value)
    69  			}
    70  			cd.ID = uint32(value.Int64)
    71  		case coindescription.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  				cd.CreatedAt = uint32(value.Int64)
    76  			}
    77  		case coindescription.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  				cd.UpdatedAt = uint32(value.Int64)
    82  			}
    83  		case coindescription.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  				cd.DeletedAt = uint32(value.Int64)
    88  			}
    89  		case coindescription.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  				cd.EntID = *value
    94  			}
    95  		case coindescription.FieldAppID:
    96  			if value, ok := values[i].(*uuid.UUID); !ok {
    97  				return fmt.Errorf("unexpected type %T for field app_id", values[i])
    98  			} else if value != nil {
    99  				cd.AppID = *value
   100  			}
   101  		case coindescription.FieldCoinTypeID:
   102  			if value, ok := values[i].(*uuid.UUID); !ok {
   103  				return fmt.Errorf("unexpected type %T for field coin_type_id", values[i])
   104  			} else if value != nil {
   105  				cd.CoinTypeID = *value
   106  			}
   107  		case coindescription.FieldUsedFor:
   108  			if value, ok := values[i].(*sql.NullString); !ok {
   109  				return fmt.Errorf("unexpected type %T for field used_for", values[i])
   110  			} else if value.Valid {
   111  				cd.UsedFor = value.String
   112  			}
   113  		case coindescription.FieldTitle:
   114  			if value, ok := values[i].(*sql.NullString); !ok {
   115  				return fmt.Errorf("unexpected type %T for field title", values[i])
   116  			} else if value.Valid {
   117  				cd.Title = value.String
   118  			}
   119  		case coindescription.FieldMessage:
   120  			if value, ok := values[i].(*sql.NullString); !ok {
   121  				return fmt.Errorf("unexpected type %T for field message", values[i])
   122  			} else if value.Valid {
   123  				cd.Message = value.String
   124  			}
   125  		}
   126  	}
   127  	return nil
   128  }
   129  
   130  // Update returns a builder for updating this CoinDescription.
   131  // Note that you need to call CoinDescription.Unwrap() before calling this method if this CoinDescription
   132  // was returned from a transaction, and the transaction was committed or rolled back.
   133  func (cd *CoinDescription) Update() *CoinDescriptionUpdateOne {
   134  	return (&CoinDescriptionClient{config: cd.config}).UpdateOne(cd)
   135  }
   136  
   137  // Unwrap unwraps the CoinDescription entity that was returned from a transaction after it was closed,
   138  // so that all future queries will be executed through the driver which created the transaction.
   139  func (cd *CoinDescription) Unwrap() *CoinDescription {
   140  	_tx, ok := cd.config.driver.(*txDriver)
   141  	if !ok {
   142  		panic("ent: CoinDescription is not a transactional entity")
   143  	}
   144  	cd.config.driver = _tx.drv
   145  	return cd
   146  }
   147  
   148  // String implements the fmt.Stringer.
   149  func (cd *CoinDescription) String() string {
   150  	var builder strings.Builder
   151  	builder.WriteString("CoinDescription(")
   152  	builder.WriteString(fmt.Sprintf("id=%v, ", cd.ID))
   153  	builder.WriteString("created_at=")
   154  	builder.WriteString(fmt.Sprintf("%v", cd.CreatedAt))
   155  	builder.WriteString(", ")
   156  	builder.WriteString("updated_at=")
   157  	builder.WriteString(fmt.Sprintf("%v", cd.UpdatedAt))
   158  	builder.WriteString(", ")
   159  	builder.WriteString("deleted_at=")
   160  	builder.WriteString(fmt.Sprintf("%v", cd.DeletedAt))
   161  	builder.WriteString(", ")
   162  	builder.WriteString("ent_id=")
   163  	builder.WriteString(fmt.Sprintf("%v", cd.EntID))
   164  	builder.WriteString(", ")
   165  	builder.WriteString("app_id=")
   166  	builder.WriteString(fmt.Sprintf("%v", cd.AppID))
   167  	builder.WriteString(", ")
   168  	builder.WriteString("coin_type_id=")
   169  	builder.WriteString(fmt.Sprintf("%v", cd.CoinTypeID))
   170  	builder.WriteString(", ")
   171  	builder.WriteString("used_for=")
   172  	builder.WriteString(cd.UsedFor)
   173  	builder.WriteString(", ")
   174  	builder.WriteString("title=")
   175  	builder.WriteString(cd.Title)
   176  	builder.WriteString(", ")
   177  	builder.WriteString("message=")
   178  	builder.WriteString(cd.Message)
   179  	builder.WriteByte(')')
   180  	return builder.String()
   181  }
   182  
   183  // CoinDescriptions is a parsable slice of CoinDescription.
   184  type CoinDescriptions []*CoinDescription
   185  
   186  func (cd CoinDescriptions) config(cfg config) {
   187  	for _i := range cd {
   188  		cd[_i].config = cfg
   189  	}
   190  }