SQL allows to atomically operate on number types, included but not limited to incrementing or decrementing a value:
UPDATE posts SET views = views + 1 WHERE ...
This should be possible with Prisma as well. Users are doing ugly workarounds.
Proposed syntax:
await prisma.user.updateMany({
where: {},
data:
age: {
set: 18, // this just sets the value, previous syntax is `data: { age: 18 }`
// or
increment: 1, // views = views + 1
// or
decrement: 2, // views = views - 2
// or
multiply: 3, // views = views * 3
// or
divide: 4, // views = views / 4
},
},
})
Related: This is also being addressed in the upcoming client API https://github.com/prisma/specs/issues/356

This was a very much wanted feature for Prisma 1: https://github.com/prisma/prisma1/issues/1349
I need this so much!
This is the reason why I don't use prisma atm
Hi,
I went through a first pass shaping the problem and adding some more context in a new issue: https://github.com/prisma/prisma-client-js/issues/775
We will be tracking changes through that one from now on, so feel free to subscribe to it for further updates on the progress.
Hi everyone, since we are now tracking progress on this feature here: https://github.com/prisma/prisma-client-js/issues/775 I will this close this one.
This is now available as a preview feature in 2.6.0.
Most helpful comment
This is the reason why I don't use prisma atm