Monitoring Mongo for changes with Node.js Monitoring Mongo for changes with Node.js database database

Monitoring Mongo for changes with Node.js


The question is if all data is added to your database through your node.js app. If so, you can use the EventEmitter class of node.js to trigger an event (http://nodejs.org/api.html#eventemitter-14).

If the database is populated by some other app, things are getting difficult. In this case you would need something like a database trigger, which is AFAIK not yet availabled in MongoDB.

Pushing Events to the Client (aka Comet) will be possible once the HTML 5 websockets API makes its way into all major browsers.

In the meantime, you can only try to emulate this behaviour using techniques like (long-term) AJAX polling, forever frame etc. but each of them has its weaknesses.


I would turn on replication in your mongodb. There is a replicate? database that contains a list of changes, similar to the mysql replication log. You can monitor that.

-daniel


Almost 3y since the last answer. I would suggest looking at:

npm install mubsub should get you there