微调了事务提交时的处理顺序

This commit is contained in:
Xu Chang 2024-01-05 14:01:41 +08:00
parent a86981512d
commit a44173cab6
2 changed files with 6 additions and 4 deletions

View File

@ -159,10 +159,11 @@ class AppLoader extends types_1.AppLoader {
await context.begin();
try {
const result = await fn(params, context);
await context.commit();
await context.refineOpRecords();
const { opRecords } = context;
await context.commit();
return {
opRecords: context.opRecords.map(ele => (0, lodash_1.omit)(ele, 'id')),
opRecords: opRecords.map(ele => (0, lodash_1.omit)(ele, 'id')),
message: context.getMessage(),
result,
};

View File

@ -215,10 +215,11 @@ export class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt extends Backe
await context.begin();
try {
const result = await fn(params, context);
await context.commit();
await context.refineOpRecords();
const { opRecords } = context;
await context.commit();
return {
opRecords: (context.opRecords as CreateOpResult<ED, keyof ED>[]).map(ele => omit(ele, 'id')),
opRecords: (opRecords as CreateOpResult<ED, keyof ED>[]).map(ele => omit(ele, 'id')),
message: context.getMessage(),
result,
};