这是我的模式(schema)。
在我的index.js中,我正在使用
在我的app.js中,我调用了这个语句,其中routes是我的变量,用于调用index.js中的welcome函数:
app.get('/welcome',routes.welcome);
我的schema也写在index.js中。我想要做的是在名为“welcome.html”的html页面中显示所有产品及其名称和描述。
请问有人能告诉我应该在我的html页面中写什么来实现这个功能?
var productSchema = new mongoose.Schema({
name: String,
description: String
});
var Product = mongoose.model('Product', productSchema);
在我的index.js中,我正在使用
exports.welcome = function(req,res) {
Product.find({},{},function(err,docs) {
res.render('welcome', {
"productlist" : docs
});
});
};
在我的app.js中,我调用了这个语句,其中routes是我的变量,用于调用index.js中的welcome函数:
app.get('/welcome',routes.welcome);
我的schema也写在index.js中。我想要做的是在名为“welcome.html”的html页面中显示所有产品及其名称和描述。
请问有人能告诉我应该在我的html页面中写什么来实现这个功能?