title: Node.js | get unique result from multiple querys
body: <p>I wrote the following module which connects to postgresql or SQLServer depending a the Type var value:</p>
  
  <pre><code>exports.GetQueryResult = function (type, Name,con,callback) {
              var sql='';
              if (Type ='PG') {
  
                          sql=sql + ' SELECT …………..';
                          pg.connect(con, function(err, client, done) {
                                  if(err) {
                                          console.log("Error :" + err);
                                          return callback(err);
                                          }
  
                                  client.query(sql,[Name], function(err, Result) {
                                          if(err) {
                                                      console.log("Error: " +err);
                                                      return callback(err);
                                                  }
                                          return callback(null,Result); 
                                          done();
                                  });     
                          });
              }
              else
              {    
                          sql=sql + ' SELECT …..';
                          sql.open(con, function (err, conn,done) {
                                 if (err) {
                                            console.log("Error :" + err);
                                            return callback(err);
                                 }
  
                                 conn.queryRaw(sql,Name, function (err, Result) {
                                            if (err) {
                                                        console.log("Error ejecutando la consulta. Error: " +err);
                                                        return callback(err);
                                            }
                                            callback(null,Result);
                                            done;
                                 });
  
                          });
              }
  }; 
  </code></pre>
  
  <p>I call this function from:</p>
  
  <pre><code>var MultiBD = require('./MultiBD.js');
  var LayerType=['PG','SQL','PG'];
  var con=’’;
  
  for (var i=1;  i&lt;=Layers.length; i++) {    
                          if (Layers[i-1]!=undefined){
                                     con=MultiBD.conexion(LayerType [i-1],server,BD);
  MultiBD.GetQueryResult(LayerType[i-1], Name[i-1],con, 
  function (err,Result){      
                                                      console.log('Result : ' + Result.rows.length);
                                                      }           
                                      );
                          }        
  }
  </code></pre>
  
  <p>The results are:</p>
  
  <pre><code>Result : 111
  
  Result : 2888
  
  Result : 5
  </code></pre>
  
  <p>I get three query results. The first one returns 111 rows, the second one 2888 and the third one 5. </p>
  
  <p>What i need is to get only one unique result with all the 3004 rows (111+2888+5).</p>
  
  <p>Regards,</p>