Skip to content

Instantly share code, notes, and snippets.

@joshrendek
Created April 17, 2017 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshrendek/0212d911726ffc10a84612e31119a0df to your computer and use it in GitHub Desktop.
Save joshrendek/0212d911726ffc10a84612e31119a0df to your computer and use it in GitHub Desktop.
** (SyntaxError) web/controllers/streamer_controller.ex:11: unexpected comma. Parentheses are required to solve ambiguity in nested calls.
query = from s in Streamer,
join: sb in Subscriber,
where: s.id == sb.streamer_id,
select: s.name as name, s.id as id, count(sb.id) as subs,
group: s.name, s.id,
order: subs desc,
limit: 100
#preload: [:subscribers]
streamers = Repo.all(query)
rows, err := app.DB.Table("streamers").Select(
"streamers.id as id, streamers.name as name, count(subscribers.id) as subs",
).Joins(
"left join subscribers on streamers.id = subscribers.streamer_id",
).Group(
"streamers.name, streamers.id",
).Order("subs desc").Limit(100).Rows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment