Triggers are building upon Stitch functions to execute when a database collection changes for database triggers, or execute authentication logic when a user is modified using authentication triggers.
Database triggers can execute on one or more of the INSERT, UPDATE, REPLACE, and DELETE database operations.
We need to define the linked function, which is the function that will execute once the trigger fires. An interesting option for the UPDATE operation is fullDocument. When set to true, this will include the full result of the operation. This is, as always, subject to the 16 MB document size limit, so updates to documents really close to the 16 MB limit may fail as the result will exceed the limit.
Authentication triggers, on the other hand, allow us to execute custom code on authentication events. These can be triggered on CREATE, LOGIN, and DELETE operation types from the following providers:
- oauth2-google
- oauth2-facebook
- custom-token
- local-userpass
- api-key
- anon-user
Triggers are quite similar to RDBMS trigger functionality, with the added bonus that they are easy and flexible to manage via the Stitch trigger's GUI console.