Registry / database / drizzle-orm-beta

drizzle-orm-beta

JSON →
library0.44.4jsnpmunverified

Drizzle ORM is a lightweight (~7.4kb gzipped), headless TypeScript ORM for SQL databases (PostgreSQL, MySQL, SQLite) with zero dependencies. Version 0.44.4 is the current beta release. It supports serverless and edge runtimes (Node.js, Bun, Deno, Cloudflare Workers) without any data proxies. Key differentiators include tree-shakeability, full type safety without code generation, relational and SQL-like query builders, and seamless integration with Drizzle Kit for migrations. Compared to Prisma or TypeORM, Drizzle offers finer control, lower overhead, and no lock-in.

npm install drizzle-orm-beta
INSTALL
IMPORT
SIG · DRIZZLE-ORM-BETA
D
drizzle-orm-beta
databasejavascriptv0.44.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

drizzle
import { drizzle } from 'drizzle-orm-beta'
const { drizzle } = require('drizzle-orm-beta')
ESM-only; CJS require() will cause runtime error.
pgTable
import { pgTable } from 'drizzle-orm-beta/pg-core'
import { pgTable } from 'drizzle-orm-beta'
pgTable is exported from the pg-core subpath, not the main entry.
sql
import { sql } from 'drizzle-orm-beta'
import { sql } from 'drizzle-orm-beta/sql'
sql is directly re-exported from the main entry; no subpath needed.
eq
import { eq } from 'drizzle-orm-beta/expressions'
import { eq } from 'drizzle-orm-beta'
SQL operators and expressions live under the /expressions subpath.
sqliteTable
import { sqliteTable } from 'drizzle-orm-beta/sqlite-core'
Similar to pgTable, requires the sqlite-core subpath.

Basic usage of Drizzle ORM with PostgreSQL: connect, define a table, insert, select with eq filter, and execute raw SQL.

import { drizzle } from 'drizzle-orm-beta'; import { pgTable, serial, text, varchar } from 'drizzle-orm-beta/pg-core'; import { eq } from 'drizzle-orm-beta/expressions'; import { sql } from 'drizzle-orm-beta'; import { Pool } from 'pg'; const pool = new Pool({ connectionString: process.env.DATABASE_URL ?? '' }); const db = drizzle(pool); // Define schema const users = pgTable('users', { id: serial('id').primaryKey(), name: varchar('name', { length: 255 }).notNull(), email: text('email').notNull().unique(), }); // Insert await db.insert(users).values({ name: 'Alice', email: 'alice@example.com' }); // Select const result = await db.select().from(users).where(eq(users.email, 'alice@example.com')); console.log(result); // Raw SQL const count = await db.execute(sql`SELECT COUNT(*) FROM ${users}`); console.log(count);
Debug
Known issues
gotchaImport paths are different per dialect (e.g., 'drizzle-orm-beta/pg-core' vs 'drizzle-orm-beta/sqlite-core'). Using wrong export path will cause undefined imports.
fix
Use correct subpath: for PostgreSQL use 'drizzle-orm-beta/pg-core', for SQLite use 'drizzle-orm-beta/sqlite-core', for MySQL use 'drizzle-orm-beta/mysql-core'.
affects: >=0.31.0
deprecatedThe `mysql2` driver support is deprecated in favor of `@planetscale/database`. For MySQL, prefer `@planetscale/database` or `mysql2` with caution.
fix
Use `@planetscale/database` as the driver or continue with `mysql2` but consider migrating.
affects: >=0.33.0
breakingDefault export `drizzle` no longer accepts a callback for session management in v0.30.0+. Use client/driver instance directly.
fix
Pass a client instance (e.g., `new Pool()`) to `drizzle()` instead of a callback.
affects: >=0.30.0
gotchaDrizzle ORM is ESM-only since v0.31.0. Using `require()` will fail with 'ERR_REQUIRE_ESM'.
fix
Use `import` statements or dynamic `import()`; if using TypeScript, set `"module": "ESNext"` (or similar) and `"moduleResolution": "bundler"`.
affects: >=0.31.0
gotchaThe `pg` driver requires `pg` version >=8. Using older versions may cause compatibility issues with prepared statements.
fix
Install `pg@>=8` as a peer dependency.
affects: >=0.28.0
deprecatedThe `better-sqlite3` driver is deprecated in favor of `@libsql/client` for Turso/remote SQLite. Local SQLite still works but may be removed.
fix
Switch to `@libsql/client` for remote and local SQLite, or continue using `better-sqlite3` with potential future breakage.
affects: >=0.35.0
gotchaDrizzle Kit (migrations) is a separate package `drizzle-kit-beta`. Do not confuse with `drizzle-orm-beta`. Both must be compatible versions.
fix
Use `npm install drizzle-kit-beta` and ensure version aligns with `drizzle-orm-beta`.
affects: >=0.20.0
Errors
Common errors & fixes
Error: Cannot find module 'drizzle-orm-beta/pg-core'
Incorrect import path; using main entry instead of dialect-specific subpath.
fix
Change to `import { pgTable } from 'drizzle-orm-beta/pg-core'`.
TypeError: drizzle is not a function
Using CommonJS `require()` on ESM-only package.
fix
Switch to ES module syntax: `import { drizzle } from 'drizzle-orm-beta'`.
SyntaxError: Unexpected token 'export'
Using older Node.js <14 or CommonJS without transpilation.
fix
Update Node.js to v14+ and use ES modules (`.mjs` or `"type": "module"` in package.json).
Error: No driver specified. Please pass a client instance to drizzle()
Calling `drizzle()` without providing a database client or driver.
fix
Pass a client instance (e.g., `new Pool()` for pg, `new Database()` for better-sqlite3).
Upgrade
Version history
0.44.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
Resources
drizzle-orm-beta — npm install drizzle-orm-beta · libregistry