zkt24/z2/backend/ent/validators.go
2024-04-25 13:51:47 +02:00

150 lines
4.7 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"thesis/ent/validators"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// Validators is the model entity for the Validators schema.
type Validators struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// Facilitator holds the value of the "facilitator" field.
Facilitator string `json:"facilitator,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the ValidatorsQuery when eager-loading is set.
Edges ValidatorsEdges `json:"edges"`
blocks_caster *int
white_list_sponsor *int
selectValues sql.SelectValues
}
// ValidatorsEdges holds the relations/edges for other nodes in the graph.
type ValidatorsEdges struct {
// Key holds the value of the key edge.
Key []*Key `json:"key,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool
}
// KeyOrErr returns the Key value or an error if the edge
// was not loaded in eager-loading.
func (e ValidatorsEdges) KeyOrErr() ([]*Key, error) {
if e.loadedTypes[0] {
return e.Key, nil
}
return nil, &NotLoadedError{edge: "key"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Validators) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case validators.FieldID:
values[i] = new(sql.NullInt64)
case validators.FieldFacilitator:
values[i] = new(sql.NullString)
case validators.ForeignKeys[0]: // blocks_caster
values[i] = new(sql.NullInt64)
case validators.ForeignKeys[1]: // white_list_sponsor
values[i] = new(sql.NullInt64)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Validators fields.
func (v *Validators) 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 validators.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
v.ID = int(value.Int64)
case validators.FieldFacilitator:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field facilitator", values[i])
} else if value.Valid {
v.Facilitator = value.String
}
case validators.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for edge-field blocks_caster", value)
} else if value.Valid {
v.blocks_caster = new(int)
*v.blocks_caster = int(value.Int64)
}
case validators.ForeignKeys[1]:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for edge-field white_list_sponsor", value)
} else if value.Valid {
v.white_list_sponsor = new(int)
*v.white_list_sponsor = int(value.Int64)
}
default:
v.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Validators.
// This includes values selected through modifiers, order, etc.
func (v *Validators) Value(name string) (ent.Value, error) {
return v.selectValues.Get(name)
}
// QueryKey queries the "key" edge of the Validators entity.
func (v *Validators) QueryKey() *KeyQuery {
return NewValidatorsClient(v.config).QueryKey(v)
}
// Update returns a builder for updating this Validators.
// Note that you need to call Validators.Unwrap() before calling this method if this Validators
// was returned from a transaction, and the transaction was committed or rolled back.
func (v *Validators) Update() *ValidatorsUpdateOne {
return NewValidatorsClient(v.config).UpdateOne(v)
}
// Unwrap unwraps the Validators 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 (v *Validators) Unwrap() *Validators {
_tx, ok := v.config.driver.(*txDriver)
if !ok {
panic("ent: Validators is not a transactional entity")
}
v.config.driver = _tx.drv
return v
}
// String implements the fmt.Stringer.
func (v *Validators) String() string {
var builder strings.Builder
builder.WriteString("Validators(")
builder.WriteString(fmt.Sprintf("id=%v, ", v.ID))
builder.WriteString("facilitator=")
builder.WriteString(v.Facilitator)
builder.WriteByte(')')
return builder.String()
}
// ValidatorsSlice is a parsable slice of Validators.
type ValidatorsSlice []*Validators