Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prisma transaction in nodejs and typescript not working

I have 100 over record to update. So I use transaction but I got following error -:

Argument of type '(tx: any) => Promise' is not assignable to parameter of type 'PrismaPromise[]'. Type '(tx: any) => Promise' is missing the following properties from type 'PrismaPromise[]': pop, push, concat, join, and 28 more.

May I know how to solve?

await prisma.$transaction(async (tx :any) /*error here*/ => {

    const updateSong = await tx.songs.update({
      where: {
        id: d.id,
      },
      data: {
        duration: duration,
      },
    })

  })
like image 473
Alex Aung Avatar asked Jun 07 '26 00:06

Alex Aung


1 Answers

I got the same error, I fix that with added previewFeatures = ["interactiveTransactions"] and then regenerate my schema with npx prisma generate

like image 58
Nasrul Avatar answered Jun 08 '26 19:06

Nasrul