Ad

Foreach Call On Function

- 1 answer

I got an 2 dimensional array which contains a influx function and a value which should be added to the influx function.

let influxFunctions = [
    {key: "function1", value: "value1"},
    {key: "function2", value: "value2"},
];
/*
 "mean" should be function1 for example
 and name should be value1 and that for each element in the array
*/
influxClient.query(`database`)
    .addFunction('mean', 'name')
    .addFunction('mean', 'email')
    .then(console.log)
    .catch(console.error);

Is there a way to add these Functions to the influxClient.query(`database`) without submitting it?

The used influx Client is https://www.npmjs.com/package/influxdb-nodejs.

I know that there is the function .field(fields), which can handle a array but this function only allows fields.

Ad

Answer

Found a workaround.

There was a other lib for influx available where its possible to craft querys over SQL https://www.npmjs.com/package/influx so i crafted it as a string.

I used before https://www.npmjs.com/package/influxdb-nodejs

Ad
source: stackoverflow.com
Ad