UNPKG

1.62 kBTypeScriptView Raw
1import { ModuleMetadata, Type } from '@nestjs/common';
2import { Connection, ConnectionOptions } 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 */
29 keepConnectionAlive?: boolean;
30 /**
31 * If `true`, will show verbose error messages on each connection retry.
32 */
33 verboseRetryLog?: boolean;
34} & Partial<ConnectionOptions>;
35export interface TypeOrmOptionsFactory {
36 createTypeOrmOptions(connectionName?: string): Promise<TypeOrmModuleOptions> | TypeOrmModuleOptions;
37}
38export declare type TypeOrmConnectionFactory = (options?: ConnectionOptions) => Promise<Connection>;
39export interface TypeOrmModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
40 name?: string;
41 useExisting?: Type<TypeOrmOptionsFactory>;
42 useClass?: Type<TypeOrmOptionsFactory>;
43 useFactory?: (...args: any[]) => Promise<TypeOrmModuleOptions> | TypeOrmModuleOptions;
44 connectionFactory?: TypeOrmConnectionFactory;
45 inject?: any[];
46}