0

这是结构models_gen.go

type Students struct {
    StudentID       string          `json:"student_id"`
    Class           string          `json:"class"`
    TestsHistory    []*TestsHistory `json:"test_history" 
}

type TestsHistory struct {
    English    string      `json:"eng"`
    Math       string      `json:"math"`
    Music      string      `json:"music"`
    PE         string      `json:"pe"`
}

中的查询功能resolvers.go

func (r *queryResolver) GetStudents(ctx context.Context, id *int) (*model.Students, error) {
   var students []*model.students       
   engine.Sync2(new(model.students))
   fmt.Printf("%v\n", engine.Find(students))
   return nil, nil
}

当我检查 MySQL 时,学生表只包含“StudentID”和“Class”字段,没有“TestsHistory”。如何在解析器中获取“TestsHistory”?

4

0 回答 0