Named binding for initial queryable

If I have:

Thing
|> join(:inner, [t], x in X, as: :x, on: t.x_id = x.id)
|> join(:inner, [_, x], y in Y, as: :y, on: x.y_id = y.id)

I have named bindings for x and y, which is great so i don’t have to remember their position. Is there a way to name the binding used to represent Thing?

isn’t t the binding that represents Thing (the first one in the list, that’s ignored in the second join)?

Yeah but I want to be able to name that binding so the order doesn’t matter.

UPD, ignore this :slightly_smiling_face: Benjamin has the answer =)


I see.
as far as I remember the main relation (Thing) will always be the first in the list and the rest could be a keyword list like

Account
|> join(:inner, [a], u in User, as: :user, on: u.account_id = a.id)
|> join(:inner, [_, user: u], l in Like, as: :like, on: l.user_id = u.id)
|> join(:inner, [thing, user: u, like: l], ...)

from/2 allows you to set the name for the first binding.

Thing
|> from(as: :thing)
|> …
3 Likes