You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
918 B
��

package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// Question holds the schema definition for the Question entity.
type Question struct {
ent.Schema
}
// Fields of the Question.
func (Question) Fields() []ent.Field {
return []ent.Field{
field.String("theme").NotEmpty().MaxLen(100),
field.Text("text").NotEmpty().MaxLen(1000),
field.String("answer").NotEmpty().MaxLen(500),
field.Text("hint").Optional().MaxLen(500),
field.Enum("difficulty").Values("easy", "medium", "hard").Default("medium"),
field.Bool("is_active").Default(true),
field.Time("created_at").Default(time.Now).Immutable(),
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now),
}
}
// Indexes of the Question.
func (Question) Indexes() []ent.Index {
return []ent.Index{
index.Fields("theme", "is_active"),
index.Fields("difficulty", "is_active"),
}
}