// Code generated by ent, DO NOT EDIT. package ent import ( "encoding/json" "fmt" "strings" "voidraft/internal/models/ent/theme" "entgo.io/ent" "entgo.io/ent/dialect/sql" ) // Theme is the model entity for the Theme schema. type Theme struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` // UUID for cross-device sync (UUIDv7) UUID string `json:"uuid"` // creation time CreatedAt string `json:"created_at"` // update time UpdatedAt string `json:"updated_at"` // deleted at DeletedAt *string `json:"deleted_at,omitempty"` // theme name Name string `json:"name"` // theme type Type theme.Type `json:"type"` // theme colors Colors map[string]interface{} `json:"colors"` selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. func (*Theme) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case theme.FieldColors: values[i] = new([]byte) case theme.FieldID: values[i] = new(sql.NullInt64) case theme.FieldUUID, theme.FieldCreatedAt, theme.FieldUpdatedAt, theme.FieldDeletedAt, theme.FieldName, theme.FieldType: 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 Theme fields. func (_m *Theme) 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 theme.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } _m.ID = int(value.Int64) case theme.FieldUUID: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field uuid", values[i]) } else if value.Valid { _m.UUID = value.String } case theme.FieldCreatedAt: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field created_at", values[i]) } else if value.Valid { _m.CreatedAt = value.String } case theme.FieldUpdatedAt: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field updated_at", values[i]) } else if value.Valid { _m.UpdatedAt = value.String } case theme.FieldDeletedAt: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) } else if value.Valid { _m.DeletedAt = new(string) *_m.DeletedAt = value.String } case theme.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { _m.Name = value.String } case theme.FieldType: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field type", values[i]) } else if value.Valid { _m.Type = theme.Type(value.String) } case theme.FieldColors: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field colors", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &_m.Colors); err != nil { return fmt.Errorf("unmarshal field colors: %w", err) } } default: _m.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the Theme. // This includes values selected through modifiers, order, etc. func (_m *Theme) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // Update returns a builder for updating this Theme. // Note that you need to call Theme.Unwrap() before calling this method if this Theme // was returned from a transaction, and the transaction was committed or rolled back. func (_m *Theme) Update() *ThemeUpdateOne { return NewThemeClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the Theme 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 *Theme) Unwrap() *Theme { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: Theme is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *Theme) String() string { var builder strings.Builder builder.WriteString("Theme(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("uuid=") builder.WriteString(_m.UUID) builder.WriteString(", ") builder.WriteString("created_at=") builder.WriteString(_m.CreatedAt) builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(_m.UpdatedAt) builder.WriteString(", ") if v := _m.DeletedAt; v != nil { builder.WriteString("deleted_at=") builder.WriteString(*v) } builder.WriteString(", ") builder.WriteString("name=") builder.WriteString(_m.Name) builder.WriteString(", ") builder.WriteString("type=") builder.WriteString(fmt.Sprintf("%v", _m.Type)) builder.WriteString(", ") builder.WriteString("colors=") builder.WriteString(fmt.Sprintf("%v", _m.Colors)) builder.WriteByte(')') return builder.String() } // Themes is a parsable slice of Theme. type Themes []*Theme