Replies: 1 comment
-
DB.from{comments.as(:c)}.
select_all(:c).
select_append{count(ls[:id]).as(:like_count)}.
left_join(Sequel[:likes].as(:ls), likeable_id: :id, likeable_type: 'Comment').
where{{c[:commentable_id]=>3, c[:commentable_type]=>'Post', c[:parent_id]=>nil}}.
group{c[:id]}.
reverse(:like_count) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What is the most efficient way of writing this query in
Sequel
without usingDB.fetch(raw_sql)
?Beta Was this translation helpful? Give feedback.
All reactions