mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-23 23:36:30 +00:00
193 lines
6.2 KiB
Go
193 lines
6.2 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/content/backend/ent/group"
|
|
"github.com/hay-kot/content/backend/ent/location"
|
|
)
|
|
|
|
// Location is the model entity for the Location schema.
|
|
type Location 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"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the LocationQuery when eager-loading is set.
|
|
Edges LocationEdges `json:"edges"`
|
|
group_locations *uuid.UUID
|
|
}
|
|
|
|
// LocationEdges holds the relations/edges for other nodes in the graph.
|
|
type LocationEdges 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 LocationEdges) 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 LocationEdges) 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 (*Location) scanValues(columns []string) ([]interface{}, error) {
|
|
values := make([]interface{}, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case location.FieldName, location.FieldDescription:
|
|
values[i] = new(sql.NullString)
|
|
case location.FieldCreatedAt, location.FieldUpdatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
case location.FieldID:
|
|
values[i] = new(uuid.UUID)
|
|
case location.ForeignKeys[0]: // group_locations
|
|
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
|
|
default:
|
|
return nil, fmt.Errorf("unexpected column %q for type Location", columns[i])
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the Location fields.
|
|
func (l *Location) 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 location.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 location.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 location.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 location.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 location.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 location.ForeignKeys[0]:
|
|
if value, ok := values[i].(*sql.NullScanner); !ok {
|
|
return fmt.Errorf("unexpected type %T for field group_locations", values[i])
|
|
} else if value.Valid {
|
|
l.group_locations = new(uuid.UUID)
|
|
*l.group_locations = *value.S.(*uuid.UUID)
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// QueryGroup queries the "group" edge of the Location entity.
|
|
func (l *Location) QueryGroup() *GroupQuery {
|
|
return (&LocationClient{config: l.config}).QueryGroup(l)
|
|
}
|
|
|
|
// QueryItems queries the "items" edge of the Location entity.
|
|
func (l *Location) QueryItems() *ItemQuery {
|
|
return (&LocationClient{config: l.config}).QueryItems(l)
|
|
}
|
|
|
|
// Update returns a builder for updating this Location.
|
|
// Note that you need to call Location.Unwrap() before calling this method if this Location
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (l *Location) Update() *LocationUpdateOne {
|
|
return (&LocationClient{config: l.config}).UpdateOne(l)
|
|
}
|
|
|
|
// Unwrap unwraps the Location 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 *Location) Unwrap() *Location {
|
|
_tx, ok := l.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: Location is not a transactional entity")
|
|
}
|
|
l.config.driver = _tx.drv
|
|
return l
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (l *Location) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("Location(")
|
|
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.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// Locations is a parsable slice of Location.
|
|
type Locations []*Location
|
|
|
|
func (l Locations) config(cfg config) {
|
|
for _i := range l {
|
|
l[_i].config = cfg
|
|
}
|
|
}
|