// Code generated by ent, DO NOT EDIT. package ent import ( "fmt" "strings" "entgo.io/ent/dialect/sql" "github.com/FrankenBotDev/FrankenAPI/ent/punishments" ) // Punishments is the model entity for the Punishments schema. type Punishments struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` // Serverid holds the value of the "serverid" field. Serverid string `json:"serverid,omitempty"` // Warnamount holds the value of the "warnamount" field. Warnamount string `json:"warnamount,omitempty"` // Actiontype holds the value of the "actiontype" field. Actiontype string `json:"actiontype,omitempty"` // Duration holds the value of the "duration" field. Duration string `json:"duration,omitempty"` // Reason holds the value of the "reason" field. Reason string `json:"reason,omitempty"` } // scanValues returns the types for scanning values from sql.Rows. func (*Punishments) scanValues(columns []string) ([]interface{}, error) { values := make([]interface{}, len(columns)) for i := range columns { switch columns[i] { case punishments.FieldID: values[i] = new(sql.NullInt64) case punishments.FieldServerid, punishments.FieldWarnamount, punishments.FieldActiontype, punishments.FieldDuration, punishments.FieldReason: values[i] = new(sql.NullString) default: return nil, fmt.Errorf("unexpected column %q for type Punishments", columns[i]) } } return values, nil } // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Punishments fields. func (pu *Punishments) assignValues(columns []string, values []interface{}) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } for i := range columns { switch columns[i] { case punishments.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } pu.ID = int(value.Int64) case punishments.FieldServerid: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field serverid", values[i]) } else if value.Valid { pu.Serverid = value.String } case punishments.FieldWarnamount: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field warnamount", values[i]) } else if value.Valid { pu.Warnamount = value.String } case punishments.FieldActiontype: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field actiontype", values[i]) } else if value.Valid { pu.Actiontype = value.String } case punishments.FieldDuration: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field duration", values[i]) } else if value.Valid { pu.Duration = value.String } case punishments.FieldReason: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field reason", values[i]) } else if value.Valid { pu.Reason = value.String } } } return nil } // Update returns a builder for updating this Punishments. // Note that you need to call Punishments.Unwrap() before calling this method if this Punishments // was returned from a transaction, and the transaction was committed or rolled back. func (pu *Punishments) Update() *PunishmentsUpdateOne { return (&PunishmentsClient{config: pu.config}).UpdateOne(pu) } // Unwrap unwraps the Punishments entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. func (pu *Punishments) Unwrap() *Punishments { _tx, ok := pu.config.driver.(*txDriver) if !ok { panic("ent: Punishments is not a transactional entity") } pu.config.driver = _tx.drv return pu } // String implements the fmt.Stringer. func (pu *Punishments) String() string { var builder strings.Builder builder.WriteString("Punishments(") builder.WriteString(fmt.Sprintf("id=%v, ", pu.ID)) builder.WriteString("serverid=") builder.WriteString(pu.Serverid) builder.WriteString(", ") builder.WriteString("warnamount=") builder.WriteString(pu.Warnamount) builder.WriteString(", ") builder.WriteString("actiontype=") builder.WriteString(pu.Actiontype) builder.WriteString(", ") builder.WriteString("duration=") builder.WriteString(pu.Duration) builder.WriteString(", ") builder.WriteString("reason=") builder.WriteString(pu.Reason) builder.WriteByte(')') return builder.String() } // PunishmentsSlice is a parsable slice of Punishments. type PunishmentsSlice []*Punishments func (pu PunishmentsSlice) config(cfg config) { for _i := range pu { pu[_i].config = cfg } }