Created
April 6, 2019 06:27
-
-
Save marchpig/28ce4e3b9e2566e2d1b98307ffa1fdbd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://medium.com/@marchpig/mongodb-change-streams-baa78eaa82ed