diff --git a/lib/connection.js b/lib/connection.js index 2f847bffc2f..a6754208061 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -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);