Row locking on prisma suggestions

Hi, I have been using Prisma to develop a text based game, this has been going very smooth. However I have been stumbling on some very big issues for concurrent updates on certain rows e.g. auction, withdraw, depositing, where my players can get under their balance if they click very fast, which results in a - balance and offcourse unwanted results.
I was able to solve this with raw sql row locking, see picture. However I think the way to do this isn't very smooth and I have to change some extra things on plus to get the collect errors in the frontend.
I am contemplating switching from ORM, but I was wondering if there are some better ways to solve these race conditions.
I have tried optimistic locking a few weeks ago but had some issues there. I want to have a good decoupled code without having to many changes in response/logic for specific locking cases.
Any tips here how I should proceed further?
image.png
Was this page helpful?