Skip to content

Commit

Permalink
Update connection.js
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 authored Aug 30, 2022
1 parent 53d4f38 commit c6d5889
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,11 @@ Connection.prototype.model = function(name, schema, collection, options) {
}

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

if (!model) {
Expand Down

0 comments on commit c6d5889

Please sign in to comment.