mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 10:37:01 +00:00
chore: add transaction in set field action (#1647)
This commit is contained in:
parent
b7abdfb9e6
commit
83daf55741
@ -4,8 +4,10 @@ export default {
|
||||
async ['collections:setFields'](ctx, next) {
|
||||
const { filterByTk, values } = ctx.action.params;
|
||||
|
||||
// WARN: 删掉 key 才能保存
|
||||
const fields = values.fields?.map(f => {
|
||||
const transaction = await ctx.app.db.sequelize.transaction();
|
||||
|
||||
try {
|
||||
const fields = values.fields?.map((f) => {
|
||||
delete f.key;
|
||||
return f;
|
||||
});
|
||||
@ -16,6 +18,7 @@ export default {
|
||||
filter: {
|
||||
name: filterByTk,
|
||||
},
|
||||
transaction,
|
||||
});
|
||||
|
||||
await db.getRepository('collections').update({
|
||||
@ -23,9 +26,18 @@ export default {
|
||||
values: {
|
||||
fields,
|
||||
},
|
||||
transaction,
|
||||
});
|
||||
|
||||
await collection.loadFields();
|
||||
await collection.loadFields({
|
||||
transaction,
|
||||
});
|
||||
|
||||
await transaction.commit();
|
||||
} catch (e) {
|
||||
await transaction.rollback();
|
||||
throw e;
|
||||
}
|
||||
|
||||
await next();
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user