title: How to send the newly updated rows to client in Node.js
body: <p>Currently i am working on <strong>Node.js + MySQL</strong> POC and its works really well as of now... with the rows getting updated or added are automatically notified to all the clients who are connected to socket port. But i feel its bit unnecessary to send all the row ( lets say 100+) each time to all clients as it will not make any sense - <strong>is there any module in node.js which takes the NEWLY inserted or UPDATED rows from mysql send broadcast it clients ?</strong> or ignore the rows / datas are which are already transmitted to clients ?</p>
  
  <p>Thanks.</p>
  
  <blockquote>
  <pre><code>io.sockets.on( 'connection', function (
  socket ) {
  
  console.log('Number of connections:' + connectionsArray.length);
  
  if (!connectionsArray.length) {
      pollingLoop();
  }
  
  socket.on('disconnect', function () {
      var socketIndex = connectionsArray.indexOf( socket );
      console.log('socket = ' + socketIndex + ' disconnected');
      if (socketIndex &gt;= 0) {
          connectionsArray.splice( socketIndex, 1 );
      }
  });
  
  console.log( 'A new socket is connected!' );
  connectionsArray.push( socket );
   });
  
  var updateSockets = function ( data ) {
  
  data.time = new Date();
  
  connectionsArray.forEach(function( tmpSocket ){
      tmpSocket.volatile.emit( 'notification' , data );
  }); };
  </code></pre>
  </blockquote>
  
  <p>Currently the above code sends all the datas to client. Just wondering to get an idea about opt logic to send only the new or updated one. </p>
  
  <p>MySQL connection codes</p>
  
  <blockquote>
  <pre><code>mysql               = require('mysql'),
  connectionsArray    = [],
  connection          = mysql.createConnection({
      host        : 'localhost',
      user        : 'root',
      password    : 'root',
      database    : 'nodejs',
      port        : 3306
  }),
  POLLING_INTERVAL = 3000,
  pollingTimer;
  
  // If there is an error connecting to the database
  connection.connect(function(err) {   // connected! (unless `err` is
  set)   console.log( err ); });
  </code></pre>
  </blockquote>
  
  <p>This is how i am selecting the rows - </p>
  
  <blockquote>
  <pre><code>var query = connection.query('SELECT * FROM users')
  </code></pre>
  </blockquote>