tss-rocks/backend/ent/dailycategorycontent.go
CDN 05ddc1f783
Some checks failed
Build Backend / Build Docker Image (push) Successful in 3m33s
Test Backend / test (push) Failing after 31s
[feature] migrate to monorepo
2025-02-21 00:49:20 +08:00

153 lines
5.5 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"tss-rocks-be/ent/dailycategory"
"tss-rocks-be/ent/dailycategorycontent"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// DailyCategoryContent is the model entity for the DailyCategoryContent schema.
type DailyCategoryContent struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// LanguageCode holds the value of the "language_code" field.
LanguageCode dailycategorycontent.LanguageCode `json:"language_code,omitempty"`
// Name holds the value of the "name" field.
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the DailyCategoryContentQuery when eager-loading is set.
Edges DailyCategoryContentEdges `json:"edges"`
daily_category_contents *int
selectValues sql.SelectValues
}
// DailyCategoryContentEdges holds the relations/edges for other nodes in the graph.
type DailyCategoryContentEdges struct {
// Category holds the value of the category edge.
Category *DailyCategory `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 DailyCategoryContentEdges) CategoryOrErr() (*DailyCategory, error) {
if e.Category != nil {
return e.Category, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: dailycategory.Label}
}
return nil, &NotLoadedError{edge: "category"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*DailyCategoryContent) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case dailycategorycontent.FieldID:
values[i] = new(sql.NullInt64)
case dailycategorycontent.FieldLanguageCode, dailycategorycontent.FieldName:
values[i] = new(sql.NullString)
case dailycategorycontent.ForeignKeys[0]: // daily_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 DailyCategoryContent fields.
func (dcc *DailyCategoryContent) 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 dailycategorycontent.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
dcc.ID = int(value.Int64)
case dailycategorycontent.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 {
dcc.LanguageCode = dailycategorycontent.LanguageCode(value.String)
}
case dailycategorycontent.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
dcc.Name = value.String
}
case dailycategorycontent.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for edge-field daily_category_contents", value)
} else if value.Valid {
dcc.daily_category_contents = new(int)
*dcc.daily_category_contents = int(value.Int64)
}
default:
dcc.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the DailyCategoryContent.
// This includes values selected through modifiers, order, etc.
func (dcc *DailyCategoryContent) Value(name string) (ent.Value, error) {
return dcc.selectValues.Get(name)
}
// QueryCategory queries the "category" edge of the DailyCategoryContent entity.
func (dcc *DailyCategoryContent) QueryCategory() *DailyCategoryQuery {
return NewDailyCategoryContentClient(dcc.config).QueryCategory(dcc)
}
// Update returns a builder for updating this DailyCategoryContent.
// Note that you need to call DailyCategoryContent.Unwrap() before calling this method if this DailyCategoryContent
// was returned from a transaction, and the transaction was committed or rolled back.
func (dcc *DailyCategoryContent) Update() *DailyCategoryContentUpdateOne {
return NewDailyCategoryContentClient(dcc.config).UpdateOne(dcc)
}
// Unwrap unwraps the DailyCategoryContent 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 (dcc *DailyCategoryContent) Unwrap() *DailyCategoryContent {
_tx, ok := dcc.config.driver.(*txDriver)
if !ok {
panic("ent: DailyCategoryContent is not a transactional entity")
}
dcc.config.driver = _tx.drv
return dcc
}
// String implements the fmt.Stringer.
func (dcc *DailyCategoryContent) String() string {
var builder strings.Builder
builder.WriteString("DailyCategoryContent(")
builder.WriteString(fmt.Sprintf("id=%v, ", dcc.ID))
builder.WriteString("language_code=")
builder.WriteString(fmt.Sprintf("%v", dcc.LanguageCode))
builder.WriteString(", ")
builder.WriteString("name=")
builder.WriteString(dcc.Name)
builder.WriteByte(')')
return builder.String()
}
// DailyCategoryContents is a parsable slice of DailyCategoryContent.
type DailyCategoryContents []*DailyCategoryContent