【发布时间】:2019-09-01 23:46:23
【问题描述】:
我正在尝试使用 Pug 遍历 MongoDb 集合。
Console.log 显示收集项目。 Put 遍历列表但不显示任何数据。
Mongo 架构:
mongoose.Schema({
name: String,
email: String,
});
控制器:
exports.listDB = (req, res) => {
Db.find({}, (err, users) => {
if (err) throw err;
console.log(users); // this shows the collection with id, name, email
res.render('dblist', { title: 'Database List', db_list: users });
});
};
在帕格:
extends layout
block content
h1 List Database Records
p.lead This page will show all the records in the database
hr
ul
each user, index in db_list
li= db_list.name
输出显示两行带点,但没有数据。
【问题讨论】:
标签: javascript mongodb express pug