github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/fiat.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/fiat" 11 "github.com/google/uuid" 12 ) 13 14 // Fiat is the model entity for the Fiat schema. 15 type Fiat 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 // Name holds the value of the "name" field. 28 Name string `json:"name,omitempty"` 29 // Logo holds the value of the "logo" field. 30 Logo string `json:"logo,omitempty"` 31 // Unit holds the value of the "unit" field. 32 Unit string `json:"unit,omitempty"` 33 } 34 35 // scanValues returns the types for scanning values from sql.Rows. 36 func (*Fiat) scanValues(columns []string) ([]interface{}, error) { 37 values := make([]interface{}, len(columns)) 38 for i := range columns { 39 switch columns[i] { 40 case fiat.FieldID, fiat.FieldCreatedAt, fiat.FieldUpdatedAt, fiat.FieldDeletedAt: 41 values[i] = new(sql.NullInt64) 42 case fiat.FieldName, fiat.FieldLogo, fiat.FieldUnit: 43 values[i] = new(sql.NullString) 44 case fiat.FieldEntID: 45 values[i] = new(uuid.UUID) 46 default: 47 return nil, fmt.Errorf("unexpected column %q for type Fiat", 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 Fiat fields. 55 func (f *Fiat) 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 fiat.FieldID: 62 value, ok := values[i].(*sql.NullInt64) 63 if !ok { 64 return fmt.Errorf("unexpected type %T for field id", value) 65 } 66 f.ID = uint32(value.Int64) 67 case fiat.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 f.CreatedAt = uint32(value.Int64) 72 } 73 case fiat.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 f.UpdatedAt = uint32(value.Int64) 78 } 79 case fiat.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 f.DeletedAt = uint32(value.Int64) 84 } 85 case fiat.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 f.EntID = *value 90 } 91 case fiat.FieldName: 92 if value, ok := values[i].(*sql.NullString); !ok { 93 return fmt.Errorf("unexpected type %T for field name", values[i]) 94 } else if value.Valid { 95 f.Name = value.String 96 } 97 case fiat.FieldLogo: 98 if value, ok := values[i].(*sql.NullString); !ok { 99 return fmt.Errorf("unexpected type %T for field logo", values[i]) 100 } else if value.Valid { 101 f.Logo = value.String 102 } 103 case fiat.FieldUnit: 104 if value, ok := values[i].(*sql.NullString); !ok { 105 return fmt.Errorf("unexpected type %T for field unit", values[i]) 106 } else if value.Valid { 107 f.Unit = value.String 108 } 109 } 110 } 111 return nil 112 } 113 114 // Update returns a builder for updating this Fiat. 115 // Note that you need to call Fiat.Unwrap() before calling this method if this Fiat 116 // was returned from a transaction, and the transaction was committed or rolled back. 117 func (f *Fiat) Update() *FiatUpdateOne { 118 return (&FiatClient{config: f.config}).UpdateOne(f) 119 } 120 121 // Unwrap unwraps the Fiat 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 (f *Fiat) Unwrap() *Fiat { 124 _tx, ok := f.config.driver.(*txDriver) 125 if !ok { 126 panic("ent: Fiat is not a transactional entity") 127 } 128 f.config.driver = _tx.drv 129 return f 130 } 131 132 // String implements the fmt.Stringer. 133 func (f *Fiat) String() string { 134 var builder strings.Builder 135 builder.WriteString("Fiat(") 136 builder.WriteString(fmt.Sprintf("id=%v, ", f.ID)) 137 builder.WriteString("created_at=") 138 builder.WriteString(fmt.Sprintf("%v", f.CreatedAt)) 139 builder.WriteString(", ") 140 builder.WriteString("updated_at=") 141 builder.WriteString(fmt.Sprintf("%v", f.UpdatedAt)) 142 builder.WriteString(", ") 143 builder.WriteString("deleted_at=") 144 builder.WriteString(fmt.Sprintf("%v", f.DeletedAt)) 145 builder.WriteString(", ") 146 builder.WriteString("ent_id=") 147 builder.WriteString(fmt.Sprintf("%v", f.EntID)) 148 builder.WriteString(", ") 149 builder.WriteString("name=") 150 builder.WriteString(f.Name) 151 builder.WriteString(", ") 152 builder.WriteString("logo=") 153 builder.WriteString(f.Logo) 154 builder.WriteString(", ") 155 builder.WriteString("unit=") 156 builder.WriteString(f.Unit) 157 builder.WriteByte(')') 158 return builder.String() 159 } 160 161 // Fiats is a parsable slice of Fiat. 162 type Fiats []*Fiat 163 164 func (f Fiats) config(cfg config) { 165 for _i := range f { 166 f[_i].config = cfg 167 } 168 }