oak-domain/lib/store/SyncRowStore.d.ts

31 lines
2.3 KiB
TypeScript

import { EntityDict, RowStore, OperateOption, OperationResult, SelectOption, TxnOption, Context, AggregationResult } from "../types";
import { EntityDict as BaseEntityDict } from '../base-app-domain';
export declare abstract class SyncContext<ED extends EntityDict & BaseEntityDict> implements Context {
rowStore: SyncRowStore<ED, this>;
private uuid?;
constructor(rowStore: SyncRowStore<ED, SyncContext<ED>>);
abstract getCurrentUserId(allowUnloggedIn?: boolean): string | undefined;
abstract isRoot(): boolean;
abstract toString(): Promise<string>;
begin(option?: TxnOption): void;
commit(): void;
rollback(): void;
getCurrentTxnId(): string | undefined;
getSchema(): import("../types").StorageSchema<ED>;
operate<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], option: OP): OperationResult<ED>;
select<T extends keyof ED, OP extends SelectOption>(entity: T, selection: ED[T]['Selection'], option: OP): Partial<ED[T]["Schema"]>[];
aggregate<T extends keyof ED, OP extends SelectOption>(entity: T, aggregation: ED[T]['Aggregation'], option: OP): AggregationResult<ED[T]["Schema"]>;
count<T extends keyof ED, OP extends SelectOption>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, option: OP): number;
mergeMultipleResults(toBeMerged: OperationResult<ED>[]): OperationResult<ED>;
abstract allowUserUpdate(): boolean;
}
export interface SyncRowStore<ED extends EntityDict & BaseEntityDict, Cxt extends SyncContext<ED>> extends RowStore<ED> {
operate<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): OperationResult<ED>;
select<T extends keyof ED, OP extends SelectOption>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Partial<ED[T]['Schema']>[];
count<T extends keyof ED, OP extends SelectOption>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option: OP): number;
aggregate<T extends keyof ED, OP extends SelectOption>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): AggregationResult<ED[T]['Schema']>;
begin(option?: TxnOption): string;
commit(txnId: string): void;
rollback(txnId: string): void;
}