I have this server in Node.js using socket.io. I have a function
function updatePoints(){
pool.getConnection(function(err, connection) {
connection.query("SELECT * FROM `users`", function(error, rows) {
//here it fetchs the users' points and emit to their respective sockets
});
connection.release();
});
}
Alright, when I call this function inside another one, it seems to run before the codes that come before it. Here:
function(){
connection.query('UPDATE `users` SET '...});
connection.query('UPDATE `users` SET '...});
updatePoints();
}
This second function is when a user is donating points to another one, so I decrease the points from the donor and increase the receiver's points. Funny thing that when the function is called it emits for the donor just like I want it to do. The donor sees his points updating real time, while in the receiver's side he can't see it, unless the other one donates him points for a second time, then he sees the first donation going on. If the function is running before if should, how can I make it work?