Postgres VARCHAR 不显示在 html 表中
我目前正在将节点/express 应用程序从 mongodb 设置移动到 postgres 设置。我有一个页面(report.ejs),它显示一个项目表以及它们是“True”还是“False”。但是,尽管当我在 SQL Shell 中访问表时,这些“true”或“false”值已成功保存在数据库中,但报告似乎并未显示这些“true”或“false”值。
这是 div 结构的示例。 pipeline.url
和 pipeline.score
已成功显示在网页上,但是 pipeline.firstItem
、pipeline.secondItem
并且所有其他项目均未显示在表中。
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>
尽管表中的每个项目都已使用 VARCHAR(100)
数据类型进行了设置,但仍然如此。我尝试使用 BOOLEAN
和 TEXT
数据类型,但问题仍然存在。
来自 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,
);`;
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" 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>
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,
);`;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如上面的评论中提到的,问题只是我在 pipeline.firstItem 和 pipeline.secondItem 中包含大写字符。将它们更改为
pipeline.firstitem
和pipeline.seconditem
解决了该问题。As mentioned in the comments above, the issue was simply that I had uppercase characters in
pipeline.firstItem
andpipeline.secondItem
. Changing them topipeline.firstitem
andpipeline.seconditem
fixed the issue.