Triggers

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.

These values all need to be case sensitive.

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
Authentication operation types are case sensitive and need to be all uppercaseUp to 50 triggers per second can be concurrently executed. If we try to invoke more, they will get into a queue to be processed in a first-in first-out (FIFO) fashion.

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset