185 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			185 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
// Code generated by ent, DO NOT EDIT.
 | 
						|
 | 
						|
package ent
 | 
						|
 | 
						|
import (
 | 
						|
	"fmt"
 | 
						|
	"strings"
 | 
						|
	"time"
 | 
						|
 | 
						|
	"code.icod.de/postfix/manager/ent/alias"
 | 
						|
	"code.icod.de/postfix/manager/ent/domain"
 | 
						|
	"entgo.io/ent"
 | 
						|
	"entgo.io/ent/dialect/sql"
 | 
						|
)
 | 
						|
 | 
						|
// Alias is the model entity for the Alias schema.
 | 
						|
type Alias struct {
 | 
						|
	config `json:"-"`
 | 
						|
	// ID of the ent.
 | 
						|
	ID int64 `json:"id,omitempty"`
 | 
						|
	// Created holds the value of the "created" field.
 | 
						|
	Created time.Time `json:"created,omitempty"`
 | 
						|
	// Modified holds the value of the "modified" field.
 | 
						|
	Modified *time.Time `json:"modified,omitempty"`
 | 
						|
	// DomainID holds the value of the "domain_id" field.
 | 
						|
	DomainID int64 `json:"domain_id,omitempty"`
 | 
						|
	// Goto holds the value of the "goto" field.
 | 
						|
	Goto string `json:"goto,omitempty"`
 | 
						|
	// Active holds the value of the "active" field.
 | 
						|
	Active bool `json:"active,omitempty"`
 | 
						|
	// Edges holds the relations/edges for other nodes in the graph.
 | 
						|
	// The values are being populated by the AliasQuery when eager-loading is set.
 | 
						|
	Edges        AliasEdges `json:"edges"`
 | 
						|
	selectValues sql.SelectValues
 | 
						|
}
 | 
						|
 | 
						|
// AliasEdges holds the relations/edges for other nodes in the graph.
 | 
						|
type AliasEdges struct {
 | 
						|
	// Domain holds the value of the domain edge.
 | 
						|
	Domain *Domain `json:"domain,omitempty"`
 | 
						|
	// loadedTypes holds the information for reporting if a
 | 
						|
	// type was loaded (or requested) in eager-loading or not.
 | 
						|
	loadedTypes [1]bool
 | 
						|
}
 | 
						|
 | 
						|
// DomainOrErr returns the Domain value or an error if the edge
 | 
						|
// was not loaded in eager-loading, or loaded but was not found.
 | 
						|
func (e AliasEdges) DomainOrErr() (*Domain, error) {
 | 
						|
	if e.Domain != nil {
 | 
						|
		return e.Domain, nil
 | 
						|
	} else if e.loadedTypes[0] {
 | 
						|
		return nil, &NotFoundError{label: domain.Label}
 | 
						|
	}
 | 
						|
	return nil, &NotLoadedError{edge: "domain"}
 | 
						|
}
 | 
						|
 | 
						|
// scanValues returns the types for scanning values from sql.Rows.
 | 
						|
func (*Alias) scanValues(columns []string) ([]any, error) {
 | 
						|
	values := make([]any, len(columns))
 | 
						|
	for i := range columns {
 | 
						|
		switch columns[i] {
 | 
						|
		case alias.FieldActive:
 | 
						|
			values[i] = new(sql.NullBool)
 | 
						|
		case alias.FieldID, alias.FieldDomainID:
 | 
						|
			values[i] = new(sql.NullInt64)
 | 
						|
		case alias.FieldGoto:
 | 
						|
			values[i] = new(sql.NullString)
 | 
						|
		case alias.FieldCreated, alias.FieldModified:
 | 
						|
			values[i] = new(sql.NullTime)
 | 
						|
		default:
 | 
						|
			values[i] = new(sql.UnknownType)
 | 
						|
		}
 | 
						|
	}
 | 
						|
	return values, nil
 | 
						|
}
 | 
						|
 | 
						|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
 | 
						|
// to the Alias fields.
 | 
						|
