Developer Platform•v1.0.0•2 min read

CRUD Order of Operations & Lifecycle Guide

Precise execution sequence of permission evaluations, before/after triggers, database transactions, and async background workers during CRUD mutations.

Understanding the precise sequence of events during a data operation is crucial for debugging, extending functionality, and building reliable automations. This document outlines the step-by-step process the system follows for every Create, Update, and Delete action on a record.


1. Core Concepts

The system's logic is enhanced by two types of customizable actions that run during a CRUD operation: Record Triggers and Record Trigger Automations.

  • Record Triggers: Python scripts (.py files) executed via the Platform Context for maximum flexibility and custom code logic.
  • Record Trigger Automations: No-code/low-code workflows built directly in the Flow Builder UI.

Both Triggers and Automations execute within specific lifecycle stages:

  • Before: Runs synchronously before the record is written to the database. Use this to validate data, enforce business constraints, or modify values in-place.
  • After: Runs synchronously immediately after the record is committed to the database. Ideal for modifying related records, creating logs, or emitting side effects.
  • Async: Runs asynchronously in background workers after the HTTP response has returned to the client.

2. Create Operation Sequence

Rendering diagram...

3. Update Operation Sequence

  1. Schema & Model Loading: Loads target object schema.
  2. Fetch Old State (old_map): Retrieves the existing database record state prior to mutation.
  3. Field & Object Permissions: Verifies update rights across all modified payload fields.
  4. Data Merging: Merges incoming fields with existing attributes.
  5. Before Update Triggers: Runs synchronous Python triggers (context.is_changed() checks).
  6. Database Commit: Commits merged document to tenant MongoDB collection.
  7. After Update Triggers: Executes synchronous side effects.
  8. Cache Invalidation & Async Tasks: Enqueues background worker tasks and flushes Redis caches.