Search code examples
nestjstypeorm

Where should I change the value received from client? in nest.js


If the value { a: 1 } comes in from the client, I want to change it to { a : 1, b : 2 }

In this case, where does Nestjs recommend changing the data?

First. Method using transform decorator in dto Second. service Third, using typeorm with customRepository. (https://typeorm.io/#/custom-repository)

In the first case, I don't think I should use it if there is a value that needs to be processed before validation.

Of course I know that dto should have only getter and setter.

However, I am worried about whether I should use Transform decoder or not.


Solution

  • You can just write like this a = { a:1 } b = { ...a, b:2 }