Created
May 15, 2019 11:46
-
-
Save sergey-chechaev/0210279b035b160629858d35c6a4e9f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def list_user_posts_select(user_id) do | |
Post | |
|> where([p], p.user_id == ^user_id) | |
|> join( | |
:inner, | |
[post], | |
user in User, | |
on: user.id == post.user_id and is_nil(user.deleted_at) == true and | |
is_nil(user.blocked_at) == true | |
) | |
|> select([:id, :content, user: [:id, :email]]) | |
|> preload([p, u], user: u) | |
|> preload(user: [:country, :city]) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment