Skip to content

Commit

Permalink
update createMongooseProviders
Browse files Browse the repository at this point in the history
createMongooseProviders to prevent reloading compiled model if already existed, and return the loaded one
  • Loading branch information
Omar Berrami committed Jul 19, 2023
1 parent 5d7be6c commit 3d2fe54
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mongoose.providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 3d2fe54

Please sign in to comment.