189 lines
6.3 KiB
Go
189 lines
6.3 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"tinyskin/db/ent/texture"
|
|
"tinyskin/db/ent/userprofile"
|
|
"tinyskin/db/ent/usertexture"
|
|
)
|
|
|
|
// UserTexture is the model entity for the UserTexture schema.
|
|
type UserTexture struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// UserProfileID holds the value of the "user_profile_id" field.
|
|
UserProfileID int `json:"user_profile_id,omitempty"`
|
|
// TextureID holds the value of the "texture_id" field.
|
|
TextureID int `json:"texture_id,omitempty"`
|
|
// Type holds the value of the "type" field.
|
|
Type string `json:"type,omitempty"`
|
|
// Variant holds the value of the "variant" field.
|
|
Variant string `json:"variant,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the UserTextureQuery when eager-loading is set.
|
|
Edges UserTextureEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// UserTextureEdges holds the relations/edges for other nodes in the graph.
|
|
type UserTextureEdges struct {
|
|
// UserProfile holds the value of the user_profile edge.
|
|
UserProfile *UserProfile `json:"user_profile,omitempty"`
|
|
// Texture holds the value of the texture edge.
|
|
Texture *Texture `json:"texture,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [2]bool
|
|
}
|
|
|
|
// UserProfileOrErr returns the UserProfile value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e UserTextureEdges) UserProfileOrErr() (*UserProfile, error) {
|
|
if e.loadedTypes[0] {
|
|
if e.UserProfile == nil {
|
|
// Edge was loaded but was not found.
|
|
return nil, &NotFoundError{label: userprofile.Label}
|
|
}
|
|
return e.UserProfile, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "user_profile"}
|
|
}
|
|
|
|
// TextureOrErr returns the Texture value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e UserTextureEdges) TextureOrErr() (*Texture, error) {
|
|
if e.loadedTypes[1] {
|
|
if e.Texture == nil {
|
|
// Edge was loaded but was not found.
|
|
return nil, &NotFoundError{label: texture.Label}
|
|
}
|
|
return e.Texture, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "texture"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*UserTexture) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case usertexture.FieldID, usertexture.FieldUserProfileID, usertexture.FieldTextureID:
|
|
values[i] = new(sql.NullInt64)
|
|
case usertexture.FieldType, usertexture.FieldVariant:
|
|
values[i] = new(sql.NullString)
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the UserTexture fields.
|
|
func (ut *UserTexture) 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 usertexture.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
ut.ID = int(value.Int64)
|
|
case usertexture.FieldUserProfileID:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field user_profile_id", values[i])
|
|
} else if value.Valid {
|
|
ut.UserProfileID = int(value.Int64)
|
|
}
|
|
case usertexture.FieldTextureID:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field texture_id", values[i])
|
|
} else if value.Valid {
|
|
ut.TextureID = int(value.Int64)
|
|
}
|
|
case usertexture.FieldType:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field type", values[i])
|
|
} else if value.Valid {
|
|
ut.Type = value.String
|
|
}
|
|
case usertexture.FieldVariant:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field variant", values[i])
|
|
} else if value.Valid {
|
|
ut.Variant = value.String
|
|
}
|
|
default:
|
|
ut.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the UserTexture.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (ut *UserTexture) Value(name string) (ent.Value, error) {
|
|
return ut.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryUserProfile queries the "user_profile" edge of the UserTexture entity.
|
|
func (ut *UserTexture) QueryUserProfile() *UserProfileQuery {
|
|
return NewUserTextureClient(ut.config).QueryUserProfile(ut)
|
|
}
|
|
|
|
// QueryTexture queries the "texture" edge of the UserTexture entity.
|
|
func (ut *UserTexture) QueryTexture() *TextureQuery {
|
|
return NewUserTextureClient(ut.config).QueryTexture(ut)
|
|
}
|
|
|
|
// Update returns a builder for updating this UserTexture.
|
|
// Note that you need to call UserTexture.Unwrap() before calling this method if this UserTexture
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (ut *UserTexture) Update() *UserTextureUpdateOne {
|
|
return NewUserTextureClient(ut.config).UpdateOne(ut)
|
|
}
|
|
|
|
// Unwrap unwraps the UserTexture 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 (ut *UserTexture) Unwrap() *UserTexture {
|
|
_tx, ok := ut.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: UserTexture is not a transactional entity")
|
|
}
|
|
ut.config.driver = _tx.drv
|
|
return ut
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (ut *UserTexture) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("UserTexture(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", ut.ID))
|
|
builder.WriteString("user_profile_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", ut.UserProfileID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("texture_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", ut.TextureID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("type=")
|
|
builder.WriteString(ut.Type)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("variant=")
|
|
builder.WriteString(ut.Variant)
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// UserTextures is a parsable slice of UserTexture.
|
|
type UserTextures []*UserTexture
|