【发布时间】:2017-03-15 19:03:35
【问题描述】:
如何返回表中唯一值的计数?这将返回一个唯一 ID 数组...
req.models.pages.aggregate().distinct("page").get(function (err, page) {...
// returns [ '6', '92', '90', '91', '93', '94', '102' ]
// the unique ids of the individual pages
但是,如何返回具有相应计数的对象?比如……
{ '6': 2, '92':7, '90':12, etc...}
// the unique page ids with their associated counts
我了解了如何聚合,也了解了如何 count(),但我不知道在哪里可以同时进行。
【问题讨论】: