@joktec/mysql
Version:
JokTec - MySql Service
40 lines • 2.5 kB
TypeScript
import { ConfigService, Constructor, ICondition, KeyOf, LogService, OnApplicationBootstrap, OnModuleInit } from '@joktec/core';
import { DeepPartial, EntityManager, FindManyOptions, Repository } from 'typeorm';
import { SelectQueryBuilder } from 'typeorm/query-builder/SelectQueryBuilder';
import { UpsertOptions } from 'typeorm/repository/UpsertOptions';
import { IMysqlOption, IMysqlRequest, IMysqlResponse, MysqlId, MysqlModel } from './models';
import { IMysqlRepository } from './mysql.client';
import { MysqlService } from './mysql.service';
export declare abstract class MysqlRepo<T extends MysqlModel, ID extends MysqlId = MysqlId> implements IMysqlRepository<T, ID>, OnModuleInit, OnApplicationBootstrap {
protected mysqlService: MysqlService;
protected model: Constructor<T>;
protected conId: string;
protected configService: ConfigService;
protected logService: LogService;
protected constructor(mysqlService: MysqlService, model: Constructor<T>, conId?: string);
onModuleInit(): Promise<void>;
onApplicationBootstrap(): void;
get entityManager(): EntityManager;
get repository(): Repository<T>;
protected transform(docs: any | any[]): T | T[];
qb(query?: IMysqlRequest<T>, opts?: IMysqlOption<T>): SelectQueryBuilder<T>;
finder(query?: IMysqlRequest<T>, opts?: IMysqlOption<T>): FindManyOptions<T>;
private whereById;
paginate(query: IMysqlRequest<T>, opts?: IMysqlOption<T>): Promise<IMysqlResponse<T>>;
find(query: IMysqlRequest<T>, opts?: IMysqlOption<T>): Promise<T[]>;
count(query: IMysqlRequest<T>, opts?: IMysqlOption<T>): Promise<number>;
findOne(cond: ID | ICondition<T>, query?: Omit<IMysqlRequest<T>, 'condition'>, opts?: IMysqlOption<T>): Promise<T>;
create(body: DeepPartial<T>, opts?: IMysqlOption<T>): Promise<T>;
update(cond: ID | ICondition<T>, body: DeepPartial<T>, options?: IMysqlOption<T>): Promise<T>;
delete(cond: ID | ICondition<T>, opts?: IMysqlOption<T> & {
force?: boolean;
}): Promise<T>;
restore(cond: ID | ICondition<T>, opts?: IMysqlOption<T> & {
reload?: false;
}): Promise<T>;
upsert(body: DeepPartial<T>, onConflicts: KeyOf<T>[], opts?: IMysqlOption<T> & Omit<UpsertOptions<T>, 'conflictPaths'>): Promise<T>;
bulkUpsert(body: DeepPartial<T>[], onConflicts: KeyOf<T>[], opts?: IMysqlOption<T> & Omit<UpsertOptions<T>, 'conflictPaths'> & {
chunkSize?: number;
}): Promise<T[]>;
}
//# sourceMappingURL=mysql.repo.d.ts.map