0

I mongod, nodejs, and download mongo-oplog. My replication is set is working on my computer .I have tried to run a replication set on my computer ,while I try to access it from node.js but I still nothing. Am I missing a piece of code ?

var MongoOplog = require('mongo-oplog');
var oplog = MongoOplog('mongodb://127.0.0.1:27017/local', { ns: 'test.posts' }).tail();
console.log("Please Work");
oplog.on('op', function (data) {
  console.log(data);
});
Nick
  • 195
  • 1
  • 3
  • 13

1 Answers1

0

Did you insert some data in posts collection in the test database? All your program does is tail the oplog. You need something else to insert some data, e.g. open a mongo shell and run:

use test
for (var i = 0; i < 20; i++) {db.posts.insert({x:i})}
helmy
  • 9,068
  • 3
  • 32
  • 31