r/typescript • u/theZozole • Sep 02 '26
Manage Model
Am I the only one who had a problem with how separated the data manipulation is?
Creating something in different ways (eg. create a chat message from only a text or creating from an api response ) Defaults in 3 files, parsing, validation, and sorting everything inline just to search it up later and copy it.
My solution? Put stuff like that in one place: See the screenshots.
Basically define all that sh in one place and just use:
userModel.parser.db.from(response)
habitModel.inits.createFromTitle("Do a blackflip")
people.sort(peopleModel.sorters.lastCreated)
View all comments
Show parent comment
1
u/bodimahdi Sep 02 '26
I wouldn’t go through all the points but I will however rewrite your doc example using zod: