Skip to content

Commit

Permalink
chore(): Aligned MongooseModuleOptions with MongooseModuleAsyncOptions
Browse files Browse the repository at this point in the history
Fixes nestjs#244

BREAKING CHANGE: Removed URI param in MongooseCoreModule.forRoot and made it non-optional in option object
  • Loading branch information
BorntraegerMarc committed Jan 26, 2020
1 parent e2e88b3 commit 64f9721
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/interfaces/mongoose-options.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 3 additions & 9 deletions lib/mongoose-core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -54,7 +51,7 @@ export class MongooseCoreModule implements OnApplicationShutdown {
useFactory: async (): Promise<any> =>
await defer(async () =>
mongooseConnectionFactory(
mongoose.createConnection(uri, mongooseOptions),
mongoose.createConnection(options.uri, mongooseOptions),
mongooseConnectionName,
),
)
Expand Down Expand Up @@ -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,
),
)
Expand Down

0 comments on commit 64f9721

Please sign in to comment.