Code examples are not clear on how to actually save the queried rows to a variable
sylvesterroos opened this issue · comments
Sylvester commented
Specifications
- Client Version: 1.33.0
- InfluxDB Version: latest docker version
- Platform: Linux
Code sample to reproduce problem
function queryRows() {
console.log('*** QueryRows ***')
queryApi.queryRows(fluxQuery, {
next: (row: string[], tableMeta: FluxTableMetaData) => {
// the following line creates an object for each row
const o = tableMeta.toObject(row)
// console.log(JSON.stringify(o, null, 2))
console.log(
`${o._time} ${o._measurement} in '${o.location}' (${o.example}): ${o._field}=${o._value}`
)
},
error: (error: Error) => {
console.error(error)
console.log('\nQueryRows ERROR')
},
complete: () => {
console.log('\nQueryRows SUCCESS')
},
})
}
Expected behavior
I expect a result that will show me how to return the queried rows to a variable when calling the function.
Actual behavior
The example only show how to log the row to the console
Additional info
No response
Jakub Bednář commented
Hi @Pistrie,
thanks for using our client.
Expected behavior
I expect a result that will show me how to return the queried rows to a variable when calling the function.
You can use QueryApi.collectRows() method for this purpose.
Here is an example:
influxdb-client-js/examples/query.ts
Line 68 in 2075d83
Regards
Sylvester commented
It works, thanks :)