
Database with TypeORM
Entities, repositories, relations, migrations, query builder, transactions, cascades
1What is an Entity in TypeORM?
What is an Entity in TypeORM?
Câu trả lời
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().
2Which decorator to use to mark a property as a column in TypeORM?
Which decorator to use to mark a property as a column in TypeORM?
Câu trả lời
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.
3What is the difference between @PrimaryColumn() and @PrimaryGeneratedColumn()?
What is the difference between @PrimaryColumn() and @PrimaryGeneratedColumn()?
Câu trả lời
@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.
How to inject a TypeORM repository into a NestJS service?
Which decorator to use to define a nullable column in TypeORM?
+27 câu hỏi phỏng vấn
Các chủ đề phỏng vấn Node.js / NestJS khác
Node.js Fundamentals
Node.js Core APIs
Asynchronous Programming
Express.js Basics
NestJS Fundamentals
REST API Design
Validation & DTO
API Documentation & Contracts
Error Handling
Unit Testing
Task Scheduling
NestJS Modules & DI
Configuration & Environment Management
JWT Authentication
Authorization & RBAC
Prisma ORM
Middleware & Interceptors
File Upload
WebSockets
GraphQL with NestJS
End-to-End Testing
Caching with Redis
Queues with Bull
DevOps, Logging & CI/CD
Docker & Containerization
Microservices
Security Best Practices
Performance & Cloud Deployment
Nắm vững Node.js / NestJS cho lần phỏng vấn tiếp theo
Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.
Bắt đầu miễn phí