Filter stream events with a pipeline.
Section: Change streams
Watch only selected changes
javascript
javascript
const stream = db.orders.watch([{ $match: { operationType: "insert" } }])Explanation
Filtering early helps keep change events focused and lighter to process.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Change streams