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

3 messages · Page 1 of 1 (latest)

past nova
#

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).

manic quartzBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

past nova
#

FIXED
Prisma have a problem for update(). I use updateMany() for update my data.