title: Mssql / nodejs ConnectionPool is not a constructor
body: <p>Im currently following a tutorial on Youtube about nodejs and mssq.
  While following the tutorial, i came across an issue about ConnectionPool.
  Since it's a 5 years old video, the nodejs plugin changed overtime (mssq/tedious).</p>
  
  <p>My version is now 6.2.0 for mssql/tedious (latest version)</p>
  
  <p>It's not using "sql.Connection(config)" anymore.
  Many people reported that changing sql.Connection(config) to sql.ConnectionPool(config)fixed their issues.</p>
  
  <p>but for me, it did not.</p>
  
  <p>Below you'll find 3 files but the line that makes it go bad is this one (connect.js):</p>
  
  <pre class="lang-js prettyprint-override"><code>var conn = new sql.ConnectionPool(config);
  </code></pre>
  
  <p>the config is actually this : </p>
  
  <pre class="lang-js prettyprint-override"><code>exports.config = {
    user: 'dataGetter',
    password: '1234',
    server: 'localhost',
    database: 'cegeptest',
  };
  </code></pre>
  
  <p>Errors:</p>
  
  <pre><code>TypeError: sql.ConnectionPool is not a constructor
      at Object.exports.connectDatabase (C:\_Programming\Work\InventoryCegep\database\connect.js:7:14)
      at Object.exports.getList (C:\_Programming\Work\InventoryCegep\database\queries\villes.js:5:11)
      at C:\_Programming\Work\InventoryCegep\routes\villes.routes.js:6:10
      at Layer.handle [as handle_request] (C:\_Programming\Work\InventoryCegep\node_modules\express\lib\router\layer.js:95:5)
      at next (C:\_Programming\Work\InventoryCegep\node_modules\express\lib\router\route.js:137:13)
      at Route.dispatch (C:\_Programming\Work\InventoryCegep\node_modules\express\lib\router\route.js:112:3)
      at Layer.handle [as handle_request] (C:\_Programming\Work\InventoryCegep\node_modules\express\lib\router\layer.js:95:5)
      at C:\_Programming\Work\InventoryCegep\node_modules\express\lib\router\index.js:281:22
      at Function.process_params (C:\_Programming\Work\InventoryCegep\node_modules\express\lib\router\index.js:335:12)
      at next (C:\_Programming\Work\InventoryCegep\node_modules\express\lib\router\index.js:275:10)
  </code></pre>
  
  <p><strong>Thanks in advance for the help :)</strong> </p>
  
  <p>Here's the code related to this:</p>
  
  <p><strong>villes.routes.js</strong></p>
  
  <pre class="lang-js prettyprint-override"><code>const router = require('express').Router();
  const villes = require('../database/queries/villes.js');
  
  router.get('/', (req, res) =&gt; {
    //database.getList(req, res);
    villes.getList(req, res);
    res.render('villes');
  });
  
  module.exports = router;
  </code></pre>
  
  <p><strong>villes.js</strong></p>
  
  <pre class="lang-js prettyprint-override"><code>var connect = require('../connect');
  //CRUD pour villes
  
  exports.getList = function (req, res) {
    connect.connectDatabase('SELECT * FROM Ville', function (data, err) {
      if (err) {
        res.writeHeader(500, 'Internal error occured', {
          'Content-Type': 'text/html',
        });
        res.write(
          '&lt;html&gt;&lt;head&gt;&lt;title&gt;500&lt;/title&gt;&lt;/head&gt;&lt;body&gt;500: internal error. Details: ' +
            err +
            '&lt;/body&gt;&lt;/html&gt;'
        );
      } else {
        res.writeHeader(200, { 'Content-type': 'application/json' });
        res.write(JSON.stringify(data));
      }
      res.end();
    });
  }; //sortir la liste complète des villes
  </code></pre>
  
  <p><strong>connect.js</strong></p>
  
  <pre class="lang-js prettyprint-override"><code>var sql = require('mssql'); //On call le module microsoft Sql   (Installer avec :  npm i mssql)
  var config = require('../settings').config; //On va chercher notre configuration exportée dans database/config.js
  
  //sql.connect(config).then((pool) =&gt; {});
  
  exports.connectDatabase = function (sql, callback) {
    var conn = new sql.ConnectionPool(config);
    console.log(conn);
  
  };
  
  </code></pre>