question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ability to update relation fields inside `updateMany`

See original GitHub issue

Problem

Given this schema:

model Booking {
  worker Worker
}

If we want to disconnect multiple bookings at once, we currently have to run a separate update call for each individual booking:

await Promise.all(bookings.map(booking => {
  return prisma.booking.update({
    data: { worker: { disconnect: true } },
    where: { id: booking.id }
  })
}))

Suggested solution

It would be really nice if we could do something like this instead:

return ctx.prisma.booking.updateMany({
  data: { worker: { disconnect: true } },
  where: { id: { in: bookingIds } }
})

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:74
  • Comments:10

github_iconTop GitHub Comments

7reactions
pavlo-maiscommented, Jun 9, 2022

any updates?

6reactions
kostenickjcommented, Dec 10, 2021

Can anyone advise if this is on the roadmap?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Relation queries (Concepts) - Prisma
A key feature of Prisma Client is the ability to query relations between two or more models. Relation queries include: Nested reads (sometimes...
Read more >
Updating a many-to-many relationship in Prisma
Here is what I'd like to do. Get a post with category ids attached to it and insert it into the schema above....
Read more >
Update Multiple Documents using updateMany() in MongoDB
Learn how to update multiple documents using the updateMany() method in MongoDB. ... The following will update or add location field in all...
Read more >
How Can I update data with lookup - MongoDB
I want to update collection A on based on Collection B field. My query like this, db.a.updateMany(condition,{$set:{ "productMinQty":collection b ...
Read more >
MongoDB - Update Document - Tutorialspoint
MongoDB's update() and save() methods are used to update document into a collection. The update() method updates the values in the existing document...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found