MongoDB Atlas Triggers

Hello, is it possible for me to access the changed field values returned by a trigger from my React front-end?

Hi, not entirely sure what you are looking for, but we do expose a way to get the same ChangeEvent directly to your device. See the thread here on Watch() in the SDK’s: How to use watch() on web SDK? - #3 by Aurelio_Petrone

Hi, thank you for your prompt reply. Please educate me if I am wrong, as I have only recently read through a number of ways to enable real-time capability on MongoDB.

My understanding of the link you sent was that it’s one of the methods of using a change stream. However, I notice on my MongoDB Atlas UI there was a ‘Triggers’ under Data Services. I am looking to use ‘Triggers’ instead.

From there, I am hoping to allow my front-end to store values from certain fields of the updated documents immediately after the change event happens.

Hi, so Watch() is a way for SDKs to consume a change stream and Triggers is a way to have Realm be in charge of consuming a Change Stream and run a function on each event. I guess you could have your function insert the change events to another collection and then have your SDK sync/watch that collection, but I am still a little confused by what you are trying to do and how it differs from what Watch() does.

Owhh I see now, so they are essentially still change streams. I didn’t understand this. Thank you for explaining. In that case, the two has indeed no difference.

Thanks for your time. Have a good day!

Of course, sorry if that was unclear. Under the hood, they both use Change Streams. Triggers just do it server-side without any SDK and runs a custom function.

Have a nice day as well!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.