Bird
0
0

Which decorator is used to define a simple column in a NestJS entity?

easy📝 Conceptual Q2 of 15
NestJS - Database with TypeORM
Which decorator is used to define a simple column in a NestJS entity?
A@Column()
B@Entity()
C@PrimaryColumn()
D@JoinColumn()
Step-by-Step Solution
Solution:
  1. Step 1: Identify the decorator for columns

    In NestJS with TypeORM, @Column() is used to define a regular column in the database table.
  2. Step 2: Differentiate from other decorators

    @Entity() defines the whole entity, @PrimaryColumn() defines a primary key column, and @JoinColumn() is for relations.
  3. Final Answer:

    @Column() -> Option A
  4. Quick Check:

    Simple column decorator [OK]
Quick Trick: Use @Column() for normal fields in entities [OK]
Common Mistakes:
  • Using @Entity() instead of @Column() for fields
  • Confusing primary key decorators with normal columns
  • Using relation decorators for simple columns

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes