googleinterns / knative-source-mongodb

Apache License 2.0
3 stars 2 forks source link

Filtering of Changes using mongo pipeline #25

Open selim5 opened 4 years ago

selim5 commented 4 years ago

In order to add a filter to the type of changes to log, we can easily add a pipeline to the code like such

matchPipeline := bson.D{
   {
      "$match", bson.D{
            {"operationType", "insert"},
            {"fullDocument.duration", bson.D{
               {"$gt", 30},
            }},
      },
   },
}

episodesStream, err := episodesCollection.Watch(context.TODO(), mongo.Pipeline{matchPipeline})

Ressource

https://developer.mongodb.com/quickstart/golang-change-streams

selim5 commented 4 years ago

Reopened to remember we can add support for that