Watch MongoDB oplog (replica set operation log) for real-time changes in Node.js. Version 2.1.4 supports Promise/async-await, event-based streaming using eventemitter3, and filtering by namespace (database/collection). Requires MongoDB replica set configuration. Built on the native MongoDB driver. Breaking changes in 2.x dropped old callback API in favor of promises. Differentiators: lightweight, small footprint, backward-compatible callbacks in v2, and strong readability with XO.
npm install mongo-oplogNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initialize mongo-oplog, start tailing the oplog, and listen for insert/update/delete events. Stop after 10 seconds.
Replace callbacks with .then()/await; see UPGRADE.md
Start mongod with --replSet rs0 and run rs.initiate() in mongo shell
Upgrade Node.js to 8+ or use v1.x
Use 'dbName.collectionName' (case-sensitive) or regex string like '/test.posts/'
Ensure connection string includes replicaSet=rs0 or use an existing replica set member
Add ?slaveOk=true to the URI or set options.slaveOk: true
Add ?replicaSet=rs0 to the URI
Use import MongoOplog from 'mongo-oplog' (default import)
Start MongoDB with --replSet and run rs.initiate()