UNPKG

1.68 kBTypeScriptView Raw
1import { ModuleMetadata, Provider, Type } from '@nestjs/common';
2import { DataSource, DataSourceOptions } from 'typeorm';
3export declare type TypeOrmModuleOptions = {
4 /**
5 * Number of times to retry connecting
6 * Default: 10
7 */
8 retryAttempts?: number;
9 /**
10 * Delay between connection retry attempts (ms)
11 * Default: 3000
12 */
13 retryDelay?: number;
14 /**
15 * Function that determines whether the module should
16 * attempt to connect upon failure.
17 *
18 * @param err error that was thrown
19 * @returns whether to retry connection or not
20 */
21 toRetry?: (err: any) => boolean;
22 /**
23 * If `true`, entities will be loaded automatically.
24 */
25 autoLoadEntities?: boolean;
26 /**
27 * If `true`, connection will not be closed on application shutdown.
28 * @deprecated
29 */
30 keepConnectionAlive?: boolean;
31 /**
32 * If `true`, will show verbose error messages on each connection retry.
33 */
34 verboseRetryLog?: boolean;
35} & Partial<DataSourceOptions>;
36export interface TypeOrmOptionsFactory {
37 createTypeOrmOptions(connectionName?: string): Promise<TypeOrmModuleOptions> | TypeOrmModuleOptions;
38}
39export declare type TypeOrmDataSourceFactory = (options?: DataSourceOptions) => Promise<DataSource>;
40export interface TypeOrmModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
41 name?: string;
42 useExisting?: Type<TypeOrmOptionsFactory>;
43 useClass?: Type<TypeOrmOptionsFactory>;
44 useFactory?: (...args: any[]) => Promise<TypeOrmModuleOptions> | TypeOrmModuleOptions;
45 dataSourceFactory?: TypeOrmDataSourceFactory;
46 inject?: any[];
47 extraProviders?: Provider[];
48}