-
Notifications
You must be signed in to change notification settings - Fork 376
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
support keyword distinct #123
Comments
There isn't. I started the project as a way for people to completely avoid using sql but now I'm thinking about having that possibility (with a warning about compatibility if switching to other dbms). |
About the distinct, that's the query you want to do (in your example) or a more complex one? I was thinking about the aggregation functions.. |
just the distinct. Using sql while some functions have not been developped. |
Usually, when using .avg('age'), ORM will define an alias called avg_age to the returned value. If you want to change this do .avg('age').as('my_age').
This is probably going to appear a little odd, perhaps we can shorten the code in the future. I added Person.aggregate().distinct('country').as('country').groupBy('country').get(function (err, countries) {
// groupBy is needed or else it will return only the first one
}); As you can see, |
This is because |
Acturally it is a bit odd, we use it temporarily. |
You should now be able to do: Person.aggregate().distinct('country').get(function (err, countries) {
// countries should be an Array like [ 'country1', 'country2', ... ]
}); |
If you have a more complex query please post it, I'm not sure how it handles it using more functions. |
hello,
Here is another request:
How to get it?
And Can I execute any sql like hsql in hibernate?
The text was updated successfully, but these errors were encountered: