【发布时间】:2021-07-18 17:03:20
【问题描述】:
我发现很难将订购商品的客户支付的所有金额加起来
订单架构
const orderschema = new Mongoose.Schema({
created: { type: Date, default: Date.now() },
amount: { type: Number, default: 0 }
User: [{ type: Mongoose.Schema.ObjectId, ref: 'Users'}]
...
})
路线
Get('/total-amount', total-amount)
控制器
Exports.total-amount = () => {
Order.find()...
}
我不知道要在这里添加什么才能得到所有客户的总金额。
使用 NodeJS 和 MongoDB。
感谢您的帮助
【问题讨论】:
标签: node.js reactjs mongodb mongoose