[feature] migrate to monorepo
This commit is contained in:
commit
05ddc1f783
267 changed files with 75165 additions and 0 deletions
51
backend/ent/schema/categorycontent.go
Normal file
51
backend/ent/schema/categorycontent.go
Normal file
|
@ -0,0 +1,51 @@
|
|||
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(),
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue