What are Database Triggers?
A database trigger is code that executes server-side logic when a database event occurs, such as when data is added, updated, replaced, or removed.
FAQ
Code that is automatically triggered by a database operation or an event/schedule.
There are three types of triggers in MongoDB Atlas. One is the Database trigger used for updating data based on some action, and another is the Scheduled trigger used to execute a set of code at a specific time. On the Realm applications, there is also an Authentication trigger type used for events related to application user authentication.
MongoDB database triggers are stored at the Project level of an Organization in a specific Realm application. (Atlas triggers will provision this application automatically for you.)
A trigger can be used for many use cases, like updating a Last Updated date when an edit is made on a document, recording the last Login Date on a User Profile, or making all updates to a specific field be automatically changed to UPPERCASE to provide consistency in a collection.
Triggers provide a method for a database developer to have an automated set of code that can be executed based on the incoming DML statements or other events.
Database triggers are applied to a database collection or table using either the database UI or executing code. Other types of triggers are based on scheduled time or authentication events.
Yes, MongoDB Atlas provides extensive functionality through the use of triggers. More about MongoDB triggers can be found in the documentation: https://docs.atlas.mongodb.com/triggers/
Get started with Atlas today
Get started in seconds. Our free clusters come with 512 MB of storage so you can play around with sample data and get oriented with our platform.
GET STARTED WITH:
- 125+ regions worldwide
- Sample data sets
- Always-on authentication
- End-to-end encryption
- Command line tools