diff --git a/lib/interfaces/mongoose-options.interface.ts b/lib/interfaces/mongoose-options.interface.ts index e07e7d50..5309ef14 100644 --- a/lib/interfaces/mongoose-options.interface.ts +++ b/lib/interfaces/mongoose-options.interface.ts @@ -3,7 +3,7 @@ import { ModuleMetadata } from '@nestjs/common/interfaces'; import { ConnectionOptions } from 'mongoose'; export interface MongooseModuleOptions extends ConnectionOptions { - uri?: string; + uri: string; retryAttempts?: number; retryDelay?: number; connectionName?: string; diff --git a/lib/mongoose-core.module.ts b/lib/mongoose-core.module.ts index 8e4e081c..a5b9f440 100644 --- a/lib/mongoose-core.module.ts +++ b/lib/mongoose-core.module.ts @@ -29,10 +29,7 @@ export class MongooseCoreModule implements OnApplicationShutdown { private readonly moduleRef: ModuleRef, ) {} - static forRoot( - uri: string, - options: MongooseModuleOptions = {}, - ): DynamicModule { + static forRoot(options: MongooseModuleOptions): DynamicModule { const { retryAttempts, retryDelay, @@ -54,7 +51,7 @@ export class MongooseCoreModule implements OnApplicationShutdown { useFactory: async (): Promise => await defer(async () => mongooseConnectionFactory( - mongoose.createConnection(uri, mongooseOptions), + mongoose.createConnection(options.uri, mongooseOptions), mongooseConnectionName, ), ) @@ -95,10 +92,7 @@ export class MongooseCoreModule implements OnApplicationShutdown { return await defer(async () => mongooseConnectionFactory( - mongoose.createConnection( - mongooseModuleOptions.uri as string, - mongooseOptions, - ), + mongoose.createConnection(uri, mongooseOptions), mongooseConnectionName, ), )