Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

nestjs - How to add two dto for one query param?

I want to use two dto's for one query param.

@Query() query: CurrencyTypeDto|PaginationLimitDto

I know I can use inheritance. Maybe there is another way?

question from:https://stackoverflow.com/questions/65932726/how-to-add-two-dto-for-one-query-param

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

NestJs offers something called IntersectionType() to combine two types into one new type (dto), to Implement that you:

    export class queryDto extends IntersectionType(
  CurrencyTypeDto,
  PaginationLimitDto,
) {}

then you can use it: @Query() query: queryDto

Ref : intersection


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...