mirror of
https://github.com/simon-ding/polaris.git
synced 2026-03-12 04:30:46 +08:00
159 lines
5.0 KiB
Go
159 lines
5.0 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"polaris/ent/series"
|
|
"strings"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
// Series is the model entity for the Series schema.
|
|
type Series struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// TmdbID holds the value of the "tmdb_id" field.
|
|
TmdbID int `json:"tmdb_id,omitempty"`
|
|
// ImdbID holds the value of the "imdb_id" field.
|
|
ImdbID string `json:"imdb_id,omitempty"`
|
|
// Title holds the value of the "title" field.
|
|
Title string `json:"title,omitempty"`
|
|
// OriginalName holds the value of the "original_name" field.
|
|
OriginalName string `json:"original_name,omitempty"`
|
|
// Overview holds the value of the "overview" field.
|
|
Overview string `json:"overview,omitempty"`
|
|
// Path holds the value of the "path" field.
|
|
Path string `json:"path,omitempty"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*Series) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case series.FieldID, series.FieldTmdbID:
|
|
values[i] = new(sql.NullInt64)
|
|
case series.FieldImdbID, series.FieldTitle, series.FieldOriginalName, series.FieldOverview, series.FieldPath:
|
|
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 Series fields.
|
|
func (s *Series) 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 series.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
s.ID = int(value.Int64)
|
|
case series.FieldTmdbID:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field tmdb_id", values[i])
|
|
} else if value.Valid {
|
|
s.TmdbID = int(value.Int64)
|
|
}
|
|
case series.FieldImdbID:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field imdb_id", values[i])
|
|
} else if value.Valid {
|
|
s.ImdbID = value.String
|
|
}
|
|
case series.FieldTitle:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field title", values[i])
|
|
} else if value.Valid {
|
|
s.Title = value.String
|
|
}
|
|
case series.FieldOriginalName:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field original_name", values[i])
|
|
} else if value.Valid {
|
|
s.OriginalName = value.String
|
|
}
|
|
case series.FieldOverview:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field overview", values[i])
|
|
} else if value.Valid {
|
|
s.Overview = value.String
|
|
}
|
|
case series.FieldPath:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field path", values[i])
|
|
} else if value.Valid {
|
|
s.Path = value.String
|
|
}
|
|
default:
|
|
s.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the Series.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (s *Series) Value(name string) (ent.Value, error) {
|
|
return s.selectValues.Get(name)
|
|
}
|
|
|
|
// Update returns a builder for updating this Series.
|
|
// Note that you need to call Series.Unwrap() before calling this method if this Series
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (s *Series) Update() *SeriesUpdateOne {
|
|
return NewSeriesClient(s.config).UpdateOne(s)
|
|
}
|
|
|
|
// Unwrap unwraps the Series 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 (s *Series) Unwrap() *Series {
|
|
_tx, ok := s.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: Series is not a transactional entity")
|
|
}
|
|
s.config.driver = _tx.drv
|
|
return s
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (s *Series) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("Series(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", s.ID))
|
|
builder.WriteString("tmdb_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", s.TmdbID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("imdb_id=")
|
|
builder.WriteString(s.ImdbID)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("title=")
|
|
builder.WriteString(s.Title)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("original_name=")
|
|
builder.WriteString(s.OriginalName)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("overview=")
|
|
builder.WriteString(s.Overview)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("path=")
|
|
builder.WriteString(s.Path)
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// SeriesSlice is a parsable slice of Series.
|
|
type SeriesSlice []*Series
|