// Code generated by ent, DO NOT EDIT. package ent import ( "fmt" "polaris/ent/history" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" ) // History is the model entity for the History schema. type History 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"` // EpisodeID holds the value of the "episode_id" field. EpisodeID int `json:"episode_id,omitempty"` // SourceTitle holds the value of the "source_title" field. SourceTitle string `json:"source_title,omitempty"` // Date holds the value of the "date" field. Date time.Time `json:"date,omitempty"` selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. func (*History) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case history.FieldID, history.FieldSeriesID, history.FieldEpisodeID: values[i] = new(sql.NullInt64) case history.FieldSourceTitle: values[i] = new(sql.NullString) case history.FieldDate: values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) } } return values, nil } // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the History fields. func (h *History) 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 history.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } h.ID = int(value.Int64) case history.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 { h.SeriesID = int(value.Int64) } case history.FieldEpisodeID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field episode_id", values[i]) } else if value.Valid { h.EpisodeID = int(value.Int64) } case history.FieldSourceTitle: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field source_title", values[i]) } else if value.Valid { h.SourceTitle = value.String } case history.FieldDate: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field date", values[i]) } else if value.Valid { h.Date = value.Time } default: h.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the History. // This includes values selected through modifiers, order, etc. func (h *History) Value(name string) (ent.Value, error) { return h.selectValues.Get(name) } // Update returns a builder for updating this History. // Note that you need to call History.Unwrap() before calling this method if this History // was returned from a transaction, and the transaction was committed or rolled back. func (h *History) Update() *HistoryUpdateOne { return NewHistoryClient(h.config).UpdateOne(h) } // Unwrap unwraps the History 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 (h *History) Unwrap() *History { _tx, ok := h.config.driver.(*txDriver) if !ok { panic("ent: History is not a transactional entity") } h.config.driver = _tx.drv return h } // String implements the fmt.Stringer. func (h *History) String() string { var builder strings.Builder builder.WriteString("History(") builder.WriteString(fmt.Sprintf("id=%v, ", h.ID)) builder.WriteString("series_id=") builder.WriteString(fmt.Sprintf("%v", h.SeriesID)) builder.WriteString(", ") builder.WriteString("episode_id=") builder.WriteString(fmt.Sprintf("%v", h.EpisodeID)) builder.WriteString(", ") builder.WriteString("source_title=") builder.WriteString(h.SourceTitle) builder.WriteString(", ") builder.WriteString("date=") builder.WriteString(h.Date.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } // Histories is a parsable slice of History. type Histories []*History