Skip to content

Commit

Permalink
perf: connectionError to connectionErrorFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
jiayisheji committed Oct 28, 2022
1 parent 923ca93 commit 5b6503a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 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 @@ -9,7 +9,7 @@ export interface MongooseModuleOptions
retryDelay?: number;
connectionName?: string;
connectionFactory?: (connection: any, name: string) => any;
connectionError?: (error: MongooseError) => MongooseError;
connectionErrorFactory?: (error: MongooseError) => MongooseError;
}

export interface MongooseOptionsFactory {
Expand Down
8 changes: 4 additions & 4 deletions lib/mongoose-core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ export class MongooseCoreModule implements OnApplicationShutdown {
retryDelay,
connectionName,
connectionFactory,
connectionError,
connectionErrorFactory,
...mongooseOptions
} = options;

const mongooseConnectionFactory =
connectionFactory || ((connection) => connection);

const mongooseConnectionError =
connectionError || ((error) => error);
connectionErrorFactory || ((error) => error);

const mongooseConnectionName = getConnectionToken(connectionName);

Expand Down Expand Up @@ -98,15 +98,15 @@ export class MongooseCoreModule implements OnApplicationShutdown {
retryDelay,
uri,
connectionFactory,
connectionError,
connectionErrorFactory,
...mongooseOptions
} = mongooseModuleOptions;

const mongooseConnectionFactory =
connectionFactory || ((connection) => connection);

const mongooseConnectionError =
connectionError || ((error) => error);
connectionErrorFactory || ((error) => error);

return await lastValueFrom(
defer(async () =>
Expand Down

0 comments on commit 5b6503a

Please sign in to comment.