func (a *Alias) 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 alias.FieldID:
 | 
						|
			value, ok := values[i].(*sql.NullInt64)
 | 
						|
			if !ok {
 | 
						|
				return fmt.Errorf("unexpected type %T for field id", value)
 | 
						|
			}
 | 
						|
			a.ID = int64(value.Int64)
 | 
						|
		case alias.FieldCreated:
 | 
						|
			if value, ok := values[i].(*sql.NullTime); !ok {
 | 
						|
				return fmt.Errorf("unexpected type %T for field created", values[i])
 | 
						|
			} else if value.Valid {
 | 
						|
				a.Created = value.Time
 | 
						|
			}
 | 
						|
		case alias.FieldModified:
 | 
						|
			if value, ok := values[i].(*sql.NullTime); !ok {
 | 
						|
				return fmt.Errorf("unexpected type %T for field modified", values[i])
 | 
						|
			} else if value.Valid {
 | 
						|
				a.Modified = new(time.Time)
 | 
						|
				*a.Modified = value.Time
 | 
						|
			}
 | 
						|
		case alias.FieldDomainID:
 | 
						|
			if value, ok := values[i].(*sql.NullInt64); !ok {
 | 
						|
				return fmt.Errorf("unexpected type %T for field domain_id", values[i])
 | 
						|
			} else if value.Valid {
 | 
						|
				a.DomainID = value.Int64
 | 
						|
			}
 | 
						|
		case alias.FieldGoto:
 | 
						|
			if value, ok := values[i].(*sql.NullString); !ok {
 | 
						|
				return fmt.Errorf("unexpected type %T for field goto", values[i])
 | 
						|
			} else if value.Valid {
 | 
						|
				a.Goto = value.String
 | 
						|
			}
 | 
						|
		case alias.FieldActive:
 | 
						|
			if value, ok := values[i].(*sql.NullBool); !ok {
 | 
						|
				return fmt.Errorf("unexpected type %T for field active", values[i])
 | 
						|
			} else if value.Valid {
 | 
						|
				a.Active = value.Bool
 | 
						|
			}
 | 
						|
		default:
 | 
						|
			a.selectValues.Set(columns[i], values[i])
 | 
						|
		}
 | 
						|
	}
 | 
						|
	return nil
 | 
						|
}
 | 
						|
 | 
						|
// Value returns the ent.Value that was dynamically selected and assigned to the Alias.
 | 
						|
// This includes values selected through modifiers, order, etc.
 | 
						|
func (a *Alias) Value(name string) (ent.Value, error) {
 | 
						|
	return a.selectValues.Get(name)
 | 
						|
}
 | 
						|
 | 
						|
// QueryDomain queries the "domain" edge of the Alias entity.
 | 
						|
func (a *Alias) QueryDomain() *DomainQuery {
 | 
						|
	return NewAliasClient(a.config).QueryDomain(a)
 | 
						|
}
 | 
						|
 | 
						|
// Update returns a builder for updating this Alias.
 | 
						|
// Note that you need to call Alias.Unwrap() before calling this method if this Alias
 | 
						|
// was returned from a transaction, and the transaction was committed or rolled back.
 | 
						|
func (a *Alias) Update() *AliasUpdateOne {
 | 
						|
	return NewAliasClient(a.config).UpdateOne(a)
 | 
						|
}
 | 
						|
 | 
						|
// Unwrap unwraps the Alias 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 *Alias) Unwrap() *Alias {
 | 
						|
	_tx, ok := a.config.driver.(*txDriver)
 | 
						|
	if !ok {
 | 
						|
		panic("ent: Alias is not a transactional entity")
 | 
						|
	}
 | 
						|
	a.config.driver = _tx.drv
 | 
						|
	return a
 | 
						|
}
 | 
						|
 | 
						|
// String implements the fmt.Stringer.
 | 
						|
func (a *Alias) String() string {
 | 
						|
	var builder strings.Builder
 | 
						|
	builder.WriteString("Alias(")
 | 
						|
	builder.WriteString(fmt.Sprintf("id=%v, ", a.ID))
 | 
						|
	builder.WriteString("created=")
 | 
						|
	builder.WriteString(a.Created.Format(time.ANSIC))
 | 
						|
	builder.WriteString(", ")
 | 
						|
	if v := a.Modified; v != nil {
 | 
						|
		builder.WriteString("modified=")
 | 
						|
		builder.WriteString(v.Format(time.ANSIC))
 | 
						|
	}
 | 
						|
	builder.WriteString(", ")
 | 
						|
	builder.WriteString("domain_id=")
 | 
						|
	builder.WriteString(fmt.Sprintf("%v", a.DomainID))
 | 
						|
	builder.WriteString(", ")
 | 
						|
	builder.WriteString("goto=")
 | 
						|
	builder.WriteString(a.Goto)
 | 
						|
	builder.WriteString(", ")
 | 
						|
	builder.WriteString("active=")
 | 
						|
	builder.WriteString(fmt.Sprintf("%v", a.Active))
 | 
						|
	builder.WriteByte(')')
 | 
						|
	return builder.String()
 | 
						|
}
 | 
						|
 | 
						|
// AliasSlice is a parsable slice of Alias.
 | 
						|
type AliasSlice []*Alias
 |