Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 'group by' in aggregating #99

Closed
huangyingjie opened this issue Apr 8, 2013 · 1 comment
Closed

add 'group by' in aggregating #99

huangyingjie opened this issue Apr 8, 2013 · 1 comment

Comments

@huangyingjie
Copy link

Hello,
How can I use the words 'group by'? To achieve the effect like "select avg(weight), age from person group by age". Or is there any way by method find?

dresende added a commit that referenced this issue Apr 8, 2013
@dresende
Copy link
Owner

dresende commented Apr 8, 2013

Using the git version (not npm), try this: (adjust to your needs)

Person.aggregate([ 'age' ]).avg('weight').groupBy('age').get(function (err, stats) {
    // stats is an Array, each item should have 'age' and 'avg_weight'
});

@dresende dresende closed this as completed Apr 8, 2013
dresende added a commit that referenced this issue Apr 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants