have tow relation struct
type ExamPaper struct {
gorm.Model
Name string gorm:"type:varchar(255);index"
PaperType int gorm:"type:tinyint;index"
State int gorm:"type:tinyint;index"
CreatorID int gorm:"type:bigint;index"
TotalQuestion int gorm:"type:int"
TotalScore int gorm:"type:int"
Describe string gorm:"type:text"
UserID int gorm:"type:bigint;index"
MaintainerID int gorm:"type:bigint;index"
ExamTime int gorm:"type:bigint;comment:考试时间"
PassScore int gorm:"type:int" //及格分数
MD5s Strings gorm:"comment:試卷里面的题的md5值"
PaperQuestions PaperQuestions gorm:"foreignKey:PaperID"
}
and
type PaperQuestion struct {
gorm.Model
PaperID int gorm:"type:bigint;index"
Score int gorm:"type:int"
Stem string gorm:"type:varchar(255);index;comment:题干"
QuestionType int gorm:"type:tinyint;index;comment:题型"
KnowledgeId int gorm:"type:tinyint;index;comment:知识类型"
CreatorID uint gorm:"type:bigint;index"
TopicType int gorm:"type:tinyint;index;comment:题目类型" //公开私有
Options Options gorm:"comment:题选项"
Answers Answers gorm:"comment:答案"
OrderNumber int gorm:"type:tinyint;index"
// QuestionID int gorm:"type:bigint;uniqueIndex:idx_paper_question"
// State int gorm:"type:tinyint;index"
}
this is my sql code
s.DBModel.GetSess().Model(&exampaper.ExamPaper{}).Preload("PaperQuestions").Where("id = ?", id).First(paper)
where did i go wrong
Comment From: rob121
I am having this EXACT same issue for what it's worth...no answer either.