3

How to specify the Pipeline array for the watch method

I am trying to use Mongoose with MongoDB and set a watch on a collection using a pipeline. Both the Mongoose documentation (https://mongoosejs.com/docs/api/model.html#model_Model.watch ) & the JS mongodb API (http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#watch ) mention 2 parameters for the Watch method. However, in Visual Code, the watch method allows only 1 parameter.

this.DataModel.watch(matchStage,{ fullDocument: 'updateLookup' }).on('change', change => console.log(change));

Visual Studio complains that 'Expected 0-1 arguments, but got 2'. If I remove the matchStage parameter in the watch method, no error is reported but I am unable to set the filter represented by matchStage

user5336
  • 161
  • 5

0 Answers0