I have a collection named Items
with wokrspace_id
(ObjectId) field on it. So whenever an item inserted/updated or deleted i want to use change stream watch method to broadcast it to users that belong to this workspace.
I have no difficulties dealing with insert/update operationTypes, i am able to access workspace_id
within fullDocument
prop. But it turns out to be not that straightforward to access it on delete
operation.
i’ve encountered this SO issue, where @Asya_Kamsky mentioned in comments that it can be done by composing the documentKey, but unfortunately i could not accomplish this (would be grateful if there are any gists on that)
So, the question is how this can be done in most elegant way?