Home > Blockchain >  How to setup a Webhook on MongoDB
How to setup a Webhook on MongoDB

Time:09-13

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?

CodePudding user response:

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.

  • Related