UNPKG

1.07 kBTypeScriptView Raw
1import { ModuleMetadata, Type } from '@nestjs/common';
2import { ConnectOptions, MongooseError, Connection } from 'mongoose';
3export interface MongooseModuleOptions extends ConnectOptions {
4 uri?: string;
5 retryAttempts?: number;
6 retryDelay?: number;
7 connectionName?: string;
8 connectionFactory?: (connection: any, name: string) => any;
9 connectionErrorFactory?: (error: MongooseError) => MongooseError;
10 lazyConnection?: boolean;
11 onConnectionCreate?: (connection: Connection) => void;
12}
13export interface MongooseOptionsFactory {
14 createMongooseOptions(): Promise<MongooseModuleOptions> | MongooseModuleOptions;
15}
16export type MongooseModuleFactoryOptions = Omit<MongooseModuleOptions, 'connectionName'>;
17export interface MongooseModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
18 connectionName?: string;
19 useExisting?: Type<MongooseOptionsFactory>;
20 useClass?: Type<MongooseOptionsFactory>;
21 useFactory?: (...args: any[]) => Promise<MongooseModuleFactoryOptions> | MongooseModuleFactoryOptions;
22 inject?: any[];
23}