html table 中未显示 Postgres VARCHAR
Postgres VARCHAR not displaying in html table
我目前正在将 node/express 应用程序从 mongodb 设置移动到 postgres 设置。我有一个页面 (report.ejs),其中显示 table 个项目以及它们是“真”还是“假”。但是,报告似乎没有显示这些“真”或“假”值,尽管当我访问 SQL Shell 中的 table 时它们已成功保存在数据库中.
这里是 div 结构的一个例子。 pipeline.url
和 pipeline.score
成功显示在网页上,但是 pipeline.firstItem
、pipeline.secondItem
和所有其他项目都没有显示在 table.
report.ejs示例代码:
<div id="main_content_wrap" class="outer">
<section id="main_content" class="inner">
<div class="container">
<h1 class="mb-1" id="reportURL"><%= pipeline.url %></h1>
<div class="text-muted mb-2" id="reportDate">
<%= pipeline.createdAt %>
</div>
<div class="text-muted mb-2">
Score Succesfully Saved
</div>
<div class="text-muted mb-2">
<%= 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="/" class="btn btn-secondary">Home</a>
<a href="/pipelines/edit/<%= pipeline.id %>" class="btn btn-info">Edit</a>
</div>
</section>
</div>
尽管 table 中的每个项目都已设置为 VARCHAR(100)
数据类型。我已尝试使用 BOOLEAN
和 TEXT
数据类型,但问题仍然存在。
Table 创建样本来自 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,
);`;
如上面的评论所述,问题只是我在 pipeline.firstItem
和 pipeline.secondItem
中有大写字符。将它们更改为 pipeline.firstitem
和 pipeline.seconditem
解决了这个问题。
我目前正在将 node/express 应用程序从 mongodb 设置移动到 postgres 设置。我有一个页面 (report.ejs),其中显示 table 个项目以及它们是“真”还是“假”。但是,报告似乎没有显示这些“真”或“假”值,尽管当我访问 SQL Shell 中的 table 时它们已成功保存在数据库中.
这里是 div 结构的一个例子。 pipeline.url
和 pipeline.score
成功显示在网页上,但是 pipeline.firstItem
、pipeline.secondItem
和所有其他项目都没有显示在 table.
report.ejs示例代码:
<div id="main_content_wrap" class="outer">
<section id="main_content" class="inner">
<div class="container">
<h1 class="mb-1" id="reportURL"><%= pipeline.url %></h1>
<div class="text-muted mb-2" id="reportDate">
<%= pipeline.createdAt %>
</div>
<div class="text-muted mb-2">
Score Succesfully Saved
</div>
<div class="text-muted mb-2">
<%= 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="/" class="btn btn-secondary">Home</a>
<a href="/pipelines/edit/<%= pipeline.id %>" class="btn btn-info">Edit</a>
</div>
</section>
</div>
尽管 table 中的每个项目都已设置为 VARCHAR(100)
数据类型。我已尝试使用 BOOLEAN
和 TEXT
数据类型,但问题仍然存在。
Table 创建样本来自 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,
);`;
如上面的评论所述,问题只是我在 pipeline.firstItem
和 pipeline.secondItem
中有大写字符。将它们更改为 pipeline.firstitem
和 pipeline.seconditem
解决了这个问题。