0.1.1 • Published 10 years ago

oploggery v0.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

Oploggery

A MongoDB oplog watcher for Node.js, part of the entangler.js project.

Oploggery is based off the fabulous Mongo Watch project by Brandon Mason, re-written in JavaScript (sorry CoffeeScripters!) and updated to give more flexibility when connecting to your database.

Many of the options are similar to Mongo Watch, but the connection options have been completely replaced with client and uri options.

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

Install

To install oploggery from npm, run:

npm install oploggery

Usage

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);
});

Credits

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!