202 lines
6.5 KiB
Go
202 lines
6.5 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"code.icod.de/auth/accountserver/ent/account"
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// Account is the model entity for the Account schema.
|
|
type Account struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// CreatedAt holds the value of the "created_at" field.
|
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
|
// UpdatedAt holds the value of the "updated_at" field.
|
|
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
|
// Nickname holds the value of the "nickname" field.
|
|
Nickname string `json:"nickname,omitempty"`
|
|
// Name holds the value of the "name" field.
|
|
Name string `json:"name,omitempty"`
|
|
// Secret holds the value of the "secret" field.
|
|
Secret []byte `json:"secret,omitempty"`
|
|
// Aes holds the value of the "aes" field.
|
|
Aes []byte `json:"aes,omitempty"`
|
|
// X509 holds the value of the "x509" field.
|
|
X509 []byte `json:"x509,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the AccountQuery when eager-loading is set.
|
|
Edges AccountEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// AccountEdges holds the relations/edges for other nodes in the graph.
|
|
type AccountEdges struct {
|
|
// Emails holds the value of the emails edge.
|
|
Emails []*Email `json:"emails,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [1]bool
|
|
}
|
|
|
|
// EmailsOrErr returns the Emails value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e AccountEdges) EmailsOrErr() ([]*Email, error) {
|
|
if e.loadedTypes[0] {
|
|
return e.Emails, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "emails"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*Account) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case account.FieldSecret, account.FieldAes, account.FieldX509:
|
|
values[i] = new([]byte)
|
|
case account.FieldNickname, account.FieldName:
|
|
values[i] = new(sql.NullString)
|
|
case account.FieldCreatedAt, account.FieldUpdatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
case account.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 Account fields.
|
|
func (a *Account) 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 account.FieldID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", values[i])
|
|
} else if value != nil {
|
|
a.ID = *value
|
|
}
|
|
case account.FieldCreatedAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
|
} else if value.Valid {
|
|
a.CreatedAt = value.Time
|
|
}
|
|
case account.FieldUpdatedAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
|
} else if value.Valid {
|
|
a.UpdatedAt = value.Time
|
|
}
|
|
case account.FieldNickname:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field nickname", values[i])
|
|
} else if value.Valid {
|
|
a.Nickname = value.String
|
|
}
|
|
case account.FieldName:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
|
} else if value.Valid {
|
|
a.Name = value.String
|
|
}
|
|
case account.FieldSecret:
|
|
if value, ok := values[i].(*[]byte); !ok {
|
|
return fmt.Errorf("unexpected type %T for field secret", values[i])
|
|
} else if value != nil {
|
|
a.Secret = *value
|
|
}
|
|
case account.FieldAes:
|
|
if value, ok := values[i].(*[]byte); !ok {
|
|
return fmt.Errorf("unexpected type %T for field aes", values[i])
|
|
} else if value != nil {
|
|
a.Aes = *value
|
|
}
|
|
case account.FieldX509:
|
|
if value, ok := values[i].(*[]byte); !ok {
|
|
return fmt.Errorf("unexpected type %T for field x509", values[i])
|
|
} else if value != nil {
|
|
a.X509 = *value
|
|
}
|
|
default:
|
|
a.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the Account.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (a *Account) Value(name string) (ent.Value, error) {
|
|
return a.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryEmails queries the "emails" edge of the Account entity.
|
|
func (a *Account) QueryEmails() *EmailQuery {
|
|
return NewAccountClient(a.config).QueryEmails(a)
|
|
}
|
|
|
|
// Update returns a builder for updating this Account.
|
|
// Note that you need to call Account.Unwrap() before calling this method if this Account
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (a *Account) Update() *AccountUpdateOne {
|
|
return NewAccountClient(a.config).UpdateOne(a)
|
|
}
|
|
|
|
// Unwrap unwraps the Account 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 (a *Account) Unwrap() *Account {
|
|
_tx, ok := a.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: Account is not a transactional entity")
|
|
}
|
|
a.config.driver = _tx.drv
|
|
return a
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (a *Account) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("Account(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", a.ID))
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(a.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("updated_at=")
|
|
builder.WriteString(a.UpdatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("nickname=")
|
|
builder.WriteString(a.Nickname)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("name=")
|
|
builder.WriteString(a.Name)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("secret=")
|
|
builder.WriteString(fmt.Sprintf("%v", a.Secret))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("aes=")
|
|
builder.WriteString(fmt.Sprintf("%v", a.Aes))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("x509=")
|
|
builder.WriteString(fmt.Sprintf("%v", a.X509))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// Accounts is a parsable slice of Account.
|
|
type Accounts []*Account
|