Code:
var connection = mongoose.createConnection('mongodb://localhost:9000/' + databaseName);
connection.db.dropDatabase(function(err){
// never reach this point!
debugger;
console.log(err);
console.log('-------------->Dropped database: ' + databaseName);
});
If I do connection.open it says that it’s already opening and no multiple calls to “open” are supported for the same connection.
Even this doesn’t work
var conn = mongoose.createConnection('mongodb://localhost',databaseName, 9000, {}, function(){
console.log('created'); // is reached
conn.db.dropDatabase(callback); // but the callback is not called anyway
});
What is the problem? (“mongoose”: “3.1.0”)
The database is not even dropped…
thanks
The problem is that the dropDatabase command was not queued and not run when the connection opened. So if I used a callback on the createConnection then it worked and drop the db after this, it worked!