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