Skip to content

Instantly share code, notes, and snippets.

@lakesare
Created August 1, 2018 13:34
Show Gist options
  • Save lakesare/6e293901e986890b3aa622ff9f6700bc to your computer and use it in GitHub Desktop.
Save lakesare/6e293901e986890b3aa622ff9f6700bc to your computer and use it in GitHub Desktop.
group_by sql vs js
SELECT COUNT(MOVIES.ID), MOVIES.DIRECTOR
FROM MOVIES
GROUP BY MOVIES.DIRECTOR
movies = [{ id: 5, director: 'a' }, { id: 8, director: 'a' }, { id: 3, director: 'b' }]
//=> [{ amount: 2, director: 'a' }, { amount: 1, director: 'b' }]
function group_by(field){
}
movies.group_by()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment