(key string, value string)
| 165 | } |
| 166 | |
| 167 | func UpdateOption(key string, value string) error { |
| 168 | // Save to database first |
| 169 | option := Option{ |
| 170 | Key: key, |
| 171 | } |
| 172 | // https://gorm.io/docs/update.html#Save-All-Fields |
| 173 | DB.FirstOrCreate(&option, Option{Key: key}) |
| 174 | option.Value = value |
| 175 | // Save is a combination function. |
| 176 | // If save value does not contain primary key, it will execute Create, |
| 177 | // otherwise it will execute Update (with all fields). |
| 178 | DB.Save(&option) |
| 179 | // Update OptionMap |
| 180 | return updateOptionMap(key, value) |
| 181 | } |
| 182 | |
| 183 | func updateOptionMap(key string, value string) (err error) { |
| 184 | common.OptionMapRWMutex.Lock() |
no test coverage detected