LearnBoost/mongoose — pull request #2084 by DasAng (2014-05-17 15:32:41+00:00)
Title: emit reconnected event and change readyState to Connected

I'm quite new to this project so maybe I've missed out something.

Anyway I'm facing the issue with keeping track of when my mongodb connection has been reconnected (because I'm using autoReconnect option) and there was no "reconnected" event being emitted. So I did some digging around the code and added this code to the listen() function in connection.js

conn.db.on('reconnect', function(){
conn.readyState = STATES.connected;
console.log("reconnected");
conn.emit('reconnected');
});

Now I can listen on the "reconnected" event:

mongoose.connection.on("reconnected", function() {})

Help and feedback is appreciated :)