2022-08-30 18:04:50 +00:00
|
|
|
// Code generated by ent, DO NOT EDIT.
|
|
|
|
|
|
|
|
package ent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
2023-07-23 03:57:51 +00:00
|
|
|
"entgo.io/ent"
|
2022-08-30 18:04:50 +00:00
|
|
|
"entgo.io/ent/dialect/sql"
|
|
|
|
"github.com/google/uuid"
|
2022-10-30 04:05:38 +00:00
|
|
|
"github.com/hay-kot/homebox/backend/internal/data/ent/group"
|
2022-08-30 18:04:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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.
|
2024-01-05 17:35:50 +00:00
|
|
|
Currency string `json:"currency,omitempty"`
|
2022-08-30 18:04:50 +00:00
|
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
|
|
// The values are being populated by the GroupQuery when eager-loading is set.
|
2023-07-23 03:57:51 +00:00
|
|
|
Edges GroupEdges `json:"edges"`
|
|
|
|
selectValues sql.SelectValues
|
2022-08-30 18:04:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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"`
|
2022-09-12 22:47:27 +00:00
|
|
|
// Documents holds the value of the documents edge.
|
|
|
|
Documents []*Document `json:"documents,omitempty"`
|
2022-10-07 02:54:09 +00:00
|
|
|
// InvitationTokens holds the value of the invitation_tokens edge.
|
|
|
|
InvitationTokens []*GroupInvitationToken `json:"invitation_tokens,omitempty"`
|
2023-03-07 06:18:58 +00:00
|
|
|
// Notifiers holds the value of the notifiers edge.
|
|
|
|
Notifiers []*Notifier `json:"notifiers,omitempty"`
|
2022-08-30 18:04:50 +00:00
|
|
|
// loadedTypes holds the information for reporting if a
|
|
|
|
// type was loaded (or requested) in eager-loading or not.
|
2023-03-07 06:18:58 +00:00
|
|
|
loadedTypes [7]bool
|
2022-08-30 18:04:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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"}
|
|
|
|
}
|
|
|
|
|
2022-09-12 22:47:27 +00:00
|
|
|
// 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"}
|
|
|
|
}
|
|
|
|
|
2022-10-07 02:54:09 +00:00
|
|
|
// 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"}
|
|
|
|
}
|
|
|
|
|
2023-03-07 06:18:58 +00:00
|
|
|
// 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"}
|
|
|
|
}
|
|
|
|
|
2022-08-30 18:04:50 +00:00
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
2022-09-29 05:42:33 +00:00
|
|
|
func (*Group) scanValues(columns []string) ([]any, error) {
|
|
|
|
values := make([]any, len(columns))
|
2022-08-30 18:04:50 +00:00
|
|
|
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:
|
2023-07-23 03:57:51 +00:00
|
|
|
values[i] = new(sql.UnknownType)
|
2022-08-30 18:04:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return values, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
|
|
// to the Group fields.
|
2022-09-29 05:42:33 +00:00
|
|
|
func (gr *Group) assignValues(columns []string, values []any) error {
|
2022-08-30 18:04:50 +00:00
|
|
|
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 {
|
2024-01-05 17:35:50 +00:00
|
|
|
gr.Currency = value.String
|
2022-08-30 18:04:50 +00:00
|
|
|
}
|
2023-07-23 03:57:51 +00:00
|
|
|
default:
|
|
|
|
gr.selectValues.Set(columns[i], values[i])
|
2022-08-30 18:04:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-23 03:57:51 +00:00
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
|
2022-08-30 18:04:50 +00:00
|
|
|
// QueryUsers queries the "users" edge of the Group entity.
|
|
|
|
func (gr *Group) QueryUsers() *UserQuery {
|
2023-01-28 21:03:51 +00:00
|
|
|
return NewGroupClient(gr.config).QueryUsers(gr)
|
2022-08-30 18:04:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// QueryLocations queries the "locations" edge of the Group entity.
|
|
|
|
func (gr *Group) QueryLocations() *LocationQuery {
|
2023-01-28 21:03:51 +00:00
|
|
|
return NewGroupClient(gr.config).QueryLocations(gr)
|
2022-08-30 18:04:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// QueryItems queries the "items" edge of the Group entity.
|
|
|
|
func (gr *Group) QueryItems() *ItemQuery {
|
2023-01-28 21:03:51 +00:00
|
|
|
return NewGroupClient(gr.config).QueryItems(gr)
|
2022-08-30 18:04:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// QueryLabels queries the "labels" edge of the Group entity.
|
|
|
|
func (gr *Group) QueryLabels() *LabelQuery {
|
2023-01-28 21:03:51 +00:00
|
|
|
return NewGroupClient(gr.config).QueryLabels(gr)
|
2022-08-30 18:04:50 +00:00
|
|
|
}
|
|
|
|
|
2022-09-12 22:47:27 +00:00
|
|
|
// QueryDocuments queries the "documents" edge of the Group entity.
|
|
|
|
func (gr *Group) QueryDocuments() *DocumentQuery {
|
2023-01-28 21:03:51 +00:00
|
|
|
return NewGroupClient(gr.config).QueryDocuments(gr)
|
2022-09-12 22:47:27 +00:00
|
|
|
}
|
|
|
|
|
2022-10-07 02:54:09 +00:00
|
|
|
// QueryInvitationTokens queries the "invitation_tokens" edge of the Group entity.
|
|
|
|
func (gr *Group) QueryInvitationTokens() *GroupInvitationTokenQuery {
|
2023-01-28 21:03:51 +00:00
|
|
|
return NewGroupClient(gr.config).QueryInvitationTokens(gr)
|
2022-10-07 02:54:09 +00:00
|
|
|
}
|
|
|
|
|
2023-03-07 06:18:58 +00:00
|
|
|
// QueryNotifiers queries the "notifiers" edge of the Group entity.
|
|
|
|
func (gr *Group) QueryNotifiers() *NotifierQuery {
|
|
|
|
return NewGroupClient(gr.config).QueryNotifiers(gr)
|
|
|
|
}
|
|
|
|
|
2022-08-30 18:04:50 +00:00
|
|
|
// 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 {
|
2023-01-28 21:03:51 +00:00
|
|
|
return NewGroupClient(gr.config).UpdateOne(gr)
|
2022-08-30 18:04:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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=")
|
2024-01-05 17:35:50 +00:00
|
|
|
builder.WriteString(gr.Currency)
|
2022-08-30 18:04:50 +00:00
|
|
|
builder.WriteByte(')')
|
|
|
|
return builder.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Groups is a parsable slice of Group.
|
|
|
|
type Groups []*Group
|