Search code examples
mongodbspring-data-mongodbttl

Changing flag in other document when ttl reached in mongo?


I'm having two collections: Devices and Registrations.

When I add device then I populate Devices with appropriate entry and create document in Registrations with ttl. After one hour entry expires in Registrations but I would like to additionally set status flag in Devices.

Is there an option to create kind of 'function' that would change such flag for a given device after reaching a ttl?


Solution

  • You're probably looking for Change Streams and invalidate event.

    There's also spring data mongodb support.