title: Function running before the outer one?
body: <p>I have this server in Node.js using socket.io.
  I have a function</p>
  
  <pre><code>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();
      });
  }
  </code></pre>
  
  <p>Alright, when I call this function inside another one, it seems to run before the codes that come before it.
  Here:</p>
  
  <pre><code>function(){
      connection.query('UPDATE `users` SET '...});
  
      connection.query('UPDATE `users` SET '...});
  
      updatePoints();
  }
  </code></pre>
  
  <p>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?</p>