fix: docs
This commit is contained in:
@@ -5,15 +5,12 @@ import "time"
|
|||||||
// ConfigEntry stores runtime-tunable configuration in the database.
|
// ConfigEntry stores runtime-tunable configuration in the database.
|
||||||
// Values are stored as strings but helpers exist for ints/bools/durations.
|
// Values are stored as strings but helpers exist for ints/bools/durations.
|
||||||
//
|
//
|
||||||
// NOTE: keep keys stable; they are effectively part of the public admin surface.
|
|
||||||
//
|
|
||||||
// Example keys:
|
// Example keys:
|
||||||
// - upload.max_file_size_bytes
|
// - upload.max_file_size_bytes
|
||||||
// - upload.multi.max_files
|
// - upload.multi.max_files
|
||||||
// - upload.max_hours
|
// - upload.max_hours
|
||||||
// - ratelimit.login.per_minute
|
// - ratelimit.login.per_minute
|
||||||
// - ratelimit.api.per_minute
|
// - ratelimit.api.per_minute
|
||||||
//
|
|
||||||
type ConfigEntry struct {
|
type ConfigEntry struct {
|
||||||
Key string `gorm:"primaryKey;size:128"`
|
Key string `gorm:"primaryKey;size:128"`
|
||||||
Value string `gorm:"size:2048"`
|
Value string `gorm:"size:2048"`
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ func (r *Repository) Get(key string) (*ConfigEntry, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Repository) Upsert(key, value string) error {
|
func (r *Repository) Upsert(key, value string) error {
|
||||||
// Prefer a simple approach that works across sqlite/postgres/mysql.
|
|
||||||
// Try update first, then insert if nothing updated.
|
// Try update first, then insert if nothing updated.
|
||||||
res := r.db.Model(&ConfigEntry{}).Where("key = ?", key).Update("value", value)
|
res := r.db.Model(&ConfigEntry{}).Where("key = ?", key).Update("value", value)
|
||||||
if res.Error != nil {
|
if res.Error != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user