// Code generated by ent, DO NOT EDIT. package ent import ( "fmt" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/Wei-Shaw/sub2api/ent/sorausagestat" ) // SoraUsageStat is the model entity for the SoraUsageStat schema. type SoraUsageStat struct { config `json:"-"` // ID of the ent. ID int64 `json:"id,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` // UpdatedAt holds the value of the "updated_at" field. UpdatedAt time.Time `json:"updated_at,omitempty"` // ๅ…ณ่” accounts ่กจ็š„ ID AccountID int64 `json:"account_id,omitempty"` // ImageCount holds the value of the "image_count" field. ImageCount int `json:"image_count,omitempty"` // VideoCount holds the value of the "video_count" field. VideoCount int `json:"video_count,omitempty"` // ErrorCount holds the value of the "error_count" field. ErrorCount int `json:"error_count,omitempty"` // LastErrorAt holds the value of the "last_error_at" field. LastErrorAt *time.Time `json:"last_error_at,omitempty"` // TodayImageCount holds the value of the "today_image_count" field. TodayImageCount int `json:"today_image_count,omitempty"` // TodayVideoCount holds the value of the "today_video_count" field. TodayVideoCount int `json:"today_video_count,omitempty"` // TodayErrorCount holds the value of the "today_error_count" field. TodayErrorCount int `json:"today_error_count,omitempty"` // TodayDate holds the value of the "today_date" field. TodayDate *time.Time `json:"today_date,omitempty"` // ConsecutiveErrorCount holds the value of the "consecutive_error_count" field. ConsecutiveErrorCount int `json:"consecutive_error_count,omitempty"` selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. func (*SoraUsageStat) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case sorausagestat.FieldID, sorausagestat.FieldAccountID, sorausagestat.FieldImageCount, sorausagestat.FieldVideoCount, sorausagestat.FieldErrorCount, sorausagestat.FieldTodayImageCount, sorausagestat.FieldTodayVideoCount, sorausagestat.FieldTodayErrorCount, sorausagestat.FieldConsecutiveErrorCount: values[i] = new(sql.NullInt64) case sorausagestat.FieldCreatedAt, sorausagestat.FieldUpdatedAt, sorausagestat.FieldLastErrorAt, sorausagestat.FieldTodayDate: 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 SoraUsageStat fields. func (_m *SoraUsageStat) 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 sorausagestat.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } _m.ID = int64(value.Int64) case sorausagestat.FieldCreatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field created_at", values[i]) } else if value.Valid { _m.CreatedAt = value.Time } case sorausagestat.FieldUpdatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field updated_at", values[i]) } else if value.Valid { _m.UpdatedAt = value.Time } case sorausagestat.FieldAccountID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field account_id", values[i]) } else if value.Valid { _m.AccountID = value.Int64 } case sorausagestat.FieldImageCount: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field image_count", values[i]) } else if value.Valid { _m.ImageCount = int(value.Int64) } case sorausagestat.FieldVideoCount: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field video_count", values[i]) } else if value.Valid { _m.VideoCount = int(value.Int64) } case sorausagestat.FieldErrorCount: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field error_count", values[i]) } else if value.Valid { _m.ErrorCount = int(value.Int64) } case sorausagestat.FieldLastErrorAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field last_error_at", values[i]) } else if value.Valid { _m.LastErrorAt = new(time.Time) *_m.LastErrorAt = value.Time } case sorausagestat.FieldTodayImageCount: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field today_image_count", values[i]) } else if value.Valid { _m.TodayImageCount = int(value.Int64) } case sorausagestat.FieldTodayVideoCount: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field today_video_count", values[i]) } else if value.Valid { _m.TodayVideoCount = int(value.Int64) } case sorausagestat.FieldTodayErrorCount: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field today_error_count", values[i]) } else if value.Valid { _m.TodayErrorCount = int(value.Int64) } case sorausagestat.FieldTodayDate: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field today_date", values[i]) } else if value.Valid { _m.TodayDate = new(time.Time) *_m.TodayDate = value.Time } case sorausagestat.FieldConsecutiveErrorCount: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field consecutive_error_count", values[i]) } else if value.Valid { _m.ConsecutiveErrorCount = int(value.Int64) } default: _m.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the SoraUsageStat. // This includes values selected through modifiers, order, etc. func (_m *SoraUsageStat) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // Update returns a builder for updating this SoraUsageStat. // Note that you need to call SoraUsageStat.Unwrap() before calling this method if this SoraUsageStat // was returned from a transaction, and the transaction was committed or rolled back. func (_m *SoraUsageStat) Update() *SoraUsageStatUpdateOne { return NewSoraUsageStatClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the SoraUsageStat 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 (_m *SoraUsageStat) Unwrap() *SoraUsageStat { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: SoraUsageStat is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *SoraUsageStat) String() string { var builder strings.Builder builder.WriteString("SoraUsageStat(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("created_at=") builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("account_id=") builder.WriteString(fmt.Sprintf("%v", _m.AccountID)) builder.WriteString(", ") builder.WriteString("image_count=") builder.WriteString(fmt.Sprintf("%v", _m.ImageCount)) builder.WriteString(", ") builder.WriteString("video_count=") builder.WriteString(fmt.Sprintf("%v", _m.VideoCount)) builder.WriteString(", ") builder.WriteString("error_count=") builder.WriteString(fmt.Sprintf("%v", _m.ErrorCount)) builder.WriteString(", ") if v := _m.LastErrorAt; v != nil { builder.WriteString("last_error_at=") builder.WriteString(v.Format(time.ANSIC)) } builder.WriteString(", ") builder.WriteString("today_image_count=") builder.WriteString(fmt.Sprintf("%v", _m.TodayImageCount)) builder.WriteString(", ") builder.WriteString("today_video_count=") builder.WriteString(fmt.Sprintf("%v", _m.TodayVideoCount)) builder.WriteString(", ") builder.WriteString("today_error_count=") builder.WriteString(fmt.Sprintf("%v", _m.TodayErrorCount)) builder.WriteString(", ") if v := _m.TodayDate; v != nil { builder.WriteString("today_date=") builder.WriteString(v.Format(time.ANSIC)) } builder.WriteString(", ") builder.WriteString("consecutive_error_count=") builder.WriteString(fmt.Sprintf("%v", _m.ConsecutiveErrorCount)) builder.WriteByte(')') return builder.String() } // SoraUsageStats is a parsable slice of SoraUsageStat. type SoraUsageStats []*SoraUsageStat