How is .upsertMany() implemented in Prisma ORM?

Prisma ORM has an implementation of the update or create upsert() method and a group of
bulk requests,
but there is no such thing as .upsertMany(), i.e. bulk “create or update existing records”.

What is the best way to implement such a method using Prisma ORM?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Prisma doesn’t natively support upsertMany.

There is a Feature Request to provide the upsertMany method.

As of now the best approach would be to loop over the data and invoke upsert in the loop along with using $transaction.


const collection = await prisma.$transaction( =>
        where: { id: },
        update: {},
        create: { id: },

Here’s a reference to $transaction API which should be helpful.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x