Skip to content

Instantly share code, notes, and snippets.

@marchpig
Created April 6, 2019 06:27
Show Gist options
  • Save marchpig/28ce4e3b9e2566e2d1b98307ffa1fdbd to your computer and use it in GitHub Desktop.
Save marchpig/28ce4e3b9e2566e2d1b98307ffa1fdbd 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'
};
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