0

Here is the struct in 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"`
}

The query function in 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
}

When I check MySQL, the students table only contains "StudentID" and "Class" Field, no "TestsHistory". How do I get "TestsHistory" in resolvers?

Emily
  • 137
  • 1
  • 2
  • 8

0 Answers0