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