What is TypeORM in Node.js?
Why Interviewers Ask This
Candidates at the intermediate level are expected to not only know this concept but explain the trade-offs involved. Interviewers use this question to see if you can reason about design decisions, not just recall facts.
Answer
TypeORM is an ORM for TypeScript and JavaScript that supports PostgreSQL, MySQL, SQLite, MongoDB, and more. It is particularly popular in TypeScript projects and with the NestJS framework. It supports two patterns: (1) Active Record: models extend BaseEntity and have CRUD methods directly — await user.save(); (2) Data Mapper: separate repository classes handle persistence — await userRepository.save(user) (more testable, recommended). Entities are defined with decorators: @Entity() class User { @PrimaryGeneratedColumn() id: number; @Column() name: string; @OneToMany(() => Post, post => post.user) posts: Post[]; }. TypeORM migrations track schema changes over time. Compared to Sequelize: better TypeScript and decorator support; compared to Prisma: TypeORM uses real TypeScript classes (Prisma generates its own types), but Prisma's query API is considered more ergonomic by many developers. TypeORM is the native ORM choice for NestJS applications.
Pro Tip
If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.
Previous
What is the Sequelize ORM in Node.js?
Next
How do you implement logging in a Node.js application?