I have document in one collection. once its reaches TTL, I need to remove documents from other collections based on some lookup(i.e, foreignKey reference). How to do this in mongo query
I think the best way is to populate the relevant documents with a corresponding TTL field/index as well so they will be removed as well with that document.
Otherwise you can use Atlas triggers on “delete” event if the data is in Atlas or MongoDB change streams on delete event and use the delete _id key to run remove commands on other collections.
Thanks @Pavel_Duchovny. I will try with Triggers