Hi @Ivan_Lysov,
Welcome to MongoDB community!
So there is a nice workaround I presented for Atlas triggers. Since they are based on change stream events eventually same one can be applied to your scenario.
The main Idea in the linked post is:
- There is a new expireField with 0 life time ttl on it.
- When you want to delete a document you actually set this field to current time.
- Your change stream event listen to an update where the expiry field is present and specify full document.
- The change stream will perform the needed operation and ttl will meanwhile delete that document.
To me this is the most elegant way I can think of.
Let me know if that helps
Thanks
Pavel