mirror of
https://github.com/simon-ding/polaris.git
synced 2026-03-05 09:00:45 +08:00
159 lines
5.2 KiB
Go
159 lines
5.2 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"polaris/ent/epidodes"
|
|
"strings"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
// Epidodes is the model entity for the Epidodes schema.
|
|
type Epidodes struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// SeriesID holds the value of the "series_id" field.
|
|
SeriesID int `json:"series_id,omitempty"`
|
|
// SeasonNumber holds the value of the "season_number" field.
|
|
SeasonNumber int `json:"season_number,omitempty"`
|
|
// EpisodeNumber holds the value of the "episode_number" field.
|
|
EpisodeNumber int `json:"episode_number,omitempty"`
|
|
// Title holds the value of the "title" field.
|
|
Title string `json:"title,omitempty"`
|
|
// Overview holds the value of the "overview" field.
|
|
Overview string `json:"overview,omitempty"`
|
|
// AirDate holds the value of the "air_date" field.
|
|
AirDate string `json:"air_date,omitempty"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*Epidodes) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case epidodes.FieldID, epidodes.FieldSeriesID, epidodes.FieldSeasonNumber, epidodes.FieldEpisodeNumber:
|
|
values[i] = new(sql.NullInt64)
|
|
case epidodes.FieldTitle, epidodes.FieldOverview, epidodes.FieldAirDate:
|
|
values[i] = new(sql.NullString)
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the Epidodes fields.
|
|
func (e *Epidodes) assignValues(columns []string, values []any) 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 epidodes.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
e.ID = int(value.Int64)
|
|
case epidodes.FieldSeriesID:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field series_id", values[i])
|
|
} else if value.Valid {
|
|
e.SeriesID = int(value.Int64)
|
|
}
|
|
case epidodes.FieldSeasonNumber:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field season_number", values[i])
|
|
} else if value.Valid {
|
|
e.SeasonNumber = int(value.Int64)
|
|
}
|
|
case epidodes.FieldEpisodeNumber:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field episode_number", values[i])
|
|
} else if value.Valid {
|
|
e.EpisodeNumber = int(value.Int64)
|
|
}
|
|
case epidodes.FieldTitle:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field title", values[i])
|
|
} else if value.Valid {
|
|
e.Title = value.String
|
|
}
|
|
case epidodes.FieldOverview:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field overview", values[i])
|
|
} else if value.Valid {
|
|
e.Overview = value.String
|
|
}
|
|
case epidodes.FieldAirDate:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field air_date", values[i])
|
|
} else if value.Valid {
|
|
e.AirDate = value.String
|
|
}
|
|
default:
|
|
e.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the Epidodes.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (e *Epidodes) Value(name string) (ent.Value, error) {
|
|
return e.selectValues.Get(name)
|
|
}
|
|
|
|
// Update returns a builder for updating this Epidodes.
|
|
// Note that you need to call Epidodes.Unwrap() before calling this method if this Epidodes
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (e *Epidodes) Update() *EpidodesUpdateOne {
|
|
return NewEpidodesClient(e.config).UpdateOne(e)
|
|
}
|
|
|
|
// Unwrap unwraps the Epidodes 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 (e *Epidodes) Unwrap() *Epidodes {
|
|
_tx, ok := e.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: Epidodes is not a transactional entity")
|
|
}
|
|
e.config.driver = _tx.drv
|
|
return e
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (e *Epidodes) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("Epidodes(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", e.ID))
|
|
builder.WriteString("series_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", e.SeriesID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("season_number=")
|
|
builder.WriteString(fmt.Sprintf("%v", e.SeasonNumber))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("episode_number=")
|
|
builder.WriteString(fmt.Sprintf("%v", e.EpisodeNumber))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("title=")
|
|
builder.WriteString(e.Title)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("overview=")
|
|
builder.WriteString(e.Overview)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("air_date=")
|
|
builder.WriteString(e.AirDate)
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// EpidodesSlice is a parsable slice of Epidodes.
|
|
type EpidodesSlice []*Epidodes
|