Is there a way to unset fields is document similar to expire TTL

Instead of removing the whole document as TTL expire does, can we unset particular fields?
If yes, how ?

Hi @shamim_khan ,

Welcome to MongoDB Community.

Do you mean if there is a way to automate the unset of fields based on a time field in that document?

Best regards,
Pavel

absolutely, I have a use case where depending on time field I want to unset selective fields

Hi @shamim_khan ,

Read the following trick it uses Atlas triggers and a temp collection to orchestrate that. If you are not using atlas (Super recommended) you can consider writing a small piece of code using chnage streams to catch the TTL deletes of the temp doc:

This may allow you to have logic to unset fields in the final event.

Best regards,
Pavel