What is DTO mappers and how to implement DTO mappers?

1 day ago 3
ARTICLE AD BOX

I'm developing the a website using repository architecture and recently i learned about DTOs and a developer suggested me to use DTO mappers and i found that its something related to transform data from on type to another like

interface UserInputDTO { userId: number; fullName: string; userEmail: string; } interface UserOutputDTO { id: number; name: string; email: string; }

like changing the fieldname to one to another and for that we will use mapper functions and also there are some packages to make it easier so these are the things that i learned

so i have some questions

If i have to convert multiple DTOs to one another do i have to create multiple mapper functions?

I actually don't get what is the purpose of using it like if the fieldname that is getting from the frontend is same and the fieldname in the db there is no need to use it

Where do use DTO mappers? do i have to use the mapper function for every data coming from a API call

why do we use it

Read Entire Article