问题描述
在当前项目中,我正在努力。用户可以输入他们想要投资的金额,我已经将每个用户与他们输入的金额相关联。问题是我想向每个用户显示他们选择的金额的历史记录。
以下是供用户选择所需投资金额的模式
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const Package1Schema = new Schema({
amount: {
type: Number,required: true
},investor:{
id: {
type: mongoose.Schema.Types.ObjectId,ref: "User"
},email: String,firstname: String,lastname: String
},date: {
type: Date,default: Date.now
}
});
const Package1 = mongoose.model('Package1',Package1Schema);
module.exports = Package1;
这是路由器代码
//Investment History
router.get("/investment-history/",ensureAuthenticated,(req,res) =>{
res.render("investment-history",{
firstname: req.package2.firstname,lastname: req.package2.lastname,amount: req.package2.amount
});
});
这是ejs代码
<tbody>
<% package2.forEach(function(package2){ %>
<tr>
<td>Package 2</td>
<td><%= package2.firstname %></td>
<td><%= package2.lastname %></td>
<td><%= package2.amount %></td>
<td>Pending</td>
<%});%>
</tbody>
</table>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)