Improve Changestream metadata by including userId(who), action/intent (event name).
This can be done by including meta data in the options for C(R)UD operations!
Something like: User.updateOne({ _id }, { $set: { name: "newName" } }, { $meta: { userId: _id, action: "nameUpdated" })
This is super useful because now changestream can be used to create event store or audit logs, out of the box. I just have to store all the changestream events from the relevant collections. This also makes event driven architecture in micro services super useful. Developers can use this to publish events directly to a message broker such as kafka, where action would be equivalent to topic. This makes sure that events are published at least once to the message broker and also no need to add publishing logic to every database operations!
![](https://secure.gravatar.com/avatar/c7be74c13bb8f297e8ca70c053adcdd7?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)