127 lines
3.9 KiB
Go
127 lines
3.9 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/settings"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// Settings is the model entity for the Settings schema.
|
|
type Settings struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// api key for the hibp service
|
|
HibpAPIKey string `json:"-"`
|
|
// api key for the dehashed.com service
|
|
DehashedAPIKey string `json:"-"`
|
|
// the number of searches performed
|
|
Searches uint64 `json:"searches,omitempty"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*Settings) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case settings.FieldSearches:
|
|
values[i] = new(sql.NullInt64)
|
|
case settings.FieldHibpAPIKey, settings.FieldDehashedAPIKey:
|
|
values[i] = new(sql.NullString)
|
|
case settings.FieldID:
|
|
values[i] = new(uuid.UUID)
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the Settings fields.
|
|
func (s *Settings) 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 settings.FieldID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", values[i])
|
|
} else if value != nil {
|
|
s.ID = *value
|
|
}
|
|
case settings.FieldHibpAPIKey:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field hibp_api_key", values[i])
|
|
} else if value.Valid {
|
|
s.HibpAPIKey = value.String
|
|
}
|
|
case settings.FieldDehashedAPIKey:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field dehashed_api_key", values[i])
|
|
} else if value.Valid {
|
|
s.DehashedAPIKey = value.String
|
|
}
|
|
case settings.FieldSearches:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field searches", values[i])
|
|
} else if value.Valid {
|
|
s.Searches = uint64(value.Int64)
|
|
}
|
|
default:
|
|
s.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the Settings.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (s *Settings) Value(name string) (ent.Value, error) {
|
|
return s.selectValues.Get(name)
|
|
}
|
|
|
|
// Update returns a builder for updating this Settings.
|
|
// Note that you need to call Settings.Unwrap() before calling this method if this Settings
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (s *Settings) Update() *SettingsUpdateOne {
|
|
return NewSettingsClient(s.config).UpdateOne(s)
|
|
}
|
|
|
|
// Unwrap unwraps the Settings 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 (s *Settings) Unwrap() *Settings {
|
|
_tx, ok := s.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: Settings is not a transactional entity")
|
|
}
|
|
s.config.driver = _tx.drv
|
|
return s
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (s *Settings) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("Settings(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", s.ID))
|
|
builder.WriteString("hibp_api_key=<sensitive>")
|
|
builder.WriteString(", ")
|
|
builder.WriteString("dehashed_api_key=<sensitive>")
|
|
builder.WriteString(", ")
|
|
builder.WriteString("searches=")
|
|
builder.WriteString(fmt.Sprintf("%v", s.Searches))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// SettingsSlice is a parsable slice of Settings.
|
|
type SettingsSlice []*Settings
|