Back

How 2 Access Newly Created Document Data in Database Trigger Function for a Blog Newsletter System.

  • 0
  • Functions
  • REST API
Sundeeep Dasari
18 Oct, 2024, 05:24

šŸ‘‰šŸ¼ I have a "blogs" collection in my production database "blogify"

šŸ‘‰šŸ¼ I want to write a function "sendNewsletter" which sends the newsletter immediately after someone wrote the blog and the audience subscribed to them.

šŸ‘‰šŸ¼ I would like to add an event to listen the "blogs" collection... and after some blog is created, this function should be executed.

šŸ‘‰šŸ¼ My Question is: In the context of a database trigger or event listener for new blog post creation, how can the "sendNewsletter" function access the details of the newly created blog post document? Specifically, what methods or techniques can be used to retrieve the content of the document that triggered the function, so that the function can identify the author and their subscribers?

PLEASE HELP ME OUT!

TL;DR
- Developer wants to trigger a newsletter function after a blog post is created - Needs to access newly created blog post document data in the trigger function - Looking for methods or techniques to retrieve the content of the document that triggered the function Solution: Use MongoDB Change Streams with triggers to access newly created document data within the trigger function. This allows the function to identify the author and their subscribers when sending the newsletter.
Sundeeep Dasari
18 Oct, 2024, 05:26

How 2 Access Newly Created Document Data in Database Trigger Function for a Blog Newsletter System.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more