Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Ground Controller Lvl 1
Message 1 of 1

Converting Postgresql into knex.js

I am Using knex and objection to make an API. I am trying to translate the SQL below into knex without using raw so I can get all posts associated with a list of groups and other users. The data is spread across 4 tables groups, posts, votes, and friends.

 

select posts.*, sum(voted.vote), users.full_name
            from  users, posts left outer join voted
            on posts.id = voted.post_id
            where(users.id = posts.user_id and posts.group_id = ${group_id})
            group by posts.id, voted.post_id, users.full_name;