From 3d2fe5456a3c077056d64dca50f9094c33e7774b Mon Sep 17 00:00:00 2001 From: Omar Berrami Date: Wed, 19 Jul 2023 16:26:57 +0200 Subject: [PATCH] update createMongooseProviders createMongooseProviders to prevent reloading compiled model if already existed, and return the loaded one --- lib/mongoose.providers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mongoose.providers.ts b/lib/mongoose.providers.ts index 1c2eb77b..18cb8d9e 100644 --- a/lib/mongoose.providers.ts +++ b/lib/mongoose.providers.ts @@ -19,7 +19,7 @@ export function createMongooseProviders( { provide: getModelToken(option.name, connectionName), useFactory: (connection: Connection) => { - const model = connection.model( + const model = connection.models[option.name] ? connection.models[option.name] : connection.model( option.name, option.schema, option.collection,