-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Labels
Milestone
Description
Problem
prisma.$use(async (params, next) => {
if (params.model === "User") {
//process
}
});In the above, params.model is typed as a string, when the prisma client generated should be able to deduce the models based on the schema.prisma file and form a union.
Suggested solution
If a schema.prisma has models User, Project, Task for instance, then params.model should be typed as "User" | "Project" | "Task". If we had an enum, it could even params.model: Model
Ideally, we'd also have an enum we could leverage:
import { Model } from "@prisma/client";
Model.User // "User"
Model.Project // "Project"
Model.Task // "Task"
// This would allow for:
prisma.$use(async (params, next) => {
switch (params.model) {
case Model.User:
case Model.Project:
...
}
})This should all be deduced and generated from the schema.prisma.
Additional context
This is largely a QoL improvement.
Reactions are currently unavailable