A continuation of HomeBox the inventory and organization system built for the Home User
// 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/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 string `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"`
// EntityTypes holds the value of the entity_types edge.
EntityTypes []*EntityType `json:"entity_types,omitempty"`
// Entities holds the value of the entities edge.
Entities []*Entity `json:"entities,omitempty"`
// Tags holds the value of the tags edge.
Tags []*Tag `json:"tags,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"`
// EntityTemplates holds the value of the entity_templates edge.
EntityTemplates []*EntityTemplate `json:"entity_templates,omitempty"`
// Exports holds the value of the exports edge.
Exports []*Export `json:"exports,omitempty"`
// UserGroups holds the value of the user_groups edge.
UserGroups []*UserGroup `json:"user_groups,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [9]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"}
}
// EntityTypesOrErr returns the EntityTypes value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) EntityTypesOrErr() ([]*EntityType, error) {
if e.loadedTypes[1] {
return e.EntityTypes, nil
}
return nil, &NotLoadedError{edge: "entity_types"}
}
// EntitiesOrErr returns the Entities value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) EntitiesOrErr() ([]*Entity, error) {
if e.loadedTypes[2] {
return e.Entities, nil
}
return nil, &NotLoadedError{edge: "entities"}
}
// TagsOrErr returns the Tags value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) TagsOrErr() ([]*Tag, error) {
if e.loadedTypes[3] {
return e.Tags, nil
}
return nil, &NotLoadedError{edge: "tags"}
}
// 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[4] {
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[5] {
return e.Notifiers, nil
}
return nil, &NotLoadedError{edge: "notifiers"}
}
// EntityTemplatesOrErr returns the EntityTemplates value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) EntityTemplatesOrErr() ([]*EntityTemplate, error) {
if e.loadedTypes[6] {
return e.EntityTemplates, nil
}
return nil, &NotLoadedError{edge: "entity_templates"}
}
// ExportsOrErr returns the Exports value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) ExportsOrErr() ([]*Export, error) {
if e.loadedTypes[7] {
return e.Exports, nil
}
return nil, &NotLoadedError{edge: "exports"}
}
// UserGroupsOrErr returns the UserGroups value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) UserGroupsOrErr() ([]*UserGroup, error) {
if e.loadedTypes[8] {
return e.UserGroups, nil
}
return nil, &NotLoadedError{edge: "user_groups"}
}
// 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 (_m *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 {
_m.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 {
_m.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 {
_m.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 {
_m.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 {
_m.Currency = value.String
}
default:
_m.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 (_m *Group) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryUsers queries the "users" edge of the Group entity.
func (_m *Group) QueryUsers() *UserQuery {
return NewGroupClient(_m.config).QueryUsers(_m)
}
// QueryEntityTypes queries the "entity_types" edge of the Group entity.
func (_m *Group) QueryEntityTypes() *EntityTypeQuery {
return NewGroupClient(_m.config).QueryEntityTypes(_m)
}
// QueryEntities queries the "entities" edge of the Group entity.
func (_m *Group) QueryEntities() *EntityQuery {
return NewGroupClient(_m.config).QueryEntities(_m)
}
// QueryTags queries the "tags" edge of the Group entity.
func (_m *Group) QueryTags() *TagQuery {
return NewGroupClient(_m.config).QueryTags(_m)
}
// QueryInvitationTokens queries the "invitation_tokens" edge of the Group entity.
func (_m *Group) QueryInvitationTokens() *GroupInvitationTokenQuery {
return NewGroupClient(_m.config).QueryInvitationTokens(_m)
}
// QueryNotifiers queries the "notifiers" edge of the Group entity.
func (_m *Group) QueryNotifiers() *NotifierQuery {
return NewGroupClient(_m.config).QueryNotifiers(_m)
}
// QueryEntityTemplates queries the "entity_templates" edge of the Group entity.
func (_m *Group) QueryEntityTemplates() *EntityTemplateQuery {
return NewGroupClient(_m.config).QueryEntityTemplates(_m)
}
// QueryExports queries the "exports" edge of the Group entity.
func (_m *Group) QueryExports() *ExportQuery {
return NewGroupClient(_m.config).QueryExports(_m)
}
// QueryUserGroups queries the "user_groups" edge of the Group entity.
func (_m *Group) QueryUserGroups() *UserGroupQuery {
return NewGroupClient(_m.config).QueryUserGroups(_m)
}
// 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 (_m *Group) Update() *GroupUpdateOne {
return NewGroupClient(_m.config).UpdateOne(_m)
}
// 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 (_m *Group) Unwrap() *Group {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: Group is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *Group) String() string {
var builder strings.Builder
builder.WriteString("Group(")
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("currency=")
builder.WriteString(_m.Currency)
builder.WriteByte(')')
return builder.String()
}
// Groups is a parsable slice of Group.
type Groups []*Group