summaryrefslogtreecommitdiff
path: root/internal/database/repos/defaults.go
blob: e0b5e52e3085e3d1df7a08e3b28d5811d3760772 (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
package repos

type DefaultsRepo interface {
	DBGetDefaultsMap() (map[string]string, error)
}

func (p *Provider) DBGetDefaultsMap() (map[string]string, error) {
	rows, err := p.db.Queryx(`SELECT key, value
        FROM defaults;
    `)
	if err != nil {
		return nil, err
	}
	res := make(map[string]string)
	for rows.Next() {
		keyval, err := rows.SliceScan()
		if err != nil {
			return nil, err
		}
		key := keyval[0].(string)
		value := keyval[1].(string)
		res[key] = value
	}
	return res, nil
}