mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-29 20:15:41 +00:00
184 lines
6.1 KiB
Go
184 lines
6.1 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/actiontoken"
|
|
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
|
)
|
|
|
|
// ActionToken is the model entity for the ActionToken schema.
|
|
type ActionToken struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// UserID holds the value of the "user_id" field.
|
|
UserID uuid.UUID `json:"user_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"`
|
|
// Action holds the value of the "action" field.
|
|
Action actiontoken.Action `json:"action,omitempty"`
|
|
// Token holds the value of the "token" field.
|
|
Token []byte `json:"token,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the ActionTokenQuery when eager-loading is set.
|
|
Edges ActionTokenEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// ActionTokenEdges holds the relations/edges for other nodes in the graph.
|
|
type ActionTokenEdges struct {
|
|
// 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 [1]bool
|
|
}
|
|
|
|
// 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 ActionTokenEdges) UserOrErr() (*User, error) {
|
|
if e.loadedTypes[0] {
|
|
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 (*ActionToken) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case actiontoken.FieldToken:
|
|
values[i] = new([]byte)
|
|
case actiontoken.FieldAction:
|
|
values[i] = new(sql.NullString)
|
|
case actiontoken.FieldCreatedAt, actiontoken.FieldUpdatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
case actiontoken.FieldID, actiontoken.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 ActionToken fields.
|
|
func (at *ActionToken) 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 actiontoken.FieldID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", values[i])
|
|
} else if value != nil {
|
|
at.ID = *value
|
|
}
|
|
case actiontoken.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 {
|
|
at.UserID = *value
|
|
}
|
|
case actiontoken.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 {
|
|
at.CreatedAt = value.Time
|
|
}
|
|
case actiontoken.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 {
|
|
at.UpdatedAt = value.Time
|
|
}
|
|
case actiontoken.FieldAction:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field action", values[i])
|
|
} else if value.Valid {
|
|
at.Action = actiontoken.Action(value.String)
|
|
}
|
|
case actiontoken.FieldToken:
|
|
if value, ok := values[i].(*[]byte); !ok {
|
|
return fmt.Errorf("unexpected type %T for field token", values[i])
|
|
} else if value != nil {
|
|
at.Token = *value
|
|
}
|
|
default:
|
|
at.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the ActionToken.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (at *ActionToken) Value(name string) (ent.Value, error) {
|
|
return at.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryUser queries the "user" edge of the ActionToken entity.
|
|
func (at *ActionToken) QueryUser() *UserQuery {
|
|
return NewActionTokenClient(at.config).QueryUser(at)
|
|
}
|
|
|
|
// Update returns a builder for updating this ActionToken.
|
|
// Note that you need to call ActionToken.Unwrap() before calling this method if this ActionToken
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (at *ActionToken) Update() *ActionTokenUpdateOne {
|
|
return NewActionTokenClient(at.config).UpdateOne(at)
|
|
}
|
|
|
|
// Unwrap unwraps the ActionToken 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 (at *ActionToken) Unwrap() *ActionToken {
|
|
_tx, ok := at.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: ActionToken is not a transactional entity")
|
|
}
|
|
at.config.driver = _tx.drv
|
|
return at
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (at *ActionToken) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("ActionToken(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", at.ID))
|
|
builder.WriteString("user_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", at.UserID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(at.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("updated_at=")
|
|
builder.WriteString(at.UpdatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("action=")
|
|
builder.WriteString(fmt.Sprintf("%v", at.Action))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("token=")
|
|
builder.WriteString(fmt.Sprintf("%v", at.Token))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// ActionTokens is a parsable slice of ActionToken.
|
|
type ActionTokens []*ActionToken
|