skip to Main Content

I have an application that stores data in a MongoDB collection "x".

I need that when some new data is inserted into this collection, MongoDB sends a post to another application saying "Hey, new data {"something":"ok"} has been inserted into collection x".

Is there a default function in MongoDB to allow a webhook configuration or do I need to run a Node.js server and listen for this "x" collection?

2

Answers


  1. There is no built-in webhook option in MongoDB natively. You will need to have some server-side code subscribe to a change stream and listen to DB events.

    However, if you use a managed solution like MongoDB Atlas, you could configure a database trigger that can be used (among other things) to notify an external service about DB events. The MongoDB Atlas triggers also use change streams in the background.

    Login or Signup to reply.
  2. I believe MongoDB have their own way to do that. You can check Triggers

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search