I'm trying to send an email to the user periodically(daily, weekly, monthly) based on their preference from my nodejs application using node-cron
. Here, user can edit/change their mail preference(weekly, daily..etc). so when they do, the cron expression gets updated to match their preference from the backend.
However, the previous preference still getting triggered, I believe that we have to destroy the previous job. how to do it?
Is this the right approach for my problem? or Do I need to store their preferences in database and triggered the mails manually based on the date?