A continuation of HomeBox the inventory and organization system built for the Home User
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/export"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
)
// Export is the model entity for the Export schema.
type Export 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"`
// GroupID holds the value of the "group_id" field.
GroupID uuid.UUID `json:"group_id,omitempty"`
// Kind holds the value of the "kind" field.
Kind export.Kind `json:"kind,omitempty"`
// Status holds the value of the "status" field.
Status export.Status `json:"status,omitempty"`
// Progress holds the value of the "progress" field.
Progress int `json:"progress,omitempty"`
// ArtifactPath holds the value of the "artifact_path" field.
ArtifactPath string `json:"artifact_path,omitempty"`
// SizeBytes holds the value of the "size_bytes" field.
SizeBytes int64 `json:"size_bytes,omitempty"`
// Error holds the value of the "error" field.
Error string `json:"error,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the ExportQuery when eager-loading is set.
Edges ExportEdges `json:"edges"`
selectValues sql.SelectValues
}
// ExportEdges holds the relations/edges for other nodes in the graph.
type ExportEdges struct {
// Group holds the value of the group edge.
Group *Group `json:"group,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool
}
// GroupOrErr returns the Group value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e ExportEdges) GroupOrErr() (*Group, error) {
if e.Group != nil {
return e.Group, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: group.Label}
}
return nil, &NotLoadedError{edge: "group"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Export) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case export.FieldProgress, export.FieldSizeBytes:
values[i] = new(sql.NullInt64)
case export.FieldKind, export.FieldStatus, export.FieldArtifactPath, export.FieldError:
values[i] = new(sql.NullString)
case export.FieldCreatedAt, export.FieldUpdatedAt:
values[i] = new(sql.NullTime)
case export.FieldID, export.FieldGroupID:
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 Export fields.
func (_m *Export) 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 export.FieldID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field id", values[i])
} else if value != nil {
_m.ID = *value
}
case export.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 {
_m.CreatedAt = value.Time
}
case export.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 {
_m.UpdatedAt = value.Time
}
case export.FieldGroupID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field group_id", values[i])
} else if value != nil {
_m.GroupID = *value
}
case export.FieldKind:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field kind", values[i])
} else if value.Valid {
_m.Kind = export.Kind(value.String)
}
case export.FieldStatus:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
_m.Status = export.Status(value.String)
}
case export.FieldProgress:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field progress", values[i])
} else if value.Valid {
_m.Progress = int(value.Int64)
}
case export.FieldArtifactPath:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field artifact_path", values[i])
} else if value.Valid {
_m.ArtifactPath = value.String
}
case export.FieldSizeBytes:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field size_bytes", values[i])
} else if value.Valid {
_m.SizeBytes = value.Int64
}
case export.FieldError:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field error", values[i])
} else if value.Valid {
_m.Error = value.String
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Export.
// This includes values selected through modifiers, order, etc.
func (_m *Export) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryGroup queries the "group" edge of the Export entity.
func (_m *Export) QueryGroup() *GroupQuery {
return NewExportClient(_m.config).QueryGroup(_m)
}
// Update returns a builder for updating this Export.
// Note that you need to call Export.Unwrap() before calling this method if this Export
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *Export) Update() *ExportUpdateOne {
return NewExportClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the Export 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 (_m *Export) Unwrap() *Export {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: Export is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *Export) String() string {
var builder strings.Builder
builder.WriteString("Export(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("group_id=")
builder.WriteString(fmt.Sprintf("%v", _m.GroupID))
builder.WriteString(", ")
builder.WriteString("kind=")
builder.WriteString(fmt.Sprintf("%v", _m.Kind))
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", _m.Status))
builder.WriteString(", ")
builder.WriteString("progress=")
builder.WriteString(fmt.Sprintf("%v", _m.Progress))
builder.WriteString(", ")
builder.WriteString("artifact_path=")
builder.WriteString(_m.ArtifactPath)
builder.WriteString(", ")
builder.WriteString("size_bytes=")
builder.WriteString(fmt.Sprintf("%v", _m.SizeBytes))
builder.WriteString(", ")
builder.WriteString("error=")
builder.WriteString(_m.Error)
builder.WriteByte(')')
return builder.String()
}
// Exports is a parsable slice of Export.
type Exports []*Export