I am trying Mongodb change streams using Mongoose:
Person.watch().on('change', data => console.log(data));
It tracked all the change of the database, is it possible to apply condition and track certain documents instead, like how to check id==1 and id==2 documents only?
I'm not sure if you can do this on the model. But assuming you can, you probably can pass a pipeline to filter the input docs. I personnaly use watch on the DB and it works fine.
Here, i use the
{fullDocument:"updateLookup"}option to add the whole object to results. I can then match theidwith simple$inquery operator.