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

139 lines
4.4 KiB
Go

// Code generated by ent, DO NOT EDIT.
package categorycontent
import (
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the categorycontent type in the database.
Label = "category_content"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldLanguageCode holds the string denoting the language_code field in the database.
FieldLanguageCode = "language_code"
// FieldName holds the string denoting the name field in the database.
FieldName = "name"
// FieldDescription holds the string denoting the description field in the database.
FieldDescription = "description"
// FieldSlug holds the string denoting the slug field in the database.
FieldSlug = "slug"
// EdgeCategory holds the string denoting the category edge name in mutations.
EdgeCategory = "category"
// Table holds the table name of the categorycontent in the database.
Table = "category_contents"
// CategoryTable is the table that holds the category relation/edge.
CategoryTable = "category_contents"
// CategoryInverseTable is the table name for the Category entity.
// It exists in this package in order to avoid circular dependency with the "category" package.
CategoryInverseTable = "categories"
// CategoryColumn is the table column denoting the category relation/edge.
CategoryColumn = "category_contents"
)
// Columns holds all SQL columns for categorycontent fields.
var Columns = []string{
FieldID,
FieldLanguageCode,
FieldName,
FieldDescription,
FieldSlug,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the "category_contents"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"category_contents",
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
for i := range ForeignKeys {
if column == ForeignKeys[i] {
return true
}
}
return false
}
var (
// NameValidator is a validator for the "name" field. It is called by the builders before save.
NameValidator func(string) error
// SlugValidator is a validator for the "slug" field. It is called by the builders before save.
SlugValidator func(string) error
)
// LanguageCode defines the type for the "language_code" enum field.
type LanguageCode string
// LanguageCode values.
const (
LanguageCodeEN LanguageCode = "en"
LanguageCodeZH_HANS LanguageCode = "zh-Hans"
LanguageCodeZH_HANT LanguageCode = "zh-Hant"
)
func (lc LanguageCode) String() string {
return string(lc)
}
// LanguageCodeValidator is a validator for the "language_code" field enum values. It is called by the builders before save.
func LanguageCodeValidator(lc LanguageCode) error {
switch lc {
case LanguageCodeEN, LanguageCodeZH_HANS, LanguageCodeZH_HANT:
return nil
default:
return fmt.Errorf("categorycontent: invalid enum value for language_code field: %q", lc)
}
}
// OrderOption defines the ordering options for the CategoryContent queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByLanguageCode orders the results by the language_code field.
func ByLanguageCode(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLanguageCode, opts...).ToFunc()
}
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
// ByDescription orders the results by the description field.
func ByDescription(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDescription, opts...).ToFunc()
}
// BySlug orders the results by the slug field.
func BySlug(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSlug, opts...).ToFunc()
}
// ByCategoryField orders the results by category field.
func ByCategoryField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newCategoryStep(), sql.OrderByField(field, opts...))
}
}
func newCategoryStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(CategoryInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, CategoryTable, CategoryColumn),
)
}