export const modelConverter = middleware(async (opts) => {
const ctx: Record<string, any> = {};
if (typeof opts.rawInput === "object") {
for await (const key of Object.keys(opts.rawInput)) {
const prismaModelKey = Object.keys(prisma).find(
(m) => m.toLowerCase() === key
);
if (!prismaModelKey) {
continue;
}
opts.ctx[prismaModelKey] = prisma[prismaModelKey]; // this should actually be `model.findUniqueOrThrow(rawInputValue)`
}
}
return opts.next({ ctx } as { ctx: { [key: keyof typeof ctx]: any } });
});
export const modelConverter = middleware(async (opts) => {
const ctx: Record<string, any> = {};
if (typeof opts.rawInput === "object") {
for await (const key of Object.keys(opts.rawInput)) {
const prismaModelKey = Object.keys(prisma).find(
(m) => m.toLowerCase() === key
);
if (!prismaModelKey) {
continue;
}
opts.ctx[prismaModelKey] = prisma[prismaModelKey]; // this should actually be `model.findUniqueOrThrow(rawInputValue)`
}
}
return opts.next({ ctx } as { ctx: { [key: keyof typeof ctx]: any } });
});