You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As the title suggest, I'm having trouble writing to the database when using a for-loop to construct the object that I want to send. If I write out the same data one-by-one, it works like it should.
When I debug the output from my function, it is of the same format as another function where I do not use for-loop. Also the stackhero influxdb-V2 write node does give an output with empty payload (no error).
Also, if the measurement does not exist in the bucket, it will be created by the write node, so it is sending something to the DB.
This is the code used for constructing in a function node, the incoming msg.payload is an array of 24 objects. Each object consists of energy prices valid for one hour, and a timestamp to define what hour it is valid from (output from node nordpool-api-plus). This also means I will be writing to the past, and also to the future in the database.
`var dataset = [];
for (i = 0; i < msg.payload.length; i++) {
dataset.push(
{
measurement: 'technical',
tags: {
location: 'power'
},
fields: {
price: (msg.payload[i].price / 1000)
},
timestamp: Date.parse(msg.payload[i].timestamp)
}
)
}
As the title suggest, I'm having trouble writing to the database when using a for-loop to construct the object that I want to send. If I write out the same data one-by-one, it works like it should.
When I debug the output from my function, it is of the same format as another function where I do not use for-loop. Also the stackhero influxdb-V2 write node does give an output with empty payload (no error).
Also, if the measurement does not exist in the bucket, it will be created by the write node, so it is sending something to the DB.
This is the code used for constructing in a function node, the incoming msg.payload is an array of 24 objects. Each object consists of energy prices valid for one hour, and a timestamp to define what hour it is valid from (output from node nordpool-api-plus). This also means I will be writing to the past, and also to the future in the database.
`var dataset = [];
for (i = 0; i < msg.payload.length; i++) {
dataset.push(
{
measurement: 'technical',
tags: {
location: 'power'
},
fields: {
price: (msg.payload[i].price / 1000)
},
timestamp: Date.parse(msg.payload[i].timestamp)
}
)
}
msg.payload = {
bucket: 'test',
presicion: 'ms',
data: dataset
}
return msg;`
The text was updated successfully, but these errors were encountered: