focalboard/server/services/store/sqlstore/system.go

45 lines
910 B
Go
Raw Normal View History

package sqlstore
func (s *SQLStore) GetSystemSettings() (map[string]string, error) {
2021-04-17 09:06:57 +02:00
query := s.getQueryBuilder().Select("*").From(s.tablePrefix + "system_settings")
2020-10-20 20:00:46 +02:00
rows, err := query.Query()
if err != nil {
return nil, err
}
defer s.CloseRows(rows)
results := map[string]string{}
for rows.Next() {
var id string
var value string
err := rows.Scan(&id, &value)
if err != nil {
return nil, err
}
results[id] = value
}
return results, nil
}
2021-03-21 09:28:26 +01:00
func (s *SQLStore) SetSystemSetting(id, value string) error {
2021-04-17 09:06:57 +02:00
query := s.getQueryBuilder().Insert(s.tablePrefix+"system_settings").Columns("id", "value").Values(id, value)
2021-04-30 16:48:45 +02:00
if s.dbType == mysqlDBType {
query = query.Suffix("ON DUPLICATE KEY UPDATE value = ?", value)
} else {
query = query.Suffix("ON CONFLICT (id) DO UPDATE SET value = EXCLUDED.value")
}
2020-10-20 20:00:46 +02:00
_, err := query.Exec()
if err != nil {
return err
}
return nil
}