Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.8k views
Welcome To Ask or Share your Answers For Others

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...