mission.core
Version:
mission core
45 lines (44 loc) • 2.41 kB
TypeScript
import { QueryOptionBuilder } from '../util';
import { ApiRequest, ApiResponse, CreateOptions, FindOptions, LoggerInstance, PageContext, QueryOptions, Request, Sequelize, UpdateOptions, UpsertOptions } from '../vendor';
import { BaseBoConstructor, IBaseBo } from './bo-registry.decorator';
import { TModel } from './repository';
export declare type Scope<T extends Attributes> = string | string[] | TModel<T> | null;
export declare abstract class BaseBo<TAttributes extends Attributes> implements IBaseBo {
protected request?: Request;
protected dal: Sequelize;
protected log: LoggerInstance;
protected get models(): Models;
protected get items(): TModel<TAttributes>;
constructor(request?: Request);
protected abstract get session(): {
[key: string]: any;
userId: number;
};
abstract getModel(): TModel<TAttributes>;
protected abstract get userId(): number;
deleteById(entity: TAttributes, scope?: Scope<TAttributes>): Promise<number>;
executeSQLQuery(queryText: string | {
query: string;
values: any[];
}, param?: QueryOptions): Promise<any>;
executeStoredProcedure(procName: string, param?: QueryOptions): Promise<any>;
getById(id: number, scope?: Scope<TAttributes>): Promise<TAttributes>;
findOne(options?: FindOptions, scope?: Scope<TAttributes>): Promise<TAttributes>;
findAll(options?: FindOptions, scope?: Scope<TAttributes>): Promise<TAttributes[]>;
findAndCount(options?: FindOptions, scope?: Scope<TAttributes>): Promise<{
rows: TAttributes[];
count: number;
}>;
save(entity: TAttributes, options?: CreateOptions, scope?: Scope<TAttributes>): Promise<TAttributes>;
saveOrUpdate(entity: TAttributes, options?: UpsertOptions & {
returning?: false | undefined;
}, scope?: Scope<TAttributes>): Promise<boolean>;
update(entity: TAttributes, options?: UpdateOptions, scope?: Scope<TAttributes>): Promise<[number, TAttributes[]]>;
protected getScope(scope?: Scope<TAttributes>): TModel<TAttributes>;
protected getQoBuilder(reqBody?: ApiRequest<any>): QueryOptionBuilder;
protected getResponse<T>(data: T, pageContext?: PageContext, error?: Error): ApiResponse<T>;
protected get queryGenerator(): any;
protected getBo<T extends IBaseBo>(type: BaseBoConstructor<T>, req?: Request): T;
private checkId;
private get transaction();
}