title: ReferenceError: [tablename] is not defined | Node.js, Express, Axios, PostgreSQL
body: <p>I am trying to build a web app and I really have problems when it comes to the database connection.</p>
  
  <p>I am currently working with his Tutorial:</p>
  
  <p><a href="https://scotch.io/tutorials/getting-started-with-node-express-and-postgres-using-sequelize" rel="nofollow noreferrer">https://scotch.io/tutorials/getting-started-with-node-express-and-postgres-using-sequelize</a>
  And my client and also the server are working.</p>
  
  <p>But now I have to do the database access. For that reason I am using Postman to try out my POST- and GET-Statements.</p>
  
  <p>Everytime when I am trying the following GET-Statement:</p>
  
  <blockquote>
    <p>localhost:8000/api/tools</p>
  </blockquote>
  
  <p>I just get </p>
  
  <blockquote>
    <p><pre>ReferenceError: Tools is not defined
                <br> &nbsp; &nbsp;at list (server\controllers\tools.js:17:5)
                <br> &nbsp; &nbsp;at Layer.handle [as handle_request] (server\node_modules\express\lib\router\layer.js:95:5)
                <br> &nbsp; &nbsp;at next (server\node_modules\express\lib\router\route.js:137:13)
                <br> &nbsp; &nbsp;at Route.dispatch (server\node_modules\express\lib\router\route.js:112:3)</p>
  </blockquote>
  
  <p>And I really don't get why it always says "Tools is not defined".
  I have a database scheme called "public".
  So maybe that could be a thing? 
  I also tried to set database to public.[DATABASENAME] but it doesn't changed a thing. </p>
  
  <p>I hope you guys can help me and I described the case good enough.</p>
  
  <p>My files for that looks like that:</p>
  
  <p><strong>/server/config/config.json</strong></p>
  
  <pre><code>{
    "development": {
      "username": "[USERNAME]",
      "password": "[PASSWORD]",
      "database": "testdb",
      "host": "localhost",
      "port": [PORT],
      "dialect": "postgres"
    }
  </code></pre>
  
  <p><strong>/routes/index.js</strong></p>
  
  <pre><code>const toolsController = require('../controllers').tools;
  const toolitemsController = require('../controllers').toolitems;
  
  module.exports = (app) =&gt; {
    app.get('/api', (req, res) =&gt; res.status(200).send({
      message: 'Welcome to the tools API!',
    }));
  
    app.post('/api/tools', toolsController.create);
    app.get('/api/tools', toolsController.list);
    app.get('/api/tools/:toolId', toolsController.retrieve);
    app.put('/api/tools/:toolId', toolsController.update);
    app.delete('/api/tools/:toolId', toolsController.destroy);
  
    app.post('/api/tools/:toolId/items', toolitemsController.create);
    app.put('/api/tools/:toolId/items/:toolitemId', toolitemsController.update);
    app.delete(
      '/api/tools/:toolId/items/:toolitemId', toolitemsController.destroy
    );
    app.all('/api/tools/:toolId/items', (req, res) =&gt; res.status(405).send({
      message: 'Method Not Allowed',
    }));
  };
  </code></pre>
  
  <p><strong>/server/controllers/tools.js</strong></p>
  
  <pre><code>const tool = require('../models').tool;
      const toolitem = require('../models').toolitem;
  
      module.exports = {
        create(req, res) {
          return Tools
            .create({
              tool_id: req.body.tool_id,
              tool_name: req.body.tool_name,
              status: req.body.status
            })
            .then((tools) =&gt; res.status(201).send(tools))
            .catch((error) =&gt; res.status(400).send(error));
        },
  
        list(req, res) {
          return Tools
            .all()
            .then(tools =&gt; res.status(200).send(tools))
            .catch(error =&gt; res.status(400).send(error));
        },
      };
  </code></pre>
  
  <p>edited Version of <strong>/server/controllers/tools.js</strong></p>
  
  <code>const tools = require('../models').tools;
  const toolitem = require('../models').toolitem;
  
  module.exports = {
    create(req, res) {
      return tools
        .create({
          tool_id: req.body.tool_id,
          tool_name: req.body.tool_name,
          status: req.body.status
        })
        .then((tools) =&gt; res.status(201).send(tools))
        .catch((error) =&gt; res.status(400).send(error));
    },
  
    list(req, res) {
      return tools
        .all()
        .then(tools =&gt; res.status(200).send(tools))
        .catch(error =&gt; res.status(400).send(error));
    },
    /*
    list(req, res) {
      return tool
        .findAll({
          include: [{
            model: toolitem,
            as: 'toolitems',
          }],
          order: [
            ['createdAt', 'DESC'],
            [{ model: toolitem, as: 'toolitems' }, 'createdAt', 'ASC'],
          ],
        })
        .then((tools) =&gt; res.status(200).send(tools))
        .catch((error) =&gt; res.status(400).send(error));
    },*/
  
    retrieve(req, res) {
      return tools
        .findById(req.params.toolId, {
          include: [{
            model: toolitem,
            as: 'toolitems',
          }],
        })
        .then((tools) =&gt; {
          if (!tools) {
            return res.status(404).send({
              message: 'tools Not Found',
            });
          }
          return res.status(200).send(tools);
        })
        .catch((error) =&gt; res.status(400).send(error));
    },
  
    update(req, res) {
      return tools
        .findById(req.params.toolId, {
          include: [{
            model: toolitem,
            as: 'toolitems',
          }],
        })
        .then(tools =&gt; {
          if (!tools) {
            return res.status(404).send({
              message: 'tools Not Found',
            });
          }
          return tools
            .update({
              title: req.body.title || tool.title,
            })
            .then(() =&gt; res.status(200).send(tools))
            .catch((error) =&gt; res.status(400).send(error));
        })
        .catch((error) =&gt; res.status(400).send(error));
    },
  
    destroy(req, res) {
      return tools
        .findById(req.params.toolId)
        .then(tools =&gt; {
          if (!tools) {
            return res.status(400).send({
              message: 'tool Not Found',
            });
          }
          return tools
            .destroy()
            .then(() =&gt; res.status(204).send())
            .catch((error) =&gt; res.status(400).send(error));
        })
        .catch((error) =&gt; res.status(400).send(error));
    },
  };
  </code></pre>