Is your feature request related to a problem? Please describe.
I have created a mulit-tenancy application in which I segregate data per user group in different schemas. With ecto I can do this by using the prefix. For example, a query for all products looks like this:
def list_products(tenant) do
query = from p in Product, preload: [:producer]
Repo.all(query, prefix: tenant)
end
I would like to use Flop but it seems that I can only set the prefix in the query_opts in adapter_opts in the Flop.Schema, based on this changelog for v0.22.
Describe the solution you'd like
I would like to add a prefix per query in order to dynamically change the tenant per query. Perhaps by allowing for adding query options as an option to validate_and_run. For instance:
def list_products(params, tenant) do
query = from p in Product, preload: [:producer]
query
|> Flop.validate_and_run(params, for: Product, prefix: tenant)
end
Additional context
This is the first time I'm trying out Flop, so not too familiair with the package and its API. It might very well be that there is a way of achieving this, if the case, I'd be happy to hear and close this issue asap.
Is your feature request related to a problem? Please describe. I have created a mulit-tenancy application in which I segregate data per user group in different schemas. With ecto I can do this by using the prefix. For example, a query for all products looks like this:
I would like to use Flop but it seems that I can only set the prefix in the
query_opts
inadapter_opts
in the Flop.Schema, based on this changelog for v0.22.Describe the solution you'd like I would like to add a prefix per query in order to dynamically change the tenant per query. Perhaps by allowing for adding query options as an option to validate_and_run. For instance:
Additional context This is the first time I'm trying out Flop, so not too familiair with the package and its API. It might very well be that there is a way of achieving this, if the case, I'd be happy to hear and close this issue asap.