fix(settings): streamline settings type creation in settingsService and initialization
- Refactored settingsService to use findOrCreate for settings type, improving efficiency and error handling. - Added initialization for 'account' settings type in initializeSettings, ensuring all necessary settings are created during setup.
This commit is contained in:
@@ -42,12 +42,10 @@ class SettingsService extends BaseService{
|
||||
return null;
|
||||
}
|
||||
|
||||
const settingsType = await SettingsType.findOne({
|
||||
where: { name: definition.setting }
|
||||
const [settingsType] = await SettingsType.findOrCreate({
|
||||
where: { name: definition.setting },
|
||||
defaults: { name: definition.setting }
|
||||
});
|
||||
if (!settingsType) {
|
||||
throw new Error(`Missing settings type: ${definition.setting}`);
|
||||
}
|
||||
|
||||
const [paramType] = await UserParamType.findOrCreate({
|
||||
where: { description },
|
||||
|
||||
Reference in New Issue
Block a user