如何使用sailsjs ORM(水线)执行此查询

时间:2013-11-27 23:10:10

标签: node.js orm sails.js waterline

如何执行此查询?

SELECT * FROM blog
GROUP BY MONTH(createdAt)

我尝试了什么:

Blog.find()
.groupBy({MONTH:'createdAt'})
.exec(function(err,months){

        res.view({
          layout: 'blogLayout',
          archive:months
        });


 });

给我错误:无法进行groupBy

1 个答案:

答案 0 :(得分:4)

此时水线(风帆使用的ORM)仅支持将groupBy与sum(),count()等结合使用。您可以在此处找到验证此内容的代码行:https://github.com/balderdashy/sails-mongo/blob/master/lib/query/aggregate.js#L43