sql update query not perfectly updating with node js and socket.io #4824
Unanswered
SaqibMehmood08
asked this question in
Q&A
Replies: 1 comment
-
@SaqibMehmood08 hi! I think you need to wrap your queries inside a transaction, in order to prevent any race condition. References:
Note: this issue does not seem related to Socket.IO, please use StackOverflow the next time 👼 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using Socket.io and Node.js for the backend and React Native for the frontend, sending 1000 requests in 100 seconds to deduct 100, 1000 etc from the "beans" column in the users' table. Despite switching to asynchronous code and MySQL2 promises, there are still issues with accurate deductions. Other insertions are perfect. Here is my code:
react native emit is :
emit('/user/bit/play', {1,'A',100});
I switched from synchronous to asynchronous programming using MySQL2 promises. I want the "beans" to deduct based on the number I emit. For example, emitting 100 five times should deduct a total of 500 beans but this deduct 400 or 300.
EDIT by @darrachequesne: code formatting
Beta Was this translation helpful? Give feedback.
All reactions