---
title: "Build a Database App with Drizzle ORM and Deno"
description: "Drizzle ORM can be used from Deno via npm compatibility to get type-safe CRUD access to PostgreSQL."
url: "https://swe.quest/articles/build-a-database-app-with-drizzle-orm-and-deno-692f9df52f193839"
canonical: "https://deno.com/blog/build-database-app-drizzle"
source: "Deno"
published: "2024-11-13"
difficulty: "medium"
kind: "How-to"
reading_minutes: 7
tags: ["typescript","postgres","javascript","schema-migrations"]
---

# Build a Database App with Drizzle ORM and Deno

A post on [Deno](https://swe.quest/sources/deno.md), published 2024-11-13, 7 min read, How-to. Original: [https://deno.com/blog/build-database-app-drizzle](https://deno.com/blog/build-database-app-drizzle)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [TypeScript](https://swe.quest/tags/typescript.md) (Languages)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)
- [Schema migrations](https://swe.quest/tags/schema-migrations.md) (Data & databases)

## Prerequisites

- TypeScript basics ([easy posts on TypeScript](https://swe.quest/tags/typescript.md?difficulty=easy))
- PostgreSQL basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- ORM concepts

## Keywords

Drizzle ORM, Deno, drizzle-kit, PostgreSQL, node-postgres

## Related posts

- [ORMs vs. Query Builders for your Typescript application](https://swe.quest/articles/orms-vs-query-builders-for-your-typescript-application-9783c98c487b60f6.md): Neon · 2023-05-16 · Medium · 9 min read · TypeScript, PostgreSQL, Schema migrations, Developer tools, SQL
  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.
- [Migrating Schemas Across Many Neon Projects Using DrizzleORM](https://swe.quest/articles/migrating-schemas-across-many-neon-projects-using-drizzleorm-bb1d354116390120.md): Neon · 2024-11-21 · Medium · 10 min read · Schema migrations, Multi-tenancy, PostgreSQL, CI/CD, JavaScript
  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.
- [Build a serverless API using Cloudflare Workers, Drizzle ORM, and Neon](https://swe.quest/articles/build-a-serverless-api-using-cloudflare-workers-drizzle-orm-and-neon-f83c472c9d399a17.md): Neon · 2023-05-30 · Medium · 9 min read · Serverless, PostgreSQL, TypeScript, Schema migrations
  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.
- [How to Build a GraphQL Server with Deno](https://swe.quest/articles/how-to-build-a-graphql-server-with-deno-b4bf15abf8edf07f.md): Deno · 2023-01-11 · Medium · 7 min read · GraphQL, TypeScript, PostgreSQL, API design
  A GraphQL API server can be built in Deno with the std HTTP Server, the gql middleware, graphql\_tools' makeExecutableSchema and graphql\_tag.
- [Persist Data in Deno with npm using Prisma, Mongoose, Apollo, and more.](https://swe.quest/articles/persist-data-in-deno-with-npm-using-prisma-mongoose-apollo-and-more-93a981bba3f6dd39.md): Deno · 2022-11-15 · Medium · 7 min read · JavaScript, TypeScript, Databases, GraphQL
  Deno'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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
