frankenapi/ent/warns.go
2022-09-08 09:18:04 +02:00

166 lines
5.1 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"entgo.io/ent/dialect/sql"
"github.com/FrankenBotDev/FrankenAPI/ent/warns"
)
// Warns is the model entity for the Warns schema.
type Warns struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// Emitter holds the value of the "emitter" field.
Emitter string `json:"emitter,omitempty"`
// Serverid holds the value of the "serverid" field.
Serverid string `json:"serverid,omitempty"`
// Target holds the value of the "target" field.
Target string `json:"target,omitempty"`
// Type holds the value of the "type" field.
Type string `json:"type,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"`
// Refid holds the value of the "refid" field.
Refid string `json:"refid,omitempty"`
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Warns) scanValues(columns []string) ([]interface{}, error) {
values := make([]interface{}, len(columns))
for i := range columns {
switch columns[i] {
case warns.FieldID:
values[i] = new(sql.NullInt64)
case warns.FieldEmitter, warns.FieldServerid, warns.FieldTarget, warns.FieldType, warns.FieldDuration, warns.FieldReason, warns.FieldRefid:
values[i] = new(sql.NullString)
default:
return nil, fmt.Errorf("unexpected column %q for type Warns", columns[i])
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Warns fields.
func (w *Warns) 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 warns.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
w.ID = int(value.Int64)
case warns.FieldEmitter:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field emitter", values[i])
} else if value.Valid {
w.Emitter = value.String
}
case warns.FieldServerid:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field serverid", values[i])
} else if value.Valid {
w.Serverid = value.String
}
case warns.FieldTarget:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field target", values[i])
} else if value.Valid {
w.Target = value.String
}
case warns.FieldType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field type", values[i])
} else if value.Valid {
w.Type = value.String
}
case warns.FieldDuration:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field duration", values[i])
} else if value.Valid {
w.Duration = value.String
}
case warns.FieldReason:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field reason", values[i])
} else if value.Valid {
w.Reason = value.String
}
case warns.FieldRefid:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field refid", values[i])
} else if value.Valid {
w.Refid = value.String
}
}
}
return nil
}
// Update returns a builder for updating this Warns.
// Note that you need to call Warns.Unwrap() before calling this method if this Warns
// was returned from a transaction, and the transaction was committed or rolled back.
func (w *Warns) Update() *WarnsUpdateOne {
return (&WarnsClient{config: w.config}).UpdateOne(w)
}
// Unwrap unwraps the Warns 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 (w *Warns) Unwrap() *Warns {
_tx, ok := w.config.driver.(*txDriver)
if !ok {
panic("ent: Warns is not a transactional entity")
}
w.config.driver = _tx.drv
return w
}
// String implements the fmt.Stringer.
func (w *Warns) String() string {
var builder strings.Builder
builder.WriteString("Warns(")
builder.WriteString(fmt.Sprintf("id=%v, ", w.ID))
builder.WriteString("emitter=")
builder.WriteString(w.Emitter)
builder.WriteString(", ")
builder.WriteString("serverid=")
builder.WriteString(w.Serverid)
builder.WriteString(", ")
builder.WriteString("target=")
builder.WriteString(w.Target)
builder.WriteString(", ")
builder.WriteString("type=")
builder.WriteString(w.Type)
builder.WriteString(", ")
builder.WriteString("duration=")
builder.WriteString(w.Duration)
builder.WriteString(", ")
builder.WriteString("reason=")
builder.WriteString(w.Reason)
builder.WriteString(", ")
builder.WriteString("refid=")
builder.WriteString(w.Refid)
builder.WriteByte(')')
return builder.String()
}
// WarnsSlice is a parsable slice of Warns.
type WarnsSlice []*Warns
func (w WarnsSlice) config(cfg config) {
for _i := range w {
w[_i].config = cfg
}
}