200 lines
6.4 KiB
Go
200 lines
6.4 KiB
Go
|
// Code generated by entc, DO NOT EDIT.
|
||
|
|
||
|
package ent
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"strings"
|
||
|
"time"
|
||
|
|
||
|
"code.icod.de/postfix/manager/ent/account"
|
||
|
"code.icod.de/postfix/manager/ent/domain"
|
||
|
"code.icod.de/postfix/manager/ent/logentry"
|
||
|
"entgo.io/ent/dialect/sql"
|
||
|
)
|
||
|
|
||
|
// Logentry is the model entity for the Logentry schema.
|
||
|
type Logentry struct {
|
||
|
config `json:"-"`
|
||
|
// ID of the ent.
|
||
|
ID int64 `json:"id,omitempty"`
|
||
|
// Timestamp holds the value of the "timestamp" field.
|
||
|
Timestamp time.Time `json:"timestamp,omitempty"`
|
||
|
// Action holds the value of the "action" field.
|
||
|
Action string `json:"action,omitempty"`
|
||
|
// Data holds the value of the "data" field.
|
||
|
Data *string `json:"data,omitempty"`
|
||
|
// AccountID holds the value of the "account_id" field.
|
||
|
AccountID int64 `json:"account_id,omitempty"`
|
||
|
// DomainID holds the value of the "domain_id" field.
|
||
|
DomainID int64 `json:"domain_id,omitempty"`
|
||
|
// Edges holds the relations/edges for other nodes in the graph.
|
||
|
// The values are being populated by the LogentryQuery when eager-loading is set.
|
||
|
Edges LogentryEdges `json:"edges"`
|
||
|
}
|
||
|
|
||
|
// LogentryEdges holds the relations/edges for other nodes in the graph.
|
||
|
type LogentryEdges struct {
|
||
|
// Account holds the value of the account edge.
|
||
|
Account *Account `json:"account,omitempty"`
|
||
|
// 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 [2]bool
|
||
|
}
|
||
|
|
||
|
// AccountOrErr returns the Account value or an error if the edge
|
||
|
// was not loaded in eager-loading, or loaded but was not found.
|
||
|
func (e LogentryEdges) AccountOrErr() (*Account, error) {
|
||
|
if e.loadedTypes[0] {
|
||
|
if e.Account == nil {
|
||
|
// The edge account was loaded in eager-loading,
|
||
|
// but was not found.
|
||
|
return nil, &NotFoundError{label: account.Label}
|
||
|
}
|
||
|
return e.Account, nil
|
||
|
}
|
||
|
return nil, &NotLoadedError{edge: "account"}
|
||
|
}
|
||
|
|
||
|
// 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 LogentryEdges) DomainOrErr() (*Domain, error) {
|
||
|
if e.loadedTypes[1] {
|
||
|
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 (*Logentry) scanValues(columns []string) ([]interface{}, error) {
|
||
|
values := make([]interface{}, len(columns))
|
||
|
for i := range columns {
|
||
|
switch columns[i] {
|
||
|
case logentry.FieldID, logentry.FieldAccountID, logentry.FieldDomainID:
|
||
|
values[i] = new(sql.NullInt64)
|
||
|
case logentry.FieldAction, logentry.FieldData:
|
||
|
values[i] = new(sql.NullString)
|
||
|
case logentry.FieldTimestamp:
|
||
|
values[i] = new(sql.NullTime)
|
||
|
default:
|
||
|
return nil, fmt.Errorf("unexpected column %q for type Logentry", columns[i])
|
||
|
}
|
||
|
}
|
||
|
return values, nil
|
||
|
}
|
||
|
|
||
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||
|
// to the Logentry fields.
|
||
|
func (l *Logentry) 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 logentry.FieldID:
|
||
|
value, ok := values[i].(*sql.NullInt64)
|
||
|
if !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field id", value)
|
||
|
}
|
||
|
l.ID = int64(value.Int64)
|
||
|
case logentry.FieldTimestamp:
|
||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field timestamp", values[i])
|
||
|
} else if value.Valid {
|
||
|
l.Timestamp = value.Time
|
||
|
}
|
||
|
case logentry.FieldAction:
|
||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field action", values[i])
|
||
|
} else if value.Valid {
|
||
|
l.Action = value.String
|
||
|
}
|
||
|
case logentry.FieldData:
|
||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field data", values[i])
|
||
|
} else if value.Valid {
|
||
|
l.Data = new(string)
|
||
|
*l.Data = value.String
|
||
|
}
|
||
|
case logentry.FieldAccountID:
|
||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field account_id", values[i])
|
||
|
} else if value.Valid {
|
||
|
l.AccountID = value.Int64
|
||
|
}
|
||
|
case logentry.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 {
|
||
|
l.DomainID = value.Int64
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// QueryAccount queries the "account" edge of the Logentry entity.
|
||
|
func (l *Logentry) QueryAccount() *AccountQuery {
|
||
|
return (&LogentryClient{config: l.config}).QueryAccount(l)
|
||
|
}
|
||
|
|
||
|
// QueryDomain queries the "domain" edge of the Logentry entity.
|
||
|
func (l *Logentry) QueryDomain() *DomainQuery {
|
||
|
return (&LogentryClient{config: l.config}).QueryDomain(l)
|
||
|
}
|
||
|
|
||
|
// Update returns a builder for updating this Logentry.
|
||
|
// Note that you need to call Logentry.Unwrap() before calling this method if this Logentry
|
||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||
|
func (l *Logentry) Update() *LogentryUpdateOne {
|
||
|
return (&LogentryClient{config: l.config}).UpdateOne(l)
|
||
|
}
|
||
|
|
||
|
// Unwrap unwraps the Logentry 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 (l *Logentry) Unwrap() *Logentry {
|
||
|
tx, ok := l.config.driver.(*txDriver)
|
||
|
if !ok {
|
||
|
panic("ent: Logentry is not a transactional entity")
|
||
|
}
|
||
|
l.config.driver = tx.drv
|
||
|
return l
|
||
|
}
|
||
|
|
||
|
// String implements the fmt.Stringer.
|
||
|
func (l *Logentry) String() string {
|
||
|
var builder strings.Builder
|
||
|
builder.WriteString("Logentry(")
|
||
|
builder.WriteString(fmt.Sprintf("id=%v", l.ID))
|
||
|
builder.WriteString(", timestamp=")
|
||
|
builder.WriteString(l.Timestamp.Format(time.ANSIC))
|
||
|
builder.WriteString(", action=")
|
||
|
builder.WriteString(l.Action)
|
||
|
if v := l.Data; v != nil {
|
||
|
builder.WriteString(", data=")
|
||
|
builder.WriteString(*v)
|
||
|
}
|
||
|
builder.WriteString(", account_id=")
|
||
|
builder.WriteString(fmt.Sprintf("%v", l.AccountID))
|
||
|
builder.WriteString(", domain_id=")
|
||
|
builder.WriteString(fmt.Sprintf("%v", l.DomainID))
|
||
|
builder.WriteByte(')')
|
||
|
return builder.String()
|
||
|
}
|
||
|
|
||
|
// Logentries is a parsable slice of Logentry.
|
||
|
type Logentries []*Logentry
|
||
|
|
||
|
func (l Logentries) config(cfg config) {
|
||
|
for _i := range l {
|
||
|
l[_i].config = cfg
|
||
|
}
|
||
|
}
|