Next.js & Prisma Update don't work (in build)
Answered
Mateo M posted this in #help-forum
![Avatar](https://cdn.discordapp.com/avatars/206117019752464384/7fed833f2c4a5f0a488931f419ae174a.webp?size=256)
Mateo MOP
Hello,
When I create an API (eg: user.router.tsx), using this part of the code:
in production, ctx.db.user.update() won't work.
But as soon as I use next dev or next start, it does.
I should point out that before (1 month ago), it worked, and I haven't modified the code since.
Input or ctx.session work very well (as does the "user" table).
When I create an API (eg: user.router.tsx), using this part of the code:
updatePassword: protectedProcedure
.input(passwordSchema)
.mutation(async ({ ctx, input }) => {
if (ctx.session?.user.id) {
const hashedPassword = UserUtils.hashPassword(input.confirmNewPassword)
await ctx.db.user.update({
where: { id: ctx.session.user.id },
data: { password: hashedPassword },
})
return true
} else {
throw new TRPCError({
code: "UNAUTHORIZED",
})
}
}),
in production, ctx.db.user.update() won't work.
But as soon as I use next dev or next start, it does.
I should point out that before (1 month ago), it worked, and I haven't modified the code since.
Input or ctx.session work very well (as does the "user" table).
Answered by Mateo M
FIXED
Prisma have a problem for update(). I use updateMany() for update my data.
Prisma have a problem for update(). I use updateMany() for update my data.
1 Reply
![Avatar](https://cdn.discordapp.com/avatars/206117019752464384/7fed833f2c4a5f0a488931f419ae174a.webp?size=256)
Mateo MOP
FIXED
Prisma have a problem for update(). I use updateMany() for update my data.
Prisma have a problem for update(). I use updateMany() for update my data.
Answer