Flux Parametrized Queries

Hi everyone,

I was wondering if it exists a library or another InfluxDB service to transform some code in a specific language, for example Javascript, into the query itself. I’m dealing with some queries that depending on the use-case have more or less filters to be applied. I can do it myself, but I prefer using an existing library, if exists. Here is an example that could help to better understand my question:

from(bucket: "prodx_test")
    |> range(start, stop)
    |> filter(fn: (r) => r["_measurement"] == "energy")
    |> filter(fn: (r) => r["_field"] == "consumedkWh" or r["_field"] == "producedkWh")
    |> filter(fn: (r) => r["deviceId"] == "PEDRAFORCA" or
                        r["deviceId"] == "LLEVANT" or
                        r["deviceId"] == "GREGAL" or
                        r["deviceId"] == "MESTRAL" or
                        r["deviceId"] == "TRAMUNTANA" or
                        r["deviceId"] == "XALOC" or
                        r["deviceId"] == "GARBI" or
                        r["deviceId"] == "PUIGMAL" or
                        r["deviceId"] == "MONTSENY" or
                        r["deviceId"] == "SUPORT"
    |> yield(name: "gridEnergyConsumption")

So, this filters to be applied are buildings within an energetic community. So, depending on the community, the amount of filters will be different.

And this could be extrapolated to other operations. If a library already exists, I think the creation of flux queries would be more scalable. If that is not possible, I will write a service inside my application to transform the desired operations into a flux query script.

Thanks you in advance.

Roger