refactor: delete transaction
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2022-12-20 09:09:21 +01:00
parent 4e8896202a
commit 1a616fa1d4
1 changed files with 6 additions and 16 deletions

View File

@ -26,25 +26,15 @@ module.exports = Self => {
const models = Self.app.models;
const myOptions = {};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
try {
const mdbApp = await models.MdbApp.findById(appName, null, myOptions);
const updatedMdbApp = await mdbApp.updateAttributes({
userFk: null,
locked: null
}, myOptions);
const mdbApp = await models.MdbApp.findById(appName, null, myOptions);
const updatedMdbApp = await mdbApp.updateAttributes({
userFk: null,
locked: null
}, myOptions);
if (tx) await tx.commit();
return updatedMdbApp;
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
return updatedMdbApp;
};
};