I want to create ticketing system . Where ticket get cancelled after given period of time ?.For deleting after some time I am going to use indexing feature by MongoDb . But before it gets expire or after the expiry of that particular ticket I want to retrive or save it in different collection for future is it possible using mongodb ?
In the current version of MongoDB, 5.0.8 as I'm writing this, it's not directly supported, but it will be in MongoDB 6.0 (CF this jira ticket) and there is a workaround that you can use in the meantime (keep reading!).
Let me explain. What you are trying to do is:
In 5.0.8, this change stream event will only contain the
_id field of the deleted document, and nothing else, as that's the only information currently available in the oplog.
In 6.0, you will be able to access the previous state of this document (so it's last state before being deleted).
That being said, there is a workaround that Pavel Duchovny explained in his blog post. You can easily accommodate his notification system to achieve your desired behaviour.