当创建modi时不触发相应的trigger

This commit is contained in:
Xu Chang 2023-08-01 18:17:40 +08:00
parent 6e82643e42
commit d248a41cbe
2 changed files with 18 additions and 5 deletions

View File

@ -34,7 +34,7 @@ var DebugStore = /** @class */ (function (_super) {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!!option.blockTrigger) return [3 /*break*/, 2];
if (!(!option.blockTrigger && !option.modiParentEntity)) return [3 /*break*/, 2];
return [4 /*yield*/, this.executor.preOperation(entity, operation, context, option)];
case 1:
_a.sent();
@ -42,7 +42,7 @@ var DebugStore = /** @class */ (function (_super) {
case 2: return [4 /*yield*/, _super.prototype.cascadeUpdateAsync.call(this, entity, operation, context, option)];
case 3:
result = _a.sent();
if (!!option.blockTrigger) return [3 /*break*/, 5];
if (!(!option.blockTrigger && !option.modiParentEntity)) return [3 /*break*/, 5];
return [4 /*yield*/, this.executor.postOperation(entity, operation, context, option)];
case 4:
_a.sent();
@ -58,8 +58,16 @@ var DebugStore = /** @class */ (function (_super) {
switch (_a.label) {
case 0:
(0, assert_1.default)(context.getCurrentTxnId());
/**
* 这里似乎还有点问题如果在后续的checker里增加了cascadeUpdate是无法在一开始检查权限的
* 后台的DbStore也一样 by Xc 20230801
*/
return [4 /*yield*/, this.relationAuth.checkRelationAsync(entity, operation, context)];
case 1:
/**
* 这里似乎还有点问题如果在后续的checker里增加了cascadeUpdate是无法在一开始检查权限的
* 后台的DbStore也一样 by Xc 20230801
*/
_a.sent();
return [2 /*return*/, _super.prototype.operateAsync.call(this, entity, operation, context, option)];
}

View File

@ -46,11 +46,12 @@ export class DebugStore<ED extends EntityDict & BaseEntityDict, Cxt extends Asyn
}
protected async cascadeUpdateAsync<T extends keyof ED, OP extends DebugStoreOperateOption>(entity: T, operation: ED[T]['Operation'], context: AsyncContext<ED>, option: OP) {
if (!option.blockTrigger) {
// 如果是在modi处理过程中所有的trigger也可以延时到apply时再处理这时候因为modi中的数据并不实际存在处理会有问题
if (!option.blockTrigger && !option.modiParentEntity) {
await this.executor.preOperation(entity, operation, context, option);
}
const result = await super.cascadeUpdateAsync(entity, operation, context, option);
if (!option.blockTrigger) {
if (!option.blockTrigger && !option.modiParentEntity) {
await this.executor.postOperation(entity, operation, context, option);
}
return result;
@ -62,7 +63,11 @@ export class DebugStore<ED extends EntityDict & BaseEntityDict, Cxt extends Asyn
context: Cxt,
option: OP
) {
assert(context.getCurrentTxnId());
assert(context.getCurrentTxnId());
/**
* checker里增加了cascadeUpdate
* DbStore也一样 by Xc 20230801
*/
await this.relationAuth.checkRelationAsync(entity, operation, context);
return super.operateAsync(entity, operation, context, option);
}