Created
April 6, 2019 07:38
-
-
Save marchpig/792116cb2fa988cd43d8a7286656be7b 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', | |
resumeAfter: { | |
_data: '825CA853CB000000012B022C0100296E5A1004E62EBE797624459D883AA0118B77877146645F696400645CA8538A8983695F9374DBA00004' | |
} | |
}; | |
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