Node.js / NestJS

Database with TypeORM

Entities, repositories, relations, migrations, query builder, transactions, cascades

30 면접 질문·
Mid-Level
1

What is an Entity in TypeORM?

답변

An Entity in TypeORM is a TypeScript class decorated with @Entity() that represents a database table. Each instance of the Entity corresponds to a row in the table. Class properties are automatically mapped to table columns using decorators like @Column().

2

Which decorator to use to mark a property as a column in TypeORM?

답변

The @Column() decorator transforms a class property into a database column. TypeORM automatically infers the SQL type from the TypeScript type, but it can be explicitly specified with @Column('varchar', { length: 255 }). This decorator is essential for all columns except the primary key.

3

What is the difference between @PrimaryColumn() and @PrimaryGeneratedColumn()?

답변

@PrimaryGeneratedColumn() creates a primary key auto-incremented by the database, ideal for numeric identifiers. @PrimaryColumn() defines a primary key whose value must be provided manually, useful for UUID identifiers or composite keys. For most cases, using @PrimaryGeneratedColumn() is simpler and safer.

4

How to inject a TypeORM repository into a NestJS service?

5

Which decorator to use to define a nullable column in TypeORM?

+27 면접 질문

다음 면접을 위해 Node.js / NestJS을 마스터하세요

모든 질문, flashcards, 기술 테스트, 코드 리뷰 연습, 면접 시뮬레이터에 접근하세요.

무료로 시작하기