MongoDB Oplog tailing DSL.
var oplog = require('oplog')('localhost:27017/local');
oplog.query({ i: /u|d/ });
oplog.filter()
.ns('*.users')
.on('update', function(){ });
.on('remove', function(){ });
oplog.tail();- Represents an unique connection to the mongodb host to tail.
- Emits
opevent for each operation read with an object.
Builds the tailer based on an existing monk instance.
Builds the tailer by connecting to the given mongodb uri.
- Accepts
rsandlocal - Defaults to
rsif connected to multiple hosts, orlocalotherwise. - If the defaults are not suitable, it needs to be called, otherwise
oplogcan't decide whether to tail theoplog.$mainoroplog.rscollections.
- Sets the query by which to tail.
- Defaults to
{ ts: { $gt: { $timestamp: { t: <now>, i: 0 } } } }
Creates a new Filter.
- Starts the query and grabs the tailable cursor.
- Must be called to get events firing.
- Kills the cursor.
- Multiple filters can be declared per
oplog. - Emits
update,remove,insertevents with each operation.
Only emits the events for namespaces matching ns pattern.
Shortcut for .ns('{db}.*').
Shortcut for .ns('*.{col}').
oplog must be used with mongodb 2.2.2+
Make sure to be running a replica set (which can be single-member) before executing
$ make test