Build a Database App with Drizzle ORM and Deno
Drizzle ORM can be used from Deno via npm compatibility to get type-safe CRUD access to PostgreSQL. The walkthrough installs drizzle-orm, drizzle-kit and pg, configures drizzle.config.ts with a DATABASE_URL, and shows two schema paths: introspecting an existing database with `drizzle-kit pull` or defining pgTable schemas in TypeScript and generating migrations with `drizzle-kit generate`. It then builds helper functions for inserting, querying, updating and deleting rows across two related tables using a pg Pool-backed Drizzle client, with the Deno flags (--env, --node-modules-dir) needed to make drizzle-kit work.
Related posts
- ORMs vs. Query Builders for your Typescript application
Neon mediumAdept
Drizzle, Kysely, Prisma and Zapatos are compared as type-safe Postgres libraries for TypeScript across schema definition, query syntax, raw SQL support, migrations, edge-runtime support and community size. Drizzle offers SQL-like syntax with drizzle-kit migration generation, Kysely favors WYSIWYG TypeScript-centric queries with hand-written up/down migrations, Zapatos generates types from the database but has no migrations, and Prisma uses its own schema language with Prisma Migrate. Performance differences were negligible in a small test (averages within 3ms). Prisma has by far the largest community, while the other three can run on edge runtimes via serverless Postgres drivers, which Prisma could not at the time.
- Migrating Schemas Across Many Neon Projects Using DrizzleORM
Neon mediumAdept
Database-per-tenant setups need every tenant database kept on the same schema, and this walkthrough automates that across many Neon projects with DrizzleORM, the Neon API and GitHub Actions. A create script provisions a Neon project per customer. A generate script lists all projects, writes a per-tenant drizzle.config.ts, runs drizzle-kit generate, stores each connection string as an encrypted GitHub secret, and rewrites the workflow YAML to expose those secrets. A migrate script, triggered when a PR is merged to main, runs drizzle-kit migrate against every config so schema changes reach all tenants.
- Build a serverless API using Cloudflare Workers, Drizzle ORM, and Neon
Neon mediumAdept
A step-by-step setup for a serverless TypeScript API on Cloudflare Workers that uses Hono for routing, Drizzle ORM for schema definition and migrations, and Neon serverless Postgres for storage. It scaffolds a Worker with create-cloudflare, defines a products table in TypeScript, and uses drizzle-kit to generate SQL migrations. Migrations run through a postgres.js script capped at a single connection so they execute in order. The Worker queries Neon over HTTP via @neondatabase/serverless, is deployed with wrangler, and gets its DATABASE_URL from Cloudflare's Neon integration instead of manually configured secrets.
- How to Build a GraphQL Server with Deno
Deno mediumAdeptA GraphQL API server can be built in Deno with the std HTTP Server, the gql middleware, graphql_tools' makeExecutableSchema and graphql_tag. The walkthrough starts with a "Hello, World!" query served at /graphql with GraphiQL enabled, then refactors into separate type definition and resolver files. The expanded version adds Postgres-backed queries (allDinosaurs, oneDinosaur) and an addDinosaur mutation using deno-postgres connection pools and tagged-template SQL. It runs with the --allow-net and --allow-env permission flags.
- Persist Data in Deno with npm using Prisma, Mongoose, Apollo, and more.
Deno mediumAdeptDeno's npm: specifiers let you use popular data-layer packages directly, with Deno's opt-in permission flags limiting what a possibly compromised dependency can reach, such as environment variables holding database credentials. Three quick-start walkthroughs follow. Prisma is initialized against a Supabase PostgreSQL database and routed through Prisma Data Platform's Data Proxy. A Mongoose schema with validations writes to and reads from MongoDB. An Apollo GraphQL server defines typeDefs and resolvers over a static dataset.