Skip to content

Commit

Permalink
fix(connection): throw helpful error when using legacy `mongoose.conn…
Browse files Browse the repository at this point in the history
…ect()` syntax

Fix #6756
  • Loading branch information
vkarpov15 committed Jul 26, 2018
1 parent 42ddc42 commit 7965494
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/connection.js
Expand Up @@ -414,6 +414,13 @@ Connection.prototype.openUri = function(uri, options, callback) {
options = null;
}

if (['string', 'number'].indexOf(typeof options) !== -1) {
throw new MongooseError('Mongoose 5.x no longer supports ' +
'`mongoose.connect(host, dbname, port)` or ' +
'`mongoose.createConnection(host, dbname, port)`. See ' +
'http://mongoosejs.com/docs/connections.html for supported connection syntax');
}

const Promise = PromiseProvider.get();
const _this = this;

Expand Down

0 comments on commit 7965494

Please sign in to comment.