'Decrement value if value after reduction is not less than 0 Prisma
I'm looking for a method to decrement a data, if the data after the reduction is not less than zero then the data is saved to the DB, else throw some error. I've been looking for things in the docs but there is no any solution using a transaction for this method and I'm quite skeptical about if there is a concurrent request.
Can anyone help me giving the best method or solution to achieve this? Thanks!
Solution 1:[1]
I was looking into the same thing, I came across this interactive transactions mode in Prisma docs where it allows to pass an async function to $transactions api so that custom application logic can be introduced between database transactions. This might help, but be aware that it is in preview.
Find link here, Interactive Transactions (In Preview)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ege Çavu?o?lu |
