I have 100 items in the collection, each item has a "money" field, I need to get the total amount of money from all, preferably without crutches. i don't know how to did it.
const allMoney = async () => {
let count = 0;
await User.find({}).sort({ money: -1 }).forEach(plr => { count+=plr.money });
return count;
}
"user is my model"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…