How to use mongodb change streams

1.5k views Asked by At

How do I use the change stream approach to reference a collection or number of collections for a user.

Scenario similar to Facebook where friends news shows on your feed.

2

There are 2 answers

0
heydar dasoomi On
0
Rajath Rao - Software Engineer On
conn = new Mongo("mongodb://localhost:27017/demo?replicaSet=rs");
db = conn.getDB("demo");
collection = db.example;
const changeStreamCursor = collection.watch();

By using the parameterless watch() method, this change stream will signal every write to the example collection.