summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrail Finder (aider) <wohilas@gmail.com>2025-04-05 14:56:26 +0300
committerGrail Finder (aider) <wohilas@gmail.com>2025-04-05 14:56:26 +0300
commit0e55ccf54731669cd879ad08bde610761ef37f3d (patch)
treebb6a3a7f7999ad326c733d9ccc572c868f2e659a
parent492c6449937cb07731526bd2c4577927a1ff463f (diff)
feat: implement DBGetDefaultsMap in SQL provider
-rw-r--r--internal/database/sql/main.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/database/sql/main.go b/internal/database/sql/main.go
index 0ac81a6..93d644f 100644
--- a/internal/database/sql/main.go
+++ b/internal/database/sql/main.go
@@ -45,6 +45,24 @@ func (d *DB) DBGetQuestion(id string) (*models.Question, error) {
return &question, nil
}
+func (d *DB) DBGetDefaultsMap() (map[string]string, error) {
+ rows, err := d.Conn.Queryx(`SELECT key, value FROM defaults`)
+ if err != nil {
+ return nil, err
+ }
+ defer rows.Close()
+
+ result := make(map[string]string)
+ for rows.Next() {
+ var key, value string
+ if err := rows.Scan(&key, &value); err != nil {
+ return nil, err
+ }
+ result[key] = value
+ }
+ return result, nil
+}
+
func (d *DB) CloseAll() error {
for _, conn := range []*sqlx.DB{d.Conn} {
if err := closeConn(conn); err != nil {