I want to get User's fields from a request body.
Below is my current solution, the reason I use : User is it mandates required fields to be destructed also it gives autocompletion.
const { username, password, email, birthday, country_code, preferences }: User = req.body;
I want to automatically get all fields from req.body. Maybe something like below.
const namedObject = ({} : User = req.body);
model User {
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
created_at DateTime @default(now())
birthday DateTime?
country_code String?
preferences Json?
Message Message[]
}
What is the proper solution for this?