Skip to content

Instantly share code, notes, and snippets.

@bruchu
Created October 23, 2015 22:03
Show Gist options
  • Save bruchu/52466549f397fee65ee9 to your computer and use it in GitHub Desktop.
Save bruchu/52466549f397fee65ee9 to your computer and use it in GitHub Desktop.
dbUrl = conf.mongo.oplogUrl || "mongodb://localhost:27017/local";
dbUrl = dbUrl + '?socketTimeoutMS=3000000'
query = {};
query = {$gte:MongoDB.Timestamp(Date.now()/1000 - 86400, 0)};
// query = {$gte:0};
console.log(query);
// dbUrl = 'mongodb://localhost:27017/local'
// Open the connection to the database
MongoDB.MongoClient.connect(dbUrl, function(err, db) {
// Get to oplog collection
db.collection("oplog.rs", function(err, oplog) {
if (err) {
return console.log(err);
}
// Find the highest timestamp
oplog.find(
query,
{
explain:true,
// tailable: true,
timeout: false,
awaitdata: true,
oplogReplay: true,
cursorReplay: true,
numberOfRetries: Number.MAX_VALUE // using -1 doesn't work here
}
).toArray(function(err, docs) {
if (err) {
return console.error(err);
}
console.log(docs);
process.exit();
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment