oef/orm/answer.go

46 lines
905 B
Go
Raw Normal View History

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) {
2019-11-13 13:57:41 +01:00
var answers []*Answer
if err := DB().Order("created_at").Find(&answers).Error; err != nil {
return nil, err
}
2019-11-13 13:57:41 +01:00
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
}