Registry /
database / netlify-drizzle-orm-tests
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/pg-core'
✗ import { drizzle } from 'drizzle-orm'
drizzle function is exported from driver-specific modules like pg-core, mysql2-core, sqlite-core. Avoid importing from 'drizzle-orm' directly.
pgTable
✓ import { pgTable } from 'drizzle-orm/pg-core'
✗ import { pgTable } from 'drizzle-orm'
Table definition functions are scoped to their driver module.
eq
✓ import { eq } from 'drizzle-orm'
✗ import { eq } from 'drizzle-orm/pg-core'
Operators like eq, and, or are exported from the core module.
sql
✓ import { sql } from 'drizzle-orm'
✗ const { sql } = require('drizzle-orm')
Drizzle is ESM-only; CommonJS require may fail or require special bundler config.
InferModel
✓ import { InferModel } from 'drizzle-orm'
Used to infer types from table definitions. Available from v0.23+.
Shows PostgreSQL setup: pool connection, table definition, insert and select using Drizzle ORM.
import { drizzle } from 'drizzle-orm/pg-core';
import { pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core';
import { eq } from 'drizzle-orm';
import { Pool } from 'pg';
const pool = new Pool({ connectionString: process.env.DATABASE_URL ?? '' });
const db = drizzle(pool);
const users = pgTable('users', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
email: text('email').unique(),
createdAt: timestamp('created_at').defaultNow(),
});
await db.insert(users).values({ name: 'John', email: 'john@example.com' });
const result = await db.select().from(users).where(eq(users.name, 'John'));
console.log(result);
await pool.end();
Debug
Known issues
breakingSince v0.25.0, the `drizzle` function no longer accepts a raw connection string; you must pass a driver/client instance.fixUse a client object (e.g., new Pool(...)) instead of a string.
affects: >=0.25.0
breakingIn v0.24.0, the `drizzle` function signature changed from `drizzle(client, schema?)` to `drizzle(client, config?)` with config object containing schema.fixPass schema inside config object: drizzle(client, { schema: mySchema }). affects: >=0.24.0 <0.25.0
deprecated`InferModel` type is deprecated since v0.28.0; use `typeof users.$inferSelect` or `typeof users.$inferInsert` instead.fixReplace `InferModel<typeof users>` with `typeof users.$inferSelect` for select types or `typeof users.$inferInsert` for insert types.
affects: >=0.28.0
gotchaDrizzle is ESM-only and does not support CommonJS `require()` directly. Trying to import it with CommonJS may work in some bundlers but is not guaranteed.fixUse ES module imports: `import { drizzle } from 'drizzle-orm/pg-core'` – or configure your bundler to handle ESM. affects: >=0.28.0
gotchaWhen using `$default` function for default values, the function may be called multiple times for the same row if not careful.fixUse `$defaultFn` or a SQL default expression instead of `$default` with a function.
affects: >=0.28.0
Errors
Common errors & fixes
Error: No driver specified. You must provide a database client to the drizzle function.
Calling drizzle() without a valid client instance or passing a connection string string directly (since v0.25.0).
fixInitialize a client (e.g., new Pool(...) for PostgreSQL) and pass it: const db = drizzle(pool);
Cannot find module 'drizzle-orm/pg-core' or its corresponding type declarations.
Missing optional peer dependency for the specific database driver (e.g., pg, mysql2).
fixInstall the required driver package: npm install pg (for PostgreSQL) or mysql2 (for MySQL).
TypeError: Cannot read properties of undefined (reading 'schema')
Passing schema object as a second positional argument to drizzle() instead of inside config object (since v0.24.0).
fixUse drizzle(client, { schema: mySchema }) instead of drizzle(client, mySchema). Property '$inferSelect' does not exist on type 'Table'.
Using $inferSelect on a table definition that was created with an older drizzle version (<0.28.0).
fixUpdate drizzle-orm to v0.28.0 or later and ensure you are using the correct table import (e.g., pgTable).
Audit
Dependencies
pgoptionalPostgreSQL driver
mysql2optionalMySQL driver
better-sqlite3optionalSQLite driver
@libsql/clientoptionalTurso (libSQL) driver
@planetscale/databaseoptionalPlanetScale driver
@neondatabase/serverlessoptionalNeon serverless driver
zodoptionalSchema validation support