summaryrefslogtreecommitdiff
path: root/internal/database/repos
diff options
context:
space:
mode:
Diffstat (limited to 'internal/database/repos')
-rw-r--r--internal/database/repos/defaults.go25
-rw-r--r--internal/database/repos/main.go1
2 files changed, 26 insertions, 0 deletions
diff --git a/internal/database/repos/defaults.go b/internal/database/repos/defaults.go
new file mode 100644
index 0000000..e0b5e52
--- /dev/null
+++ b/internal/database/repos/defaults.go
@@ -0,0 +1,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
+}
diff --git a/internal/database/repos/main.go b/internal/database/repos/main.go
index 25eeec4..72860dd 100644
--- a/internal/database/repos/main.go
+++ b/internal/database/repos/main.go
@@ -7,6 +7,7 @@ import (
type FullRepo interface {
ActionRepo
UserScoreRepo
+ DefaultsRepo
}
type Provider struct {