DbStore增加了checkRelationAsync接口
This commit is contained in:
parent
d00eb839a2
commit
8c3b74cb89
|
|
@ -8,6 +8,7 @@ export declare class DbStore<ED extends EntityDict & BaseEntityDict, Cxt extends
|
|||
private executor;
|
||||
private relationAuth;
|
||||
constructor(storageSchema: StorageSchema<ED>, contextBuilder: () => Cxt, mysqlConfiguration: MySQLConfiguration, authDeduceRelationMap: AuthDeduceRelationMap<ED>, selectFreeEntities?: SelectFreeEntities<ED>, updateFreeDict?: UpdateFreeDict<ED>, onVolatileTrigger?: <T extends keyof ED>(entity: T, trigger: VolatileTrigger<ED, T, Cxt>, ids: string[], cxtStr: string, option: OperateOption) => Promise<void>);
|
||||
checkRelationAsync<T extends keyof ED, Cxt extends AsyncContext<ED>>(entity: T, operation: Omit<ED[T]["Operation"] | ED[T]["Selection"], "id">, context: Cxt): Promise<void>;
|
||||
protected cascadeUpdateAsync<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], context: AsyncContext<ED>, option: MysqlOperateOption): Promise<import("oak-domain/lib/types").OperationResult<ED>>;
|
||||
operate<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: MysqlOperateOption): Promise<import("oak-domain/lib/types").OperationResult<ED>>;
|
||||
select<T extends keyof ED>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: MySqlSelectOption): Promise<Partial<ED[T]["Schema"]>[]>;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ class DbStore extends oak_db_1.MysqlStore {
|
|||
this.executor = new TriggerExecutor_1.TriggerExecutor(contextBuilder, undefined, onVolatileTrigger);
|
||||
this.relationAuth = new RelationAuth_1.RelationAuth(storageSchema, authDeduceRelationMap, selectFreeEntities, updateFreeDict);
|
||||
}
|
||||
checkRelationAsync(entity, operation, context) {
|
||||
return this.relationAuth.checkRelationAsync(entity, operation, context);
|
||||
}
|
||||
async cascadeUpdateAsync(entity, operation, context, option) {
|
||||
// 如果是在modi处理过程中,所有的trigger也可以延时到apply时再处理(这时候因为modi中的数据并不实际存在,处理会有问题)
|
||||
if (!option.blockTrigger) {
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ export class DbStore<ED extends EntityDict & BaseEntityDict, Cxt extends Backend
|
|||
private relationAuth: RelationAuth<ED>;
|
||||
|
||||
constructor(
|
||||
storageSchema: StorageSchema<ED>,
|
||||
contextBuilder: () => Cxt,
|
||||
storageSchema: StorageSchema<ED>,
|
||||
contextBuilder: () => Cxt,
|
||||
mysqlConfiguration: MySQLConfiguration,
|
||||
authDeduceRelationMap: AuthDeduceRelationMap<ED>,
|
||||
selectFreeEntities: SelectFreeEntities<ED> = [],
|
||||
|
|
@ -25,6 +25,10 @@ export class DbStore<ED extends EntityDict & BaseEntityDict, Cxt extends Backend
|
|||
this.relationAuth = new RelationAuth(storageSchema, authDeduceRelationMap, selectFreeEntities, updateFreeDict);
|
||||
}
|
||||
|
||||
checkRelationAsync<T extends keyof ED, Cxt extends AsyncContext<ED>>(entity: T, operation: Omit<ED[T]["Operation"] | ED[T]["Selection"], "id">, context: Cxt): Promise<void> {
|
||||
return this.relationAuth.checkRelationAsync(entity, operation, context);
|
||||
}
|
||||
|
||||
protected async cascadeUpdateAsync<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], context: AsyncContext<ED>, option: MysqlOperateOption) {
|
||||
// 如果是在modi处理过程中,所有的trigger也可以延时到apply时再处理(这时候因为modi中的数据并不实际存在,处理会有问题)
|
||||
if (!option.blockTrigger) {
|
||||
|
|
@ -89,7 +93,7 @@ export class DbStore<ED extends EntityDict & BaseEntityDict, Cxt extends Backend
|
|||
|
||||
if (!option.blockTrigger) {
|
||||
await this.executor.postOperation(entity, selection as ED[T]['Operation']
|
||||
, context, option, result);
|
||||
, context, option, result);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
|
|
@ -145,8 +149,8 @@ export class DbStore<ED extends EntityDict & BaseEntityDict, Cxt extends Backend
|
|||
setOnVolatileTrigger(
|
||||
onVolatileTrigger: <T extends keyof ED>(
|
||||
entity: T,
|
||||
trigger: VolatileTrigger<ED, T, Cxt>,
|
||||
ids: string[],
|
||||
trigger: VolatileTrigger<ED, T, Cxt>,
|
||||
ids: string[],
|
||||
cxtStr: string,
|
||||
option: OperateOption) => Promise<void>
|
||||
) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue