// Code generated by entc, 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/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"` } // 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.loadedTypes[0] { if e.Domain == nil { // The edge domain was loaded in eager-loading, // but was not found. return nil, &NotFoundError{label: domain.Label} } return e.Domain, nil } return nil, &NotLoadedError{edge: "domain"} } // scanValues returns the types for scanning values from sql.Rows. func (*Alias) scanValues(columns []string) ([]interface{}, error) { values := make([]interface{}, 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: return nil, fmt.Errorf("unexpected column %q for type Alias", columns[i]) } } 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 []interface{}) 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 } } } return nil } // QueryDomain queries the "domain" edge of the Alias entity. func (a *Alias) QueryDomain() *DomainQuery { return (&AliasClient{config: 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 (&AliasClient{config: 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)) if v := a.Modified; v != nil { builder.WriteString(", modified=") builder.WriteString(v.Format(time.ANSIC)) } builder.WriteString(", domain_id=") builder.WriteString(fmt.Sprintf("%v", a.DomainID)) builder.WriteString(", goto=") builder.WriteString(a.Goto) 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 func (a AliasSlice) config(cfg config) { for _i := range a { a[_i].config = cfg } }