mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-22 16:45:43 +00:00
a042496c71
* bump all deps * run code-gen
262 lines
8.5 KiB
Go
262 lines
8.5 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/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"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// 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"`
|
|
// Documents holds the value of the documents edge.
|
|
Documents []*Document `json:"documents,omitempty"`
|
|
// InvitationTokens holds the value of the invitation_tokens edge.
|
|
InvitationTokens []*GroupInvitationToken `json:"invitation_tokens,omitempty"`
|
|
// Notifiers holds the value of the notifiers edge.
|
|
Notifiers []*Notifier `json:"notifiers,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [7]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"}
|
|
}
|
|
|
|
// DocumentsOrErr returns the Documents value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e GroupEdges) DocumentsOrErr() ([]*Document, error) {
|
|
if e.loadedTypes[4] {
|
|
return e.Documents, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "documents"}
|
|
}
|
|
|
|
// InvitationTokensOrErr returns the InvitationTokens value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e GroupEdges) InvitationTokensOrErr() ([]*GroupInvitationToken, error) {
|
|
if e.loadedTypes[5] {
|
|
return e.InvitationTokens, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "invitation_tokens"}
|
|
}
|
|
|
|
// NotifiersOrErr returns the Notifiers value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e GroupEdges) NotifiersOrErr() ([]*Notifier, error) {
|
|
if e.loadedTypes[6] {
|
|
return e.Notifiers, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "notifiers"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*Group) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, 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:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
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 []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 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)
|
|
}
|
|
default:
|
|
gr.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the Group.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (gr *Group) Value(name string) (ent.Value, error) {
|
|
return gr.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryUsers queries the "users" edge of the Group entity.
|
|
func (gr *Group) QueryUsers() *UserQuery {
|
|
return NewGroupClient(gr.config).QueryUsers(gr)
|
|
}
|
|
|
|
// QueryLocations queries the "locations" edge of the Group entity.
|
|
func (gr *Group) QueryLocations() *LocationQuery {
|
|
return NewGroupClient(gr.config).QueryLocations(gr)
|
|
}
|
|
|
|
// QueryItems queries the "items" edge of the Group entity.
|
|
func (gr *Group) QueryItems() *ItemQuery {
|
|
return NewGroupClient(gr.config).QueryItems(gr)
|
|
}
|
|
|
|
// QueryLabels queries the "labels" edge of the Group entity.
|
|
func (gr *Group) QueryLabels() *LabelQuery {
|
|
return NewGroupClient(gr.config).QueryLabels(gr)
|
|
}
|
|
|
|
// QueryDocuments queries the "documents" edge of the Group entity.
|
|
func (gr *Group) QueryDocuments() *DocumentQuery {
|
|
return NewGroupClient(gr.config).QueryDocuments(gr)
|
|
}
|
|
|
|
// QueryInvitationTokens queries the "invitation_tokens" edge of the Group entity.
|
|
func (gr *Group) QueryInvitationTokens() *GroupInvitationTokenQuery {
|
|
return NewGroupClient(gr.config).QueryInvitationTokens(gr)
|
|
}
|
|
|
|
// QueryNotifiers queries the "notifiers" edge of the Group entity.
|
|
func (gr *Group) QueryNotifiers() *NotifierQuery {
|
|
return NewGroupClient(gr.config).QueryNotifiers(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 NewGroupClient(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
|