Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Turso 5 min read How-to mediumAdept

Use SQLite triggers to send new user emails

An AFTER INSERT trigger on a users table copies each new row into a new_users outbox table. A Cloudflare Worker cron job polls that table every two minutes, sends welcome emails and deletes the processed rows. The tutorial covers trigger syntax, libSQL client setup, wrangler cron configuration and deployment. It notes the approach adds extra row reads and writes, and suggests Cloudflare Queues for retries or the libSQL /listen endpoint for high volume.

Assumes: basic SQLJavaScript/TypeScriptCloudflare Workers basics

Related posts

  • Save Resend email events to your Turso Database

    Turso mediumAdept

    Resend email webhook events (sent, delivered, bounced, opened, clicked, etc.) can be persisted to a Turso database through a small Hono/Node.js handler using @libsql/client. The walkthrough creates `events` and `clicks` tables. It parses the webhook payload, generates UUIDs, flattens recipient arrays to CSV, and inserts click details separately for `email.clicked` events. Local testing uses a Hookdeck CLI tunnel. Production advice covers verifying signatures with svix, queueing events for background processing, adding indexes, and deploying to a cloud host.

  • Processing large jobs with Edge Functions, Cron, and Queues

    Supabase mediumAdept

    Large data-processing jobs on Supabase can be split into a three-layer pipeline: cron-triggered Edge Functions collect work, distributor jobs route it into per-source Postgres queue tables, and specialized workers process one item at a time to stay within serverless timeouts. The worked example is an NFL news aggregator that scrapes sites, classifies articles with OpenAI, upserts player and team entities, and stores pgvector embeddings for search. Key practices include letting unique constraints handle deduplication, always marking queue items processed in a finally block to avoid infinite retries, reporting failures to Sentry, queuing user interactions for batched trending updates, and offloading expensive work like embeddings to background tasks.

  • Updates for Supabase Functions

    Supabase mediumAdept

    Supabase is shipping Database Webhooks in alpha, a convenience wrapper around Postgres triggers that fires asynchronous HTTP requests on INSERT, UPDATE and DELETE with a Realtime-style JSON payload. It also adds dashboard editors for Postgres functions and triggers, and lays out a staged roadmap toward its own serverless Supabase Functions. The networking layer is pg_net, a new Postgres extension that queues requests to a background worker using the libcurl multi interface. Queuing 10 GETs returned in 1.5 ms versus 3.5 s for the synchronous pgsql-http, and the extension handles over 300 requests per second.

  • When a file is uploaded, run the job on Neon

    Neon mediumAdept

    Neon added a storage_object_created function trigger that invokes a Neon Function via HTTP POST when an object is created in a Neon Object Storage bucket, optionally filtered by key prefix. The payload carries the bucket name and object key. Functions are long-running and scale to zero, and they wake Postgres compute on demand. Example pipelines include cataloging uploads in Postgres, generating image variants under a separate prefix to avoid self-triggering, AI tagging, PDF chunking and embedding for search, and moderation, which runs after the upload lands and so cannot block it. Triggers branch with the data but are disabled by default on child branches, and they can be declared in a neon.ts config file alongside buckets and functions.

  • Bringing SQLite to Vercel Functions with Turso

    Turso mediumAdept

    Turso's partial sync replicates a subset of SQLite database pages into Vercel Functions so reads run in-process with no network round-trip, while writes go to the remote Turso database for durability and consistency. On cold start the driver fetches the first 128 KiB of the SQLite file, then pulls further 128 KiB segments on demand into the ephemeral /tmp directory, so cold-start cost scales with the working set rather than total database size. The experimental @tursodatabase/vercel-experimental package also auto-provisions databases by name for database-per-tenant or per-agent-session patterns. It offers an optional local-write batching mode that trades consistency for lower write latency, and uses a waitUntil() safety net that pushes pending changes if close() is forgotten.

The quest for software engineering knowledge.

Look:
Layout: