Files
tinyquiz/pkg/model/ent/schema/askedQuestion.go
Vojtěch Káně 41ae2283b1 Update ent
The package changed its import path so we had to reflect
2021-02-18 14:51:45 +01:00

44 lines
752 B
Go

package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
)
type AskedQuestion struct {
ent.Schema
}
func (AskedQuestion) Fields() []ent.Field {
return []ent.Field{
field.UUID("id", uuid.Nil).Immutable(),
field.Time("asked").Immutable(),
field.Time("ended"),
}
}
func (AskedQuestion) Indexes() []ent.Index {
return []ent.Index{}
}
func (AskedQuestion) Edges() []ent.Edge {
return []ent.Edge{
edge.From("session", Session.Type).
Ref("askedQuestions").
Unique().
Required(),
edge.From("question", Question.Type).
Ref("asked").
Unique().
Required(),
}
}
func (AskedQuestion) Config() ent.Config {
return ent.Config{
Table: "asked_questions",
}
}