Last active
June 29, 2019 12:56
-
-
Save crbelaus/82c41b1852021a16e0d9eaa73a0fd3ec to your computer and use it in GitHub Desktop.
Shows examples of the Trans 2.0 QueryBuilder
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
| # Fetch Articles titled "Trans" in French and having an English comment | |
| # containing the word "good" | |
| iex> Repo.all(from a in Article, | |
| ...> join: c in assoc(a, :comments), | |
| ...> where: translated(Article, a.title, :fr) == "Trans", | |
| ...> where: ilike(translated(Comment, c.comment, :en), "good")) | |
| # SELECT a0."id", a0."title", a0."body", a0."translations" | |
| # FROM "articles" AS a0 | |
| # INNER JOIN "comments" AS c1 ON a0."id" = c1."article_id" | |
| # WHERE ((a0."translations"->"fr"->>"title") = "Trans") | |
| # AND ((c1."transcriptions"->"en"->>"comment") ILIKE 'good') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment