DEV Community

Shivam
Shivam

Posted on

3

Event emails reminder using Mongo DB Atlas

Overview of My Submission

The main aim of this project is to fire an email to the user with an appropriate description when the time of the particular event (set by the user prior) is up.

Working

1.The events are stored in documents. Each event has keys: description, time, processed, emailId.

Image description

Index is used to make query process fast
db. remindersList.createIndex({ processed: 1, date: 1 })

2.The time (in time field) controls when the event will be fired. The scheduled trigger type is deployed which checks what event has been passed in regular intervals.

Image description

3.The event occurrence, email is fired to email id (in emailId field) with description (in description field). For sending email, I am using 3rd party dependency SendGrid.

Image description

4.After the event is processed, the processed field is set true, so that event is not fired again.
context.services.get("mongodb-atlas").db("reminders").collection("remindersList").updateOne({_id:id},{$set:{processed:true}})

Submission Category:

Choose Your Own Adventure

Atlas services used:

  1. Atlas Database
  2. Realm Triggers
  3. Realm Functions

Link to Code

GitHub logo shivamarora1 / mongodb-realm

Email Reminder Service Mongo DB Realm application

Submission for MongoDB Atlashackathon

The main aim of this project is to fire an email to the user with an appropriate description when the time of the particular event (set by the user prior) is up.

Working

  1. The events are stored in documents. Each event has keys: description, time, processed, emailId.

Image description

Index is used to make query process fast db. remindersList.createIndex({ processed: 1, date: 1 })

  1. The time (in time field) controls when the event will be fired. The scheduled trigger type is deployed which checks what event has been passed in regular intervals.

Image description

  1. The event occurrence, email is fired to email id (in emailId field) with description (in description field). For sending email, I am using 3rd party dependency SendGrid.

Image description

  1. After the event is processed, the processed field is set true, so that event is not fired again context.services.get("mongodb-atlas").db("reminders").collection("remindersList").updateOne({_id:id},{$set:{processed:true}})

Submission Category:

Choose

Additional Resources / Info

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay