0

I have a application built with nodejs. It's hosted on AWS and uses postgres as the database. The application allows for users to create bookings. When a booking is created, an email is sent to the user to notify them of the booking.

The problem I'm having trouble wrapping my head around is how I'd implement recurring bookings. Let's say a user books something on Tuesday, July 12, how could I create a system that automatically sends an email to them every 12th of the month to notify them of the booking.

I was thinking of having a field on each booking record the specifies the recurring date. Then, I'd have a seperate lambda function that runs every hour that searches and selects all the bookings that have the same recurring date and hour as the current day and hour. Then for each booking, I'd send a notification/email. Having the lambda run every hour would ensure the same record would not be processed twice.

Is my solution good, does it have any problems? I'm also not sure if there is an AWS service that does this that already exists.

3
  • An EventBridge object can be created with a cron style schedule that can call a Lambda. So calling a lambda every hour is possible. Jul 13, 2022 at 2:22
  • 2
    You should not deal with sending emails for a particular type of booking at all. The mail is or should be sent as a result of a booking being processed. As soon as you process the recurring booking, the email being sent will not be your concern. It just happens. Jul 13, 2022 at 5:32
  • You are almost implementing your own calendar, and also bookings. It might be more useful to model the recurrence, rather than pre-calculating dates. Do these recurring bookings have an end date? Can bookings be made to recur indefinitely? Jul 14, 2022 at 1:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.