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"), } }