175 lines
6.1 KiB
Go
175 lines
6.1 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"tss-rocks-be/ent/category"
|
|
"tss-rocks-be/ent/categorycontent"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
// CategoryContent is the model entity for the CategoryContent schema.
|
|
type CategoryContent struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// LanguageCode holds the value of the "language_code" field.
|
|
LanguageCode categorycontent.LanguageCode `json:"language_code,omitempty"`
|
|
// Name holds the value of the "name" field.
|
|
Name string `json:"name,omitempty"`
|
|
// Description holds the value of the "description" field.
|
|
Description string `json:"description,omitempty"`
|
|
// Slug holds the value of the "slug" field.
|
|
Slug string `json:"slug,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the CategoryContentQuery when eager-loading is set.
|
|
Edges CategoryContentEdges `json:"edges"`
|
|
category_contents *int
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// CategoryContentEdges holds the relations/edges for other nodes in the graph.
|
|
type CategoryContentEdges struct {
|
|
// Category holds the value of the category edge.
|
|
Category *Category `json:"category,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [1]bool
|
|
}
|
|
|
|
// CategoryOrErr returns the Category value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e CategoryContentEdges) CategoryOrErr() (*Category, error) {
|
|
if e.Category != nil {
|
|
return e.Category, nil
|
|
} else if e.loadedTypes[0] {
|
|
return nil, &NotFoundError{label: category.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "category"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*CategoryContent) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case categorycontent.FieldID:
|
|
values[i] = new(sql.NullInt64)
|
|
case categorycontent.FieldLanguageCode, categorycontent.FieldName, categorycontent.FieldDescription, categorycontent.FieldSlug:
|
|
values[i] = new(sql.NullString)
|
|
case categorycontent.ForeignKeys[0]: // category_contents
|
|
values[i] = new(sql.NullInt64)
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the CategoryContent fields.
|
|
func (cc *CategoryContent) 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 categorycontent.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
cc.ID = int(value.Int64)
|
|
case categorycontent.FieldLanguageCode:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field language_code", values[i])
|
|
} else if value.Valid {
|
|
cc.LanguageCode = categorycontent.LanguageCode(value.String)
|
|
}
|
|
case categorycontent.FieldName:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
|
} else if value.Valid {
|
|
cc.Name = value.String
|
|
}
|
|
case categorycontent.FieldDescription:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field description", values[i])
|
|
} else if value.Valid {
|
|
cc.Description = value.String
|
|
}
|
|
case categorycontent.FieldSlug:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field slug", values[i])
|
|
} else if value.Valid {
|
|
cc.Slug = value.String
|
|
}
|
|
case categorycontent.ForeignKeys[0]:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for edge-field category_contents", value)
|
|
} else if value.Valid {
|
|
cc.category_contents = new(int)
|
|
*cc.category_contents = int(value.Int64)
|
|
}
|
|
default:
|
|
cc.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the CategoryContent.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (cc *CategoryContent) Value(name string) (ent.Value, error) {
|
|
return cc.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryCategory queries the "category" edge of the CategoryContent entity.
|
|
func (cc *CategoryContent) QueryCategory() *CategoryQuery {
|
|
return NewCategoryContentClient(cc.config).QueryCategory(cc)
|
|
}
|
|
|
|
// Update returns a builder for updating this CategoryContent.
|
|
// Note that you need to call CategoryContent.Unwrap() before calling this method if this CategoryContent
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (cc *CategoryContent) Update() *CategoryContentUpdateOne {
|
|
return NewCategoryContentClient(cc.config).UpdateOne(cc)
|
|
}
|
|
|
|
// Unwrap unwraps the CategoryContent 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 (cc *CategoryContent) Unwrap() *CategoryContent {
|
|
_tx, ok := cc.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: CategoryContent is not a transactional entity")
|
|
}
|
|
cc.config.driver = _tx.drv
|
|
return cc
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (cc *CategoryContent) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("CategoryContent(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", cc.ID))
|
|
builder.WriteString("language_code=")
|
|
builder.WriteString(fmt.Sprintf("%v", cc.LanguageCode))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("name=")
|
|
builder.WriteString(cc.Name)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("description=")
|
|
builder.WriteString(cc.Description)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("slug=")
|
|
builder.WriteString(cc.Slug)
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// CategoryContents is a parsable slice of CategoryContent.
|
|
type CategoryContents []*CategoryContent
|