The following is my code:
mongoose.connect(\'mongodb://localhost/mydatabase\');
var db = mongoose.connection;
db.on(\'error\', console.error.bind(console, \'co
Make sure that you are actually connected to your Mongo instance, otherwise queries will be left hanging and often no error is thrown or returned. An error in my Mongo URI was causing this for me.
In your code, you have your Mongo URI set to mongodb://localhost/mydatabase
. I imagine that this is probably not correct and is the cause of your problem. Change your URI to just localhost:27017
, which is the default port that Mongo is set to run on.