tss-rocks/backend/ent/dailycategory.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

157 lines
5.2 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"tss-rocks-be/ent/dailycategory"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// DailyCategory is the model entity for the DailyCategory schema.
type DailyCategory struct {
config `json:"-"`
// ID of the ent.
ID int `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"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the DailyCategoryQuery when eager-loading is set.
Edges DailyCategoryEdges `json:"edges"`
selectValues sql.SelectValues
}
// DailyCategoryEdges holds the relations/edges for other nodes in the graph.
type DailyCategoryEdges struct {
// Contents holds the value of the contents edge.
Contents []*DailyCategoryContent `json:"contents,omitempty"`
// DailyItems holds the value of the daily_items edge.
DailyItems []*Daily `json:"daily_items,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [2]bool
}
// ContentsOrErr returns the Contents value or an error if the edge
// was not loaded in eager-loading.
func (e DailyCategoryEdges) ContentsOrErr() ([]*DailyCategoryContent, error) {
if e.loadedTypes[0] {
return e.Contents, nil
}
return nil, &NotLoadedError{edge: "contents"}
}
// DailyItemsOrErr returns the DailyItems value or an error if the edge
// was not loaded in eager-loading.
func (e DailyCategoryEdges) DailyItemsOrErr() ([]*Daily, error) {
if e.loadedTypes[1] {
return e.DailyItems, nil
}
return nil, &NotLoadedError{edge: "daily_items"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*DailyCategory) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case dailycategory.FieldID:
values[i] = new(sql.NullInt64)
case dailycategory.FieldCreatedAt, dailycategory.FieldUpdatedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the DailyCategory fields.
func (dc *DailyCategory) 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 dailycategory.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
dc.ID = int(value.Int64)
case dailycategory.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 {
dc.CreatedAt = value.Time
}
case dailycategory.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 {
dc.UpdatedAt = value.Time
}
default:
dc.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the DailyCategory.
// This includes values selected through modifiers, order, etc.
func (dc *DailyCategory) Value(name string) (ent.Value, error) {
return dc.selectValues.Get(name)
}
// QueryContents queries the "contents" edge of the DailyCategory entity.
func (dc *DailyCategory) QueryContents() *DailyCategoryContentQuery {
return NewDailyCategoryClient(dc.config).QueryContents(dc)
}
// QueryDailyItems queries the "daily_items" edge of the DailyCategory entity.
func (dc *DailyCategory) QueryDailyItems() *DailyQuery {
return NewDailyCategoryClient(dc.config).QueryDailyItems(dc)
}
// Update returns a builder for updating this DailyCategory.
// Note that you need to call DailyCategory.Unwrap() before calling this method if this DailyCategory
// was returned from a transaction, and the transaction was committed or rolled back.
func (dc *DailyCategory) Update() *DailyCategoryUpdateOne {
return NewDailyCategoryClient(dc.config).UpdateOne(dc)
}
// Unwrap unwraps the DailyCategory 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 (dc *DailyCategory) Unwrap() *DailyCategory {
_tx, ok := dc.config.driver.(*txDriver)
if !ok {
panic("ent: DailyCategory is not a transactional entity")
}
dc.config.driver = _tx.drv
return dc
}
// String implements the fmt.Stringer.
func (dc *DailyCategory) String() string {
var builder strings.Builder
builder.WriteString("DailyCategory(")
builder.WriteString(fmt.Sprintf("id=%v, ", dc.ID))
builder.WriteString("created_at=")
builder.WriteString(dc.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(dc.UpdatedAt.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}
// DailyCategories is a parsable slice of DailyCategory.
type DailyCategories []*DailyCategory