title: node.js - listen for database changes and update them
body: <p>I'm running node.js code on my server to get data from mysql database.<br>This is my code:</p>
  
  <pre><code>var express   =    require("express");
  var mysql     =    require('mysql');
  var app       =    express();
  
  var pool      =    mysql.createPool({
      connectionLimit : 100, //important
      host     : 'localhost',
      user     : 'root',
      password : '',
      database : 'coinflip',
      debug    :  true
  });
  
  function handle_database(req,res) {
  
      pool.getConnection(function(err,connection){
          if (err) {
            connection.release();
            res.json({"code" : 100, "status" : "Error in connection database"});
            return;
          }  
  
          console.log('connected as id ' + connection.threadId);
  
          connection.query("SELECT * FROM games WHERE winner=''",function(err,rows){
              connection.release();
              if(!err) {
                  res.json(rows);
              }          
          });
  
          connection.on('error', function(err) {      
                res.json({"code" : 100, "status" : "Error in connection database"});
                return;    
          });
    });
  }
  
  app.get("/",function(req,res){-
          handle_database(req,res);
  });
  
  app.listen(3000);
  </code></pre>
  
  <p>It gets all data I want from database, but I want it to auto-refresh without refreshing whole site. By auto-refresh I mean if there is any change (<code>update</code>, <code>insert</code>), display them on site. 
  <br>Is that possible?</p>