Skip to content

Instantly share code, notes, and snippets.

@nietaki
Created October 15, 2019 21:32
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 nietaki/c489d38bed039d5dc060a82321d4595c to your computer and use it in GitHub Desktop.
Save nietaki/c489d38bed039d5dc060a82321d4595c to your computer and use it in GitHub Desktop.
# aliases and imports omitted
query =
from(c in Comment,
where: c.user_id == ^charlie_id,
preload: [:post]
)
comments_by_charlie = Repo.all(query)
refute Enum.any?(comments_by_charlie, fn c -> c.post == nil end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment