diff options
author | Grail Finder (aider) <wohilas@gmail.com> | 2025-04-05 14:56:26 +0300 |
---|---|---|
committer | Grail Finder (aider) <wohilas@gmail.com> | 2025-04-05 14:56:26 +0300 |
commit | 0e55ccf54731669cd879ad08bde610761ef37f3d (patch) | |
tree | bb6a3a7f7999ad326c733d9ccc572c868f2e659a | |
parent | 492c6449937cb07731526bd2c4577927a1ff463f (diff) |
feat: implement DBGetDefaultsMap in SQL provider
-rw-r--r-- | internal/database/sql/main.go | 18 |
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 { |