Mathias
Explore posts from serversPPrisma
•Created by Mathias on 11/19/2024 in #help-and-questions
Concurrent request (Prisma)
Hello,
I have a problem with Prisma on PostgreSQL. I don't know how to fix it
Context
I have a questionnaire to answer. When the person click on the questionnaire, I create
entry in the database. The backend sends the generated line ID (UUID) to the frontend. Then, each time the user's answers on the questionnaire are modified, the frontend sends the data to the backend, which updates them using this UUID
Problem: in rare cases, if I send the query twice in a row, it may create two rows in the database
Constraint: I can't have a unique constraint in the answers table, as a questionnaire can sometimes (not always) have several answers
Any advice on how to create a lock with Prisma / PostgreSQL to avoid having 2 inserts at the same time for the same user?
Thanks!8 replies