Skip to content

Commit 7965494

Browse files
committedJul 26, 2018
fix(connection): throw helpful error when using legacy mongoose.connect() syntax
Fix #6756
1 parent 42ddc42 commit 7965494

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
 

‎lib/connection.js

+7
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,13 @@ Connection.prototype.openUri = function(uri, options, callback) {
414414
options = null;
415415
}
416416

417+
if (['string', 'number'].indexOf(typeof options) !== -1) {
418+
throw new MongooseError('Mongoose 5.x no longer supports ' +
419+
'`mongoose.connect(host, dbname, port)` or ' +
420+
'`mongoose.createConnection(host, dbname, port)`. See ' +
421+
'http://mongoosejs.com/docs/connections.html for supported connection syntax');
422+
}
423+
417424
const Promise = PromiseProvider.get();
418425
const _this = this;
419426

0 commit comments

Comments
 (0)
Please sign in to comment.