Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup a Webhook on MongoDB

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?

like image 748
Vitor Avatar asked Oct 28 '25 09:10

Vitor


2 Answers

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.

like image 191
Boaz Avatar answered Oct 30 '25 23:10

Boaz


I believe MongoDB have their own way to do that. You can check Triggers

enter image description here

like image 41
GeekDev Avatar answered Oct 30 '25 21:10

GeekDev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!