Drizzle ORM
A tool that helps you talk to your database using JavaScript in a way that feels natural and stays very fast.
Drizzle ORM
General JSA tool that helps you talk to your database using JavaScript in a way that feels natural and stays very fast.
Fit
Bundle (gzip)
8.3 kB
27.0 kB raw
Install size includes transitive dependencies. Bundle size is gzipped browser payload.
Freshness
The Problem
Writing raw SQL queries directly within an application can be cumbersome and error-prone, yet many developers hesitate to use traditional ORMs because of the heavy abstraction layers that sacrifice execution speed. The challenge lies in finding a middle ground: a solution that avoids the complexity of manual string manipulation without introducing significant performance bloat. Furthermore, functionality alone isn't enough; maintaining a high-quality developer experience is essential to ensure that interacting with the database remains intuitive, predictable, and clean as the codebase grows.
What It Does
Drizzle ORM solves these issues by providing a "headless" approach that offers the type safety of a modern tool without the performance tax of a traditional abstraction layer. It eliminates the need to write raw SQL by allowing you to define schemas and queries in standard JavaScript, yet it stays blazingly fast by remaining thin and lightweight. By prioritizing developer experience, Drizzle ensures that you get the convenience of a powerful query builder while keeping your application lean and your database interactions transparent and efficient.
Installation
npm i drizzle-ormUsage Example
Initialize Drizzle, using SQLite for this example :
// drizzle.js
import { drizzle } from "drizzle-orm/better-sqlite3";
import Database from "better-sqlite3";
import path from "path";
import * as schema from "./schema";
const dbName = "database.db";
const dbPath = path.join(process.cwd(), dbName);
const client = new Database(dbPath);
export const db = drizzle(client, { schema });Define your schema :
// schema.js
import { sqliteTable, text, blob } from "drizzle-orm/sqlite-core";
import { sql } from "drizzle-orm";
export const Documentations = sqliteTable("Documentations", {
id: text("id").primaryKey()
.$defaultFn(() => sql`lower(hex(randomblob(16)))`),
imageBlob: blob("image_blob").notNull(),
});Do a query to get all data :
import { db } from "./drizzle";
import { Documentations } from "./schema";
const result = await db
.select({
id: Documentations.id,
imageBlob: Documentations.imageBlob,
})
.from(Documentations);Related packages
Unified TypeScript SDK for building AI-powered apps — switch between 20+ LLM providers without rewriting code.
animejsGeneral JSLightweight JavaScript animation library with a tiny footprint and a powerful, expressive API.
AOSGeneral JSAn easy-to-use library that makes elements fade, slide, or zoom into view as the user scrolls down your page.
archiverGeneral JSStreaming interface for generating ZIP and TAR archives in Node.js — create compressed archives programmatically from files, directories, and buffers.
@formkit/auto-animateGeneral JS> Add smooth transitions to any element with a single line — zero-config animations for adds, removes, and moves.