In phx_gen_auth there is a query that does a join and then selects only the joined record. A simplified version of it is:
from token in UserToken, join: user in assoc(token, :user), select: user
and this works all rainbows and unicorns. However when I try to translate it into “pipe-based” syntax:
UserToken |> join(:inner, [user_token], user in assoc(user_token, :user))
so far so good, the query translates to an equivalent JOIN SQL. But then comes the select part where I keep getting stuck at. A hint how to SELECT the joined record using “pipe-based” syntax would be appreciated
Now that’s interesting… could you please elaborate a bit on what the three dots represent? Yes, it works - I just checked
Update:
OK, found it: “Similarly, if you are interested only in the last binding (or the last bindings) in a query, you can use ... to specify “all bindings before” and match on the last one.”