Skip to content

Commit

Permalink
Merge pull request #12359 from chochihim/patch-1
Browse files Browse the repository at this point in the history
Fix regression for `overwriteModels` flag
  • Loading branch information
vkarpov15 authored Aug 30, 2022
2 parents 67bfddd + c6d5889 commit f858ca5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,14 @@ Connection.prototype.model = function(name, schema, collection, options) {
// do not cache the sub model
return sub;
}

if (arguments.length === 1) {
model = this.models[name];
if (!model) {
throw new MongooseError.MissingSchemaError(name);
}
return model;
}

if (!model) {
throw new MongooseError.MissingSchemaError(name);
Expand Down

0 comments on commit f858ca5

Please sign in to comment.