package orm import ( "github.com/jinzhu/gorm" "net/http" ) type Answer struct { gorm.Model Text string Correct bool QuestionID uint } func (a *Answer) GetID() uint { return a.ID } func (a *Answer) String() string { return a.Text } func (a *Answer) Create(args map[string]string, r *http.Request) (interface{}, error) { return nil, nil } func (a *Answer) Read(args map[string]string, r *http.Request) (interface{}, error) { return nil, nil } func (a *Answer) ReadAll(args map[string]string, r *http.Request) (interface{}, error) { var answers []*Answer if err := DB().Order("created_at").Find(&answers).Error; err != nil { return nil, err } return answers, nil } func (a *Answer) Update(args map[string]string, r *http.Request) (interface{}, error) { return nil, nil } func (a *Answer) Delete(args map[string]string, r *http.Request) (interface{}, error) { return nil, nil }