mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-12 10:08:04 +00:00
bd321af29f
* new PR tasks * add homebox to know words * formatting * bump deps * generate db models * ts errors * drop id * fix accessor * drop unused time field * change CI * add expected error * add type check * resolve serveral type errors * hoise in CI
198 lines
6.4 KiB
Go
198 lines
6.4 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"github.com/google/uuid"
|
|
"github.com/hay-kot/homebox/backend/internal/data/ent/group"
|
|
"github.com/hay-kot/homebox/backend/internal/data/ent/label"
|
|
)
|
|
|
|
// Label is the model entity for the Label schema.
|
|
type Label 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"`
|
|
// Color holds the value of the "color" field.
|
|
Color string `json:"color,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the LabelQuery when eager-loading is set.
|
|
Edges LabelEdges `json:"edges"`
|
|
group_labels *uuid.UUID
|
|
}
|
|
|
|
// LabelEdges holds the relations/edges for other nodes in the graph.
|
|
type LabelEdges struct {
|
|
// Group holds the value of the group edge.
|
|
Group *Group `json:"group,omitempty"`
|
|
// Items holds the value of the items edge.
|
|
Items []*Item `json:"items,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [2]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 LabelEdges) GroupOrErr() (*Group, error) {
|
|
if e.loadedTypes[0] {
|
|
if e.Group == nil {
|
|
// Edge was loaded but was not found.
|
|
return nil, &NotFoundError{label: group.Label}
|
|
}
|
|
return e.Group, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "group"}
|
|
}
|
|
|
|
// ItemsOrErr returns the Items value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e LabelEdges) ItemsOrErr() ([]*Item, error) {
|
|
if e.loadedTypes[1] {
|
|
return e.Items, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "items"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*Label) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case label.FieldName, label.FieldDescription, label.FieldColor:
|
|
values[i] = new(sql.NullString)
|
|
case label.FieldCreatedAt, label.FieldUpdatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
case label.FieldID:
|
|
values[i] = new(uuid.UUID)
|
|
case label.ForeignKeys[0]: // group_labels
|
|
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
|
|
default:
|
|
return nil, fmt.Errorf("unexpected column %q for type Label", columns[i])
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the Label fields.
|
|
func (l *Label) 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 label.FieldID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", values[i])
|
|
} else if value != nil {
|
|
l.ID = *value
|
|
}
|
|
case label.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 {
|
|
l.CreatedAt = value.Time
|
|
}
|
|
case label.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 {
|
|
l.UpdatedAt = value.Time
|
|
}
|
|
case label.FieldName:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
|
} else if value.Valid {
|
|
l.Name = value.String
|
|
}
|
|
case label.FieldDescription:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field description", values[i])
|
|
} else if value.Valid {
|
|
l.Description = value.String
|
|
}
|
|
case label.FieldColor:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field color", values[i])
|
|
} else if value.Valid {
|
|
l.Color = value.String
|
|
}
|
|
case label.ForeignKeys[0]:
|
|
if value, ok := values[i].(*sql.NullScanner); !ok {
|
|
return fmt.Errorf("unexpected type %T for field group_labels", values[i])
|
|
} else if value.Valid {
|
|
l.group_labels = new(uuid.UUID)
|
|
*l.group_labels = *value.S.(*uuid.UUID)
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// QueryGroup queries the "group" edge of the Label entity.
|
|
func (l *Label) QueryGroup() *GroupQuery {
|
|
return NewLabelClient(l.config).QueryGroup(l)
|
|
}
|
|
|
|
// QueryItems queries the "items" edge of the Label entity.
|
|
func (l *Label) QueryItems() *ItemQuery {
|
|
return NewLabelClient(l.config).QueryItems(l)
|
|
}
|
|
|
|
// Update returns a builder for updating this Label.
|
|
// Note that you need to call Label.Unwrap() before calling this method if this Label
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (l *Label) Update() *LabelUpdateOne {
|
|
return NewLabelClient(l.config).UpdateOne(l)
|
|
}
|
|
|
|
// Unwrap unwraps the Label 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 *Label) Unwrap() *Label {
|
|
_tx, ok := l.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: Label is not a transactional entity")
|
|
}
|
|
l.config.driver = _tx.drv
|
|
return l
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (l *Label) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("Label(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", l.ID))
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(l.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("updated_at=")
|
|
builder.WriteString(l.UpdatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("name=")
|
|
builder.WriteString(l.Name)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("description=")
|
|
builder.WriteString(l.Description)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("color=")
|
|
builder.WriteString(l.Color)
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// Labels is a parsable slice of Label.
|
|
type Labels []*Label
|