What is thing? Why do you still have the Enum.map(&Enum.to_list/1) line? Did you run the line I suggested to help you understand what calling Enum.map on a map results in?
The issue here is that I think you’re simply combining bits of code people are giving you without understanding what each piece is doing, and what the values are at each point. Start at the very very beginning
query = user_params
|> Enum.map(fn x -> IO.inspect(x) end)
Figure out what that does, and what it means. Until you do that all this other stuff isn’t gonna help.
hence i updated my codebase by putting for each loop
for {key, value} <- thing do
field = String.to_existing_atom(key)
search = "%#{value}%"
from q in query, where: like(field(q, ^field), ^search)
end
Enum.map(&Enum.to_list/1)
and reduce in any language require some sort of array to loop that is why it is there and mapping is for conversion array like structure for key value pairs
but it was throwing error since i forgot to remove [] from earlier payload
legacy payload [%{"age" => 19}, %{"name" => "matt213"}, %{"sex" => "male"}]
updated harcoded payload for evaluation purpose user_params = [%{"age" => 19,"name" => "matt213"}]
actual payload user_params = %{"age" => 19,"name" => "matt213"}
hence, by which you have suggested by that time i forgot to remove [] from harcoded payload params
Really apologize for inconvenience in context with so much time and intellectual programming power put into ! :101: would be really carefull moving forword !