// 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/soratask" ) // SoraTask is the model entity for the SoraTask schema. type SoraTask struct { config `json:"-"` // ID of the ent. ID int64 `json:"id,omitempty"` // TaskID holds the value of the "task_id" field. TaskID string `json:"task_id,omitempty"` // AccountID holds the value of the "account_id" field. AccountID int64 `json:"account_id,omitempty"` // Model holds the value of the "model" field. Model string `json:"model,omitempty"` // Prompt holds the value of the "prompt" field. Prompt string `json:"prompt,omitempty"` // Status holds the value of the "status" field. Status string `json:"status,omitempty"` // Progress holds the value of the "progress" field. Progress float64 `json:"progress,omitempty"` // ResultUrls holds the value of the "result_urls" field. ResultUrls *string `json:"result_urls,omitempty"` // ErrorMessage holds the value of the "error_message" field. ErrorMessage *string `json:"error_message,omitempty"` // RetryCount holds the value of the "retry_count" field. RetryCount int `json:"retry_count,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` // CompletedAt holds the value of the "completed_at" field. CompletedAt *time.Time `json:"completed_at,omitempty"` selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. func (*SoraTask) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case soratask.FieldProgress: values[i] = new(sql.NullFloat64) case soratask.FieldID, soratask.FieldAccountID, soratask.FieldRetryCount: values[i] = new(sql.NullInt64) case soratask.FieldTaskID, soratask.FieldModel, soratask.FieldPrompt, soratask.FieldStatus, soratask.FieldResultUrls, soratask.FieldErrorMessage: values[i] = new(sql.NullString) case soratask.FieldCreatedAt, soratask.FieldCompletedAt: 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 SoraTask fields. func (_m *SoraTask) 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 soratask.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 soratask.FieldTaskID: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field task_id", values[i]) } else if value.Valid { _m.TaskID = value.String } case soratask.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 soratask.FieldModel: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field model", values[i]) } else if value.Valid { _m.Model = value.String } case soratask.FieldPrompt: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field prompt", values[i]) } else if value.Valid { _m.Prompt = value.String } case soratask.FieldStatus: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field status", values[i]) } else if value.Valid { _m.Status = value.String } case soratask.FieldProgress: if value, ok := values[i].(*sql.NullFloat64); !ok { return fmt.Errorf("unexpected type %T for field progress", values[i]) } else if value.Valid { _m.Progress = value.Float64 } case soratask.FieldResultUrls: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field result_urls", values[i]) } else if value.Valid { _m.ResultUrls = new(string) *_m.ResultUrls = value.String } case soratask.FieldErrorMessage: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field error_message", values[i]) } else if value.Valid { _m.ErrorMessage = new(string) *_m.ErrorMessage = value.String } case soratask.FieldRetryCount: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field retry_count", values[i]) } else if value.Valid { _m.RetryCount = int(value.Int64) } case soratask.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 soratask.FieldCompletedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field completed_at", values[i]) } else if value.Valid { _m.CompletedAt = new(time.Time) *_m.CompletedAt = value.Time } default: _m.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the SoraTask. // This includes values selected through modifiers, order, etc. func (_m *SoraTask) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // Update returns a builder for updating this SoraTask. // Note that you need to call SoraTask.Unwrap() before calling this method if this SoraTask // was returned from a transaction, and the transaction was committed or rolled back. func (_m *SoraTask) Update() *SoraTaskUpdateOne { return NewSoraTaskClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the SoraTask 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 *SoraTask) Unwrap() *SoraTask { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: SoraTask is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *SoraTask) String() string { var builder strings.Builder builder.WriteString("SoraTask(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("task_id=") builder.WriteString(_m.TaskID) builder.WriteString(", ") builder.WriteString("account_id=") builder.WriteString(fmt.Sprintf("%v", _m.AccountID)) builder.WriteString(", ") builder.WriteString("model=") builder.WriteString(_m.Model) builder.WriteString(", ") builder.WriteString("prompt=") builder.WriteString(_m.Prompt) builder.WriteString(", ") builder.WriteString("status=") builder.WriteString(_m.Status) builder.WriteString(", ") builder.WriteString("progress=") builder.WriteString(fmt.Sprintf("%v", _m.Progress)) builder.WriteString(", ") if v := _m.ResultUrls; v != nil { builder.WriteString("result_urls=") builder.WriteString(*v) } builder.WriteString(", ") if v := _m.ErrorMessage; v != nil { builder.WriteString("error_message=") builder.WriteString(*v) } builder.WriteString(", ") builder.WriteString("retry_count=") builder.WriteString(fmt.Sprintf("%v", _m.RetryCount)) builder.WriteString(", ") builder.WriteString("created_at=") builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") if v := _m.CompletedAt; v != nil { builder.WriteString("completed_at=") builder.WriteString(v.Format(time.ANSIC)) } builder.WriteByte(')') return builder.String() } // SoraTasks is a parsable slice of SoraTask. type SoraTasks []*SoraTask