Home > OS >  Postgres VARCHAR not displaying in html table
Postgres VARCHAR not displaying in html table

Time:03-24

I am currently moving a node/express application from a mongodb setup to a postgres setup. I have a page (report.ejs) which displays a table of items and whether they are "True" or "False". However, it appears that the report is not displaying the these "true" or "false" values, despite them being saved successfully in the database when I access the table in the SQL Shell.

Here is an example of the div structure. pipeline.url and pipeline.score are succesfully displaying on the webpage, however pipeline.firstItem, pipeline.secondItem and all the other items are not displaying in the table.

report.ejs sample code:

<div id="main_content_wrap" >
    <section id="main_content" > 
      <div >
        <h1  id="reportURL"><%= pipeline.url %></h1>
        <div  id="reportDate">
          <%= pipeline.createdAt %>
        </div>
        <div >
          Score Succesfully Saved
        </div>
        <div >
          <%= pipeline.score %>
        </div>

        <table id="upcReport">
            <tr>
                <th>Items</th>
                <th>Implemented</th>
            </tr>
            <tr>
                <th>Header 1</th>
                <th></th>
            </tr>
            <tr>
                <td>This is the first item</td>
                <td><%= pipeline.firstItem %></td>
            </tr>
            <tr>
                <td>This is the second item</td>
                <td><%= pipeline.secondItem %></td>
            </tr>
        </table>

        <button onclick="exportData()">Download Report</button><br>

        <a href="/" >Home</a>
        <a href="/pipelines/edit/<%= pipeline.id %>" >Edit</a>
      </div>
    </section>
  </div>

This is despite the fact that each item in the table has been set-up with a VARCHAR(100) datatype. I have attempted using BOOLEAN and TEXT datatypes but the issue persists.

Table creation smaple from server.js


  const sql_create_pipeline = `CREATE TABLE IF NOT EXISTS Pipelines (
  pipeline_id SERIAL PRIMARY KEY,
  slug VARCHAR(100) NOT NULL,
  gear VARCHAR(100) NOT NULL,
  app VARCHAR(100) NOT NULL,
  url VARCHAR(100) NOT NULL,
  score VARCHAR(100) NOT NULL,
  createdAt VARCHAR(100),
  firstItem VARCHAR(100) NOT NULL,
  secondItem VARCHAR(100) NOT NULL,
  );`;

CodePudding user response:

As mentioned in the comments above, the issue was simply that I had uppercase characters in pipeline.firstItem and pipeline.secondItem. Changing them to pipeline.firstitem and pipeline.seconditem fixed the issue.

  • Related