Skip to content

Commit c6d5889

Browse files
authored
Update connection.js
1 parent 53d4f38 commit c6d5889

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/connection.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,11 @@ Connection.prototype.model = function(name, schema, collection, options) {
12311231
}
12321232

12331233
if (arguments.length === 1) {
1234-
return this.models[name];
1234+
model = this.models[name];
1235+
if (!model) {
1236+
throw new MongooseError.MissingSchemaError(name);
1237+
}
1238+
return model;
12351239
}
12361240

12371241
if (!model) {

0 commit comments

Comments
 (0)