chore: remove update-config mutation

This commit is contained in:
Ali BARIN
2024-08-29 13:22:35 +00:00
parent cce5b3b533
commit 1f39765efe
3 changed files with 0 additions and 43 deletions

View File

@@ -1,40 +0,0 @@
import Config from '../../models/config.js';
const updateConfig = async (_parent, params, context) => {
context.currentUser.can('update', 'Config');
const config = params.input;
const configKeys = Object.keys(config);
const updates = [];
for (const key of configKeys) {
const newValue = config[key];
if (newValue) {
const entryUpdate = Config.query()
.insert({
key,
value: {
data: newValue,
},
})
.onConflict('key')
.merge({
value: {
data: newValue,
},
});
updates.push(entryUpdate);
} else {
const entryUpdate = Config.query().findOne({ key }).delete();
updates.push(entryUpdate);
}
}
await Promise.all(updates);
return config;
};
export default updateConfig;