forked from mirrors/homebox
211 lines
6.6 KiB
Go
211 lines
6.6 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"
|
||
|
)
|
||
|
|
||
|
// Group is the model entity for the Group schema.
|
||
|
type Group 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"`
|
||
|
// Currency holds the value of the "currency" field.
|
||
|
Currency group.Currency `json:"currency,omitempty"`
|
||
|
// Edges holds the relations/edges for other nodes in the graph.
|
||
|
// The values are being populated by the GroupQuery when eager-loading is set.
|
||
|
Edges GroupEdges `json:"edges"`
|
||
|
}
|
||
|
|
||
|
// GroupEdges holds the relations/edges for other nodes in the graph.
|
||
|
type GroupEdges struct {
|
||
|
// Users holds the value of the users edge.
|
||
|
Users []*User `json:"users,omitempty"`
|
||
|
// Locations holds the value of the locations edge.
|
||
|
Locations []*Location `json:"locations,omitempty"`
|
||
|
// Items holds the value of the items edge.
|
||
|
Items []*Item `json:"items,omitempty"`
|
||
|
// Labels holds the value of the labels edge.
|
||
|
Labels []*Label `json:"labels,omitempty"`
|
||
|
// loadedTypes holds the information for reporting if a
|
||
|
// type was loaded (or requested) in eager-loading or not.
|
||
|
loadedTypes [4]bool
|
||
|
}
|
||
|
|
||
|
// UsersOrErr returns the Users value or an error if the edge
|
||
|
// was not loaded in eager-loading.
|
||
|
func (e GroupEdges) UsersOrErr() ([]*User, error) {
|
||
|
if e.loadedTypes[0] {
|
||
|
return e.Users, nil
|
||
|
}
|
||
|
return nil, &NotLoadedError{edge: "users"}
|
||
|
}
|
||
|
|
||
|
// LocationsOrErr returns the Locations value or an error if the edge
|
||
|
// was not loaded in eager-loading.
|
||
|
func (e GroupEdges) LocationsOrErr() ([]*Location, error) {
|
||
|
if e.loadedTypes[1] {
|
||
|
return e.Locations, nil
|
||
|
}
|
||
|
return nil, &NotLoadedError{edge: "locations"}
|
||
|
}
|
||
|
|
||
|
// ItemsOrErr returns the Items value or an error if the edge
|
||
|
// was not loaded in eager-loading.
|
||
|
func (e GroupEdges) ItemsOrErr() ([]*Item, error) {
|
||
|
if e.loadedTypes[2] {
|
||
|
return e.Items, nil
|
||
|
}
|
||
|
return nil, &NotLoadedError{edge: "items"}
|
||
|
}
|
||
|
|
||
|
// LabelsOrErr returns the Labels value or an error if the edge
|
||
|
// was not loaded in eager-loading.
|
||
|
func (e GroupEdges) LabelsOrErr() ([]*Label, error) {
|
||
|
if e.loadedTypes[3] {
|
||
|
return e.Labels, nil
|
||
|
}
|
||
|
return nil, &NotLoadedError{edge: "labels"}
|
||
|
}
|
||
|
|
||
|
// scanValues returns the types for scanning values from sql.Rows.
|
||
|
func (*Group) scanValues(columns []string) ([]interface{}, error) {
|
||
|
values := make([]interface{}, len(columns))
|
||
|
for i := range columns {
|
||
|
switch columns[i] {
|
||
|
case group.FieldName, group.FieldCurrency:
|
||
|
values[i] = new(sql.NullString)
|
||
|
case group.FieldCreatedAt, group.FieldUpdatedAt:
|
||
|
values[i] = new(sql.NullTime)
|
||
|
case group.FieldID:
|
||
|
values[i] = new(uuid.UUID)
|
||
|
default:
|
||
|
return nil, fmt.Errorf("unexpected column %q for type Group", columns[i])
|
||
|
}
|
||
|
}
|
||
|
return values, nil
|
||
|
}
|
||
|
|
||
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||
|
// to the Group fields.
|
||
|
func (gr *Group) 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 group.FieldID:
|
||
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||
|
} else if value != nil {
|
||
|
gr.ID = *value
|
||
|
}
|
||
|
case group.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 {
|
||
|
gr.CreatedAt = value.Time
|
||
|
}
|
||
|
case group.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 {
|
||
|
gr.UpdatedAt = value.Time
|
||
|
}
|
||
|
case group.FieldName:
|
||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||
|
} else if value.Valid {
|
||
|
gr.Name = value.String
|
||
|
}
|
||
|
case group.FieldCurrency:
|
||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field currency", values[i])
|
||
|
} else if value.Valid {
|
||
|
gr.Currency = group.Currency(value.String)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// QueryUsers queries the "users" edge of the Group entity.
|
||
|
func (gr *Group) QueryUsers() *UserQuery {
|
||
|
return (&GroupClient{config: gr.config}).QueryUsers(gr)
|
||
|
}
|
||
|
|
||
|
// QueryLocations queries the "locations" edge of the Group entity.
|
||
|
func (gr *Group) QueryLocations() *LocationQuery {
|
||
|
return (&GroupClient{config: gr.config}).QueryLocations(gr)
|
||
|
}
|
||
|
|
||
|
// QueryItems queries the "items" edge of the Group entity.
|
||
|
func (gr *Group) QueryItems() *ItemQuery {
|
||
|
return (&GroupClient{config: gr.config}).QueryItems(gr)
|
||
|
}
|
||
|
|
||
|
// QueryLabels queries the "labels" edge of the Group entity.
|
||
|
func (gr *Group) QueryLabels() *LabelQuery {
|
||
|
return (&GroupClient{config: gr.config}).QueryLabels(gr)
|
||
|
}
|
||
|
|
||
|
// Update returns a builder for updating this Group.
|
||
|
// Note that you need to call Group.Unwrap() before calling this method if this Group
|
||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||
|
func (gr *Group) Update() *GroupUpdateOne {
|
||
|
return (&GroupClient{config: gr.config}).UpdateOne(gr)
|
||
|
}
|
||
|
|
||
|
// Unwrap unwraps the Group 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 (gr *Group) Unwrap() *Group {
|
||
|
_tx, ok := gr.config.driver.(*txDriver)
|
||
|
if !ok {
|
||
|
panic("ent: Group is not a transactional entity")
|
||
|
}
|
||
|
gr.config.driver = _tx.drv
|
||
|
return gr
|
||
|
}
|
||
|
|
||
|
// String implements the fmt.Stringer.
|
||
|
func (gr *Group) String() string {
|
||
|
var builder strings.Builder
|
||
|
builder.WriteString("Group(")
|
||
|
builder.WriteString(fmt.Sprintf("id=%v, ", gr.ID))
|
||
|
builder.WriteString("created_at=")
|
||
|
builder.WriteString(gr.CreatedAt.Format(time.ANSIC))
|
||
|
builder.WriteString(", ")
|
||
|
builder.WriteString("updated_at=")
|
||
|
builder.WriteString(gr.UpdatedAt.Format(time.ANSIC))
|
||
|
builder.WriteString(", ")
|
||
|
builder.WriteString("name=")
|
||
|
builder.WriteString(gr.Name)
|
||
|
builder.WriteString(", ")
|
||
|
builder.WriteString("currency=")
|
||
|
builder.WriteString(fmt.Sprintf("%v", gr.Currency))
|
||
|
builder.WriteByte(')')
|
||
|
return builder.String()
|
||
|
}
|
||
|
|
||
|
// Groups is a parsable slice of Group.
|
||
|
type Groups []*Group
|
||
|
|
||
|
func (gr Groups) config(cfg config) {
|
||
|
for _i := range gr {
|
||
|
gr[_i].config = cfg
|
||
|
}
|
||
|
}
|