Brakebein / prisma-generator-nestjs-dto

Generates NestJS DTO classes from Prisma Schema
Apache License 2.0
48 stars 26 forks source link

Feature request: Make default-values-visibility in CreateDTO and UpdateDTO into a setting 🙏 #51

Closed tofsjonas closed 1 month ago

tofsjonas commented 2 months ago

From the readme:

Default values are added in CreateDTO and UpdateDTO. However, a field with a @default() attribute is hidden by default in CreateDTO and UpdateDTO, hence requires @DtoCreateOptional and/or @DtoUpdateOptional to be present.

I like having default values, but I also like being able to set them.

Would it be possible to make this a configuration setting? Like this?

generator nestjsDto {
  provider                 = "prisma-generator-nestjs-dto"
  output                   = "../src/@generated/prisma-dtos"
  showDefaultsInCreateDtos = "true|false"
  showDefaultsInUpdateDtos = "true|false"
  //...
}

Awesome package, thank you!

Brakebein commented 2 months ago

So, you are saying that you have a lot of fields with default values and you don't want to add @DtoCreateOptional and @DtoUpdateOptional everywhere? Should not be too time-consuming to add this feature. However, I'm a bit afraid that adding more and more settings will get a bit confusing by time 😕 Shouldn't be one single setting enough to toggle it for both Create and Update dtos?

tofsjonas commented 2 months ago

Yes, that makes sense 🤔

Brakebein commented 1 month ago

The new flag showDefaultValues = "true" makes fields with @default attribute visible by default. Please checkout 1.24.0-beta1.

tofsjonas commented 1 month ago

Yay, it works! Thank you 🙌