Files
polaris/ent/indexers.go
2024-08-01 17:36:40 +08:00

174 lines
5.7 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"polaris/ent/indexers"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// Indexers is the model entity for the Indexers schema.
type Indexers struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// Name holds the value of the "name" field.
Name string `json:"name,omitempty"`
// Implementation holds the value of the "implementation" field.
Implementation string `json:"implementation,omitempty"`
// Settings holds the value of the "settings" field.
Settings string `json:"settings,omitempty"`
// EnableRss holds the value of the "enable_rss" field.
EnableRss bool `json:"enable_rss,omitempty"`
// Priority holds the value of the "priority" field.
Priority int `json:"priority,omitempty"`
// minimal seed ratio requied, before removing torrent
SeedRatio float32 `json:"seed_ratio,omitempty"`
// Disabled holds the value of the "disabled" field.
Disabled bool `json:"disabled,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Indexers) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case indexers.FieldEnableRss, indexers.FieldDisabled:
values[i] = new(sql.NullBool)
case indexers.FieldSeedRatio:
values[i] = new(sql.NullFloat64)
case indexers.FieldID, indexers.FieldPriority:
values[i] = new(sql.NullInt64)
case indexers.FieldName, indexers.FieldImplementation, indexers.FieldSettings:
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 Indexers fields.
func (i *Indexers) 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 j := range columns {
switch columns[j] {
case indexers.FieldID:
value, ok := values[j].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
i.ID = int(value.Int64)
case indexers.FieldName:
if value, ok := values[j].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[j])
} else if value.Valid {
i.Name = value.String
}
case indexers.FieldImplementation:
if value, ok := values[j].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field implementation", values[j])
} else if value.Valid {
i.Implementation = value.String
}
case indexers.FieldSettings:
if value, ok := values[j].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field settings", values[j])
} else if value.Valid {
i.Settings = value.String
}
case indexers.FieldEnableRss:
if value, ok := values[j].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field enable_rss", values[j])
} else if value.Valid {
i.EnableRss = value.Bool
}
case indexers.FieldPriority:
if value, ok := values[j].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field priority", values[j])
} else if value.Valid {
i.Priority = int(value.Int64)
}
case indexers.FieldSeedRatio:
if value, ok := values[j].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field seed_ratio", values[j])
} else if value.Valid {
i.SeedRatio = float32(value.Float64)
}
case indexers.FieldDisabled:
if value, ok := values[j].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field disabled", values[j])
} else if value.Valid {
i.Disabled = value.Bool
}
default:
i.selectValues.Set(columns[j], values[j])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Indexers.
// This includes values selected through modifiers, order, etc.
func (i *Indexers) Value(name string) (ent.Value, error) {
return i.selectValues.Get(name)
}
// Update returns a builder for updating this Indexers.
// Note that you need to call Indexers.Unwrap() before calling this method if this Indexers
// was returned from a transaction, and the transaction was committed or rolled back.
func (i *Indexers) Update() *IndexersUpdateOne {
return NewIndexersClient(i.config).UpdateOne(i)
}
// Unwrap unwraps the Indexers 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 (i *Indexers) Unwrap() *Indexers {
_tx, ok := i.config.driver.(*txDriver)
if !ok {
panic("ent: Indexers is not a transactional entity")
}
i.config.driver = _tx.drv
return i
}
// String implements the fmt.Stringer.
func (i *Indexers) String() string {
var builder strings.Builder
builder.WriteString("Indexers(")
builder.WriteString(fmt.Sprintf("id=%v, ", i.ID))
builder.WriteString("name=")
builder.WriteString(i.Name)
builder.WriteString(", ")
builder.WriteString("implementation=")
builder.WriteString(i.Implementation)
builder.WriteString(", ")
builder.WriteString("settings=")
builder.WriteString(i.Settings)
builder.WriteString(", ")
builder.WriteString("enable_rss=")
builder.WriteString(fmt.Sprintf("%v", i.EnableRss))
builder.WriteString(", ")
builder.WriteString("priority=")
builder.WriteString(fmt.Sprintf("%v", i.Priority))
builder.WriteString(", ")
builder.WriteString("seed_ratio=")
builder.WriteString(fmt.Sprintf("%v", i.SeedRatio))
builder.WriteString(", ")
builder.WriteString("disabled=")
builder.WriteString(fmt.Sprintf("%v", i.Disabled))
builder.WriteByte(')')
return builder.String()
}
// IndexersSlice is a parsable slice of Indexers.
type IndexersSlice []*Indexers