• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

249
Vistas
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?

about 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

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.

Example:

const collection = await prisma.$transaction(
    userData.map(cur =>
      prisma.cur.upsert({
        where: { id: cur.id },
        update: {},
        create: { id: cur.id },
      })
    )
  )

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

about 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda