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

51 lines
1.2 KiB
Go

package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/index"
)
// CategoryContent holds the schema definition for the CategoryContent entity.
type CategoryContent struct {
ent.Schema
}
// Fields of the CategoryContent.
func (CategoryContent) Fields() []ent.Field {
return []ent.Field{
field.Enum("language_code").
NamedValues(
"EN", "en",
"ZH_HANS", "zh-Hans",
"ZH_HANT", "zh-Hant",
),
field.String("name").
NotEmpty(),
field.String("description").
Optional(),
field.String("slug").
NotEmpty(),
}
}
// Edges of the CategoryContent.
func (CategoryContent) Edges() []ent.Edge {
return []ent.Edge{
edge.From("category", Category.Type).
Ref("contents").
Unique(),
}
}
// Indexes of the CategoryContent.
func (CategoryContent) Indexes() []ent.Index {
return []ent.Index{
index.Fields("language_code", "slug").
Unique(),
index.Fields("language_code").
Edges("category").
Unique(),
}
}