You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're connecting to our MongoDB instance with mongoose.connect. Up till the release of Mongoose 4.4.7, the returned Connection's connection.db property gave us a dropDatabase method.
After upgrading to 4.4.7, the connection.db property is undefined.
We connect this way:
vardb=mongoose.connect(config.db.uri,config.db.options,function(err){// Log Errorif(err){console.error(chalk.red('Could not connect to MongoDB!'));console.log(err);}else{// Enabling mongoose debug mode if requiredmongoose.set('debug',config.db.debug);// Call callback FNif(cb)cb(db);}});
And we have a Grunt task to drop the database:
grunt.task.registerTask('dropdb','drop the database',function(){// async modevardone=this.async();// Use mongoose configurationvarmongoose=require('./config/lib/mongoose.js');mongoose.connect(function(db){db.connection.db.dropDatabase(function(err){if(err){console.log(err);}else{console.log('Successfully dropped db: ',db.connection.db.databaseName);}db.connection.db.close(done);});});});
I reverted back to Mongoose 4.4.6 and this issue went away.
The text was updated successfully, but these errors were encountered:
Upon further investigation, it appears the connection isn't being made. When I change the above example that connects to the database, to use createConnection instead of connect, I get the following error thrown.
Perhaps, I'm complicating the matter by changing the connection method to use createConnection (for the purposes of debugging) but I find it interesting that no error is thrown when attempting the connection by using connect; but it's not making the connection.
We're connecting to our MongoDB instance with
mongoose.connect
. Up till the release of Mongoose4.4.7
, the returned Connection'sconnection.db
property gave us adropDatabase
method.After upgrading to
4.4.7
, theconnection.db
property is undefined.We connect this way:
And we have a Grunt task to drop the database:
I reverted back to Mongoose
4.4.6
and this issue went away.The text was updated successfully, but these errors were encountered: