// Code generated by ent, DO NOT EDIT. package ent import ( "fmt" "strings" "code.icod.de/auth/accountserver/ent/account" "code.icod.de/auth/accountserver/ent/email" "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/google/uuid" ) // Email is the model entity for the Email schema. type Email struct { config `json:"-"` // ID of the ent. ID uuid.UUID `json:"id,omitempty"` // Email holds the value of the "email" field. Email string `json:"email,omitempty"` // Primary holds the value of the "primary" field. Primary bool `json:"primary,omitempty"` // Verified holds the value of the "verified" field. Verified bool `json:"verified,omitempty"` // VerificationCode holds the value of the "verification_code" field. VerificationCode string `json:"verification_code,omitempty"` // ResetCode holds the value of the "reset_code" field. ResetCode string `json:"reset_code,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the EmailQuery when eager-loading is set. Edges EmailEdges `json:"edges"` account_emails *uuid.UUID selectValues sql.SelectValues } // EmailEdges holds the relations/edges for other nodes in the graph. type EmailEdges struct { // Accounts holds the value of the accounts edge. Accounts *Account `json:"accounts,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [1]bool } // AccountsOrErr returns the Accounts value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e EmailEdges) AccountsOrErr() (*Account, error) { if e.Accounts != nil { return e.Accounts, nil } else if e.loadedTypes[0] { return nil, &NotFoundError{label: account.Label} } return nil, &NotLoadedError{edge: "accounts"} } // scanValues returns the types for scanning values from sql.Rows. func (*Email) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case email.FieldPrimary, email.FieldVerified: values[i] = new(sql.NullBool) case email.FieldEmail, email.FieldVerificationCode, email.FieldResetCode: values[i] = new(sql.NullString) case email.FieldID: values[i] = new(uuid.UUID) case email.ForeignKeys[0]: // account_emails values[i] = &sql.NullScanner{S: 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 Email fields. func (e *Email) 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 email.FieldID: if value, ok := values[i].(*uuid.UUID); !ok { return fmt.Errorf("unexpected type %T for field id", values[i]) } else if value != nil { e.ID = *value } case email.FieldEmail: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field email", values[i]) } else if value.Valid { e.Email = value.String } case email.FieldPrimary: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field primary", values[i]) } else if value.Valid { e.Primary = value.Bool } case email.FieldVerified: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field verified", values[i]) } else if value.Valid { e.Verified = value.Bool } case email.FieldVerificationCode: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field verification_code", values[i]) } else if value.Valid { e.VerificationCode = value.String } case email.FieldResetCode: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field reset_code", values[i]) } else if value.Valid { e.ResetCode = value.String } case email.ForeignKeys[0]: if value, ok := values[i].(*sql.NullScanner); !ok { return fmt.Errorf("unexpected type %T for field account_emails", values[i]) } else if value.Valid { e.account_emails = new(uuid.UUID) *e.account_emails = *value.S.(*uuid.UUID) } default: e.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the Email. // This includes values selected through modifiers, order, etc. func (e *Email) Value(name string) (ent.Value, error) { return e.selectValues.Get(name) } // QueryAccounts queries the "accounts" edge of the Email entity. func (e *Email) QueryAccounts() *AccountQuery { return NewEmailClient(e.config).QueryAccounts(e) } // Update returns a builder for updating this Email. // Note that you need to call Email.Unwrap() before calling this method if this Email // was returned from a transaction, and the transaction was committed or rolled back. func (e *Email) Update() *EmailUpdateOne { return NewEmailClient(e.config).UpdateOne(e) } // Unwrap unwraps the Email 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 (e *Email) Unwrap() *Email { _tx, ok := e.config.driver.(*txDriver) if !ok { panic("ent: Email is not a transactional entity") } e.config.driver = _tx.drv return e } // String implements the fmt.Stringer. func (e *Email) String() string { var builder strings.Builder builder.WriteString("Email(") builder.WriteString(fmt.Sprintf("id=%v, ", e.ID)) builder.WriteString("email=") builder.WriteString(e.Email) builder.WriteString(", ") builder.WriteString("primary=") builder.WriteString(fmt.Sprintf("%v", e.Primary)) builder.WriteString(", ") builder.WriteString("verified=") builder.WriteString(fmt.Sprintf("%v", e.Verified)) builder.WriteString(", ") builder.WriteString("verification_code=") builder.WriteString(e.VerificationCode) builder.WriteString(", ") builder.WriteString("reset_code=") builder.WriteString(e.ResetCode) builder.WriteByte(')') return builder.String() } // Emails is a parsable slice of Email. type Emails []*Email