UNPKG

@nestjs/typeorm

Version:

TypeORM for NestJS: connections and repositories through dependency injection, entities, transactions and multiple databases.

69 lines (68 loc) • 3.47 kB
import { Type } from '@nestjs/common'; import { Observable } from 'rxjs'; import { DataSource } from 'typeorm'; import { DataSourceRef } from '../interfaces/data-source-ref.type.js'; import { EntityClassOrSchema } from '../interfaces/entity-class-or-schema.type.js'; /** * This function returns the DataSource name for the given DataSource, DataSourceOptions * or dataSource name. TypeORM v1 removed `name` from `DataSource` and `DataSourceOptions`, * so it is read defensively while remaining backward compatible with 0.3.x * (where the user-supplied options still carry it). * @param {DataSource | DataSourceOptions | string} [dataSource='default'] This optional * parameter is either a DataSource, or a DataSourceOptions or a string. * @returns {string} The DataSource name, or 'default' when no name is set. * * @publicApi */ export declare function getDataSourceName(dataSource?: DataSourceRef | { name?: string; }): string; /** * This function generates an injection token for an Entity or Repository * @param {EntityClassOrSchema} entity parameter can either be an Entity or Repository * @param {DataSource | DataSourceOptions | string} [dataSource='default'] This optional parameter is either * a DataSource, or a DataSourceOptions or a string. * @returns {string} The Entity | Repository injection token * * @publicApi */ export declare function getRepositoryToken(entity: EntityClassOrSchema, dataSource?: DataSourceRef): Function | string; /** * This function generates an injection token for an Entity or Repository * @param {Function} This parameter can either be an Entity or Repository * @returns {string} The Repository injection token * * @publicApi */ export declare function getCustomRepositoryToken(repository: Function): string; /** * This function returns a DataSource injection token for the given DataSource, DataSourceOptions or dataSource name. * @param {DataSource | DataSourceOptions | string} [dataSource='default'] This optional parameter is either * a DataSource, or a DataSourceOptions or a string. * @returns {string | Function} The DataSource injection token. * * @publicApi */ export declare function getDataSourceToken(dataSource?: DataSourceRef): string | Function | Type<DataSource>; /** * @deprecated * * @publicApi */ export declare const getConnectionToken: typeof getDataSourceToken; /** * This function returns a DataSource prefix based on the dataSource name * @param {DataSource | DataSourceOptions | string} [dataSource='default'] This optional parameter is either * a DataSource, or a DataSourceOptions or a string. * @returns {string | Function} The DataSource injection token. */ export declare function getDataSourcePrefix(dataSource?: DataSourceRef): string; /** * This function returns an EntityManager injection token for the given DataSource, DataSourceOptions or dataSource name. * @param {DataSource | DataSourceOptions | string} [dataSource='default'] This optional parameter is either * a DataSource, or a DataSourceOptions or a string. * @returns {string | Function} The EntityManager injection token. */ export declare function getEntityManagerToken(dataSource?: DataSourceRef): string | Function; export declare function handleRetry(retryAttempts?: number, retryDelay?: number, dataSourceName?: string, verboseRetryLog?: boolean, toRetry?: (err: any) => boolean): <T>(source: Observable<T>) => Observable<T>; export declare const generateString: () => string;