title: Ecto how to filter a has many through realtionship
body: <p>I am learning how to compose queries using Ecto. I would like to filter results from a has_many through relationship, with one call to the database via <code>Repo.all()</code> if that is possible.</p>
  <p>I assumed I could do this by composing this query using existing queries. e.g.</p>
  <pre><code>def users(organization_id) do
    Repo.get(Organization, organization_id)
     |&gt; Ecto.assoc(:users)
  end
  
  def bookings(%{organization_id: organization_id}) do
    Repo.get(Organization, organization_id)
      |&gt; Ecto.assoc(:bookings)
  end
  </code></pre>
  <p>and then, reuse one of the above:</p>
  <pre><code>def bookings(%{organization_id: organization_id, user_id: user_id}) do
    Repo.get(Organization, organization_id)
      |&gt; Ecto.assoc(:bookings)
      |&gt; where([u], u.user_id == ^user_id)
  end
  </code></pre>
  <p>But this does does not filter results by a given user_id. How can it be done? What am I missing?</p>
  <p><strong>Schema Info:</strong></p>
  <ul>
  <li>An Organization can have many Users.</li>
  <li>A User can have many Bookings.</li>
  <li>An Organization has many bookings through Users.</li>
  </ul>