Files
homebox/backend/internal/data/ent/entityfield.go
2025-12-13 21:23:45 -05:00

239 lines
8.5 KiB
Go
Generated

// 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/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield"
)
// EntityField is the model entity for the EntityField schema.
type EntityField 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"`
// 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"`
// Type holds the value of the "type" field.
Type entityfield.Type `json:"type,omitempty"`
// TextValue holds the value of the "text_value" field.
TextValue string `json:"text_value,omitempty"`
// NumberValue holds the value of the "number_value" field.
NumberValue int `json:"number_value,omitempty"`
// BooleanValue holds the value of the "boolean_value" field.
BooleanValue bool `json:"boolean_value,omitempty"`
// TimeValue holds the value of the "time_value" field.
TimeValue time.Time `json:"time_value,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the EntityFieldQuery when eager-loading is set.
Edges EntityFieldEdges `json:"edges"`
entity_fields *uuid.UUID
selectValues sql.SelectValues
}
// EntityFieldEdges holds the relations/edges for other nodes in the graph.
type EntityFieldEdges struct {
// Entity holds the value of the entity edge.
Entity *Entity `json:"entity,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool
}
// EntityOrErr returns the Entity value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e EntityFieldEdges) EntityOrErr() (*Entity, error) {
if e.Entity != nil {
return e.Entity, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: entity.Label}
}
return nil, &NotLoadedError{edge: "entity"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*EntityField) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case entityfield.FieldBooleanValue:
values[i] = new(sql.NullBool)
case entityfield.FieldNumberValue:
values[i] = new(sql.NullInt64)
case entityfield.FieldName, entityfield.FieldDescription, entityfield.FieldType, entityfield.FieldTextValue:
values[i] = new(sql.NullString)
case entityfield.FieldCreatedAt, entityfield.FieldUpdatedAt, entityfield.FieldTimeValue:
values[i] = new(sql.NullTime)
case entityfield.FieldID:
values[i] = new(uuid.UUID)
case entityfield.ForeignKeys[0]: // entity_fields
values[i] = &sql.NullScanner{S: 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 EntityField fields.
func (_m *EntityField) 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 entityfield.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 entityfield.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 entityfield.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 entityfield.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
_m.Name = value.String
}
case entityfield.FieldDescription:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field description", values[i])
} else if value.Valid {
_m.Description = value.String
}
case entityfield.FieldType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field type", values[i])
} else if value.Valid {
_m.Type = entityfield.Type(value.String)
}
case entityfield.FieldTextValue:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field text_value", values[i])
} else if value.Valid {
_m.TextValue = value.String
}
case entityfield.FieldNumberValue:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field number_value", values[i])
} else if value.Valid {
_m.NumberValue = int(value.Int64)
}
case entityfield.FieldBooleanValue:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field boolean_value", values[i])
} else if value.Valid {
_m.BooleanValue = value.Bool
}
case entityfield.FieldTimeValue:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field time_value", values[i])
} else if value.Valid {
_m.TimeValue = value.Time
}
case entityfield.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field entity_fields", values[i])
} else if value.Valid {
_m.entity_fields = new(uuid.UUID)
*_m.entity_fields = *value.S.(*uuid.UUID)
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the EntityField.
// This includes values selected through modifiers, order, etc.
func (_m *EntityField) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryEntity queries the "entity" edge of the EntityField entity.
func (_m *EntityField) QueryEntity() *EntityQuery {
return NewEntityFieldClient(_m.config).QueryEntity(_m)
}
// Update returns a builder for updating this EntityField.
// Note that you need to call EntityField.Unwrap() before calling this method if this EntityField
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *EntityField) Update() *EntityFieldUpdateOne {
return NewEntityFieldClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the EntityField 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 *EntityField) Unwrap() *EntityField {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: EntityField is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *EntityField) String() string {
var builder strings.Builder
builder.WriteString("EntityField(")
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("name=")
builder.WriteString(_m.Name)
builder.WriteString(", ")
builder.WriteString("description=")
builder.WriteString(_m.Description)
builder.WriteString(", ")
builder.WriteString("type=")
builder.WriteString(fmt.Sprintf("%v", _m.Type))
builder.WriteString(", ")
builder.WriteString("text_value=")
builder.WriteString(_m.TextValue)
builder.WriteString(", ")
builder.WriteString("number_value=")
builder.WriteString(fmt.Sprintf("%v", _m.NumberValue))
builder.WriteString(", ")
builder.WriteString("boolean_value=")
builder.WriteString(fmt.Sprintf("%v", _m.BooleanValue))
builder.WriteString(", ")
builder.WriteString("time_value=")
builder.WriteString(_m.TimeValue.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}
// EntityFields is a parsable slice of EntityField.
type EntityFields []*EntityField