collection.go 589 B

123456789101112131415161718192021222324252627282930313233343536
  1. package models
  2. import "encoding/json"
  3. type Collection struct {
  4. Meta
  5. Name string `json:"name"`
  6. Filter *Filter `json:"filter"`
  7. Quizzes []*Quiz `json:"quizzes" gorm:"many2many:collection_quizzes"`
  8. }
  9. func (c *Collection) String() string {
  10. return c.Name
  11. }
  12. func (c *Collection) GetID() string {
  13. return c.ID
  14. }
  15. func (c *Collection) SetID(id string) {
  16. c.ID = id
  17. }
  18. func (c *Collection) GetHash() string {
  19. return ""
  20. }
  21. func (c *Collection) Marshal() ([]byte, error) {
  22. return json.Marshal(c)
  23. }
  24. func (c *Collection) Unmarshal(data []byte) error {
  25. return json.Unmarshal(data, c)
  26. }