I have two tables, User and UserInvitations. In UserInvitations there is a column isUsed. I know that in prisma you don't have triggers but you have middlewares that can "fake" that. I am not sure how can I update the isUsed to true after a user has been created? Is it ok to use prisma client inside a middleware? because I don't think of any other way
export function InvitationUsedMiddleware<
T extends Prisma.BatchPayload = Prisma.BatchPayload,
>(): Prisma.Middleware {
return async (
params: Prisma.MiddlewareParams,
next: (params: Prisma.MiddlewareParams) => Promise<T>,
): Promise<T> => {
if (params.action === 'create' && params.model === 'User') {
}
return next(params);
};
}