2017-01-06 12:35
浏览 237


So i got two tables

type Person struct {
ID int
FirstName string
LastName string
Functions []Function
type Function struct {
Info string
Person Person

Now I create the tables like this

db.AutoMigrate(&models.Person{}, &models.Function{})

After this I init the db

user := models.Person{
    FirstName:            "Isa",
    LastName:  "istcool",
    Functions:          []models.Function{{Info: "Trainer"}, {Info: "CEO"}},

Now the problem is that my Person table only got Firstname and Lastname column and my Function table only got info column. But when I start my GET request I get people with the column function which is always null. (A screenshot from my GET request and my db) To see my whole programm visit my github repo:

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题