Database
Raw SQL and typed Kysely access through the context.
Chimpbase provides two ways to interact with your database: raw SQL via ctx.query() and a typed query builder via ctx.db().
Raw SQL
Parameters use positional placeholders (?1, ?2, etc.) that work across PostgreSQL and SQLite.
Typed Kysely Access
For complex queries, use the Kysely query builder with your database types:
Transaction Behavior
Actions, subscriptions, and worker handlers run inside runtime-managed transactions. You do not need to (and cannot) use ctx.db().transaction() — this is intentionally unsupported to prevent nested transaction issues.
The runtime handles commit/rollback automatically. If your handler throws, the transaction is rolled back.