DEV Community

Alex Spinov
Alex Spinov

Posted on

Drizzle ORM Has a Free API — SQL-Like TypeScript ORM with Zero Overhead

What if your ORM looked like SQL — so you could think in SQL while getting full TypeScript type safety?

Drizzle ORM is a TypeScript ORM that feels like writing SQL. No query builder abstraction, no magic — just typed SQL.

Why Drizzle

  • SQL-like syntax — if you know SQL, you know Drizzle
  • Zero overhead — thin wrapper, no runtime query building
  • Drizzle Kit — migration tool with push, pull, and studio
  • All databases — Postgres, MySQL, SQLite, Turso, Neon, PlanetScale
  • Edge-ready — works with HTTP-based databases (Neon, Turso)
  • Drizzle Studio — browser-based database viewer

Quick Start

npm install drizzle-orm
npm install -D drizzle-kit
Enter fullscreen mode Exit fullscreen mode
// schema.ts
import { pgTable, serial, text, timestamp, boolean } from "drizzle-orm/pg-core";

export const posts = pgTable("posts", {
  id: serial("id").primaryKey(),
  title: text("title").notNull(),
  content: text("content"),
  published: boolean("published").default(false),
  createdAt: timestamp("created_at").defaultNow(),
});
Enter fullscreen mode Exit fullscreen mode
// queries — looks like SQL, fully typed
import { db } from "./db";
import { posts } from "./schema";
import { eq, desc } from "drizzle-orm";

// SELECT * FROM posts WHERE published = true ORDER BY created_at DESC
const publishedPosts = await db
  .select()
  .from(posts)
  .where(eq(posts.published, true))
  .orderBy(desc(posts.createdAt));

// INSERT
await db.insert(posts).values({ title: "Hello", content: "World" });

// UPDATE
await db.update(posts).set({ published: true }).where(eq(posts.id, 1));
Enter fullscreen mode Exit fullscreen mode

Migrations

# Generate migration from schema changes
npx drizzle-kit generate

# Push schema directly (dev)
npx drizzle-kit push

# Open visual studio
npx drizzle-kit studio
Enter fullscreen mode Exit fullscreen mode

Real Use Case

A team used Prisma but hit performance issues — the query engine added 2MB to their serverless bundle and 500ms cold start. After switching to Drizzle, bundle size dropped to 50KB, cold starts to 80ms. The SQL-like syntax meant the team spent zero time learning a new query API.

When to Use Drizzle

  • Projects where SQL knowledge should translate to ORM usage
  • Serverless/edge apps needing small bundle size
  • Teams wanting explicit, readable queries
  • Any TypeScript project with a SQL database

Get Started

Visit orm.drizzle.team — open source, MIT licensed.


Need custom data pipelines or scraping solutions? Check out my Apify actors or email me at spinov001@gmail.com for custom solutions.

Top comments (0)