title: Querying Large Dataset in Oracle Database from NodeJS
body: <p>I'm currently working on a project from work where i have an Oracle 10 database table with about 310K give or take 10-30K rows.</p>
  
  <p>The goal is to display those rows in an angular frontend, however returning all of those through NodeJS is taking a lot of time.</p>
  
  <p>Given that I'm using both NodeJS and oracledb for the first time, i'm assuming i must be missing something?</p>
  
  <pre><code>var oracledb = require('oracledb');
  var config = require(__dirname+'/../db.js');
  
  function get(req,res,next)
  {
  var table = req.query.table;
  var meta;
  
  oracledb.getConnection(config.oracle)
  .then( function(connection)
  {
      var stream = connection.queryStream('SELECT * FROM '+table);
  
      stream.on('error', function (error) 
      {
          console.error(error);
          return next(err);
      });
  
      stream.on('metadata', function (metadata) {
          console.log(metadata);
      });
  
      stream.on('data', function (data) {
          console.log(data);
      });
  
      stream.on('end', function () 
      {
        connection.release(
          function(err) {
            if (err) {
              console.error(err.message);
              return next(err);
            }
          });
      });
  })
  .catch(function(err){
      if(err){
          connection.close(function(err){
              if(err){
                  console.error(err.message);
                  return next(err);
              }
          });
      }
  })
  }
  
  module.exports.get = get;
  </code></pre>