Databases & System Design•Part 3: NoSQL & Document Databases (MongoDB, DynamoDB) (26 - 40)
MongoDB Oplog & Change Streams:
In Simple Words: The Oplog records all write operations. Change Streams allow apps to listen to real-time database changes without polling.
javascript
const changeStream = db.collection('orders').watch();
changeStream.on('change', next => {
console.log('Realtime DB mutation:', next.operationType, next.fullDocument);
});