我正在尝试使用 Gorp 来参加所有体育课。健身房类有一个类类型,所以我运行第二个查询来检索它们。我取回了所有的类类型,但由于某种原因,最终的评估不起作用。
package entities
import (
"fmt"
"github.com/coopernurse/gorp"
"time"
)
type Class struct {
Id int
ClassTypeId int
ClassType ClassType
VideoPath string
VideoSize int
Duration float64
CreatedAt time.Time
VisibleAt time.Time
NoLongerVisibleAt time.Time
}
func LatestClasses(dbmap *gorp.DbMap) *[]Class {
var classes []Class
query := "SELECT * FROM Class"
_, err := dbmap.Select(&classes, query)
if err != nil {
panic(err)
}
for _, class := range classes {
classTypeForClass(dbmap, &class)
}
return &classes
}
func classTypeForClass(dbmap *gorp.DbMap, class *Class) {
var classType ClassType
query := "SELECT * FROM ClassType "
query += "WHERE Id=?"
err := dbmap.SelectOne(&classType, query, class.ClassTypeId)
if err != nil {
panic(err)
}
fmt.Println(classType) <<<<<<<<<<< Lists Yoga, Pilates etc.
class.ClassType = classType <<<<<<<< Seemingly does nothing
}
素胚勾勒不出你
相关分类