Skip to content

Commit 8073acb

Browse files
Merge pull request #1103 from skrtheboss/fix/async-mongoose-connection
fix(mongooose-core-module): wait for connection in forRootAsync
2 parents 683706e + 008757a commit 8073acb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/mongoose-core.module.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@ export class MongooseCoreModule implements OnApplicationShutdown {
9797
return await lastValueFrom(
9898
defer(async () =>
9999
mongooseConnectionFactory(
100-
mongoose.createConnection(
101-
mongooseModuleOptions.uri as string,
102-
mongooseOptions,
103-
),
100+
await mongoose
101+
.createConnection(
102+
mongooseModuleOptions.uri as string,
103+
mongooseOptions,
104+
)
105+
.asPromise(),
104106
mongooseConnectionName,
105107
),
106108
).pipe(

0 commit comments

Comments
 (0)