I am trying to use the class transformer in typescript (node.js): https://github.com/typestack/class-transformer
I would like to flat a JSON using only 1 model , 1 Dto that will go to the DB
if I have the following json :
{
"data":{"test":"123"}
"name":"x"
}
the DB service should receive the following object:
{
"test":"123",
"name":"x"
}
This what I tried to define but it's not working :
@Expose()
export class Dto{
name:string,
@Expose({name: "data.test"})
test: string
}
the result on the test field is undefined how can I achieve that? I don't want to create a "mediator" model