rummage_ecto
rummage_ecto copied to clipboard
Search Schema by field and field in the assoc
Hello.
Is it possible to search for both a field and a field from the assoc of the schema. For example, using the phoenix_example(v2) project, searching for all the products where the category_name = "fic" and the product_name = "the" ?
I am sending these rummage_params:
params: %{
paginate: %{page: 1, per_page: 5},
search: %{
category_name: "fic",
internal_code: %{search_term: "", search_type: :ilike},
name: %{search_term: "the", search_type: :ilike}
}
}
but the query it creates its this one (columns removed for readability) :
SELECT * FROM (SELECT * FROM (SELECT * FROM "products" AS p0) AS s0
WHERE (s0."internal_code" ILIKE $1)) AS s0 WHERE (s0."name" ILIKE $2)
LIMIT $3 OFFSET $4 ["%%", "%the%", 5, 0]
If this is not possible, can you point me in the direction for doing a PR for this functionality.
Thanks
Hi @duartepbrandao, At this point, no. There will need to be a bigger change in rummage_ecto
for this to work. The search hook needs to accept inputs in a different format. I think enough people have requested this feature, so I think maybe we should add this to 2.0 release!
What do you think @ericsullivan?
I think it's important enough to get it into the 2.0 release
Cool! I will add it to the queue then!
I have actually got it working tinkering with the rummage_scope and using the custom search.