summaryrefslogtreecommitdiff
path: root/internal/database/repos/questions.go
blob: ab5e0938e21d2c48518b6b7a9b38012927f7cccb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package repos

import "demoon/internal/models"

type QuestionsRepo interface {
	DBGetQuestion(id string) (*models.Question, error)
	DBGetMixedUbung(id uint32) (*models.MixedUbung, error)
}

func (p *Provider) DBGetMixedUbung(id uint32) (*models.MixedUbung, error) {
	var ubung models.MixedUbung
	err := p.db.Get(&ubung, "SELECT * FROM Table_Mixed WHERE mixedid = ?", id)
	if err != nil {
		return nil, err
	}
	return &ubung, nil
}

func (p *Provider) DBGetQuestion(id string) (*models.Question, error) {
	var question models.Question
	err := p.db.Get(&question, "SELECT * FROM questions WHERE id = ?", id)
	if err != nil {
		return nil, err
	}
	return &question, nil
}