Skip to content

Commit 7965494

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

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

lib/connection.js

Lines changed: 7 additions & 0 deletions
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)