mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-25 18:15:40 +00:00
a3e607a887
* bump all deps
* run code-gen
Former-commit-id: a042496c71
226 lines
7.4 KiB
Go
226 lines
7.4 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"
|
|
"github.com/hay-kot/homebox/backend/internal/data/ent/notifier"
|
|
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
|
)
|
|
|
|
// Notifier is the model entity for the Notifier schema.
|
|
type Notifier 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"`
|
|
// GroupID holds the value of the "group_id" field.
|
|
GroupID uuid.UUID `json:"group_id,omitempty"`
|
|
// UserID holds the value of the "user_id" field.
|
|
UserID uuid.UUID `json:"user_id,omitempty"`
|
|
// Name holds the value of the "name" field.
|
|
Name string `json:"name,omitempty"`
|
|
// URL holds the value of the "url" field.
|
|
URL string `json:"-"`
|
|
// IsActive holds the value of the "is_active" field.
|
|
IsActive bool `json:"is_active,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the NotifierQuery when eager-loading is set.
|
|
Edges NotifierEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// NotifierEdges holds the relations/edges for other nodes in the graph.
|
|
type NotifierEdges struct {
|
|
// Group holds the value of the group edge.
|
|
Group *Group `json:"group,omitempty"`
|
|
// User holds the value of the user edge.
|
|
User *User `json:"user,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 NotifierEdges) 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"}
|
|
}
|
|
|
|
// UserOrErr returns the User value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e NotifierEdges) UserOrErr() (*User, error) {
|
|
if e.loadedTypes[1] {
|
|
if e.User == nil {
|
|
// Edge was loaded but was not found.
|
|
return nil, &NotFoundError{label: user.Label}
|
|
}
|
|
return e.User, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "user"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*Notifier) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case notifier.FieldIsActive:
|
|
values[i] = new(sql.NullBool)
|
|
case notifier.FieldName, notifier.FieldURL:
|
|
values[i] = new(sql.NullString)
|
|
case notifier.FieldCreatedAt, notifier.FieldUpdatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
case notifier.FieldID, notifier.FieldGroupID, notifier.FieldUserID:
|
|
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 Notifier fields.
|
|
func (n *Notifier) 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 notifier.FieldID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", values[i])
|
|
} else if value != nil {
|
|
n.ID = *value
|
|
}
|
|
case notifier.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 {
|
|
n.CreatedAt = value.Time
|
|
}
|
|
case notifier.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 {
|
|
n.UpdatedAt = value.Time
|
|
}
|
|
case notifier.FieldGroupID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field group_id", values[i])
|
|
} else if value != nil {
|
|
n.GroupID = *value
|
|
}
|
|
case notifier.FieldUserID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field user_id", values[i])
|
|
} else if value != nil {
|
|
n.UserID = *value
|
|
}
|
|
case notifier.FieldName:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
|
} else if value.Valid {
|
|
n.Name = value.String
|
|
}
|
|
case notifier.FieldURL:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field url", values[i])
|
|
} else if value.Valid {
|
|
n.URL = value.String
|
|
}
|
|
case notifier.FieldIsActive:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field is_active", values[i])
|
|
} else if value.Valid {
|
|
n.IsActive = value.Bool
|
|
}
|
|
default:
|
|
n.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the Notifier.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (n *Notifier) Value(name string) (ent.Value, error) {
|
|
return n.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryGroup queries the "group" edge of the Notifier entity.
|
|
func (n *Notifier) QueryGroup() *GroupQuery {
|
|
return NewNotifierClient(n.config).QueryGroup(n)
|
|
}
|
|
|
|
// QueryUser queries the "user" edge of the Notifier entity.
|
|
func (n *Notifier) QueryUser() *UserQuery {
|
|
return NewNotifierClient(n.config).QueryUser(n)
|
|
}
|
|
|
|
// Update returns a builder for updating this Notifier.
|
|
// Note that you need to call Notifier.Unwrap() before calling this method if this Notifier
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (n *Notifier) Update() *NotifierUpdateOne {
|
|
return NewNotifierClient(n.config).UpdateOne(n)
|
|
}
|
|
|
|
// Unwrap unwraps the Notifier 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 (n *Notifier) Unwrap() *Notifier {
|
|
_tx, ok := n.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: Notifier is not a transactional entity")
|
|
}
|
|
n.config.driver = _tx.drv
|
|
return n
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (n *Notifier) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("Notifier(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", n.ID))
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(n.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("updated_at=")
|
|
builder.WriteString(n.UpdatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("group_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", n.GroupID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("user_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", n.UserID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("name=")
|
|
builder.WriteString(n.Name)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("url=<sensitive>")
|
|
builder.WriteString(", ")
|
|
builder.WriteString("is_active=")
|
|
builder.WriteString(fmt.Sprintf("%v", n.IsActive))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// Notifiers is a parsable slice of Notifier.
|
|
type Notifiers []*Notifier
|