Scheduled Triggers¶
Important
The MongoDB Stitch SDK is deprecated. For guidance on migrating to MongoDB Realm, please see Migrate Your App from Stitch to Realm.
Overview¶
Scheduled triggers allow you to execute server-side logic on a regular schedule that you define. You can use scheduled triggers to do work that happens on a periodic basis, such as updating a document every minute, generating a nightly report, or sending an automated weekly email newsletter.
Create a Scheduled Trigger¶
- Stitch UI
- Import/Export
To create a scheduled trigger in the Stitch UI:
- Click Triggers under MongoDB Cluster in the left-hand navigation.
- Select Scheduled Triggers from the trigger type dropdown menu.
- Click Add a Trigger to open the trigger configuration page.
- Enter configuration values for the trigger.
You can configure two types of trigger schedules:
Basic or Advanced.
- A Basic schedule executes the trigger periodically based on a single unit of time and an interval, such as “every five minutes” or “every Monday”.
- An Advanced schedule executes the trigger based on a custom CRON expression that you define.
- Click Save.
To create a scheduled trigger with stitch-cli:
Add a scheduled trigger configuration file to the
triggers
subdirectory of a local application directory.Note
You cannot create a trigger that runs on a Basic schedule using Stitch CLI. All imported scheduled trigger configurations must specify a CRON expression.
Import the application directory into your application.
Reference¶
Scheduled Trigger Configuration¶
- Stitch UI
- Import/Export
Scheduled triggers have the following configuration parameters:
Scheduled trigger configuration files have the following form:
Field | Description |
---|---|
Trigger Type type: <string> |
Required. The type of the trigger. For scheduled triggers, this value should be set to
|
Trigger Name name: <string> |
Required. The name of the trigger. |
Linked Function function_name: <string> |
Required. The name of the Stitch function that the trigger executes whenever it fires. Note A scheduled trigger does not pass any arguments to its linked function. |
Schedule config.schedule: <string> |
Required. The CRON expression that Stitch uses to determine when to fire the trigger. |