问题
How do I perform this query?
SELECT * FROM blog
GROUP BY MONTH(createdAt)
What I've tried:
Blog.find()
.groupBy({MONTH:'createdAt'})
.exec(function(err,months){
res.view({
layout: 'blogLayout',
archive:months
});
});
Gives me Error: Cannot groupBy without a calculation
回答1:
Waterline (the ORM used by sails) at this point only supports using groupBy in combination with sum(), count() etc. You can find the line of code that verifies this here: https://github.com/balderdashy/sails-mongo/blob/master/lib/query/aggregate.js#L43.
来源:https://stackoverflow.com/questions/20254910/how-do-i-perform-this-query-using-sailsjs-orm-waterline