TypeORM has been the default ORM for NestJS since the beginning, but Drizzle has overtaken it in new projects — it passed Prisma in weekly npm downloads in early 2026. Drizzle is a SQL-first query builder with full TypeScript inference and no decorators or metadata reflection.
Why Teams Are Switching
- Schema is plain TypeScript — no decorators, no
reflect-metadata - Queries are typed end to end; the result type is inferred from the query itself
- Migrations are generated as readable SQL you can edit
- Smaller runtime and faster cold starts — relevant for serverless and edge
Defining a Schema
import { pgTable, uuid, varchar, text, boolean, timestamp } from 'drizzle-orm/pg-core';
export const posts = pgTable('posts', {
id: uuid('id').defaultRandom().primaryKey(),
title: varchar('title').notNull(),
slug: varchar('slug').notNull().unique(),
content: text('content').notNull(),
published: boolean('published').default(false).notNull(),
createdAt: timestamp('created_at').defaultNow().notNull(),
});
Wiring It Into NestJS
Expose the Drizzle instance as an injectable provider:
import { drizzle } from 'drizzle-orm/node-postgres';
import { Pool } from 'pg';
export const DrizzleProvider = {
provide: 'DB',
useFactory: () => {
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
return drizzle(pool, { schema });
},
};
Querying
@Injectable()
export class BlogService {
constructor(@Inject('DB') private db: NodePgDatabase<typeof schema>) {}
findPublished() {
return this.db.query.posts.findMany({
where: eq(posts.published, true),
orderBy: desc(posts.createdAt),
});
}
}
Migrating From TypeORM
There is no automatic converter. The practical path:
1. Recreate entities as Drizzle schema files
2. Run drizzle-kit introspect against the existing database and diff it against your hand-written schema
3. Replace repository calls service by service — both ORMs can share the same connection pool during the transition
Conclusion
Drizzle trades TypeORM's Active Record convenience for explicit SQL and stronger inference. For a new NestJS service, or one where the query layer has become hard to reason about, it is the current default.