var agg = [
{$group: {
_id: null,
totalPrice: { $sum: "$itemPrice" },
total: {$sum: 1}
}}
];
Idea.aggregate(agg, function(err, logs){
if (err) {
return def.reject(err);
}
console.log(logs);
});
这里是模板文件
{{#each ideas}}
<div class="card card-body mb-2">
<h4>{{title}}</h4>
<p>{{details}}</p>
<a class="btn btn-dark btn-block mb-2" href="/ideas/edit/{{id}}">Edit</a>
<form method="post" action="/ideas/{{id}}?_method=DELETE">
<input type="hidden" name="_method" value="DELETE">
<input type="submit" class="btn btn-danger btn-block" value="Delete">
</form>
</div>
{{else}}
<p>No video ideas listed</p>
{{/each}}