Overview of Triggers

Learn how to use triggers to apply changes to document requests in Cosmos DB.

Introduction

Another way we can use the database engine is with triggers. Cosmos DB triggers differ from the ones we can create in traditional SQL databases in two main ways:

  • We can create triggers that run both before and after a document action:

    • Pre-trigger

    • Post-trigger

  • Triggers are not executed automatically.

Definition

Triggers are JavaScript functions that have no input arguments and don’t return a value. We use getRequest() and getResponse() to interact with the engine.

Pre-triggers

...