I notice you haven’t had a response to this topic yet - were you able to find a solution?
If not, could you confirm if my understanding for your use-case is correct?
By using changeStream event, you are trying to insert a new field: value back in the original collection that matches your $match criteria. If this is correct, then I’m afraid changestream does not have this feature yet. From the changestream documentation page:
Change streams allow applications to access real-time data changes without the complexity and risk of tailing the oplog. Applications can use change streams to subscribe to all data changes on a single collection, a database, or an entire deployment, and immediately react to them. Because change streams use the aggregation framework, applications can also filter for specific changes or transform the notifications at will.
The pipeline in the changestream only allows you to modify the changestream output from the default output but it can not update the data in database. This is so that if you’re only interested in part of a document in the changestream (e.g. if you only need to know the _id of the changed document), the changestream doesn’t need to return the whole document and instead project only the _id using the defined pipeline.
However, should you need to persist the changestream output, you might need to do it manually by modifying the code example you posted as below: