I have a designs table that has these field
design_id
design_type
user_id
and design table belongs to user table. So user has_many designs and designs belongs to user.
first I need to query on design_id and design_type and load all the designs.
Which I did something like this
from([a] in Design, where: a.design_type == ^type and a.design_id == ^id)
Where I will get results like this
[
%Design{
design_id: 1,
design_type: "document",
user: #Ecto.Association.NotLoaded<association :user is not loaded>,
user_id: 2,
},
%Design{
design_id: 1,
design_type: "document",
user: #Ecto.Association.NotLoaded<association :user is not loaded>,
user_id: 3,
]
So, I want to get a list of users for the same design_id and design_type.
Also if I’m querying ` from([a] in Design, where: a.design_type == ^type and a.design_id == ^id) from elixir shell its giving me a list of designs.
But when I tried to use it in function
def design_filters(%{"design_id" => id, "design_type" => type}) do
from([t] in Design,
where: t.design_id == ^id and t.design_type == ^type
)
end
I’m getting this error
** (FunctionClauseError) no function clause matching