Realm Triggers enable you to execute application and database logic automatically, either in response to events or based on a pre-defined schedule. MongoDB Realm supports three types of triggers:
- Database triggers, which can automatically respond upon any document insertion, alteration, or removal in a linked MongoDB collection.
- Authentication triggers, which execute additional server-side logic upon user creation, authentication, or deletion.
- Scheduled triggers, which execute functions at regular intervals according to a pre-defined schedule.
Triggers listen for application events of a configured type and are each linked with a specific Realm Function. Whenever a Trigger observes an event that matches your configuration, it "fires" and passes the event object that caused it to fire as the argument to its linked Function. You can configure the events that cause a Trigger to fire based on their operation type as well as other values specific to each type of Trigger.
MongoDB Realm limits the execution of Trigger Functions to a rate of 2500 executions per second per Trigger. If there are additional Trigger executions beyond this threshold, MongoDB Realm adds their associated Function calls to a queue and executes each one when the capacity becomes available. However, the real execution rate in your environment may be lower than the theoretical limit of 2500 executions per second, depending on your Atlas instance size.
Database Triggers with event ordering enabled are an exception to this rule. Each ordered Trigger processes events in order, waiting for the previous event execution to complete before handling the next event. Therefore, only one execution of a particular ordered Trigger executes at any given time.