As my previous attempt (described in prisma/prisma#5273) to create a "prisma crud service" failed to provide a typesafe service, i decided to take another route.
I then thought about creating a custom generator that can be invoked via the schema.prisma
file. The generator, in turn, will now create a x.service.ts
file, for each model x
in the schema.prisma
file (dmmf). This service, in turn, contains all CRUD methods that are properly typed. Note that this service than can easily extended or injected to provide this feature.
The current approach looks like this: