oef/orm/question.go
2019-11-04 15:00:46 +01:00

42 lines
894 B
Go

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