Features
- Active Record and Data Mapper patterns
- Decorator-based entity definitions
- Automatic migration generation
- Supports 10+ database drivers
Pros
- Familiar patterns for developers from C#/Java backgrounds
- Wide database support including SQL Server and Oracle
- Decorator syntax integrates well with NestJS
Cons
- Known bugs and maintenance has slowed
- Type safety is weaker than Prisma or Drizzle
- Complex queries often require QueryBuilder
Overview
TypeORM is an ORM that supports both Active Record and Data Mapper patterns, using TypeScript decorators to define entities. It was one of the first TypeScript-native ORMs and remains popular, particularly in the NestJS ecosystem where its decorator pattern fits naturally.
TypeORM supports PostgreSQL, MySQL, MariaDB, SQLite, MS SQL Server, Oracle, and more. It provides automatic migration generation, a query builder for complex queries, and transaction management. However, its maintenance pace has slowed, leading many projects to migrate to Prisma or Drizzle.
When to Use
TypeORM is appropriate for NestJS projects that use decorator-based patterns, when you need Active Record or Data Mapper patterns, or when supporting databases like Oracle or SQL Server. For new projects, Prisma or Drizzle offer better type safety and active development.
Getting Started
npm install typeorm reflect-metadata pg
import { Entity, PrimaryGeneratedColumn, Column } from "typeorm";
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column({ unique: true })
email: string;
}