45 lines
992 B
Go
45 lines
992 B
Go
package schema
|
|
|
|
import (
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/schema/field"
|
|
"entgo.io/ent/schema/edge"
|
|
"entgo.io/ent/schema/index"
|
|
)
|
|
|
|
// DailyContent holds the schema definition for the DailyContent entity.
|
|
type DailyContent struct {
|
|
ent.Schema
|
|
}
|
|
|
|
// Fields of the DailyContent.
|
|
func (DailyContent) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.Enum("language_code").
|
|
NamedValues(
|
|
"EN", "en",
|
|
"ZH_HANS", "zh-Hans",
|
|
"ZH_HANT", "zh-Hant",
|
|
),
|
|
field.Text("quote").
|
|
NotEmpty(),
|
|
}
|
|
}
|
|
|
|
// Edges of the DailyContent.
|
|
func (DailyContent) Edges() []ent.Edge {
|
|
return []ent.Edge{
|
|
edge.From("daily", Daily.Type).
|
|
Ref("contents").
|
|
Unique(),
|
|
}
|
|
}
|
|
|
|
// Indexes of the DailyContent.
|
|
func (DailyContent) Indexes() []ent.Index {
|
|
return []ent.Index{
|
|
index.Fields("language_code").
|
|
Edges("daily").
|
|
Unique(),
|
|
}
|
|
}
|