Next.js Discord

Discord Forum

Next.js & Prisma Update don't work (in build)

Answered
Mateo M posted this in #help-forum
Open in Discord
Avatar
Mateo MOP
Hello,

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.
View full answer

1 Reply

Avatar
Mateo MOP
FIXED
Prisma have a problem for update(). I use updateMany() for update my data.
Answer