1

I want to delete an entry form user's activity collection in an hour if nothing happened on it. I'm getting it with Mongoose TTL index expireAfterSeconds. But I also need to send push notification to the user, the activity belongs to, when that activity is deleted.

Is there a way, I can get callback when expiration is performed by MongoDb TTL? Or any other way without using crons as creating multiple jobs might not be good for server (according to my pov). Also I'm updating expiry time so cron would also be difficult to pause, stop, restart, etc

TalESid
  • 2,304
  • 1
  • 20
  • 41
  • Please refer this : https://stackoverflow.com/questions/49389459/mongodb-is-it-possible-to-capture-ttl-events-with-change-stream-to-emulate-a-sc – Vaibhav Tamuche Mar 15 '21 at 07:06
  • MongoDB has "Change streams". perhaps this helps?: https://docs.mongodb.com/manual/changeStreams/ – Marc Mar 15 '21 at 09:42

0 Answers0