title: How do I check if a table exists?
body: <p>In db/index.js:</p>
  
  <pre><code>const { Pool } = require('pg'); //node-postgres
  const pool = new Pool;
  
  module.exports = {
      query: (text, params, callback) =&gt; {
          return pool.query(text,params,callback);
      }
  };
  </code></pre>
  
  <p>In my main.js:</p>
  
  <pre><code>const db = require('./db/index');
  
      db.query('SELECT count(*) from pg_class where relname ="session" and relkind="r"', (err, res) =&gt; {
          if (err) {
            //TODO: What to do if there is an error?
          }
          console.log(res);
      });
  </code></pre>
  
  <p>The output is: </p>
  
  <blockquote>
    <p>undefined</p>
  </blockquote>
  
  <p>How do I check if the table with name "session" exists or not ? How do I know my query even works ?</p>
  
  <p>EDIT: This is not a duplicate of the above questions, because my question has to do with the Node.js javascript code. Not the SQL! I just want to know what to look for in the res object, since it seems to be undefined...</p>