You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I come along alot of scenarios where I want to group rows in order to find the "last updated" record. I know this can be achieved in relations by limiting it to 1 result and ordering the right way, but when there is a relation to external data (say, resources retrieved from a 3rd party) group by functionality would help alot. It's the only way I can imagine to get that one record per relation identifier without having to do a separate query for every single external id, or to process your result set afterwards.
To clarify, this is what you sorta do now (untested example)
I don't know if grouping fits in the Active Record pattern, as the resulting objects would not represent a single row, but an aggregration of multiple. However, this code could prove very useful in certain cases.
The text was updated successfully, but these errors were encountered:
I come along alot of scenarios where I want to group rows in order to find the "last updated" record. I know this can be achieved in relations by limiting it to 1 result and ordering the right way, but when there is a relation to external data (say, resources retrieved from a 3rd party) group by functionality would help alot. It's the only way I can imagine to get that one record per relation identifier without having to do a separate query for every single external id, or to process your result set afterwards.
To clarify, this is what you sorta do now (untested example)
or this (untested example)
Allthough, with group by functionality, in my mind, it could look as simple and elegant as this
I don't know if grouping fits in the Active Record pattern, as the resulting objects would not represent a single row, but an aggregration of multiple. However, this code could prove very useful in certain cases.
The text was updated successfully, but these errors were encountered: