0PricingLogin
MongoDB Academy · Lesson

Database Triggers: Reacting to CRUD Events

Learners will create a database trigger that fires on insert or update events and runs an Atlas Function to sync data or send a notification.

What Are Atlas Database Triggers?

Atlas Database Triggers are serverless event handlers that automatically execute an Atlas Function whenever a specific CRUD event (insert, update, replace, delete) occurs on a collection. They are built on top of MongoDB Change Streams and eliminate the need to run a polling process or manage infrastructure for event-driven workflows.

How Triggers Work Under the Hood

Internally, Atlas triggers use a change stream that MongoDB opens on the target collection. Every matching change event is forwarded to the trigger, which invokes the associated Atlas Function with the event document as its argument. The function runs in Atlas's managed JavaScript runtime — no servers to provision or scale. Triggers can handle up to hundreds of events per second with auto-scaling.

All lessons in this course

  1. Database Triggers: Reacting to CRUD Events
  2. Scheduled Triggers and Cron Jobs
  3. Writing Atlas Functions in JavaScript
  4. HTTPS Endpoints as Lightweight Webhooks
← Back to MongoDB Academy