homebox/backend/internal/data/ent/maintenanceentry.go
Hayden a3e607a887 chore: bump all go deps (#507)
* bump all deps

* run code-gen

Former-commit-id: a042496c71
2023-07-22 19:57:51 -08:00

217 lines
7.7 KiB
Go

// 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/hay-kot/homebox/backend/internal/data/ent/item"
"github.com/hay-kot/homebox/backend/internal/data/ent/maintenanceentry"
)
// MaintenanceEntry is the model entity for the MaintenanceEntry schema.
type MaintenanceEntry 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"`
// ItemID holds the value of the "item_id" field.
ItemID uuid.UUID `json:"item_id,omitempty"`
// Date holds the value of the "date" field.
Date time.Time `json:"date,omitempty"`
// ScheduledDate holds the value of the "scheduled_date" field.
ScheduledDate time.Time `json:"scheduled_date,omitempty"`
// Name holds the value of the "name" field.
Name string `json:"name,omitempty"`
// Description holds the value of the "description" field.
Description string `json:"description,omitempty"`
// Cost holds the value of the "cost" field.
Cost float64 `json:"cost,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the MaintenanceEntryQuery when eager-loading is set.
Edges MaintenanceEntryEdges `json:"edges"`
selectValues sql.SelectValues
}
// MaintenanceEntryEdges holds the relations/edges for other nodes in the graph.
type MaintenanceEntryEdges struct {
// Item holds the value of the item edge.
Item *Item `json:"item,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool
}
// ItemOrErr returns the Item value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e MaintenanceEntryEdges) ItemOrErr() (*Item, error) {
if e.loadedTypes[0] {
if e.Item == nil {
// Edge was loaded but was not found.
return nil, &NotFoundError{label: item.Label}
}
return e.Item, nil
}
return nil, &NotLoadedError{edge: "item"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*MaintenanceEntry) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case maintenanceentry.FieldCost:
values[i] = new(sql.NullFloat64)
case maintenanceentry.FieldName, maintenanceentry.FieldDescription:
values[i] = new(sql.NullString)
case maintenanceentry.FieldCreatedAt, maintenanceentry.FieldUpdatedAt, maintenanceentry.FieldDate, maintenanceentry.FieldScheduledDate:
values[i] = new(sql.NullTime)
case maintenanceentry.FieldID, maintenanceentry.FieldItemID:
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 MaintenanceEntry fields.
func (me *MaintenanceEntry) 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 maintenanceentry.FieldID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field id", values[i])
} else if value != nil {
me.ID = *value
}
case maintenanceentry.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 {
me.CreatedAt = value.Time
}
case maintenanceentry.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 {
me.UpdatedAt = value.Time
}
case maintenanceentry.FieldItemID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field item_id", values[i])
} else if value != nil {
me.ItemID = *value
}
case maintenanceentry.FieldDate:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field date", values[i])
} else if value.Valid {
me.Date = value.Time
}
case maintenanceentry.FieldScheduledDate:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field scheduled_date", values[i])
} else if value.Valid {
me.ScheduledDate = value.Time
}
case maintenanceentry.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
me.Name = value.String
}
case maintenanceentry.FieldDescription:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field description", values[i])
} else if value.Valid {
me.Description = value.String
}
case maintenanceentry.FieldCost:
if value, ok := values[i].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field cost", values[i])
} else if value.Valid {
me.Cost = value.Float64
}
default:
me.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the MaintenanceEntry.
// This includes values selected through modifiers, order, etc.
func (me *MaintenanceEntry) Value(name string) (ent.Value, error) {
return me.selectValues.Get(name)
}
// QueryItem queries the "item" edge of the MaintenanceEntry entity.
func (me *MaintenanceEntry) QueryItem() *ItemQuery {
return NewMaintenanceEntryClient(me.config).QueryItem(me)
}
// Update returns a builder for updating this MaintenanceEntry.
// Note that you need to call MaintenanceEntry.Unwrap() before calling this method if this MaintenanceEntry
// was returned from a transaction, and the transaction was committed or rolled back.
func (me *MaintenanceEntry) Update() *MaintenanceEntryUpdateOne {
return NewMaintenanceEntryClient(me.config).UpdateOne(me)
}
// Unwrap unwraps the MaintenanceEntry 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 (me *MaintenanceEntry) Unwrap() *MaintenanceEntry {
_tx, ok := me.config.driver.(*txDriver)
if !ok {
panic("ent: MaintenanceEntry is not a transactional entity")
}
me.config.driver = _tx.drv
return me
}
// String implements the fmt.Stringer.
func (me *MaintenanceEntry) String() string {
var builder strings.Builder
builder.WriteString("MaintenanceEntry(")
builder.WriteString(fmt.Sprintf("id=%v, ", me.ID))
builder.WriteString("created_at=")
builder.WriteString(me.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(me.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("item_id=")
builder.WriteString(fmt.Sprintf("%v", me.ItemID))
builder.WriteString(", ")
builder.WriteString("date=")
builder.WriteString(me.Date.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("scheduled_date=")
builder.WriteString(me.ScheduledDate.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("name=")
builder.WriteString(me.Name)
builder.WriteString(", ")
builder.WriteString("description=")
builder.WriteString(me.Description)
builder.WriteString(", ")
builder.WriteString("cost=")
builder.WriteString(fmt.Sprintf("%v", me.Cost))
builder.WriteByte(')')
return builder.String()
}
// MaintenanceEntries is a parsable slice of MaintenanceEntry.
type MaintenanceEntries []*MaintenanceEntry