-
Notifications
You must be signed in to change notification settings - Fork 187
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
Added GROUP BY #44
Added GROUP BY #44
Conversation
Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test." |
Would you please add a test case? |
To generalize the feature, we're considering to add more capabilities to the query filter, including:
They should be supported by all connectors if the DB has such features. |
@raymondfeng I've added a couple of tests. I agree it should be generalised, but could this suffice for now? I imagine that usage would remain the same after generalisation, this way at least mysql users will be able to use |
The code looks good. But we cannot really benefit from it without aggregate functions, right? What do you think? |
I think we need to first introduce aggregate operators such as count, sum, avg, distinct similar as http://docs.mongodb.org/manual/reference/sql-aggregation-comparison/. |
I'm not sure I'm following - if one wants to You're right that it is still lacking the others. |
What's the purpose of The group by clause is used to group a list of records so that you can get aggregated results by group, for example, average score, total score, count of registered voters by county. http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html |
In my case, I have a list of requests, and want the first requests with a given URL, e.g.
|
You can simply use:
|
I could, but I want only one row returned for each URL. I do not just want the sorting as your query provides - I want only one row for each URL. This is not an uncommon use of |
Any more thoughts on this PR? 🎱 |
I don't need joins for my original PR to be useful. I now need joins if possible. Could you briefly describe how you would want me to add the facility to do |
I'll add more comments after I'm back from a trip. Thanks! |
@raymondfeng no change that you're back yet? |
@faceleg Do you want to use the native SQL for now? For example: ds.connector.query('SELECT DISTINCT url FROM requests GROUP BY url ORDER BY created ASC' cb); I really prefer to add support for aggregation functions in a consistent and complete way. |
That's a great tip, thanks - I will use that for now 👍 I was hoping that you'd be able to outline to me how you would want it implemented, and I (when I have time) could contribute said implementation in this connector. Presumably other community members would be able to do the same for the other connectors? If there is ground work to be done in the main loopback repo, I am of course happy to contribute there as well. I understand that you are passionate about maintaining consistency and completeness across the connectors, I share the sentiments. |
@raymondfeng bump? |
Sorry @raymondfeng, but bumping again |
Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test." |
@fabien, what's your take? |
Is patch works on relational Model? Suppose I have 'Student' And 'Courses' through third thorough Model. I want to find Student's Courses with groupBY on particular field of courses schema. would it work?? Student.Courses({ Will it work? I checked it didn't work for relational Model. |
Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test." |
Closing, I don't use this module anymore. |
Copied methodology from your
ORDER BY
function.Usage: