Skip to content

Instantly share code, notes, and snippets.

@marchpig
Created April 6, 2019 07:38
Show Gist options
  • Save marchpig/792116cb2fa988cd43d8a7286656be7b to your computer and use it in GitHub Desktop.
Save marchpig/792116cb2fa988cd43d8a7286656be7b to your computer and use it in GitHub Desktop.
const MongoClient = require('mongodb').MongoClient;
const url = "mongodb://mongo1:30001,mongo2:30002,mongo3:30003?replicaSet=my-rs";
MongoClient.connect(url, { useNewUrlParser: true })
.then(client => {
const db = client.db('test');
const collection = db.collection('engineers');
const changeStreamOptions = {
fullDocument: 'updateLookup',
resumeAfter: {
_data: '825CA853CB000000012B022C0100296E5A1004E62EBE797624459D883AA0118B77877146645F696400645CA8538A8983695F9374DBA00004'
}
};
const changeStream = collection.watch(changeStreamOptions);
changeStream.on('change', next => console.log(next));
})
.catch(err => console.log(err));
@marchpig
Copy link
Author

marchpig commented Apr 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment