A MongoDB oplog watcher for Node.js, part of the entangler.js project.
client
allows you to pass an already connected MongoClient instance from the MongoDB Node.js native driver (see MongoClient().)
uri
allows you to pass a MongoDB connection URI string, frequently generated by hosted MongoDB services such as compose.io. A simple URI for a local MongoDB server might look like this:
mongodb://localhost:27017/test
To install oploggery from npm, run:
npm install oploggery
To watch a collection:
var Oploggery = require('Oploggery');
var oplogger = new Oploggery({
uri: 'mongodb://localhost:27017/test',
format: 'pretty'
});
// Database is 'test', collection is 'users'
oplogger.watch('test.users', function(event) {
console.log(event);
});
This library is based heavily off Mongo Watch by Brandon Mason. Big thanks for making this so easy!
More documentation, tests, examples etc. to come!