Created
July 5, 2016 20:44
-
-
Save mcelaney/10b513a65f1e9b654f93eefdc2a89a73 to your computer and use it in GitHub Desktop.
This file contains 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
defmodule ProductVehicle do | |
def vehicles_that_fit_product(query \\ ProductVehicle, product_id) do | |
query | |
|> join(:inner, | |
[products_vehicles], | |
product in assoc(products_vehicles, :product)) | |
|> join(:inner, | |
[products_vehicles], | |
vehicle in assoc(products_vehicles, :vehicle)) | |
|> join(:inner, | |
[_, _, vehicle], | |
vehicle in assoc(vehicle, :vehicle_model)) | |
|> join(:inner, | |
[_, _, _, vehicle_model], | |
vehicle in assoc(vehicle_model, :vehicle_make)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment