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
op
event 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
rs
andlocal
- Defaults to
rs
if connected to multiple hosts, orlocal
otherwise. - If the defaults are not suitable, it needs to be called, otherwise
oplog
can't decide whether to tail theoplog.$main
oroplog.rs
collections.
- 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
,insert
events 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