把select和operate的option改成了泛型
This commit is contained in:
parent
8fd1757f30
commit
575975eec1
|
|
@ -7,9 +7,9 @@ export declare abstract class CascadeStore<ED extends EntityDict, Cxt extends Co
|
||||||
constructor(storageSchema: StorageSchema<ED>);
|
constructor(storageSchema: StorageSchema<ED>);
|
||||||
protected abstract supportManyToOneJoin(): boolean;
|
protected abstract supportManyToOneJoin(): boolean;
|
||||||
protected abstract supportMultipleCreate(): boolean;
|
protected abstract supportMultipleCreate(): boolean;
|
||||||
protected abstract selectAbjointRow<T extends keyof ED, S extends ED[T]['Selection']>(entity: T, selection: S, context: Cxt, option?: SelectOption): Promise<SelectRowShape<ED[T]['Schema'], S['data']>[]>;
|
protected abstract selectAbjointRow<T extends keyof ED, S extends ED[T]['Selection'], OP extends SelectOption>(entity: T, selection: S, context: Cxt, option?: OP): Promise<SelectRowShape<ED[T]['Schema'], S['data']>[]>;
|
||||||
protected abstract updateAbjointRow<T extends keyof ED>(entity: T, operation: DeduceCreateMultipleOperation<ED[T]['Schema']> | DeduceCreateSingleOperation<ED[T]['Schema']> | DeduceUpdateOperation<ED[T]['Schema']> | DeduceRemoveOperation<ED[T]['Schema']>, context: Cxt, option?: OperateOption): Promise<number>;
|
protected abstract updateAbjointRow<T extends keyof ED, OP extends OperateOption>(entity: T, operation: DeduceCreateMultipleOperation<ED[T]['Schema']> | DeduceCreateSingleOperation<ED[T]['Schema']> | DeduceUpdateOperation<ED[T]['Schema']> | DeduceRemoveOperation<ED[T]['Schema']>, context: Cxt, option?: OP): Promise<number>;
|
||||||
protected cascadeSelect<T extends keyof ED, S extends ED[T]['Selection']>(entity: T, selection: S, context: Cxt, option?: SelectOption): Promise<SelectRowShape<ED[T]['Schema'], S['data']>[]>;
|
protected cascadeSelect<T extends keyof ED, S extends ED[T]['Selection'], OP extends SelectOption>(entity: T, selection: S, context: Cxt, option?: OP): Promise<SelectRowShape<ED[T]['Schema'], S['data']>[]>;
|
||||||
/**
|
/**
|
||||||
* 级联更新
|
* 级联更新
|
||||||
* A --> B
|
* A --> B
|
||||||
|
|
@ -33,6 +33,6 @@ export declare abstract class CascadeStore<ED extends EntityDict, Cxt extends Co
|
||||||
* @param context
|
* @param context
|
||||||
* @param option
|
* @param option
|
||||||
*/
|
*/
|
||||||
protected cascadeUpdate<T extends keyof ED>(entity: T, operation: DeduceCreateOperation<ED[T]['Schema']> | DeduceUpdateOperation<ED[T]['Schema']> | DeduceRemoveOperation<ED[T]['Schema']>, context: Cxt, option?: OperateOption): Promise<OperationResult<ED>>;
|
protected cascadeUpdate<T extends keyof ED, OP extends OperateOption>(entity: T, operation: DeduceCreateOperation<ED[T]['Schema']> | DeduceUpdateOperation<ED[T]['Schema']> | DeduceRemoveOperation<ED[T]['Schema']>, context: Cxt, option?: OP): Promise<OperationResult<ED>>;
|
||||||
judgeRelation(entity: keyof ED, attr: string): string | string[] | 1 | 0 | 2;
|
judgeRelation(entity: keyof ED, attr: string): string | string[] | 1 | 0 | 2;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ export declare abstract class RowStore<ED extends EntityDict, Cxt extends Contex
|
||||||
static $$LEVEL: string;
|
static $$LEVEL: string;
|
||||||
static $$CODES: OakErrorDefDict;
|
static $$CODES: OakErrorDefDict;
|
||||||
protected storageSchema: StorageSchema<ED>;
|
protected storageSchema: StorageSchema<ED>;
|
||||||
abstract operate<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], context: Cxt, option?: OperateOption): Promise<OperationResult<ED>>;
|
abstract operate<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option?: OP): Promise<OperationResult<ED>>;
|
||||||
abstract select<T extends keyof ED, S extends ED[T]['Selection']>(entity: T, selection: S, context: Cxt, option?: SelectOption): Promise<SelectionResult<ED[T]['Schema'], S['data']>>;
|
abstract select<T extends keyof ED, S extends ED[T]['Selection'], OP extends SelectOption>(entity: T, selection: S, context: Cxt, option?: OP): Promise<SelectionResult<ED[T]['Schema'], S['data']>>;
|
||||||
abstract count<T extends keyof ED>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option?: SelectOption): Promise<number>;
|
abstract count<T extends keyof ED, OP extends SelectOption>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option?: OP): Promise<number>;
|
||||||
constructor(storageSchema: StorageSchema<ED>);
|
constructor(storageSchema: StorageSchema<ED>);
|
||||||
abstract begin(option?: TxnOption): Promise<string>;
|
abstract begin(option?: TxnOption): Promise<string>;
|
||||||
abstract commit(txnId: string): Promise<void>;
|
abstract commit(txnId: string): Promise<void>;
|
||||||
|
|
|
||||||
|
|
@ -16,23 +16,23 @@ export abstract class CascadeStore<ED extends EntityDict, Cxt extends Context<ED
|
||||||
}
|
}
|
||||||
protected abstract supportManyToOneJoin(): boolean;
|
protected abstract supportManyToOneJoin(): boolean;
|
||||||
protected abstract supportMultipleCreate(): boolean;
|
protected abstract supportMultipleCreate(): boolean;
|
||||||
protected abstract selectAbjointRow<T extends keyof ED, S extends ED[T]['Selection']>(
|
protected abstract selectAbjointRow<T extends keyof ED, S extends ED[T]['Selection'], OP extends SelectOption>(
|
||||||
entity: T,
|
entity: T,
|
||||||
selection: S,
|
selection: S,
|
||||||
context: Cxt,
|
context: Cxt,
|
||||||
option?: SelectOption): Promise<SelectRowShape<ED[T]['Schema'], S['data']>[]>;
|
option?: OP): Promise<SelectRowShape<ED[T]['Schema'], S['data']>[]>;
|
||||||
|
|
||||||
protected abstract updateAbjointRow<T extends keyof ED>(
|
protected abstract updateAbjointRow<T extends keyof ED, OP extends OperateOption>(
|
||||||
entity: T,
|
entity: T,
|
||||||
operation: DeduceCreateMultipleOperation<ED[T]['Schema']> | DeduceCreateSingleOperation<ED[T]['Schema']> | DeduceUpdateOperation<ED[T]['Schema']> | DeduceRemoveOperation<ED[T]['Schema']>,
|
operation: DeduceCreateMultipleOperation<ED[T]['Schema']> | DeduceCreateSingleOperation<ED[T]['Schema']> | DeduceUpdateOperation<ED[T]['Schema']> | DeduceRemoveOperation<ED[T]['Schema']>,
|
||||||
context: Cxt,
|
context: Cxt,
|
||||||
option?: OperateOption): Promise<number>;
|
option?: OP): Promise<number>;
|
||||||
|
|
||||||
protected async cascadeSelect<T extends keyof ED, S extends ED[T]['Selection']>(
|
protected async cascadeSelect<T extends keyof ED, S extends ED[T]['Selection'], OP extends SelectOption>(
|
||||||
entity: T,
|
entity: T,
|
||||||
selection: S,
|
selection: S,
|
||||||
context: Cxt,
|
context: Cxt,
|
||||||
option?: SelectOption): Promise<SelectRowShape<ED[T]['Schema'], S['data']>[]> {
|
option?: OP): Promise<SelectRowShape<ED[T]['Schema'], S['data']>[]> {
|
||||||
const { data } = selection;
|
const { data } = selection;
|
||||||
|
|
||||||
const projection: ED[T]['Selection']['data'] = {};
|
const projection: ED[T]['Selection']['data'] = {};
|
||||||
|
|
@ -252,11 +252,11 @@ export abstract class CascadeStore<ED extends EntityDict, Cxt extends Context<ED
|
||||||
* @param context
|
* @param context
|
||||||
* @param option
|
* @param option
|
||||||
*/
|
*/
|
||||||
protected async cascadeUpdate<T extends keyof ED>(
|
protected async cascadeUpdate<T extends keyof ED, OP extends OperateOption>(
|
||||||
entity: T,
|
entity: T,
|
||||||
operation: DeduceCreateOperation<ED[T]['Schema']> | DeduceUpdateOperation<ED[T]['Schema']> | DeduceRemoveOperation<ED[T]['Schema']>,
|
operation: DeduceCreateOperation<ED[T]['Schema']> | DeduceUpdateOperation<ED[T]['Schema']> | DeduceRemoveOperation<ED[T]['Schema']>,
|
||||||
context: Cxt,
|
context: Cxt,
|
||||||
option?: OperateOption): Promise<OperationResult<ED>> {
|
option?: OP): Promise<OperationResult<ED>> {
|
||||||
const { action, data, filter } = operation;
|
const { action, data, filter } = operation;
|
||||||
const opData = {};
|
const opData = {};
|
||||||
const result: OperationResult<ED> = {};
|
const result: OperationResult<ED> = {};
|
||||||
|
|
|
||||||
|
|
@ -18,25 +18,25 @@ export abstract class RowStore<ED extends EntityDict, Cxt extends Context<ED>> {
|
||||||
};
|
};
|
||||||
protected storageSchema: StorageSchema<ED>;
|
protected storageSchema: StorageSchema<ED>;
|
||||||
// store实现CRUD动作的统一入口定义
|
// store实现CRUD动作的统一入口定义
|
||||||
abstract operate<T extends keyof ED>(
|
abstract operate<T extends keyof ED, OP extends OperateOption>(
|
||||||
entity: T,
|
entity: T,
|
||||||
operation: ED[T]['Operation'],
|
operation: ED[T]['Operation'],
|
||||||
context: Cxt,
|
context: Cxt,
|
||||||
option?: OperateOption
|
option?: OP
|
||||||
): Promise<OperationResult<ED>>;
|
): Promise<OperationResult<ED>>;
|
||||||
|
|
||||||
abstract select<T extends keyof ED, S extends ED[T]['Selection']> (
|
abstract select<T extends keyof ED, S extends ED[T]['Selection'], OP extends SelectOption> (
|
||||||
entity: T,
|
entity: T,
|
||||||
selection: S,
|
selection: S,
|
||||||
context: Cxt,
|
context: Cxt,
|
||||||
option?: SelectOption
|
option?: OP
|
||||||
): Promise<SelectionResult<ED[T]['Schema'], S['data']>>;
|
): Promise<SelectionResult<ED[T]['Schema'], S['data']>>;
|
||||||
|
|
||||||
abstract count<T extends keyof ED> (
|
abstract count<T extends keyof ED, OP extends SelectOption> (
|
||||||
entity: T,
|
entity: T,
|
||||||
selection: Pick<ED[T]['Selection'], 'filter' | 'count'>,
|
selection: Pick<ED[T]['Selection'], 'filter' | 'count'>,
|
||||||
context: Cxt,
|
context: Cxt,
|
||||||
option?: SelectOption
|
option?: OP
|
||||||
): Promise<number>;
|
): Promise<number>;
|
||||||
|
|
||||||
constructor(storageSchema: StorageSchema<ED>) {
|
constructor(storageSchema: StorageSchema<ED>) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue