NodeJS map Dtos to TypeORM Entities
NodeJS map Dtos to TypeORM Entities I have a nodejs REST API backend running the nestjs framework, using typeORM as ORM for my entities. nodejs nestjs Coming from a C#/Entity Framework background, I am very used to have my Dtos mapped to the database entities. C#/Entity Framework Is there a similar approach with typeORM? I have seen the automapper-ts library, but those magic strings in the map declarations look kind of scary... Basically it would be amazing if I could : let user: TypeORMUserEntity = mapper.map<TypeORMUserEntity>(userDto); What is the way to do this (or any alternative with same result) in nodejs/typeorm backend environment? 1 Answer 1 You can use class-transformer library. You can use it with class-validator to cast and validate POST parameters. Example: @Exclude() class SkillNewDto { @Expose() @ApiModelProperty({ required: true }) @IsString() @MaxLength(60) nam...