Our great sponsors
-
Prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
If this particular pattern is something you do often, have you considered using Zod or another validation library? Or are your types more complex than your example or unsuited for other reasons?
// Example with prisma ORM: https://www.prisma.io/ class PrismaCarMapper extends DataMapper { override serialize(car: Car): PrismaDatabaseCar { return new PrismaDatabaseCar({ id: car.id, mark: car.mark, model: car.model, }); }