43 lines
894 B
Go
43 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
|
||
|
}
|