@nestjs/typeorm
Version:
Nest - modern, fast, powerful node.js web framework (@typeorm)
49 lines (48 loc) • 1.66 kB
TypeScript
import { ModuleMetadata, Provider, Type } from '@nestjs/common';
import { DataSource, DataSourceOptions } from 'typeorm';
export type TypeOrmModuleOptions = {
/**
* Number of times to retry connecting
* Default: 10
*/
retryAttempts?: number;
/**
* Delay between connection retry attempts (ms)
* Default: 3000
*/
retryDelay?: number;
/**
* Function that determines whether the module should
* attempt to connect upon failure.
*
* @param err error that was thrown
* @returns whether to retry connection or not
*/
toRetry?: (err: any) => boolean;
/**
* If `true`, entities will be loaded automatically.
*/
autoLoadEntities?: boolean;
/**
* If `true`, connection will not be closed on application shutdown.
* @deprecated
*/
keepConnectionAlive?: boolean;
/**
* If `true`, will show verbose error messages on each connection retry.
*/
verboseRetryLog?: boolean;
} & Partial<DataSourceOptions>;
export interface TypeOrmOptionsFactory {
createTypeOrmOptions(connectionName?: string): Promise<TypeOrmModuleOptions> | TypeOrmModuleOptions;
}
export type TypeOrmDataSourceFactory = (options?: DataSourceOptions) => Promise<DataSource>;
export interface TypeOrmModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
name?: string;
useExisting?: Type<TypeOrmOptionsFactory>;
useClass?: Type<TypeOrmOptionsFactory>;
useFactory?: (...args: any[]) => Promise<TypeOrmModuleOptions> | TypeOrmModuleOptions;
dataSourceFactory?: TypeOrmDataSourceFactory;
inject?: any[];
extraProviders?: Provider[];
}